Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit 4bdcd20

Browse files
committed
Legalize load.i128 and store.i128
1 parent 0f9307d commit 4bdcd20

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

cranelift-codegen/meta/src/shared/legalize.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ pub fn define(insts: &InstructionGroup, immediates: &OperandKinds) -> TransformG
148148
let ieee32 = immediates.by_name("ieee32");
149149
let ieee64 = immediates.by_name("ieee64");
150150
let intcc = immediates.by_name("intcc");
151+
let offset32 = immediates.by_name("offset32");
151152

152153
// List of variables to reuse in patterns.
153154
let x = var("x");
@@ -286,6 +287,30 @@ pub fn define(insts: &InstructionGroup, immediates: &OperandKinds) -> TransformG
286287
],
287288
);
288289

290+
// FIXME generalize to any offset once offset+8 can be represented
291+
narrow.legalize(
292+
def!(a = load.I128(flags, ptr, Literal::constant(offset32, 0))),
293+
vec![
294+
def!(al = load.I64(flags, ptr, Literal::constant(offset32, 0))),
295+
def!(ah = load.I64(flags, ptr, Literal::constant(offset32, 8))),
296+
// `iconcat` expects the same byte order as stored in memory,
297+
// so no need to swap depending on endianness.
298+
def!(a = iconcat(al, ah)),
299+
],
300+
);
301+
302+
// FIXME generalize to any offset once offset+8 can be represented
303+
narrow.legalize(
304+
def!(store.I128(flags, a, ptr, Literal::constant(offset32, 0))),
305+
vec![
306+
// `isplit` gives the same byte order as stored in memory,
307+
// so no need to swap depending on endianness.
308+
def!((al, ah) = isplit(a)),
309+
def!(store.I64(flags, al, ptr, Literal::constant(offset32, 0))),
310+
def!(store.I64(flags, ah, ptr, Literal::constant(offset32, 8))),
311+
],
312+
);
313+
289314
// Widen instructions with one input operand.
290315
for &op in &[bnot, popcnt] {
291316
for &int_ty in &[I8, I16] {

filetests/isa/x86/i128.clif

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,21 @@ ebb0(v0: i128):
2626
; check: v6 = x86_pop.i64
2727
; check: return v3, v4, v6
2828
}
29+
30+
function u0:1(i64, i128) fast {
31+
; check: ebb0(v0: i64 [%rdi], v2: i64 [%rsi], v3: i64 [%rdx], v4: i64 [%rbp]):
32+
ebb0(v0: i64, v1: i128):
33+
; check: store v2, v0
34+
; check: store v3, v0+8
35+
store v1, v0
36+
return
37+
}
38+
39+
function u0:1(i64) -> i128 fast {
40+
ebb0(v0: i64):
41+
; check: v2 = load.i64 v0
42+
; check: v3 = load.i64 v0+8
43+
v1 = load.i128 v0
44+
; check: return v2, v3, v5
45+
return v1
46+
}

0 commit comments

Comments
 (0)