Skip to content

Commit 16a2641

Browse files
committed
Remove all usages of iconst.i128
Support was removed from Cranelift
1 parent 6768d0d commit 16a2641

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

src/cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub(crate) fn clif_int_or_float_cast(
149149
}
150150

151151
let is_not_nan = fx.bcx.ins().fcmp(FloatCC::Equal, from, from);
152-
let zero = fx.bcx.ins().iconst(to_ty, 0);
152+
let zero = type_zero_value(&mut fx.bcx, to_ty);
153153
fx.bcx.ins().select(is_not_nan, val, zero)
154154
} else if from_ty.is_float() && to_ty.is_float() {
155155
// float -> float

src/common.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,15 @@ pub(crate) fn codegen_icmp_imm(
167167
}
168168
}
169169

170+
pub(crate) fn type_zero_value(bcx: &mut FunctionBuilder<'_>, ty: Type) -> Value {
171+
if ty == types::I128 {
172+
let zero = bcx.ins().iconst(types::I64, 0);
173+
bcx.ins().iconcat(zero, zero)
174+
} else {
175+
bcx.ins().iconst(ty, 0)
176+
}
177+
}
178+
170179
pub(crate) fn type_min_max_value(
171180
bcx: &mut FunctionBuilder<'_>,
172181
ty: Type,

src/discriminant.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,14 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
278278
fx.bcx.ins().iadd(tagged_discr, delta)
279279
};
280280

281-
let untagged_variant =
282-
fx.bcx.ins().iconst(cast_to, i64::from(untagged_variant.as_u32()));
281+
let untagged_variant = if cast_to == types::I128 {
282+
let zero = fx.bcx.ins().iconst(types::I64, 0);
283+
let untagged_variant =
284+
fx.bcx.ins().iconst(types::I64, i64::from(untagged_variant.as_u32()));
285+
fx.bcx.ins().iconcat(untagged_variant, zero)
286+
} else {
287+
fx.bcx.ins().iconst(cast_to, i64::from(untagged_variant.as_u32()))
288+
};
283289
let discr = fx.bcx.ins().select(is_niche, tagged_discr, untagged_variant);
284290
let res = CValue::by_val(discr, dest_layout);
285291
dest.write_cvalue(fx, res);

src/intrinsics/simd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
713713

714714
let res_type =
715715
Type::int_with_byte_size(u16::try_from(expected_bytes).unwrap()).unwrap();
716-
let mut res = fx.bcx.ins().iconst(res_type, 0);
716+
let mut res = type_zero_value(&mut fx.bcx, res_type);
717717

718718
let lanes = match fx.tcx.sess.target.endian {
719719
Endian::Big => Box::new(0..lane_count) as Box<dyn Iterator<Item = u64>>,

0 commit comments

Comments
 (0)