Skip to content

Commit

Permalink
cranelift: Support boolean arguments larger than b1 in trampoline (b…
Browse files Browse the repository at this point in the history
  • Loading branch information
afonso360 committed Jun 30, 2022
1 parent 301142f commit 1f46ca1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cranelift/filetests/filetests/runtests/bextend.clif
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
test interpret
test run
target aarch64
target x86_64
target s390x

function %bextend_b1_b8(b1) -> b8 {
block0(v0: b1):
Expand Down
4 changes: 4 additions & 0 deletions cranelift/filetests/filetests/runtests/breduce.clif
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
test interpret
test run
target aarch64
target x86_64
target s390x

function %breduce_b8_b1(b8) -> b1 {
block0(v0: b8):
Expand Down
9 changes: 8 additions & 1 deletion cranelift/filetests/src/function_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,14 @@ fn make_trampoline(signature: &ir::Signature, isa: &dyn TargetIsa) -> Function {
// that we are using the architecture's canonical boolean representation (presumably
// comparison will emit this).
if param.value_type.is_bool() {
builder.ins().icmp_imm(IntCC::NotEqual, loaded, 0)
let b = builder.ins().icmp_imm(IntCC::NotEqual, loaded, 0);

// icmp_imm always produces a `b1`, `bextend` it if we need a larger bool
if param.value_type.bits() > 1 {
builder.ins().bextend(param.value_type, b)
} else {
b
}
} else if param.value_type.is_bool_vector() {
let zero_constant = builder.func.dfg.constants.insert(vec![0; 16].into());
let zero_vec = builder.ins().vconst(ty, zero_constant);
Expand Down

0 comments on commit 1f46ca1

Please sign in to comment.