tcx.lift_to_global
> tcx.global_tcx().lift
This commit is contained in:
parent
569ae80a0a
commit
bdd23bf215
@ -1151,8 +1151,7 @@ impl<'tcx> TerminatorKind<'tcx> {
|
||||
SwitchInt { ref values, switch_ty, .. } => {
|
||||
let size = ty::tls::with(|tcx| {
|
||||
let param_env = ty::ParamEnv::empty();
|
||||
let tcx = tcx.global_tcx();
|
||||
let switch_ty = tcx.lift(&switch_ty).unwrap();
|
||||
let switch_ty = tcx.lift_to_global(&switch_ty).unwrap();
|
||||
tcx.layout_of(param_env.and(switch_ty)).unwrap().size
|
||||
});
|
||||
values.iter()
|
||||
@ -1908,8 +1907,8 @@ pub fn print_miri_value<W: Write>(value: Value, ty: Ty, f: &mut W) -> fmt::Resul
|
||||
(Value::Scalar(Scalar::Bits { bits, .. }), &TyUint(ui)) => write!(f, "{:?}{}", bits, ui),
|
||||
(Value::Scalar(Scalar::Bits { bits, .. }), &TyInt(i)) => {
|
||||
let bit_width = ty::tls::with(|tcx| {
|
||||
let ty = tcx.global_tcx().lift(&ty).unwrap();
|
||||
tcx.global_tcx().layout_of(ty::ParamEnv::empty().and(ty)).unwrap().size.bits()
|
||||
let ty = tcx.lift_to_global(&ty).unwrap();
|
||||
tcx.layout_of(ty::ParamEnv::empty().and(ty)).unwrap().size.bits()
|
||||
});
|
||||
let amt = 128 - bit_width;
|
||||
write!(f, "{:?}{}", ((bits as i128) << amt) >> amt, i)
|
||||
|
@ -1823,8 +1823,8 @@ impl<'tcx> Const<'tcx> {
|
||||
bits: u128,
|
||||
ty: ParamEnvAnd<'tcx, Ty<'tcx>>,
|
||||
) -> &'tcx Self {
|
||||
let ty = tcx.global_tcx().lift(&ty).unwrap();
|
||||
let size = tcx.global_tcx().layout_of(ty).unwrap_or_else(|e| {
|
||||
let ty = tcx.lift_to_global(&ty).unwrap();
|
||||
let size = tcx.layout_of(ty).unwrap_or_else(|e| {
|
||||
panic!("could not compute layout for {:?}: {:?}", ty, e)
|
||||
}).size;
|
||||
let amt = 128 - size.bits();
|
||||
@ -1857,8 +1857,8 @@ impl<'tcx> Const<'tcx> {
|
||||
if self.ty != ty.value {
|
||||
return None;
|
||||
}
|
||||
let ty = tcx.global_tcx().lift(&ty).unwrap();
|
||||
let size = tcx.global_tcx().layout_of(ty).ok()?.size;
|
||||
let ty = tcx.lift_to_global(&ty).unwrap();
|
||||
let size = tcx.layout_of(ty).ok()?.size;
|
||||
match self.val {
|
||||
ConstVal::Value(val) => val.to_bits(size),
|
||||
_ => None,
|
||||
@ -1896,8 +1896,8 @@ impl<'tcx> Const<'tcx> {
|
||||
ty: ParamEnvAnd<'tcx, Ty<'tcx>>,
|
||||
) -> Option<u128> {
|
||||
assert_eq!(self.ty, ty.value);
|
||||
let ty = tcx.global_tcx().lift(&ty).unwrap();
|
||||
let size = tcx.global_tcx().layout_of(ty).ok()?.size;
|
||||
let ty = tcx.lift_to_global(&ty).unwrap();
|
||||
let size = tcx.layout_of(ty).ok()?.size;
|
||||
match self.val {
|
||||
ConstVal::Value(val) => val.to_bits(size),
|
||||
_ => None,
|
||||
|
@ -374,9 +374,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
|
||||
// Helper to get a `-1` value of the appropriate type
|
||||
fn neg_1_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> {
|
||||
let gcx = self.hir.tcx().global_tcx();
|
||||
let param_ty = ty::ParamEnv::empty().and(gcx.lift(&ty).unwrap());
|
||||
let bits = gcx.layout_of(param_ty).unwrap().size.bits();
|
||||
let param_ty = ty::ParamEnv::empty().and(self.hir.tcx().lift_to_global(&ty).unwrap());
|
||||
let bits = self.hir.tcx().layout_of(param_ty).unwrap().size.bits();
|
||||
let n = (!0u128) >> (128 - bits);
|
||||
let literal = Literal::Value {
|
||||
value: ty::Const::from_bits(self.hir.tcx(), n, param_ty)
|
||||
@ -387,10 +386,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
|
||||
// Helper to get the minimum value of the appropriate type
|
||||
fn minval_literal(&mut self, span: Span, ty: Ty<'tcx>) -> Operand<'tcx> {
|
||||
let gcx = self.hir.tcx().global_tcx();
|
||||
assert!(ty.is_signed());
|
||||
let param_ty = ty::ParamEnv::empty().and(gcx.lift(&ty).unwrap());
|
||||
let bits = gcx.layout_of(param_ty).unwrap().size.bits();
|
||||
let param_ty = ty::ParamEnv::empty().and(self.hir.tcx().lift_to_global(&ty).unwrap());
|
||||
let bits = self.hir.tcx().layout_of(param_ty).unwrap().size.bits();
|
||||
let n = 1 << (bits - 1);
|
||||
let literal = Literal::Value {
|
||||
value: ty::Const::from_bits(self.hir.tcx(), n, param_ty)
|
||||
|
@ -156,9 +156,8 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
|
||||
};
|
||||
|
||||
let trunc = |n| {
|
||||
let gcx = self.tcx.global_tcx();
|
||||
let param_ty = self.param_env.and(gcx.lift(&ty).unwrap());
|
||||
let bit_width = gcx.layout_of(param_ty).unwrap().size.bits();
|
||||
let param_ty = self.param_env.and(self.tcx.lift_to_global(&ty).unwrap());
|
||||
let bit_width = self.tcx.layout_of(param_ty).unwrap().size.bits();
|
||||
trace!("trunc {} with size {} and amt {}", n, bit_width, 128 - bit_width);
|
||||
let amt = 128 - bit_width;
|
||||
let result = (n << amt) >> amt;
|
||||
|
Loading…
x
Reference in New Issue
Block a user