1
1
use cranelift_module:: * ;
2
2
use crate :: prelude:: * ;
3
3
use crate :: rustc:: mir:: interpret:: {
4
- read_target_uint, AllocId , AllocType , Allocation , ConstValue , EvalResult , GlobalId ,
4
+ read_target_uint, AllocId , AllocType , Allocation , ConstValue , EvalResult , GlobalId , Scalar ,
5
5
} ;
6
6
use crate :: rustc:: ty:: Const ;
7
- use crate :: rustc_mir:: interpret:: { CompileTimeEvaluator , EvalContext , Memory , MemoryKind } ;
7
+ use crate :: rustc_mir:: interpret:: { EvalContext , Machine , Memory , MemoryKind , OpTy , PlaceTy } ;
8
8
9
9
#[ derive( Default ) ]
10
10
pub struct ConstantCx {
@@ -124,7 +124,7 @@ fn trans_const_place<'a, 'tcx: 'a>(
124
124
let mut ecx = EvalContext :: new (
125
125
fx. tcx . at ( DUMMY_SP ) ,
126
126
ty:: ParamEnv :: reveal_all ( ) ,
127
- CompileTimeEvaluator ,
127
+ TransPlaceInterpreter ,
128
128
( ) ,
129
129
) ;
130
130
let op = ecx. const_to_op ( const_) ?;
@@ -155,11 +155,11 @@ fn data_id_for_static<'a, 'tcx: 'a, B: Backend>(
155
155
) -> DataId {
156
156
let symbol_name = tcx. symbol_name ( Instance :: mono ( tcx, def_id) ) . as_str ( ) ;
157
157
let is_mutable = if let crate :: rustc:: hir:: Mutability :: MutMutable = tcx. is_static ( def_id) . unwrap ( ) {
158
- true
159
- } else {
160
- !tcx. type_of ( def_id)
161
- . is_freeze ( tcx, ParamEnv :: reveal_all ( ) , DUMMY_SP )
162
- } ;
158
+ true
159
+ } else {
160
+ !tcx. type_of ( def_id)
161
+ . is_freeze ( tcx, ParamEnv :: reveal_all ( ) , DUMMY_SP )
162
+ } ;
163
163
module
164
164
. declare_data ( & * symbol_name, Linkage :: Export , is_mutable)
165
165
. unwrap ( )
@@ -185,7 +185,7 @@ fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>(
185
185
module : & mut Module < B > ,
186
186
cx : & mut ConstantCx ,
187
187
) {
188
- let memory = Memory :: < CompileTimeEvaluator > :: new ( tcx. at ( DUMMY_SP ) , ( ) ) ;
188
+ let memory = Memory :: < TransPlaceInterpreter > :: new ( tcx. at ( DUMMY_SP ) , ( ) ) ;
189
189
190
190
while let Some ( todo_item) = pop_set ( & mut cx. todo ) {
191
191
let ( data_id, alloc) = match todo_item {
@@ -269,3 +269,56 @@ fn pop_set<T: Copy + Eq + ::std::hash::Hash>(set: &mut HashSet<T>) -> Option<T>
269
269
None
270
270
}
271
271
}
272
+
273
+ struct TransPlaceInterpreter ;
274
+
275
+ impl < ' a , ' mir , ' tcx > Machine < ' a , ' mir , ' tcx > for TransPlaceInterpreter {
276
+ type MemoryData = ( ) ;
277
+ type MemoryKinds = ( ) ;
278
+ const MUT_STATIC_KIND : Option < ( ) > = None ;
279
+
280
+ fn before_terminator ( _: & mut EvalContext < ' a , ' mir , ' tcx , Self > ) -> EvalResult < ' tcx > {
281
+ panic ! ( ) ;
282
+ }
283
+
284
+ fn find_fn (
285
+ _: & mut EvalContext < ' a , ' mir , ' tcx , Self > ,
286
+ _: Instance < ' tcx > ,
287
+ _: & [ OpTy < ' tcx > ] ,
288
+ _: Option < PlaceTy < ' tcx > > ,
289
+ _: Option < BasicBlock > ,
290
+ ) -> EvalResult < ' tcx , Option < & ' mir Mir < ' tcx > > > {
291
+ panic ! ( ) ;
292
+ }
293
+
294
+ fn call_intrinsic (
295
+ _: & mut EvalContext < ' a , ' mir , ' tcx , Self > ,
296
+ _: Instance < ' tcx > ,
297
+ _: & [ OpTy < ' tcx > ] ,
298
+ _: PlaceTy < ' tcx > ,
299
+ ) -> EvalResult < ' tcx > {
300
+ panic ! ( ) ;
301
+ }
302
+
303
+ fn find_foreign_static (
304
+ _: crate :: rustc:: ty:: query:: TyCtxtAt < ' a , ' tcx , ' tcx > ,
305
+ _: DefId ,
306
+ ) -> EvalResult < ' tcx , & ' tcx Allocation > {
307
+ panic ! ( ) ;
308
+ }
309
+
310
+ fn ptr_op (
311
+ _: & EvalContext < ' a , ' mir , ' tcx , Self > ,
312
+ _: mir:: BinOp ,
313
+ _: Scalar ,
314
+ _: TyLayout < ' tcx > ,
315
+ _: Scalar ,
316
+ _: TyLayout < ' tcx > ,
317
+ ) -> EvalResult < ' tcx , ( Scalar , bool ) > {
318
+ panic ! ( ) ;
319
+ }
320
+
321
+ fn box_alloc ( _: & mut EvalContext < ' a , ' mir , ' tcx , Self > , _: PlaceTy < ' tcx > ) -> EvalResult < ' tcx > {
322
+ panic ! ( ) ;
323
+ }
324
+ }
0 commit comments