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

Commit

Permalink
Handle isplit when it is not the result of a legalization
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Jun 17, 2019
1 parent 5f72faf commit 19fad8b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 8 deletions.
25 changes: 25 additions & 0 deletions cranelift-codegen/src/legalizer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,31 @@ fn legalize_inst(
}
} else if opcode.is_branch() {
split::simplify_branch_arguments(&mut pos.func.dfg, inst);
} else if opcode == ir::Opcode::Isplit {
pos.use_srcloc(inst);

let arg = match pos.func.dfg[inst] {
ir::InstructionData::Unary {
arg,
..
} => pos.func.dfg.resolve_aliases(arg),
_ => panic!("Expected isplit: {}", pos.func.dfg.display_inst(inst, None)),
};

let res = pos.func.dfg.inst_results(inst).to_vec();
assert_eq!(res.len(), 2);
let (resl, resh) = (res[0], res[1]); // Prevent borrowck error

let curpos = pos.position();
let srcloc = pos.srcloc();
let (xl, xh) = split::isplit(pos.func, cfg, curpos, srcloc, arg);

pos.func.dfg.clear_results(inst);
pos.remove_inst();
pos.func.dfg.change_to_alias(resl, xl);
pos.func.dfg.change_to_alias(resh, xh);

return true;
}

match pos.func.update_encoding(inst, isa) {
Expand Down
31 changes: 23 additions & 8 deletions filetests/isa/x86/i128.clif
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
test compile
target x86_64

function u0:0(i128) -> i128 fast {
function u0:0(i64, i64) -> i128 fast {
ebb0(v0: i64, v1: i64):
;check: ebb0(v0: i64 [%rdi], v1: i64 [%rsi], v3: i64 [%rbp]):

v2 = iconcat.i64 v0, v1
; check: regmove v0, %rdi -> %rax
; check: regmove v1, %rsi -> %rdx

return v2
; check: v4 = x86_pop.i64
; check: return v0, v1, v4
}

function u0:1(i128) -> i64, i64 fast {
ebb0(v0: i128):
v1 = iconst.i64 0
v2 = iconst.i64 42
v3 = iconcat.i64 v2, v1
return v3
; check: v1 = iconst.i64 0
; check: v2 = iconst.i64 42
; check: return v2, v1, v7
; check: ebb0(v3: i64 [%rdi], v4: i64 [%rsi], v5: i64 [%rbp]):

v1, v2 = isplit v0
; check: regmove v3, %rdi -> %rax
; check: regmove v4, %rsi -> %rdx

return v1, v2
; check: v6 = x86_pop.i64
; check: return v3, v4, v6
}

0 comments on commit 19fad8b

Please sign in to comment.