Skip to content

Commit a166ad1

Browse files
committed
Implement CompilerInterface
With `TablesWrapper` wrapped by `Compilerface`, the stable-mir's TLV stores a pointer to `Compilerface`, while the rustc-specific TLV stores a pointer to tables.
1 parent 18a029c commit a166ad1

File tree

2 files changed

+458
-18
lines changed

2 files changed

+458
-18
lines changed

compiler/rustc_smir/src/rustc_internal/mod.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use stable_mir::ty::IndexedVal;
2323
use crate::rustc_smir::context::TablesWrapper;
2424
use crate::rustc_smir::{Stable, Tables};
2525
use crate::stable_mir;
26+
use crate::stable_mir::compiler_interface::CompilerInterface;
2627

2728
mod internal;
2829
pub mod pretty;
@@ -233,7 +234,12 @@ where
233234
mir_consts: IndexMap::default(),
234235
layouts: IndexMap::default(),
235236
}));
236-
stable_mir::compiler_interface::run(&tables, || init(&tables, f))
237+
238+
let interface = CompilerInterface { cx: tables };
239+
240+
// Pass the `CompilerInterface` to compiler_interface::run
241+
// and initialize the rustc-specific TLS with tables.
242+
stable_mir::compiler_interface::run(&interface, || init(&interface.cx, f))
237243
}
238244

239245
/// Instantiate and run the compiler with the provided arguments and callback.

0 commit comments

Comments
 (0)