Remove all usages of iconst.i128

Support was removed from Cranelift
This commit is contained in:
bjorn3 2022-10-25 17:18:19 +00:00
parent 6768d0dd72
commit 16a2641444
4 changed files with 19 additions and 4 deletions

View File

@ -149,7 +149,7 @@ pub(crate) fn clif_int_or_float_cast(
} }
let is_not_nan = fx.bcx.ins().fcmp(FloatCC::Equal, from, from); let is_not_nan = fx.bcx.ins().fcmp(FloatCC::Equal, from, from);
let zero = fx.bcx.ins().iconst(to_ty, 0); let zero = type_zero_value(&mut fx.bcx, to_ty);
fx.bcx.ins().select(is_not_nan, val, zero) fx.bcx.ins().select(is_not_nan, val, zero)
} else if from_ty.is_float() && to_ty.is_float() { } else if from_ty.is_float() && to_ty.is_float() {
// float -> float // float -> float

View File

@ -167,6 +167,15 @@ pub(crate) fn codegen_icmp_imm(
} }
} }
pub(crate) fn type_zero_value(bcx: &mut FunctionBuilder<'_>, ty: Type) -> Value {
if ty == types::I128 {
let zero = bcx.ins().iconst(types::I64, 0);
bcx.ins().iconcat(zero, zero)
} else {
bcx.ins().iconst(ty, 0)
}
}
pub(crate) fn type_min_max_value( pub(crate) fn type_min_max_value(
bcx: &mut FunctionBuilder<'_>, bcx: &mut FunctionBuilder<'_>,
ty: Type, ty: Type,

View File

@ -278,8 +278,14 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
fx.bcx.ins().iadd(tagged_discr, delta) fx.bcx.ins().iadd(tagged_discr, delta)
}; };
let untagged_variant = let untagged_variant = if cast_to == types::I128 {
fx.bcx.ins().iconst(cast_to, i64::from(untagged_variant.as_u32())); let zero = fx.bcx.ins().iconst(types::I64, 0);
let untagged_variant =
fx.bcx.ins().iconst(types::I64, i64::from(untagged_variant.as_u32()));
fx.bcx.ins().iconcat(untagged_variant, zero)
} else {
fx.bcx.ins().iconst(cast_to, i64::from(untagged_variant.as_u32()))
};
let discr = fx.bcx.ins().select(is_niche, tagged_discr, untagged_variant); let discr = fx.bcx.ins().select(is_niche, tagged_discr, untagged_variant);
let res = CValue::by_val(discr, dest_layout); let res = CValue::by_val(discr, dest_layout);
dest.write_cvalue(fx, res); dest.write_cvalue(fx, res);

View File

@ -713,7 +713,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
let res_type = let res_type =
Type::int_with_byte_size(u16::try_from(expected_bytes).unwrap()).unwrap(); Type::int_with_byte_size(u16::try_from(expected_bytes).unwrap()).unwrap();
let mut res = fx.bcx.ins().iconst(res_type, 0); let mut res = type_zero_value(&mut fx.bcx, res_type);
let lanes = match fx.tcx.sess.target.endian { let lanes = match fx.tcx.sess.target.endian {
Endian::Big => Box::new(0..lane_count) as Box<dyn Iterator<Item = u64>>, Endian::Big => Box::new(0..lane_count) as Box<dyn Iterator<Item = u64>>,