Rename Cretonne to Cranelift!
This commit is contained in:
80
cranelift/filetests/regalloc/basic.clif
Normal file
80
cranelift/filetests/regalloc/basic.clif
Normal file
@@ -0,0 +1,80 @@
|
||||
test regalloc
|
||||
|
||||
; We can add more ISAs once they have defined encodings.
|
||||
target riscv32
|
||||
|
||||
; regex: RX=%x\d+
|
||||
|
||||
function %add(i32, i32) {
|
||||
ebb0(v1: i32, v2: i32):
|
||||
v3 = iadd v1, v2
|
||||
; check: [R#0c,%x5]
|
||||
; sameln: iadd
|
||||
return
|
||||
}
|
||||
|
||||
; Function with a dead argument.
|
||||
function %dead_arg(i32, i32) -> i32{
|
||||
ebb0(v1: i32, v2: i32):
|
||||
; not: regmove
|
||||
; check: return v1
|
||||
return v1
|
||||
}
|
||||
|
||||
; Return a value from a different register.
|
||||
function %move1(i32, i32) -> i32 {
|
||||
ebb0(v1: i32, v2: i32):
|
||||
; not: regmove
|
||||
; check: regmove v2, %x11 -> %x10
|
||||
; nextln: return v2
|
||||
return v2
|
||||
}
|
||||
|
||||
; Swap two registers.
|
||||
function %swap(i32, i32) -> i32, i32 {
|
||||
ebb0(v1: i32, v2: i32):
|
||||
; not: regmove
|
||||
; check: regmove v2, %x11 -> $(tmp=$RX)
|
||||
; nextln: regmove v1, %x10 -> %x11
|
||||
; nextln: regmove v2, $tmp -> %x10
|
||||
; nextln: return v2, v1
|
||||
return v2, v1
|
||||
}
|
||||
|
||||
; Return an EBB argument.
|
||||
function %retebb(i32, i32) -> i32 {
|
||||
ebb0(v1: i32, v2: i32):
|
||||
brnz v1, ebb1(v1)
|
||||
jump ebb1(v2)
|
||||
|
||||
ebb1(v10: i32):
|
||||
return v10
|
||||
}
|
||||
|
||||
; Pass an EBB argument as a function argument.
|
||||
function %callebb(i32, i32) -> i32 {
|
||||
fn0 = %foo(i32) -> i32
|
||||
|
||||
ebb0(v1: i32, v2: i32):
|
||||
brnz v1, ebb1(v1)
|
||||
jump ebb1(v2)
|
||||
|
||||
ebb1(v10: i32):
|
||||
v11 = call fn0(v10)
|
||||
return v11
|
||||
}
|
||||
|
||||
; Pass an EBB argument as a jump argument.
|
||||
function %jumpebb(i32, i32) -> i32 {
|
||||
fn0 = %foo(i32) -> i32
|
||||
|
||||
ebb0(v1: i32, v2: i32):
|
||||
brnz v1, ebb1(v1, v2)
|
||||
jump ebb1(v2, v1)
|
||||
|
||||
ebb1(v10: i32, v11: i32):
|
||||
jump ebb2(v10, v11)
|
||||
|
||||
ebb2(v20: i32, v21: i32):
|
||||
return v21
|
||||
}
|
||||
Reference in New Issue
Block a user