@@ -238,18 +238,12 @@ fn load_const_scalar<'tcx>(
238
238
if matches ! ( scalar_type, Type :: Ptr ( _) | Type :: FnPtr ( _) ) {
239
239
return load_scalar_ptr ( ctx, ptr) . cast_ptr ( scalar_type) ;
240
240
}
241
- let uint8_ptr = ctx. nptr ( Type :: Int ( Int :: U8 ) ) ;
242
- return CILNode :: LdObj {
243
- obj : Box :: new ( scalar_type) ,
244
- ptr : Box :: new ( CILNode :: TemporaryLocal ( Box :: new ( (
245
- ctx. alloc_type ( uint8_ptr) ,
246
- [ CILRoot :: SetTMPLocal {
247
- value : load_scalar_ptr ( ctx, ptr) ,
248
- } ]
249
- . into ( ) ,
250
- CILNode :: LoadAddresOfTMPLocal . cast_ptr ( ctx. nptr ( scalar_type) ) ,
251
- ) ) ) ) ,
252
- } ;
241
+ return CILNode :: transmute_on_stack (
242
+ load_scalar_ptr ( ctx, ptr) ,
243
+ ctx. nptr ( Type :: Int ( Int :: U8 ) ) ,
244
+ scalar_type,
245
+ ctx,
246
+ ) ;
253
247
}
254
248
} ;
255
249
@@ -265,30 +259,17 @@ fn load_const_scalar<'tcx>(
265
259
TyKind :: Tuple ( elements) => {
266
260
if elements. is_empty ( ) {
267
261
let scalar_ptr = ctx. nptr ( scalar_type) ;
268
- CILNode :: TemporaryLocal ( Box :: new ( (
269
- ctx. alloc_type ( scalar_ptr) ,
270
- [ ] . into ( ) ,
271
- CILNode :: LdObj {
272
- ptr : CILNode :: LoadTMPLocal . into ( ) ,
273
- obj : Type :: Void . into ( ) ,
274
- } ,
275
- ) ) )
262
+ CILNode :: uninit_val ( scalar_ptr, ctx)
276
263
} else {
277
- CILNode :: LdObj {
278
- ptr : Box :: new (
279
- CILNode :: PointerToConstValue ( Box :: new ( scalar_u128) )
280
- . cast_ptr ( ctx. nptr ( scalar_type) ) ,
281
- ) ,
282
- obj : scalar_type. into ( ) ,
283
- }
264
+ CILNode :: V2 ( ctx. alloc_node ( scalar_u128) ) . transmute_on_stack (
265
+ Type :: Int ( Int :: U128 ) ,
266
+ scalar_type,
267
+ ctx,
268
+ )
284
269
}
285
270
}
286
- TyKind :: Adt ( _, _) | TyKind :: Closure ( _, _) => CILNode :: LdObj {
287
- ptr : Box :: new (
288
- CILNode :: PointerToConstValue ( Box :: new ( scalar_u128) ) . cast_ptr ( ctx. nptr ( scalar_type) ) ,
289
- ) ,
290
- obj : scalar_type. into ( ) ,
291
- } ,
271
+ TyKind :: Adt ( _, _) | TyKind :: Closure ( _, _) => CILNode :: V2 ( ctx. alloc_node ( scalar_u128) )
272
+ . transmute_on_stack ( Type :: Int ( Int :: U128 ) , scalar_type, ctx) ,
292
273
TyKind :: Char => CILNode :: V2 ( ctx. alloc_node ( u32:: try_from ( scalar_u128) . unwrap ( ) ) ) ,
293
274
_ => todo ! ( "Can't load scalar constants of type {scalar_ty:?}!" ) ,
294
275
}
0 commit comments