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:
@@ -329,6 +329,8 @@ instruction in the EBB.
|
||||
.. autoinst:: brz
|
||||
.. autoinst:: brnz
|
||||
.. autoinst:: br_icmp
|
||||
.. autoinst:: brif
|
||||
.. autoinst:: brff
|
||||
.. autoinst:: br_table
|
||||
|
||||
.. inst:: JT = jump_table EBB0, EBB1, ..., EBBn
|
||||
@@ -722,6 +724,8 @@ Integer operations
|
||||
|
||||
.. autoinst:: icmp
|
||||
.. autoinst:: icmp_imm
|
||||
.. autoinst:: ifcmp
|
||||
.. autoinst:: ifcmp_imm
|
||||
.. autoinst:: iadd
|
||||
.. autoinst:: iadd_imm
|
||||
.. autoinst:: iadd_cin
|
||||
@@ -814,6 +818,7 @@ Floating point operations
|
||||
These operations generally follow IEEE 754-2008 semantics.
|
||||
|
||||
.. autoinst:: fcmp
|
||||
.. autoinst:: ffcmp
|
||||
.. autoinst:: fadd
|
||||
.. autoinst:: fsub
|
||||
.. autoinst:: fmul
|
||||
@@ -857,6 +862,12 @@ represented as a floating point number.
|
||||
.. autoinst:: trunc
|
||||
.. autoinst:: nearest
|
||||
|
||||
CPU flag operations
|
||||
-------------------
|
||||
|
||||
.. autoinst:: trueif
|
||||
.. autoinst:: trueff
|
||||
|
||||
Conversion operations
|
||||
---------------------
|
||||
|
||||
|
||||
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