Skip to content

Commit

Permalink
x86_32: legalize {istore,sload,uload}32.i64.
Browse files Browse the repository at this point in the history
Fixes #1747.

Co-authored-by: bjorn3
  • Loading branch information
whitequark committed Jul 5, 2020
1 parent 8d7ba0a commit ecc4fdc
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
27 changes: 27 additions & 0 deletions cranelift/codegen/meta/src/shared/legalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ pub(crate) fn define(insts: &InstructionGroup, imm: &Immediates) -> TransformGro
let isplit = insts.by_name("isplit");
let istore8 = insts.by_name("istore8");
let istore16 = insts.by_name("istore16");
let istore32 = insts.by_name("istore32");
let isub = insts.by_name("isub");
let isub_bin = insts.by_name("isub_bin");
let isub_bout = insts.by_name("isub_bout");
Expand All @@ -108,6 +109,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");
Expand All @@ -118,6 +120,7 @@ pub(crate) fn define(insts: &InstructionGroup, imm: &Immediates) -> TransformGro
let uextend = insts.by_name("uextend");
let uload8 = insts.by_name("uload8");
let uload16 = insts.by_name("uload16");
let uload32 = insts.by_name("uload32");
let umulhi = insts.by_name("umulhi");
let ushr = insts.by_name("ushr");
let ushr_imm = insts.by_name("ushr_imm");
Expand Down Expand Up @@ -213,6 +216,30 @@ 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!(istore32.I64(flags, a, ptr, offset)),
vec![
def!((al, ah) = isplit(a)),
def!(store.I32(flags, al, ptr, offset)),
],
);

expand.legalize(
def!(a = sload32.I32(flags, ptr, offset)),
vec![
def!(b = load.I32(flags, ptr, offset)),
def!(a = sextend.I64(b)),
],
);

expand.legalize(
def!(a = uload32.I32(flags, ptr, offset)),
vec![
def!(b = load.I32(flags, ptr, offset)),
def!(a = uextend.I64(b)),
],
);

for &(ty, ty_half) in &[(I128, I64), (I64, I32)] {
let inst = uextend.bind(ty).bind(ty_half);
narrow.legalize(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
; Test the legalization of load32/store32.i64 instructions on x86_32.

test compile
target i686

function u0:0(i32, i32, i32) {
block0(v0: i32, v1: i32, v2: i32):
v3 = iconcat v1, v2
; check: v4 = fill v1
; nextln: v5 = fill v0
; nextln: store v4, v5
istore32.i64 v3, v0
return
}

function u0:1(i32) -> i32 {
block0(v0: i32):
; check: v7 = fill v0
; nextln: v4 = load.i32 v7
v1 = sload32.i32 v0
v2, v3 = isplit v1
; check: return v4
return v2
}

function u0:2(i32) -> i32 {
block0(v0: i32):
; check: v6 = fill v0
; nextln: v4 = load.i32 v6
v1 = uload32.i32 v0
v2, v3 = isplit v1
; check: return v4
return v2
}

0 comments on commit ecc4fdc

Please sign in to comment.