Add instructions using CPU flags.
Add integer and floating comparison instructions that return CPU flags: ifcmp, ifcmp_imm, and ffcmp. Add conditional branch instructions that check CPU flags: brif, brff Add instructions that check a condition in the CPU flags and return a b1: trueif, trueff.
This commit is contained in:
46
cranelift/filetests/parser/flags.cton
Normal file
46
cranelift/filetests/parser/flags.cton
Normal file
@@ -0,0 +1,46 @@
|
||||
test cat
|
||||
test verifier
|
||||
|
||||
function %iflags(i32) {
|
||||
ebb0(v0: i32):
|
||||
v1 = ifcmp_imm v0, 17
|
||||
brif eq v1, ebb1
|
||||
brif ugt v1, ebb2
|
||||
v2 = iconst.i32 34
|
||||
v3 = ifcmp v0, v2
|
||||
v4 = trueif eq v3
|
||||
brnz v4, ebb2
|
||||
return
|
||||
|
||||
ebb1:
|
||||
return
|
||||
|
||||
ebb2:
|
||||
trap oob
|
||||
}
|
||||
; check: $v1 = ifcmp_imm $v0, 17
|
||||
; check: brif eq $v1, $ebb1
|
||||
; check: brif ugt $v1, $ebb2
|
||||
; check: $v3 = ifcmp $v0, $v2
|
||||
; check: $v4 = trueif eq $v3
|
||||
|
||||
function %fflags(f32) {
|
||||
ebb0(v0: f32):
|
||||
v1 = f32const 0x34.0p0
|
||||
v2 = ffcmp v0, v1
|
||||
brff eq v2, ebb1
|
||||
brff ord v2, ebb2
|
||||
v3 = trueff gt v2
|
||||
brnz v3, ebb2
|
||||
return
|
||||
|
||||
ebb1:
|
||||
return
|
||||
|
||||
ebb2:
|
||||
trap oob
|
||||
}
|
||||
; check: $v2 = ffcmp $v0, $v1
|
||||
; check: brff eq $v2, $ebb1
|
||||
; check: brff ord $v2, $ebb2
|
||||
; check: $v3 = trueff gt $v2
|
||||
Reference in New Issue
Block a user