@@ -71,15 +71,15 @@ pub(crate) fn eval_nullary_intrinsic<'tcx>(
71
71
sym:: pref_align_of => {
72
72
// Correctly handles non-monomorphic calls, so there is no need for ensure_monomorphic_enough.
73
73
let layout = tcx. layout_of ( param_env. and ( tp_ty) ) . map_err ( |e| err_inval ! ( Layout ( e) ) ) ?;
74
- ConstValue :: from_machine_usize ( layout. align . pref . bytes ( ) , & tcx)
74
+ ConstValue :: from_target_usize ( layout. align . pref . bytes ( ) , & tcx)
75
75
}
76
76
sym:: type_id => {
77
77
ensure_monomorphic_enough ( tcx, tp_ty) ?;
78
78
ConstValue :: from_u64 ( tcx. type_id_hash ( tp_ty) )
79
79
}
80
80
sym:: variant_count => match tp_ty. kind ( ) {
81
81
// Correctly handles non-monomorphic calls, so there is no need for ensure_monomorphic_enough.
82
- ty:: Adt ( adt, _) => ConstValue :: from_machine_usize ( adt. variants ( ) . len ( ) as u64 , & tcx) ,
82
+ ty:: Adt ( adt, _) => ConstValue :: from_target_usize ( adt. variants ( ) . len ( ) as u64 , & tcx) ,
83
83
ty:: Alias ( ..) | ty:: Param ( _) | ty:: Placeholder ( _) | ty:: Infer ( _) => {
84
84
throw_inval ! ( TooGeneric )
85
85
}
@@ -104,7 +104,7 @@ pub(crate) fn eval_nullary_intrinsic<'tcx>(
104
104
| ty:: GeneratorWitnessMIR ( _, _)
105
105
| ty:: Never
106
106
| ty:: Tuple ( _)
107
- | ty:: Error ( _) => ConstValue :: from_machine_usize ( 0u64 , & tcx) ,
107
+ | ty:: Error ( _) => ConstValue :: from_target_usize ( 0u64 , & tcx) ,
108
108
} ,
109
109
other => bug ! ( "`{}` is not a zero arg intrinsic" , other) ,
110
110
} )
@@ -156,7 +156,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
156
156
_ => bug ! ( ) ,
157
157
} ;
158
158
159
- self . write_scalar ( Scalar :: from_machine_usize ( result, self ) , dest) ?;
159
+ self . write_scalar ( Scalar :: from_target_usize ( result, self ) , dest) ?;
160
160
}
161
161
162
162
sym:: pref_align_of
@@ -302,15 +302,15 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
302
302
}
303
303
sym:: offset => {
304
304
let ptr = self . read_pointer ( & args[ 0 ] ) ?;
305
- let offset_count = self . read_machine_isize ( & args[ 1 ] ) ?;
305
+ let offset_count = self . read_target_isize ( & args[ 1 ] ) ?;
306
306
let pointee_ty = substs. type_at ( 0 ) ;
307
307
308
308
let offset_ptr = self . ptr_offset_inbounds ( ptr, pointee_ty, offset_count) ?;
309
309
self . write_pointer ( offset_ptr, dest) ?;
310
310
}
311
311
sym:: arith_offset => {
312
312
let ptr = self . read_pointer ( & args[ 0 ] ) ?;
313
- let offset_count = self . read_machine_isize ( & args[ 1 ] ) ?;
313
+ let offset_count = self . read_target_isize ( & args[ 1 ] ) ?;
314
314
let pointee_ty = substs. type_at ( 0 ) ;
315
315
316
316
let pointee_size = i64:: try_from ( self . layout_of ( pointee_ty) ?. size . bytes ( ) ) . unwrap ( ) ;
@@ -376,7 +376,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
376
376
// The signed form of the intrinsic allows this. If we interpret the
377
377
// difference as isize, we'll get the proper signed difference. If that
378
378
// seems *positive*, they were more than isize::MAX apart.
379
- let dist = val. to_machine_isize ( self ) ?;
379
+ let dist = val. to_target_isize ( self ) ?;
380
380
if dist >= 0 {
381
381
throw_ub_format ! (
382
382
"`{}` called when first pointer is too far before second" ,
@@ -386,7 +386,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
386
386
dist
387
387
} else {
388
388
// b >= a
389
- let dist = val. to_machine_isize ( self ) ?;
389
+ let dist = val. to_target_isize ( self ) ?;
390
390
// If converting to isize produced a *negative* result, we had an overflow
391
391
// because they were more than isize::MAX apart.
392
392
if dist < 0 {
@@ -411,10 +411,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
411
411
412
412
// Perform division by size to compute return value.
413
413
let ret_layout = if intrinsic_name == sym:: ptr_offset_from_unsigned {
414
- assert ! ( 0 <= dist && dist <= self . machine_isize_max ( ) ) ;
414
+ assert ! ( 0 <= dist && dist <= self . target_isize_max ( ) ) ;
415
415
usize_layout
416
416
} else {
417
- assert ! ( self . machine_isize_min ( ) <= dist && dist <= self . machine_isize_max ( ) ) ;
417
+ assert ! ( self . target_isize_min ( ) <= dist && dist <= self . target_isize_max ( ) ) ;
418
418
isize_layout
419
419
} ;
420
420
let pointee_layout = self . layout_of ( substs. type_at ( 0 ) ) ?;
@@ -525,12 +525,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
525
525
sym:: vtable_size => {
526
526
let ptr = self . read_pointer ( & args[ 0 ] ) ?;
527
527
let ( size, _align) = self . get_vtable_size_and_align ( ptr) ?;
528
- self . write_scalar ( Scalar :: from_machine_usize ( size. bytes ( ) , self ) , dest) ?;
528
+ self . write_scalar ( Scalar :: from_target_usize ( size. bytes ( ) , self ) , dest) ?;
529
529
}
530
530
sym:: vtable_align => {
531
531
let ptr = self . read_pointer ( & args[ 0 ] ) ?;
532
532
let ( _size, align) = self . get_vtable_size_and_align ( ptr) ?;
533
- self . write_scalar ( Scalar :: from_machine_usize ( align. bytes ( ) , self ) , dest) ?;
533
+ self . write_scalar ( Scalar :: from_target_usize ( align. bytes ( ) , self ) , dest) ?;
534
534
}
535
535
536
536
_ => return Ok ( false ) ,
@@ -669,10 +669,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
669
669
count : & OpTy < ' tcx , <M as Machine < ' mir , ' tcx > >:: Provenance > ,
670
670
nonoverlapping : bool ,
671
671
) -> InterpResult < ' tcx > {
672
- let count = self . read_machine_usize ( & count) ?;
672
+ let count = self . read_target_usize ( & count) ?;
673
673
let layout = self . layout_of ( src. layout . ty . builtin_deref ( true ) . unwrap ( ) . ty ) ?;
674
674
let ( size, align) = ( layout. size , layout. align . abi ) ;
675
- // `checked_mul` enforces a too small bound (the correct one would probably be machine_isize_max ),
675
+ // `checked_mul` enforces a too small bound (the correct one would probably be target_isize_max ),
676
676
// but no actual allocation can be big enough for the difference to be noticeable.
677
677
let size = size. checked_mul ( count, self ) . ok_or_else ( || {
678
678
err_ub_format ! (
@@ -697,9 +697,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
697
697
698
698
let dst = self . read_pointer ( & dst) ?;
699
699
let byte = self . read_scalar ( & byte) ?. to_u8 ( ) ?;
700
- let count = self . read_machine_usize ( & count) ?;
700
+ let count = self . read_target_usize ( & count) ?;
701
701
702
- // `checked_mul` enforces a too small bound (the correct one would probably be machine_isize_max ),
702
+ // `checked_mul` enforces a too small bound (the correct one would probably be target_isize_max ),
703
703
// but no actual allocation can be big enough for the difference to be noticeable.
704
704
let len = layout
705
705
. size
0 commit comments