Skip to content

Commit acec83d

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

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
@@ -18,6 +18,7 @@ use rustc_span::def_id::{CrateNum, DefId};
1818
use scoped_tls::scoped_thread_local;
1919
use stable_mir::Error;
2020
use stable_mir::abi::Layout;
21+
use stable_mir::compiler_interface::CompilerInterface;
2122
use stable_mir::ty::IndexedVal;
2223

2324
use crate::rustc_smir::context::TablesWrapper;
@@ -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)