Skip to content

Commit c9e692f

Browse files
committed
cranelift: Fix trampoline args for b1 types
Our DataValues only have one size of booleans so we are always going to have this mismatch of sizes
1 parent ebbe399 commit c9e692f

File tree

3 files changed

+17
-44
lines changed

3 files changed

+17
-44
lines changed

cranelift/codegen/src/data_value.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ impl DataValue {
6262
}
6363
}
6464

65+
/// Return true if the value is a bool (i.e. `DataValue::B`).
66+
pub fn is_bool(&self) -> bool {
67+
match self {
68+
DataValue::B(_) => true,
69+
_ => false,
70+
}
71+
}
72+
6573
/// Write a [DataValue] to a memory location.
6674
pub unsafe fn write_value_to(&self, p: *mut u128) {
6775
match self {

cranelift/filetests/filetests/runtests/br.clif

Lines changed: 8 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -90,26 +90,8 @@ block2:
9090
; run: %brz_i8(-1) == false
9191

9292

93-
; TODO: Merge this with brz_b1_false when we are able to pass bool imm's in test params
94-
function %brz_b1_true() -> b1 {
95-
block0:
96-
v1 = bconst.b1 true
97-
brz v1, block1
98-
jump block2
99-
100-
block1:
101-
v2 = bconst.b1 true
102-
return v2
103-
104-
block2:
105-
v3 = bconst.b1 false
106-
return v3
107-
}
108-
; run: %brz_b1_true() == false
109-
110-
function %brz_b1_false() -> b1 {
111-
block0:
112-
v1 = bconst.b1 false
93+
function %brz_b1(b1) -> b1 {
94+
block0(v1: b1):
11395
brz v1, block1
11496
jump block2
11597

@@ -121,8 +103,8 @@ block2:
121103
v3 = bconst.b1 false
122104
return v3
123105
}
124-
; run: %brz_b1_false() == true
125-
106+
; run: %brz_b1(true) == false
107+
; run: %brz_b1(false) == true
126108

127109

128110
function %brnz_i64(i64) -> b1 {
@@ -194,26 +176,8 @@ block2:
194176
; run: %brnz_i8(-1) == true
195177

196178

197-
; TODO: Merge this with brz_b1_false when we are able to pass bool imm's in test params
198-
function %brnz_b1_true() -> b1 {
199-
block0:
200-
v1 = bconst.b1 true
201-
brnz v1, block1
202-
jump block2
203-
204-
block1:
205-
v2 = bconst.b1 true
206-
return v2
207-
208-
block2:
209-
v3 = bconst.b1 false
210-
return v3
211-
}
212-
; run: %brnz_b1_true() == true
213-
214-
function %brnz_b1_false() -> b1 {
215-
block0:
216-
v1 = bconst.b1 false
179+
function %brnz_b1(b1) -> b1 {
180+
block0(v1: b1):
217181
brnz v1, block1
218182
jump block2
219183

@@ -225,4 +189,5 @@ block2:
225189
v3 = bconst.b1 false
226190
return v3
227191
}
228-
; run: %brnz_b1_false() == false
192+
; run: %brnz_b1(true) == true
193+
; run: %brnz_b1(false) == false

cranelift/filetests/src/function_runner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl UnboxedValues {
198198
// Store the argument values into `values_vec`.
199199
for ((arg, slot), param) in arguments.iter().zip(&mut values_vec).zip(&signature.params) {
200200
assert!(
201-
arg.ty() == param.value_type || arg.is_vector(),
201+
arg.ty() == param.value_type || arg.is_vector() || arg.is_bool(),
202202
"argument type mismatch: {} != {}",
203203
arg.ty(),
204204
param.value_type

0 commit comments

Comments
 (0)