Skip to content

Commit

Permalink
Update to Cranelift 0.100
Browse files Browse the repository at this point in the history
This skips Cranelift 0.99 as it depends on an object version that is broken on
macOS.
  • Loading branch information
bjorn3 committed Sep 21, 2023
1 parent 9b855a9 commit 02dec62
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 75 deletions.
95 changes: 38 additions & 57 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ crate-type = ["dylib"]

[dependencies]
# These have to be in sync with each other
cranelift-codegen = { version = "0.98", features = ["unwind", "all-arch"] }
cranelift-frontend = { version = "0.98" }
cranelift-module = { version = "0.98" }
cranelift-native = { version = "0.98" }
cranelift-jit = { version = "0.98", optional = true }
cranelift-object = { version = "0.98" }
cranelift-codegen = { version = "0.100", features = ["unwind", "all-arch"] }
cranelift-frontend = { version = "0.100" }
cranelift-module = { version = "0.100" }
cranelift-native = { version = "0.100" }
cranelift-jit = { version = "0.100", optional = true }
cranelift-object = { version = "0.100" }
target-lexicon = "0.12.0"
gimli = { version = "0.27.2", default-features = false, features = ["write"]}
object = { version = "0.30.3", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
gimli = { version = "0.28", default-features = false, features = ["write"]}
object = { version = "0.32", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }

indexmap = "2.0.0"
libloading = { version = "0.7.3", optional = true }
Expand Down
4 changes: 2 additions & 2 deletions src/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ pub(crate) fn clif_int_or_float_cast(
let (min, max) = match (to_ty, to_signed) {
(types::I8, false) => (0, i64::from(u8::MAX)),
(types::I16, false) => (0, i64::from(u16::MAX)),
(types::I8, true) => (i64::from(i8::MIN), i64::from(i8::MAX)),
(types::I16, true) => (i64::from(i16::MIN), i64::from(i16::MAX)),
(types::I8, true) => (i64::from(i8::MIN as u32), i64::from(i8::MAX as u32)),
(types::I16, true) => (i64::from(i16::MIN as u32), i64::from(i16::MAX as u32)),
_ => unreachable!(),
};
let min_val = fx.bcx.ins().iconst(types::I32, min);
Expand Down
12 changes: 6 additions & 6 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ pub(crate) fn type_min_max_value(
(types::I8, false) | (types::I16, false) | (types::I32, false) | (types::I64, false) => {
0i64
}
(types::I8, true) => i64::from(i8::MIN),
(types::I16, true) => i64::from(i16::MIN),
(types::I32, true) => i64::from(i32::MIN),
(types::I8, true) => i64::from(i8::MIN as u8),
(types::I16, true) => i64::from(i16::MIN as u16),
(types::I32, true) => i64::from(i32::MIN as u32),
(types::I64, true) => i64::MIN,
_ => unreachable!(),
};
Expand All @@ -215,9 +215,9 @@ pub(crate) fn type_min_max_value(
(types::I16, false) => i64::from(u16::MAX),
(types::I32, false) => i64::from(u32::MAX),
(types::I64, false) => u64::MAX as i64,
(types::I8, true) => i64::from(i8::MAX),
(types::I16, true) => i64::from(i16::MAX),
(types::I32, true) => i64::from(i32::MAX),
(types::I8, true) => i64::from(i8::MAX as u8),
(types::I16, true) => i64::from(i16::MAX as u16),
(types::I32, true) => i64::from(i32::MAX as u32),
(types::I64, true) => i64::MAX,
_ => unreachable!(),
};
Expand Down
2 changes: 1 addition & 1 deletion src/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub(crate) fn codegen_const_value<'tcx>(
if fx.clif_type(layout.ty).is_some() {
return CValue::const_val(fx, layout, int);
} else {
let raw_val = int.to_bits(int.size()).unwrap();
let raw_val = int.size().truncate(int.to_bits(int.size()).unwrap());
let val = match int.size().bytes() {
1 => fx.bcx.ins().iconst(types::I8, raw_val as i64),
2 => fx.bcx.ins().iconst(types::I16, raw_val as i64),
Expand Down
3 changes: 2 additions & 1 deletion src/value_and_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ impl<'tcx> CValue<'tcx> {
fx.bcx.ins().iconcat(lsb, msb)
}
ty::Bool | ty::Char | ty::Uint(_) | ty::Int(_) | ty::Ref(..) | ty::RawPtr(..) => {
fx.bcx.ins().iconst(clif_ty, const_val.to_bits(layout.size).unwrap() as i64)
let raw_val = const_val.size().truncate(const_val.to_bits(layout.size).unwrap());
fx.bcx.ins().iconst(clif_ty, raw_val as i64)
}
ty::Float(FloatTy::F32) => {
fx.bcx.ins().f32const(Ieee32::with_bits(u32::try_from(const_val).unwrap()))
Expand Down

0 comments on commit 02dec62

Please sign in to comment.