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

Commit

Permalink
Legalize load.i128 and store.i128
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Jun 29, 2019
1 parent 0f9307d commit 4bdcd20
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cranelift-codegen/meta/src/shared/legalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pub fn define(insts: &InstructionGroup, immediates: &OperandKinds) -> TransformG
let ieee32 = immediates.by_name("ieee32");
let ieee64 = immediates.by_name("ieee64");
let intcc = immediates.by_name("intcc");
let offset32 = immediates.by_name("offset32");

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

// FIXME generalize to any offset once offset+8 can be represented
narrow.legalize(
def!(a = load.I128(flags, ptr, Literal::constant(offset32, 0))),
vec![
def!(al = load.I64(flags, ptr, Literal::constant(offset32, 0))),
def!(ah = load.I64(flags, ptr, Literal::constant(offset32, 8))),
// `iconcat` expects the same byte order as stored in memory,
// so no need to swap depending on endianness.
def!(a = iconcat(al, ah)),
],
);

// FIXME generalize to any offset once offset+8 can be represented
narrow.legalize(
def!(store.I128(flags, a, ptr, Literal::constant(offset32, 0))),
vec![
// `isplit` gives the same byte order as stored in memory,
// so no need to swap depending on endianness.
def!((al, ah) = isplit(a)),
def!(store.I64(flags, al, ptr, Literal::constant(offset32, 0))),
def!(store.I64(flags, ah, ptr, Literal::constant(offset32, 8))),
],
);

// Widen instructions with one input operand.
for &op in &[bnot, popcnt] {
for &int_ty in &[I8, I16] {
Expand Down
18 changes: 18 additions & 0 deletions filetests/isa/x86/i128.clif
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,21 @@ ebb0(v0: i128):
; check: v6 = x86_pop.i64
; check: return v3, v4, v6
}

function u0:1(i64, i128) fast {
; check: ebb0(v0: i64 [%rdi], v2: i64 [%rsi], v3: i64 [%rdx], v4: i64 [%rbp]):
ebb0(v0: i64, v1: i128):
; check: store v2, v0
; check: store v3, v0+8
store v1, v0
return
}

function u0:1(i64) -> i128 fast {
ebb0(v0: i64):
; check: v2 = load.i64 v0
; check: v3 = load.i64 v0+8
v1 = load.i128 v0
; check: return v2, v3, v5
return v1
}

0 comments on commit 4bdcd20

Please sign in to comment.