wasmtime: Cranelift: can't legalize sload32
I’ve minimized a test case that currently fails on 32-bit platforms:
target i686
function u0:1516(i32) -> i32 system_v {
block0(v0: i32):
v1 = load.i32 notrap aligned readonly v0
;v2 = load.i32 v1
;v3 = sextend.i64 v2
v3 = sload32 v1
v4, v5 = isplit v3
return v4
}
I’ve tried writing a legalizer for it that would produce the commented instructions but it doesn’t do anything (same lack of result for expand, widen, narrow). What gives?
--- a/cranelift/codegen/meta/src/shared/legalize.rs
+++ b/cranelift/codegen/meta/src/shared/legalize.rs
@@ -107,6 +107,7 @@ pub(crate) fn define(insts: &InstructionGroup, imm: &Immediates) -> TransformGro
let sdiv_imm = insts.by_name("sdiv_imm");
let select = insts.by_name("select");
let sextend = insts.by_name("sextend");
+ let sload32 = insts.by_name("sload32");
let sshr = insts.by_name("sshr");
let sshr_imm = insts.by_name("sshr_imm");
let srem = insts.by_name("srem");
@@ -213,6 +214,14 @@ pub(crate) fn define(insts: &InstructionGroup, imm: &Immediates) -> TransformGro
// embedded as part of arguments), so use a custom legalization for now.
narrow.custom_legalize(iconst, "narrow_iconst");
+ narrow.legalize(
+ def!(a = sload32.I64(flags, ptr, offset)),
+ vec![
+ def!(b = load.I32(flags, ptr, offset)),
+ def!(a = sextend.I64(b)),
+ ]
+ );
+
for &(ty, ty_half) in &[(I128, I64), (I64, I32)] {
let inst = uextend.bind(ty).bind(ty_half);
narrow.legalize(
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (16 by maintainers)
Commits related to this issue
- x86_32: legalize {istore,sload,uload}32.i64. Fixes #1747. Co-authored-by: bjorn3 — committed to whitequark/wasmtime by whitequark 4 years ago
- x86_32: legalize {istore,sload,uload}32.i64. Fixes #1747. Co-authored-by: bjorn3 — committed to whitequark/wasmtime by whitequark 4 years ago
- x86_32: legalize {istore,sload,uload}32.i64. Fixes #1747. Co-authored-by: bjorn3 — committed to whitequark/wasmtime by whitequark 4 years ago
- x86_32: legalize {istore,sload,uload}32.i64. Fixes #1747. Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com> — committed to whitequark/wasmtime by whitequark 4 years ago
- x86_32: legalize {istore,sload,uload}32.i64. Fixes #1747. Co-authored-by: bjorn3 — committed to whitequark/wasmtime by whitequark 4 years ago
Sure, I tried that first, it doesn’t work there either. Or am I doing it wrong?