moved crates in lib/ to src/, renamed crates, modified some files' text (#660)
moved crates in lib/ to src/, renamed crates, modified some files' text (#660)
This commit is contained in:
35
cranelift/filetests/filetests/cfg/loop.clif
Normal file
35
cranelift/filetests/filetests/cfg/loop.clif
Normal file
@@ -0,0 +1,35 @@
|
||||
; For testing cfg generation. This code is nonsense.
|
||||
test print-cfg
|
||||
test verifier
|
||||
|
||||
function %nonsense(i32, i32) -> f32 {
|
||||
; check: digraph "%nonsense" {
|
||||
; regex: I=\binst\d+\b
|
||||
; check: label="{ebb0 | <$(BRZ=$I)>brz ebb2 | <$(JUMP=$I)>jump ebb1}"]
|
||||
|
||||
ebb0(v1: i32, v2: i32):
|
||||
v3 = f64const 0x0.0
|
||||
brz v2, ebb2 ; unordered: ebb0:$BRZ -> ebb2
|
||||
v4 = iconst.i32 0
|
||||
jump ebb1(v4) ; unordered: ebb0:$JUMP -> ebb1
|
||||
|
||||
ebb1(v5: i32):
|
||||
v6 = imul_imm v5, 4
|
||||
v7 = iadd v1, v6
|
||||
v8 = f32const 0.0
|
||||
v9 = f32const 0.0
|
||||
v10 = f32const 0.0
|
||||
v11 = fadd v9, v10
|
||||
v12 = iadd_imm v5, 1
|
||||
v13 = icmp ult v12, v2
|
||||
brnz v13, ebb1(v12) ; unordered: ebb1:inst12 -> ebb1
|
||||
v14 = f64const 0.0
|
||||
v15 = f64const 0.0
|
||||
v16 = fdiv v14, v15
|
||||
v17 = f32const 0.0
|
||||
return v17
|
||||
|
||||
ebb2:
|
||||
v100 = f32const 0.0
|
||||
return v100
|
||||
}
|
||||
21
cranelift/filetests/filetests/cfg/traps_early.clif
Normal file
21
cranelift/filetests/filetests/cfg/traps_early.clif
Normal file
@@ -0,0 +1,21 @@
|
||||
; For testing cfg generation. This code explores the implications of encountering
|
||||
; a terminating instruction before any connections have been made.
|
||||
test print-cfg
|
||||
test verifier
|
||||
|
||||
function %nonsense(i32) {
|
||||
; check: digraph "%nonsense" {
|
||||
|
||||
ebb0(v1: i32):
|
||||
trap user0 ; error: terminator instruction was encountered before the end
|
||||
brnz v1, ebb2 ; unordered: ebb0:inst1 -> ebb2
|
||||
jump ebb1 ; unordered: ebb0:inst2 -> ebb1
|
||||
|
||||
ebb1:
|
||||
v2 = iconst.i32 0
|
||||
v3 = iadd v1, v3
|
||||
jump ebb0(v3) ; unordered: ebb1:inst5 -> ebb0
|
||||
|
||||
ebb2:
|
||||
return v1
|
||||
}
|
||||
21
cranelift/filetests/filetests/cfg/unused_node.clif
Normal file
21
cranelift/filetests/filetests/cfg/unused_node.clif
Normal file
@@ -0,0 +1,21 @@
|
||||
; For testing cfg generation where some block is never reached.
|
||||
test print-cfg
|
||||
|
||||
function %not_reached(i32) -> i32 {
|
||||
; check: digraph "%not_reached" {
|
||||
; check: ebb0 [shape=record, label="{ebb0 | <inst0>brnz ebb2}"]
|
||||
; check: ebb1 [shape=record, label="{ebb1 | <inst4>jump ebb0}"]
|
||||
; check: ebb2 [shape=record, label="{ebb2}"]
|
||||
|
||||
ebb0(v0: i32):
|
||||
brnz v0, ebb2 ; unordered: ebb0:inst0 -> ebb2
|
||||
trap user0
|
||||
|
||||
ebb1:
|
||||
v1 = iconst.i32 1
|
||||
v2 = iadd v0, v1
|
||||
jump ebb0(v2) ; unordered: ebb1:inst4 -> ebb0
|
||||
|
||||
ebb2:
|
||||
return v0
|
||||
}
|
||||
46
cranelift/filetests/filetests/dce/basic.clif
Normal file
46
cranelift/filetests/filetests/dce/basic.clif
Normal file
@@ -0,0 +1,46 @@
|
||||
test dce
|
||||
|
||||
function %simple() -> i32 {
|
||||
ebb0:
|
||||
v2 = iconst.i32 2
|
||||
v3 = iconst.i32 3
|
||||
return v3
|
||||
}
|
||||
; sameln: function %simple
|
||||
; nextln: ebb0:
|
||||
; nextln: v3 = iconst.i32 3
|
||||
; nextln: return v3
|
||||
; nextln: }
|
||||
|
||||
function %some_branching(i32, i32) -> i32 {
|
||||
ebb0(v0: i32, v1: i32):
|
||||
v3 = iconst.i32 70
|
||||
v4 = iconst.i32 71
|
||||
v5 = iconst.i32 72
|
||||
v8 = iconst.i32 73
|
||||
brz v0, ebb1
|
||||
jump ebb2(v8)
|
||||
|
||||
ebb1:
|
||||
v2 = iadd v0, v3
|
||||
return v0
|
||||
|
||||
ebb2(v9: i32):
|
||||
v6 = iadd v1, v4
|
||||
v7 = iadd v6, v9
|
||||
return v7
|
||||
}
|
||||
; sameln: function %some_branching
|
||||
; nextln: ebb0(v0: i32, v1: i32):
|
||||
; nextln: v4 = iconst.i32 71
|
||||
; nextln: v8 = iconst.i32 73
|
||||
; nextln: brz v0, ebb1
|
||||
; nextln: jump ebb2(v8)
|
||||
; nextln:
|
||||
; nextln: ebb1:
|
||||
; nextln: return v0
|
||||
; nextln:
|
||||
; nextln: ebb2(v9: i32):
|
||||
; nextln: v6 = iadd.i32 v1, v4
|
||||
; nextln: v7 = iadd v6, v9
|
||||
; nextln: return v7
|
||||
25
cranelift/filetests/filetests/domtree/basic.clif
Normal file
25
cranelift/filetests/filetests/domtree/basic.clif
Normal file
@@ -0,0 +1,25 @@
|
||||
test domtree
|
||||
|
||||
function %test(i32) {
|
||||
ebb0(v0: i32):
|
||||
jump ebb1 ; dominates: ebb1
|
||||
ebb1:
|
||||
brz v0, ebb3 ; dominates: ebb3
|
||||
jump ebb2 ; dominates: ebb2
|
||||
ebb2:
|
||||
jump ebb3
|
||||
ebb3:
|
||||
return
|
||||
}
|
||||
; check: cfg_postorder:
|
||||
; sameln: ebb2
|
||||
; sameln: ebb3
|
||||
; sameln: ebb1
|
||||
; sameln: ebb0
|
||||
|
||||
; check: domtree_preorder {
|
||||
; nextln: ebb0: ebb1
|
||||
; nextln: ebb1: ebb3 ebb2
|
||||
; nextln: ebb3:
|
||||
; nextln: ebb2:
|
||||
; nextln: }
|
||||
104
cranelift/filetests/filetests/domtree/loops.clif
Normal file
104
cranelift/filetests/filetests/domtree/loops.clif
Normal file
@@ -0,0 +1,104 @@
|
||||
test domtree
|
||||
|
||||
function %test(i32) {
|
||||
ebb0(v0: i32):
|
||||
brz v0, ebb1 ; dominates: ebb1 ebb3 ebb4 ebb5
|
||||
jump ebb2 ; dominates: ebb2
|
||||
ebb1:
|
||||
jump ebb3
|
||||
ebb2:
|
||||
brz v0, ebb4
|
||||
jump ebb5
|
||||
ebb3:
|
||||
jump ebb4
|
||||
ebb4:
|
||||
brz v0, ebb3
|
||||
jump ebb5
|
||||
ebb5:
|
||||
brz v0, ebb4
|
||||
return
|
||||
}
|
||||
; Fall-through-first, prune-at-source DFT:
|
||||
;
|
||||
; ebb0 {
|
||||
; ebb0:brz v0, ebb1 {
|
||||
; ebb0:jump ebb2 {
|
||||
; ebb2 {
|
||||
; ebb2:brz v2, ebb2 -
|
||||
; ebb2:brz v3, ebb1 -
|
||||
; ebb2:brz v4, ebb4 {
|
||||
; ebb2: jump ebb5 {
|
||||
; ebb5 {}
|
||||
; }
|
||||
; ebb4 {}
|
||||
; }
|
||||
; } ebb2
|
||||
; }
|
||||
; ebb1 {
|
||||
; ebb1:jump ebb3 {
|
||||
; ebb3 {}
|
||||
; }
|
||||
; } ebb1
|
||||
; }
|
||||
; } ebb0
|
||||
;
|
||||
; check: cfg_postorder:
|
||||
; sameln: ebb5
|
||||
; sameln: ebb3
|
||||
; sameln: ebb4
|
||||
; sameln: ebb2
|
||||
; sameln: ebb1
|
||||
; sameln: ebb0
|
||||
|
||||
; check: domtree_preorder {
|
||||
; nextln: ebb0: ebb1 ebb2 ebb4 ebb3 ebb5
|
||||
; nextln: ebb1:
|
||||
; nextln: ebb2:
|
||||
; nextln: ebb4:
|
||||
; nextln: ebb3:
|
||||
; nextln: ebb5:
|
||||
; nextln: }
|
||||
|
||||
function %loop2(i32) system_v {
|
||||
ebb0(v0: i32):
|
||||
brz v0, ebb1 ; dominates: ebb1 ebb3 ebb4 ebb5
|
||||
jump ebb2 ; dominates: ebb2
|
||||
ebb1:
|
||||
jump ebb3
|
||||
ebb2:
|
||||
brz v0, ebb4
|
||||
jump ebb5
|
||||
ebb3:
|
||||
jump ebb4
|
||||
ebb4:
|
||||
brz v0, ebb3
|
||||
brnz v0, ebb5
|
||||
jump ebb6 ; dominates: ebb6
|
||||
ebb5:
|
||||
brz v0, ebb4
|
||||
trap user0
|
||||
ebb6:
|
||||
jump ebb7 ; dominates: ebb7
|
||||
ebb7:
|
||||
return
|
||||
}
|
||||
; check: cfg_postorder:
|
||||
; sameln: ebb5
|
||||
; sameln: ebb7
|
||||
; sameln: ebb6
|
||||
; sameln: ebb3
|
||||
; sameln: ebb4
|
||||
; sameln: ebb2
|
||||
; sameln: ebb1
|
||||
; sameln: ebb0
|
||||
|
||||
; check: domtree_preorder {
|
||||
; nextln: ebb0: ebb1 ebb2 ebb4 ebb3 ebb5
|
||||
; nextln: ebb1:
|
||||
; nextln: ebb2:
|
||||
; nextln: ebb4: ebb6
|
||||
; nextln: ebb6: ebb7
|
||||
; nextln: ebb7:
|
||||
; nextln: ebb3:
|
||||
; nextln: ebb5:
|
||||
; nextln: }
|
||||
79
cranelift/filetests/filetests/domtree/loops2.clif
Normal file
79
cranelift/filetests/filetests/domtree/loops2.clif
Normal file
@@ -0,0 +1,79 @@
|
||||
test domtree
|
||||
|
||||
function %loop1(i32) {
|
||||
ebb0(v0: i32):
|
||||
brz v0, ebb1 ; dominates: ebb1 ebb6
|
||||
brnz v0, ebb2 ; dominates: ebb2 ebb9
|
||||
jump ebb3 ; dominates: ebb3
|
||||
ebb1:
|
||||
jump ebb6
|
||||
ebb2:
|
||||
brz v0, ebb4 ; dominates: ebb4 ebb7 ebb8
|
||||
jump ebb5 ; dominates: ebb5
|
||||
ebb3:
|
||||
jump ebb9
|
||||
ebb4:
|
||||
brz v0, ebb4
|
||||
brnz v0, ebb6
|
||||
jump ebb7
|
||||
ebb5:
|
||||
brz v0, ebb7
|
||||
brnz v0, ebb8
|
||||
jump ebb9
|
||||
ebb6:
|
||||
return
|
||||
ebb7:
|
||||
jump ebb8
|
||||
ebb8:
|
||||
return
|
||||
ebb9:
|
||||
return
|
||||
}
|
||||
|
||||
; check: domtree_preorder {
|
||||
; nextln: ebb0: ebb1 ebb2 ebb6 ebb3 ebb9
|
||||
; nextln: ebb1:
|
||||
; nextln: ebb2: ebb4 ebb5 ebb7 ebb8
|
||||
; nextln: ebb4:
|
||||
; nextln: ebb5:
|
||||
; nextln: ebb7:
|
||||
; nextln: ebb8:
|
||||
; nextln: ebb6:
|
||||
; nextln: ebb3:
|
||||
; nextln: ebb9:
|
||||
; nextln: }
|
||||
|
||||
function %loop2(i32) system_v {
|
||||
ebb0(v0: i32):
|
||||
brz v0, ebb1 ; dominates: ebb1 ebb3 ebb4 ebb5
|
||||
jump ebb2 ; dominates: ebb2
|
||||
ebb1:
|
||||
jump ebb3
|
||||
ebb2:
|
||||
brz v0, ebb4
|
||||
jump ebb5
|
||||
ebb3:
|
||||
jump ebb4
|
||||
ebb4:
|
||||
brz v0, ebb3
|
||||
jump ebb5
|
||||
ebb5:
|
||||
brz v0, ebb4
|
||||
return
|
||||
}
|
||||
; check: cfg_postorder:
|
||||
; sameln: ebb5
|
||||
; sameln: ebb3
|
||||
; sameln: ebb4
|
||||
; sameln: ebb2
|
||||
; sameln: ebb1
|
||||
; sameln: ebb0
|
||||
|
||||
; check: domtree_preorder {
|
||||
; nextln: ebb0: ebb1 ebb2 ebb4 ebb3 ebb5
|
||||
; nextln: ebb1:
|
||||
; nextln: ebb2:
|
||||
; nextln: ebb4:
|
||||
; nextln: ebb3:
|
||||
; nextln: ebb5:
|
||||
; nextln: }
|
||||
48
cranelift/filetests/filetests/domtree/tall-tree.clif
Normal file
48
cranelift/filetests/filetests/domtree/tall-tree.clif
Normal file
@@ -0,0 +1,48 @@
|
||||
test domtree
|
||||
|
||||
function %test(i32) {
|
||||
ebb0(v0: i32):
|
||||
brz v0, ebb1 ; dominates: ebb1
|
||||
brnz v0, ebb2 ; dominates: ebb2 ebb5
|
||||
jump ebb3 ; dominates: ebb3
|
||||
ebb1:
|
||||
jump ebb4 ; dominates: ebb4
|
||||
ebb2:
|
||||
jump ebb5
|
||||
ebb3:
|
||||
jump ebb5
|
||||
ebb4:
|
||||
brz v0, ebb6 ; dominates: ebb6 ebb10
|
||||
jump ebb7 ; dominates: ebb7
|
||||
ebb5:
|
||||
return
|
||||
ebb6:
|
||||
brz v0, ebb8 ; dominates: ebb11 ebb8
|
||||
brnz v0, ebb9 ; dominates: ebb9
|
||||
jump ebb10
|
||||
ebb7:
|
||||
jump ebb10
|
||||
ebb8:
|
||||
jump ebb11
|
||||
ebb9:
|
||||
jump ebb11
|
||||
ebb10:
|
||||
return
|
||||
ebb11:
|
||||
return
|
||||
}
|
||||
|
||||
; check: domtree_preorder {
|
||||
; nextln: ebb0: ebb1 ebb2 ebb3 ebb5
|
||||
; nextln: ebb1: ebb4
|
||||
; nextln: ebb4: ebb6 ebb7 ebb10
|
||||
; nextln: ebb6: ebb8 ebb9 ebb11
|
||||
; nextln: ebb8:
|
||||
; nextln: ebb9:
|
||||
; nextln: ebb11:
|
||||
; nextln: ebb7:
|
||||
; nextln: ebb10:
|
||||
; nextln: ebb2:
|
||||
; nextln: ebb3:
|
||||
; nextln: ebb5:
|
||||
; nextln: }
|
||||
58
cranelift/filetests/filetests/domtree/wide-tree.clif
Normal file
58
cranelift/filetests/filetests/domtree/wide-tree.clif
Normal file
@@ -0,0 +1,58 @@
|
||||
test domtree
|
||||
|
||||
function %test(i32) {
|
||||
ebb0(v0: i32):
|
||||
brz v0, ebb13 ; dominates: ebb13
|
||||
jump ebb1 ; dominates: ebb1
|
||||
ebb1:
|
||||
brz v0, ebb2 ; dominates: ebb2 ebb7
|
||||
brnz v0, ebb3 ; dominates: ebb3
|
||||
brz v0, ebb4 ; dominates: ebb4
|
||||
brnz v0, ebb5 ; dominates: ebb5
|
||||
jump ebb6 ; dominates: ebb6
|
||||
ebb2:
|
||||
jump ebb7
|
||||
ebb3:
|
||||
jump ebb7
|
||||
ebb4:
|
||||
jump ebb7
|
||||
ebb5:
|
||||
jump ebb7
|
||||
ebb6:
|
||||
jump ebb7
|
||||
ebb7:
|
||||
brnz v0, ebb8 ; dominates: ebb8 ebb12
|
||||
brz v0, ebb9 ; dominates: ebb9
|
||||
brnz v0, ebb10 ; dominates: ebb10
|
||||
jump ebb11 ; dominates: ebb11
|
||||
ebb8:
|
||||
jump ebb12
|
||||
ebb9:
|
||||
jump ebb12
|
||||
ebb10:
|
||||
brz v0, ebb13
|
||||
jump ebb12
|
||||
ebb11:
|
||||
jump ebb13
|
||||
ebb12:
|
||||
return
|
||||
ebb13:
|
||||
return
|
||||
}
|
||||
|
||||
; check: domtree_preorder {
|
||||
; nextln: ebb0: ebb13 ebb1
|
||||
; nextln: ebb13:
|
||||
; nextln: ebb1: ebb2 ebb3 ebb4 ebb5 ebb6 ebb7
|
||||
; nextln: ebb2:
|
||||
; nextln: ebb3:
|
||||
; nextln: ebb4:
|
||||
; nextln: ebb5:
|
||||
; nextln: ebb6:
|
||||
; nextln: ebb7: ebb8 ebb9 ebb10 ebb12 ebb11
|
||||
; nextln: ebb8:
|
||||
; nextln: ebb9:
|
||||
; nextln: ebb10:
|
||||
; nextln: ebb12:
|
||||
; nextln: ebb11:
|
||||
; nextln: }
|
||||
14
cranelift/filetests/filetests/isa/riscv/abi-e.clif
Normal file
14
cranelift/filetests/filetests/isa/riscv/abi-e.clif
Normal file
@@ -0,0 +1,14 @@
|
||||
; Test the legalization of function signatures for RV32E.
|
||||
test legalizer
|
||||
target riscv32 enable_e
|
||||
|
||||
; regex: V=v\d+
|
||||
|
||||
function %f() {
|
||||
; Spilling into the stack args after %x15 since %16 and up are not
|
||||
; available in RV32E.
|
||||
sig0 = (i64, i64, i64, i64) -> i64 system_v
|
||||
; check: sig0 = (i32 [%x10], i32 [%x11], i32 [%x12], i32 [%x13], i32 [%x14], i32 [%x15], i32 [0], i32 [4]) -> i32 [%x10], i32 [%x11] system_v
|
||||
ebb0:
|
||||
return
|
||||
}
|
||||
32
cranelift/filetests/filetests/isa/riscv/abi.clif
Normal file
32
cranelift/filetests/filetests/isa/riscv/abi.clif
Normal file
@@ -0,0 +1,32 @@
|
||||
; Test the legalization of function signatures.
|
||||
test legalizer
|
||||
target riscv32
|
||||
|
||||
; regex: V=v\d+
|
||||
|
||||
function %f() {
|
||||
sig0 = (i32) -> i32 system_v
|
||||
; check: sig0 = (i32 [%x10]) -> i32 [%x10] system_v
|
||||
|
||||
sig1 = (i64) -> b1 system_v
|
||||
; check: sig1 = (i32 [%x10], i32 [%x11]) -> b1 [%x10] system_v
|
||||
|
||||
; The i64 argument must go in an even-odd register pair.
|
||||
sig2 = (f32, i64) -> f64 system_v
|
||||
; check: sig2 = (f32 [%f10], i32 [%x12], i32 [%x13]) -> f64 [%f10] system_v
|
||||
|
||||
; Spilling into the stack args.
|
||||
sig3 = (f64, f64, f64, f64, f64, f64, f64, i64) -> f64 system_v
|
||||
; check: sig3 = (f64 [%f10], f64 [%f11], f64 [%f12], f64 [%f13], f64 [%f14], f64 [%f15], f64 [%f16], i32 [0], i32 [4]) -> f64 [%f10] system_v
|
||||
|
||||
; Splitting vectors.
|
||||
sig4 = (i32x4) system_v
|
||||
; check: sig4 = (i32 [%x10], i32 [%x11], i32 [%x12], i32 [%x13]) system_v
|
||||
|
||||
; Splitting vectors, then splitting ints.
|
||||
sig5 = (i64x4) system_v
|
||||
; check: sig5 = (i32 [%x10], i32 [%x11], i32 [%x12], i32 [%x13], i32 [%x14], i32 [%x15], i32 [%x16], i32 [%x17]) system_v
|
||||
|
||||
ebb0:
|
||||
return
|
||||
}
|
||||
145
cranelift/filetests/filetests/isa/riscv/binary32.clif
Normal file
145
cranelift/filetests/filetests/isa/riscv/binary32.clif
Normal file
@@ -0,0 +1,145 @@
|
||||
; Binary emission of 32-bit code.
|
||||
test binemit
|
||||
target riscv32
|
||||
|
||||
function %RV32I(i32 link [%x1]) -> i32 link [%x1] {
|
||||
sig0 = ()
|
||||
fn0 = %foo()
|
||||
|
||||
ebb0(v9999: i32):
|
||||
[-,%x10] v1 = iconst.i32 1
|
||||
[-,%x21] v2 = iconst.i32 2
|
||||
|
||||
; Integer Register-Register Operations.
|
||||
; add
|
||||
[-,%x7] v10 = iadd v1, v2 ; bin: 015503b3
|
||||
[-,%x16] v11 = iadd v2, v1 ; bin: 00aa8833
|
||||
; sub
|
||||
[-,%x7] v12 = isub v1, v2 ; bin: 415503b3
|
||||
[-,%x16] v13 = isub v2, v1 ; bin: 40aa8833
|
||||
; and
|
||||
[-,%x7] v20 = band v1, v2 ; bin: 015573b3
|
||||
[-,%x16] v21 = band v2, v1 ; bin: 00aaf833
|
||||
; or
|
||||
[-,%x7] v22 = bor v1, v2 ; bin: 015563b3
|
||||
[-,%x16] v23 = bor v2, v1 ; bin: 00aae833
|
||||
; xor
|
||||
[-,%x7] v24 = bxor v1, v2 ; bin: 015543b3
|
||||
[-,%x16] v25 = bxor v2, v1 ; bin: 00aac833
|
||||
; sll
|
||||
[-,%x7] v30 = ishl v1, v2 ; bin: 015513b3
|
||||
[-,%x16] v31 = ishl v2, v1 ; bin: 00aa9833
|
||||
; srl
|
||||
[-,%x7] v32 = ushr v1, v2 ; bin: 015553b3
|
||||
[-,%x16] v33 = ushr v2, v1 ; bin: 00aad833
|
||||
; sra
|
||||
[-,%x7] v34 = sshr v1, v2 ; bin: 415553b3
|
||||
[-,%x16] v35 = sshr v2, v1 ; bin: 40aad833
|
||||
; slt
|
||||
[-,%x7] v42 = icmp slt v1, v2 ; bin: 015523b3
|
||||
[-,%x16] v43 = icmp slt v2, v1 ; bin: 00aaa833
|
||||
; sltu
|
||||
[-,%x7] v44 = icmp ult v1, v2 ; bin: 015533b3
|
||||
[-,%x16] v45 = icmp ult v2, v1 ; bin: 00aab833
|
||||
|
||||
; Integer Register-Immediate Instructions
|
||||
|
||||
; addi
|
||||
[-,%x7] v100 = iadd_imm v1, 1000 ; bin: 3e850393
|
||||
[-,%x16] v101 = iadd_imm v2, -905 ; bin: c77a8813
|
||||
; andi
|
||||
[-,%x7] v110 = band_imm v1, 1000 ; bin: 3e857393
|
||||
[-,%x16] v111 = band_imm v2, -905 ; bin: c77af813
|
||||
; ori
|
||||
[-,%x7] v112 = bor_imm v1, 1000 ; bin: 3e856393
|
||||
[-,%x16] v113 = bor_imm v2, -905 ; bin: c77ae813
|
||||
; xori
|
||||
[-,%x7] v114 = bxor_imm v1, 1000 ; bin: 3e854393
|
||||
[-,%x16] v115 = bxor_imm v2, -905 ; bin: c77ac813
|
||||
|
||||
; slli
|
||||
[-,%x7] v120 = ishl_imm v1, 31 ; bin: 01f51393
|
||||
[-,%x16] v121 = ishl_imm v2, 8 ; bin: 008a9813
|
||||
; srli
|
||||
[-,%x7] v122 = ushr_imm v1, 31 ; bin: 01f55393
|
||||
[-,%x16] v123 = ushr_imm v2, 8 ; bin: 008ad813
|
||||
; srai
|
||||
[-,%x7] v124 = sshr_imm v1, 31 ; bin: 41f55393
|
||||
[-,%x16] v125 = sshr_imm v2, 8 ; bin: 408ad813
|
||||
|
||||
; slti
|
||||
[-,%x7] v130 = icmp_imm slt v1, 1000 ; bin: 3e852393
|
||||
[-,%x16] v131 = icmp_imm slt v2, -905 ; bin: c77aa813
|
||||
; sltiu
|
||||
[-,%x7] v132 = icmp_imm ult v1, 1000 ; bin: 3e853393
|
||||
[-,%x16] v133 = icmp_imm ult v2, -905 ; bin: c77ab813
|
||||
|
||||
; lui
|
||||
[-,%x7] v140 = iconst.i32 0x12345000 ; bin: 123453b7
|
||||
[-,%x16] v141 = iconst.i32 0xffffffff_fedcb000 ; bin: fedcb837
|
||||
; addi
|
||||
[-,%x7] v142 = iconst.i32 1000 ; bin: 3e800393
|
||||
[-,%x16] v143 = iconst.i32 -905 ; bin: c7700813
|
||||
|
||||
; Copies alias to iadd_imm.
|
||||
[-,%x7] v150 = copy v1 ; bin: 00050393
|
||||
[-,%x16] v151 = copy v2 ; bin: 000a8813
|
||||
|
||||
; Control Transfer Instructions
|
||||
|
||||
; jal %x1, fn0
|
||||
call fn0() ; bin: Call(%foo) 000000ef
|
||||
|
||||
; jalr %x1, %x10
|
||||
call_indirect sig0, v1() ; bin: 000500e7
|
||||
call_indirect sig0, v2() ; bin: 000a80e7
|
||||
|
||||
brz v1, ebb3
|
||||
brnz v1, ebb1
|
||||
|
||||
; jalr %x0, %x1, 0
|
||||
return v9999 ; bin: 00008067
|
||||
|
||||
ebb1:
|
||||
; beq 0x000
|
||||
br_icmp eq v1, v2, ebb1 ; bin: 01550063
|
||||
; bne 0xffc
|
||||
br_icmp ne v1, v2, ebb1 ; bin: ff551ee3
|
||||
; blt 0xff8
|
||||
br_icmp slt v1, v2, ebb1 ; bin: ff554ce3
|
||||
; bge 0xff4
|
||||
br_icmp sge v1, v2, ebb1 ; bin: ff555ae3
|
||||
; bltu 0xff0
|
||||
br_icmp ult v1, v2, ebb1 ; bin: ff5568e3
|
||||
; bgeu 0xfec
|
||||
br_icmp uge v1, v2, ebb1 ; bin: ff5576e3
|
||||
|
||||
; Forward branches.
|
||||
; beq 0x018
|
||||
br_icmp eq v2, v1, ebb2 ; bin: 00aa8c63
|
||||
; bne 0x014
|
||||
br_icmp ne v2, v1, ebb2 ; bin: 00aa9a63
|
||||
; blt 0x010
|
||||
br_icmp slt v2, v1, ebb2 ; bin: 00aac863
|
||||
; bge 0x00c
|
||||
br_icmp sge v2, v1, ebb2 ; bin: 00aad663
|
||||
; bltu 0x008
|
||||
br_icmp ult v2, v1, ebb2 ; bin: 00aae463
|
||||
; bgeu 0x004
|
||||
br_icmp uge v2, v1, ebb2 ; bin: 00aaf263
|
||||
|
||||
fallthrough ebb2
|
||||
|
||||
ebb2:
|
||||
; jal %x0, 0x00000
|
||||
jump ebb2 ; bin: 0000006f
|
||||
|
||||
ebb3:
|
||||
; beq x, %x0
|
||||
brz v1, ebb3 ; bin: 00050063
|
||||
; bne x, %x0
|
||||
brnz v1, ebb3 ; bin: fe051ee3
|
||||
|
||||
; jal %x0, 0x1ffff4
|
||||
jump ebb2 ; bin: ff5ff06f
|
||||
}
|
||||
21
cranelift/filetests/filetests/isa/riscv/encoding.clif
Normal file
21
cranelift/filetests/filetests/isa/riscv/encoding.clif
Normal file
@@ -0,0 +1,21 @@
|
||||
test legalizer
|
||||
target riscv32 supports_m=1
|
||||
|
||||
function %int32(i32, i32) {
|
||||
ebb0(v1: i32, v2: i32):
|
||||
v10 = iadd v1, v2
|
||||
; check: [R#0c]
|
||||
; sameln: v10 = iadd
|
||||
|
||||
v11 = isub v1, v2
|
||||
; check: [R#200c]
|
||||
; sameln: v11 = isub
|
||||
|
||||
v12 = imul v1, v2
|
||||
; check: [R#10c]
|
||||
; sameln: v12 = imul
|
||||
|
||||
return
|
||||
; check: [Iret#19]
|
||||
; sameln: return
|
||||
}
|
||||
37
cranelift/filetests/filetests/isa/riscv/expand-i32.clif
Normal file
37
cranelift/filetests/filetests/isa/riscv/expand-i32.clif
Normal file
@@ -0,0 +1,37 @@
|
||||
; Test the legalization of i32 instructions that don't have RISC-V versions.
|
||||
test legalizer
|
||||
|
||||
target riscv32 supports_m=1
|
||||
|
||||
target riscv64 supports_m=1
|
||||
|
||||
; regex: V=v\d+
|
||||
|
||||
function %carry_out(i32, i32) -> i32, b1 {
|
||||
ebb0(v1: i32, v2: i32):
|
||||
v3, v4 = iadd_cout v1, v2
|
||||
return v3, v4
|
||||
}
|
||||
; check: v3 = iadd v1, v2
|
||||
; check: v4 = icmp ult v3, v1
|
||||
; check: return v3, v4
|
||||
|
||||
; Expanding illegal immediate constants.
|
||||
; Note that at some point we'll probably expand the iconst as well.
|
||||
function %large_imm(i32) -> i32 {
|
||||
ebb0(v0: i32):
|
||||
v1 = iadd_imm v0, 1000000000
|
||||
return v1
|
||||
}
|
||||
; check: $(cst=$V) = iconst.i32 0x3b9a_ca00
|
||||
; check: v1 = iadd v0, $cst
|
||||
; check: return v1
|
||||
|
||||
function %bitclear(i32, i32) -> i32 {
|
||||
ebb0(v0: i32, v1: i32):
|
||||
v2 = band_not v0, v1
|
||||
; check: iconst.i32 -1
|
||||
; check: bxor
|
||||
; check: band
|
||||
return v2
|
||||
}
|
||||
134
cranelift/filetests/filetests/isa/riscv/legalize-abi.clif
Normal file
134
cranelift/filetests/filetests/isa/riscv/legalize-abi.clif
Normal file
@@ -0,0 +1,134 @@
|
||||
; Test legalizer's handling of ABI boundaries.
|
||||
test legalizer
|
||||
target riscv32
|
||||
|
||||
; regex: V=v\d+
|
||||
; regex: SS=ss\d+
|
||||
; regex: WS=\s+
|
||||
|
||||
function %int_split_args(i64) -> i64 {
|
||||
ebb0(v0: i64):
|
||||
; check: ebb0($(v0l=$V): i32, $(v0h=$V): i32, $(link=$V): i32):
|
||||
; check: v0 = iconcat $v0l, $v0h
|
||||
v1 = iadd_imm v0, 1
|
||||
; check: $(v1l=$V), $(v1h=$V) = isplit v1
|
||||
; check: return $v1l, $v1h, $link
|
||||
return v1
|
||||
}
|
||||
|
||||
function %split_call_arg(i32) {
|
||||
fn1 = %foo(i64)
|
||||
fn2 = %foo(i32, i64)
|
||||
ebb0(v0: i32):
|
||||
v1 = uextend.i64 v0
|
||||
call fn1(v1)
|
||||
; check: $(v1l=$V), $(v1h=$V) = isplit v1
|
||||
; check: call fn1($v1l, $v1h)
|
||||
call fn2(v0, v1)
|
||||
; check: call fn2(v0, $V, $V)
|
||||
return
|
||||
}
|
||||
|
||||
function %split_ret_val() {
|
||||
fn1 = %foo() -> i64
|
||||
ebb0:
|
||||
v1 = call fn1()
|
||||
; check: ebb0($(link=$V): i32):
|
||||
; nextln: $(v1l=$V), $(v1h=$V) = call fn1()
|
||||
; check: v1 = iconcat $v1l, $v1h
|
||||
jump ebb1(v1)
|
||||
; check: jump ebb1(v1)
|
||||
|
||||
ebb1(v10: i64):
|
||||
jump ebb1(v10)
|
||||
}
|
||||
|
||||
; First return value is fine, second one is expanded.
|
||||
function %split_ret_val2() {
|
||||
fn1 = %foo() -> i32, i64
|
||||
ebb0:
|
||||
v1, v2 = call fn1()
|
||||
; check: ebb0($(link=$V): i32):
|
||||
; nextln: v1, $(v2l=$V), $(v2h=$V) = call fn1()
|
||||
; check: v2 = iconcat $v2l, $v2h
|
||||
jump ebb1(v1, v2)
|
||||
; check: jump ebb1(v1, v2)
|
||||
|
||||
ebb1(v9: i32, v10: i64):
|
||||
jump ebb1(v9, v10)
|
||||
}
|
||||
|
||||
function %int_ext(i8, i8 sext, i8 uext) -> i8 uext {
|
||||
ebb0(v1: i8, v2: i8, v3: i8):
|
||||
; check: ebb0(v1: i8, $(v2x=$V): i32, $(v3x=$V): i32, $(link=$V): i32):
|
||||
; check: v2 = ireduce.i8 $v2x
|
||||
; check: v3 = ireduce.i8 $v3x
|
||||
; check: $(v1x=$V) = uextend.i32 v1
|
||||
; check: return $v1x, $link
|
||||
return v1
|
||||
}
|
||||
|
||||
; Function produces single return value, still need to copy.
|
||||
function %ext_ret_val() {
|
||||
fn1 = %foo() -> i8 sext
|
||||
ebb0:
|
||||
v1 = call fn1()
|
||||
; check: ebb0($V: i32):
|
||||
; nextln: $(rv=$V) = call fn1()
|
||||
; check: v1 = ireduce.i8 $rv
|
||||
jump ebb1(v1)
|
||||
; check: jump ebb1(v1)
|
||||
|
||||
ebb1(v10: i8):
|
||||
jump ebb1(v10)
|
||||
}
|
||||
|
||||
function %vector_split_args(i64x4) -> i64x4 {
|
||||
ebb0(v0: i64x4):
|
||||
; check: ebb0($(v0al=$V): i32, $(v0ah=$V): i32, $(v0bl=$V): i32, $(v0bh=$V): i32, $(v0cl=$V): i32, $(v0ch=$V): i32, $(v0dl=$V): i32, $(v0dh=$V): i32, $(link=$V): i32):
|
||||
; check: $(v0a=$V) = iconcat $v0al, $v0ah
|
||||
; check: $(v0b=$V) = iconcat $v0bl, $v0bh
|
||||
; check: $(v0ab=$V) = vconcat $v0a, $v0b
|
||||
; check: $(v0c=$V) = iconcat $v0cl, $v0ch
|
||||
; check: $(v0d=$V) = iconcat $v0dl, $v0dh
|
||||
; check: $(v0cd=$V) = vconcat $v0c, $v0d
|
||||
; check: v0 = vconcat $v0ab, $v0cd
|
||||
v1 = bxor v0, v0
|
||||
; check: $(v1ab=$V), $(v1cd=$V) = vsplit v1
|
||||
; check: $(v1a=$V), $(v1b=$V) = vsplit $v1ab
|
||||
; check: $(v1al=$V), $(v1ah=$V) = isplit $v1a
|
||||
; check: $(v1bl=$V), $(v1bh=$V) = isplit $v1b
|
||||
; check: $(v1c=$V), $(v1d=$V) = vsplit $v1cd
|
||||
; check: $(v1cl=$V), $(v1ch=$V) = isplit $v1c
|
||||
; check: $(v1dl=$V), $(v1dh=$V) = isplit $v1d
|
||||
; check: return $v1al, $v1ah, $v1bl, $v1bh, $v1cl, $v1ch, $v1dl, $v1dh, $link
|
||||
return v1
|
||||
}
|
||||
|
||||
function %indirect(i32) {
|
||||
sig1 = () system_v
|
||||
ebb0(v0: i32):
|
||||
call_indirect sig1, v0()
|
||||
return
|
||||
}
|
||||
|
||||
; The first argument to call_indirect doesn't get altered.
|
||||
function %indirect_arg(i32, f32x2) {
|
||||
sig1 = (f32x2) system_v
|
||||
ebb0(v0: i32, v1: f32x2):
|
||||
call_indirect sig1, v0(v1)
|
||||
; check: call_indirect sig1, v0($V, $V)
|
||||
return
|
||||
}
|
||||
|
||||
; Call a function that takes arguments on the stack.
|
||||
function %stack_args(i32) {
|
||||
; check: $(ss0=$SS) = outgoing_arg 4
|
||||
fn1 = %foo(i64, i64, i64, i64, i32)
|
||||
ebb0(v0: i32):
|
||||
v1 = iconst.i64 1
|
||||
call fn1(v1, v1, v1, v1, v0)
|
||||
; check: [GPsp#48,$ss0]$WS $(v0s=$V) = spill v0
|
||||
; check: call fn1($(=.*), $v0s)
|
||||
return
|
||||
}
|
||||
64
cranelift/filetests/filetests/isa/riscv/legalize-i64.clif
Normal file
64
cranelift/filetests/filetests/isa/riscv/legalize-i64.clif
Normal file
@@ -0,0 +1,64 @@
|
||||
; Test the legalization of i64 arithmetic instructions.
|
||||
test legalizer
|
||||
target riscv32 supports_m=1
|
||||
|
||||
; regex: V=v\d+
|
||||
|
||||
function %bitwise_and(i64, i64) -> i64 {
|
||||
ebb0(v1: i64, v2: i64):
|
||||
v3 = band v1, v2
|
||||
return v3
|
||||
}
|
||||
; check: ebb0($(v1l=$V): i32, $(v1h=$V): i32, $(v2l=$V): i32, $(v2h=$V): i32, $(link=$V): i32):
|
||||
; check: [R#ec
|
||||
; sameln: $(v3l=$V) = band $v1l, $v2l
|
||||
; check: [R#ec
|
||||
; sameln: $(v3h=$V) = band $v1h, $v2h
|
||||
; check: v3 = iconcat $v3l, $v3h
|
||||
; check: return $v3l, $v3h, $link
|
||||
|
||||
function %bitwise_or(i64, i64) -> i64 {
|
||||
ebb0(v1: i64, v2: i64):
|
||||
v3 = bor v1, v2
|
||||
return v3
|
||||
}
|
||||
; check: ebb0($(v1l=$V): i32, $(v1h=$V): i32, $(v2l=$V): i32, $(v2h=$V): i32, $(link=$V): i32):
|
||||
; check: [R#cc
|
||||
; sameln: $(v3l=$V) = bor $v1l, $v2l
|
||||
; check: [R#cc
|
||||
; sameln: $(v3h=$V) = bor $v1h, $v2h
|
||||
; check: v3 = iconcat $v3l, $v3h
|
||||
; check: return $v3l, $v3h, $link
|
||||
|
||||
function %bitwise_xor(i64, i64) -> i64 {
|
||||
ebb0(v1: i64, v2: i64):
|
||||
v3 = bxor v1, v2
|
||||
return v3
|
||||
}
|
||||
; check: ebb0($(v1l=$V): i32, $(v1h=$V): i32, $(v2l=$V): i32, $(v2h=$V): i32, $(link=$V): i32):
|
||||
; check: [R#8c
|
||||
; sameln: $(v3l=$V) = bxor $v1l, $v2l
|
||||
; check: [R#8c
|
||||
; sameln: $(v3h=$V) = bxor $v1h, $v2h
|
||||
; check: v3 = iconcat $v3l, $v3h
|
||||
; check: return $v3l, $v3h, $link
|
||||
|
||||
function %arith_add(i64, i64) -> i64 {
|
||||
; Legalizing iadd.i64 requires two steps:
|
||||
; 1. Narrow to iadd_cout.i32, then
|
||||
; 2. Expand iadd_cout.i32 since RISC-V has no carry flag.
|
||||
ebb0(v1: i64, v2: i64):
|
||||
v3 = iadd v1, v2
|
||||
return v3
|
||||
}
|
||||
; check: ebb0($(v1l=$V): i32, $(v1h=$V): i32, $(v2l=$V): i32, $(v2h=$V): i32, $(link=$V): i32):
|
||||
; check: [R#0c
|
||||
; sameln: $(v3l=$V) = iadd $v1l, $v2l
|
||||
; check: $(c=$V) = icmp ult $v3l, $v1l
|
||||
; check: [R#0c
|
||||
; sameln: $(v3h1=$V) = iadd $v1h, $v2h
|
||||
; check: $(c_int=$V) = bint.i32 $c
|
||||
; check: [R#0c
|
||||
; sameln: $(v3h=$V) = iadd $v3h1, $c_int
|
||||
; check: v3 = iconcat $v3l, $v3h
|
||||
; check: return $v3l, $v3h, $link
|
||||
36
cranelift/filetests/filetests/isa/riscv/parse-encoding.clif
Normal file
36
cranelift/filetests/filetests/isa/riscv/parse-encoding.clif
Normal file
@@ -0,0 +1,36 @@
|
||||
; Test the parser's support for encoding annotations.
|
||||
test legalizer
|
||||
target riscv32
|
||||
|
||||
function %parse_encoding(i32 [%x5]) -> i32 [%x10] {
|
||||
; check: function %parse_encoding(i32 [%x5], i32 link [%x1]) -> i32 [%x10], i32 link [%x1] fast {
|
||||
|
||||
sig0 = (i32 [%x10]) -> i32 [%x10] system_v
|
||||
; check: sig0 = (i32 [%x10]) -> i32 [%x10] system_v
|
||||
|
||||
sig1 = (i32 [%x10], i32 [%x11]) -> b1 [%x10] system_v
|
||||
; check: sig1 = (i32 [%x10], i32 [%x11]) -> b1 [%x10] system_v
|
||||
|
||||
sig2 = (f32 [%f10], i32 [%x12], i32 [%x13]) -> f64 [%f10] system_v
|
||||
; check: sig2 = (f32 [%f10], i32 [%x12], i32 [%x13]) -> f64 [%f10] system_v
|
||||
|
||||
; Arguments on stack where not necessary
|
||||
sig3 = (f64 [%f10], i32 [0], i32 [4]) -> f64 [%f10] system_v
|
||||
; check: sig3 = (f64 [%f10], i32 [0], i32 [4]) -> f64 [%f10] system_v
|
||||
|
||||
; Stack argument before register argument
|
||||
sig4 = (f32 [72], i32 [%x10]) system_v
|
||||
; check: sig4 = (f32 [72], i32 [%x10]) system_v
|
||||
|
||||
; Return value on stack
|
||||
sig5 = () -> f32 [0] system_v
|
||||
; check: sig5 = () -> f32 [0] system_v
|
||||
|
||||
; function + signature
|
||||
fn0 = %bar(i32 [%x10]) -> b1 [%x10] system_v
|
||||
; check: sig6 = (i32 [%x10]) -> b1 [%x10] system_v
|
||||
; nextln: fn0 = %bar sig6
|
||||
|
||||
ebb0(v0: i32):
|
||||
return v0
|
||||
}
|
||||
15
cranelift/filetests/filetests/isa/riscv/regmove.clif
Normal file
15
cranelift/filetests/filetests/isa/riscv/regmove.clif
Normal file
@@ -0,0 +1,15 @@
|
||||
; Test tracking of register moves.
|
||||
test binemit
|
||||
target riscv32
|
||||
|
||||
function %regmoves(i32 link [%x1]) -> i32 link [%x1] {
|
||||
ebb0(v9999: i32):
|
||||
[-,%x10] v1 = iconst.i32 1
|
||||
[-,%x7] v2 = iadd_imm v1, 1000 ; bin: 3e850393
|
||||
regmove v1, %x10 -> %x11 ; bin: 00050593
|
||||
[-,%x7] v3 = iadd_imm v1, 1000 ; bin: 3e858393
|
||||
regmove v1, %x11 -> %x10 ; bin: 00058513
|
||||
[-,%x7] v4 = iadd_imm v1, 1000 ; bin: 3e850393
|
||||
|
||||
return v9999
|
||||
}
|
||||
55
cranelift/filetests/filetests/isa/riscv/split-args.clif
Normal file
55
cranelift/filetests/filetests/isa/riscv/split-args.clif
Normal file
@@ -0,0 +1,55 @@
|
||||
; Test the legalization of EBB arguments that are split.
|
||||
test legalizer
|
||||
target riscv32
|
||||
|
||||
; regex: V=v\d+
|
||||
|
||||
function %simple(i64, i64) -> i64 {
|
||||
ebb0(v1: i64, v2: i64):
|
||||
; check: ebb0($(v1l=$V): i32, $(v1h=$V): i32, $(v2l=$V): i32, $(v2h=$V): i32, $(link=$V): i32):
|
||||
jump ebb1(v1)
|
||||
; check: jump ebb1($v1l, $v1h)
|
||||
|
||||
ebb1(v3: i64):
|
||||
; check: ebb1($(v3l=$V): i32, $(v3h=$V): i32):
|
||||
v4 = band v3, v2
|
||||
; check: $(v4l=$V) = band $v3l, $v2l
|
||||
; check: $(v4h=$V) = band $v3h, $v2h
|
||||
return v4
|
||||
; check: return $v4l, $v4h, $link
|
||||
}
|
||||
|
||||
function %multi(i64) -> i64 {
|
||||
ebb1(v1: i64):
|
||||
; check: ebb1($(v1l=$V): i32, $(v1h=$V): i32, $(link=$V): i32):
|
||||
jump ebb2(v1, v1)
|
||||
; check: jump ebb2($v1l, $v1l, $v1h, $v1h)
|
||||
|
||||
ebb2(v2: i64, v3: i64):
|
||||
; check: ebb2($(v2l=$V): i32, $(v3l=$V): i32, $(v2h=$V): i32, $(v3h=$V): i32):
|
||||
jump ebb3(v2)
|
||||
; check: jump ebb3($v2l, $v2h)
|
||||
|
||||
ebb3(v4: i64):
|
||||
; check: ebb3($(v4l=$V): i32, $(v4h=$V): i32):
|
||||
v5 = band v4, v3
|
||||
; check: $(v5l=$V) = band $v4l, $v3l
|
||||
; check: $(v5h=$V) = band $v4h, $v3h
|
||||
return v5
|
||||
; check: return $v5l, $v5h, $link
|
||||
}
|
||||
|
||||
function %loop(i64, i64) -> i64 {
|
||||
ebb0(v1: i64, v2: i64):
|
||||
; check: ebb0($(v1l=$V): i32, $(v1h=$V): i32, $(v2l=$V): i32, $(v2h=$V): i32, $(link=$V): i32):
|
||||
jump ebb1(v1)
|
||||
; check: jump ebb1($v1l, $v1h)
|
||||
|
||||
ebb1(v3: i64):
|
||||
; check: ebb1($(v3l=$V): i32, $(v3h=$V): i32):
|
||||
v4 = band v3, v2
|
||||
; check: $(v4l=$V) = band $v3l, $v2l
|
||||
; check: $(v4h=$V) = band $v3h, $v2h
|
||||
jump ebb1(v4)
|
||||
; check: jump ebb1($v4l, $v4h)
|
||||
}
|
||||
21
cranelift/filetests/filetests/isa/riscv/verify-encoding.clif
Normal file
21
cranelift/filetests/filetests/isa/riscv/verify-encoding.clif
Normal file
@@ -0,0 +1,21 @@
|
||||
test verifier
|
||||
target riscv32
|
||||
|
||||
function %RV32I(i32 link [%x1]) -> i32 link [%x1] {
|
||||
fn0 = %foo()
|
||||
|
||||
ebb0(v9999: i32):
|
||||
; iconst.i32 needs legalizing, so it should throw a
|
||||
[R#0,-] v1 = iconst.i32 0xf0f0f0f0f0 ; error: Instruction failed to re-encode
|
||||
[Iret#19] return v9999
|
||||
}
|
||||
|
||||
function %RV32I(i32 link [%x1]) -> i32 link [%x1] {
|
||||
fn0 = %foo()
|
||||
|
||||
ebb0(v9999: i32):
|
||||
v1 = iconst.i32 1
|
||||
v2 = iconst.i32 2
|
||||
[R#0,-] v3 = iadd v1, v2 ; error: encoding R#00 should be R#0c
|
||||
[Iret#19] return v9999
|
||||
}
|
||||
13
cranelift/filetests/filetests/isa/x86/abcd.clif
Normal file
13
cranelift/filetests/filetests/isa/x86/abcd.clif
Normal file
@@ -0,0 +1,13 @@
|
||||
test regalloc
|
||||
target i686
|
||||
|
||||
; %rdi can't be used in a movsbl instruction, so test that the register
|
||||
; allocator can move it to a register that can be.
|
||||
|
||||
function %test(i32 [%rdi]) -> i32 system_v {
|
||||
ebb0(v0: i32 [%rdi]):
|
||||
v1 = ireduce.i8 v0
|
||||
v2 = sextend.i32 v1
|
||||
return v2
|
||||
}
|
||||
; check: regmove v1, %rdi -> %rax
|
||||
19
cranelift/filetests/filetests/isa/x86/abi-bool.clif
Normal file
19
cranelift/filetests/filetests/isa/x86/abi-bool.clif
Normal file
@@ -0,0 +1,19 @@
|
||||
test compile
|
||||
target x86_64 haswell
|
||||
|
||||
function %foo(i64, i64, i64, i32) -> b1 system_v {
|
||||
ebb3(v0: i64, v1: i64, v2: i64, v3: i32):
|
||||
v5 = icmp ne v2, v2
|
||||
v8 = iconst.i64 0
|
||||
jump ebb2(v8, v3, v5)
|
||||
|
||||
ebb2(v10: i64, v30: i32, v37: b1):
|
||||
v18 = load.i32 notrap aligned v2
|
||||
v27 = iadd.i64 v10, v10
|
||||
v31 = icmp eq v30, v30
|
||||
brz v31, ebb2(v27, v30, v37)
|
||||
jump ebb0(v37)
|
||||
|
||||
ebb0(v35: b1):
|
||||
return v35
|
||||
}
|
||||
20
cranelift/filetests/filetests/isa/x86/abi32.clif
Normal file
20
cranelift/filetests/filetests/isa/x86/abi32.clif
Normal file
@@ -0,0 +1,20 @@
|
||||
; Test the legalization of function signatures.
|
||||
test legalizer
|
||||
target i686
|
||||
|
||||
; regex: V=v\d+
|
||||
|
||||
function %f() {
|
||||
sig0 = (i32) -> i32 system_v
|
||||
; check: sig0 = (i32 [0]) -> i32 [%rax] system_v
|
||||
|
||||
sig1 = (i64) -> b1 system_v
|
||||
; check: sig1 = (i32 [0], i32 [4]) -> b1 [%rax] system_v
|
||||
|
||||
sig2 = (f32, i64) -> f64 system_v
|
||||
; check: sig2 = (f32 [0], i32 [4], i32 [8]) -> f64 [%xmm0] system_v
|
||||
|
||||
ebb0:
|
||||
return
|
||||
}
|
||||
|
||||
31
cranelift/filetests/filetests/isa/x86/abi64.clif
Normal file
31
cranelift/filetests/filetests/isa/x86/abi64.clif
Normal file
@@ -0,0 +1,31 @@
|
||||
; Test the legalization of function signatures.
|
||||
test legalizer
|
||||
target x86_64
|
||||
|
||||
; regex: V=v\d+
|
||||
|
||||
function %f() {
|
||||
sig0 = (i32) -> i32 system_v
|
||||
; check: sig0 = (i32 [%rdi]) -> i32 [%rax] system_v
|
||||
|
||||
sig1 = (i64) -> b1 system_v
|
||||
; check: sig1 = (i64 [%rdi]) -> b1 [%rax] system_v
|
||||
|
||||
sig2 = (f32, i64) -> f64 system_v
|
||||
; check: sig2 = (f32 [%xmm0], i64 [%rdi]) -> f64 [%xmm0] system_v
|
||||
|
||||
ebb0:
|
||||
return
|
||||
}
|
||||
|
||||
function %pass_stack_int64(i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 vmctx) baldrdash {
|
||||
sig0 = (i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 vmctx) baldrdash
|
||||
fn0 = u0:0 sig0
|
||||
|
||||
ebb0(v0: i64, v1: i64, v2: i64, v3: i64, v4: i64, v5: i64, v6: i64, v7: i64, v8: i64, v9: i64, v10: i64, v11: i64, v12: i64, v13: i64, v14: i64, v15: i64, v16: i64, v17: i64, v18: i64, v19: i64, v20: i64):
|
||||
call fn0(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20)
|
||||
jump ebb1
|
||||
|
||||
ebb1:
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
; binary emission of 32-bit code.
|
||||
test binemit
|
||||
set opt_level=best
|
||||
set allones_funcaddrs
|
||||
target i686 haswell
|
||||
|
||||
; The binary encodings can be verified with the command:
|
||||
;
|
||||
; sed -ne 's/^ *; asm: *//p' filetests/isa/x86/allones_funcaddrs32.clif | llvm-mc -show-encoding -triple=i386
|
||||
;
|
||||
|
||||
; Tests from binary32.clif affected by allones_funcaddrs.
|
||||
function %I32() {
|
||||
sig0 = ()
|
||||
fn0 = %foo()
|
||||
|
||||
ebb0:
|
||||
|
||||
; asm: movl $-1, %ecx
|
||||
[-,%rcx] v400 = func_addr.i32 fn0 ; bin: b9 Abs4(%foo) ffffffff
|
||||
; asm: movl $-1, %esi
|
||||
[-,%rsi] v401 = func_addr.i32 fn0 ; bin: be Abs4(%foo) ffffffff
|
||||
|
||||
return ; bin: c3
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
; binary emission of 64-bit code.
|
||||
test binemit
|
||||
set opt_level=best
|
||||
set allones_funcaddrs
|
||||
target x86_64 haswell
|
||||
|
||||
; The binary encodings can be verified with the command:
|
||||
;
|
||||
; sed -ne 's/^ *; asm: *//p' filetests/isa/x86/allones_funcaddrs64.clif | llvm-mc -show-encoding -triple=x86_64
|
||||
;
|
||||
|
||||
; Tests from binary64.clif affected by allones_funcaddrs.
|
||||
function %I64() {
|
||||
sig0 = ()
|
||||
fn0 = %foo()
|
||||
|
||||
ebb0:
|
||||
|
||||
; asm: movabsq $-1, %rcx
|
||||
[-,%rcx] v400 = func_addr.i64 fn0 ; bin: 48 b9 Abs8(%foo) ffffffffffffffff
|
||||
; asm: movabsq $-1, %rsi
|
||||
[-,%rsi] v401 = func_addr.i64 fn0 ; bin: 48 be Abs8(%foo) ffffffffffffffff
|
||||
; asm: movabsq $-1, %r10
|
||||
[-,%r10] v402 = func_addr.i64 fn0 ; bin: 49 ba Abs8(%foo) ffffffffffffffff
|
||||
|
||||
return ; bin: c3
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
test compile
|
||||
target x86_64 baseline
|
||||
|
||||
|
||||
; clz/ctz on 64 bit operands
|
||||
|
||||
function %i64_clz(i64) -> i64 {
|
||||
ebb0(v10: i64):
|
||||
v11 = clz v10
|
||||
; check: x86_bsr
|
||||
; check: selectif.i64
|
||||
return v11
|
||||
}
|
||||
|
||||
function %i64_ctz(i64) -> i64 {
|
||||
ebb1(v20: i64):
|
||||
v21 = ctz v20
|
||||
; check: x86_bsf
|
||||
; check: selectif.i64
|
||||
return v21
|
||||
}
|
||||
|
||||
|
||||
; clz/ctz on 32 bit operands
|
||||
|
||||
function %i32_clz(i32) -> i32 {
|
||||
ebb0(v10: i32):
|
||||
v11 = clz v10
|
||||
; check: x86_bsr
|
||||
; check: selectif.i32
|
||||
return v11
|
||||
}
|
||||
|
||||
function %i32_ctz(i32) -> i32 {
|
||||
ebb1(v20: i32):
|
||||
v21 = ctz v20
|
||||
; check: x86_bsf
|
||||
; check: selectif.i32
|
||||
return v21
|
||||
}
|
||||
|
||||
|
||||
; popcount on 64 bit operands
|
||||
|
||||
function %i64_popcount(i64) -> i64 {
|
||||
ebb0(v30: i64):
|
||||
v31 = popcnt v30;
|
||||
; check: ushr_imm
|
||||
; check: iconst.i64
|
||||
; check: band
|
||||
; check: isub
|
||||
; check: ushr_imm
|
||||
; check: band
|
||||
; check: isub
|
||||
; check: ushr_imm
|
||||
; check: band
|
||||
; check: isub
|
||||
; check: ushr_imm
|
||||
; check: iadd
|
||||
; check: iconst.i64
|
||||
; check: band
|
||||
; check: iconst.i64
|
||||
; check: imul
|
||||
; check: ushr_imm
|
||||
return v31;
|
||||
}
|
||||
|
||||
|
||||
; popcount on 32 bit operands
|
||||
|
||||
function %i32_popcount(i32) -> i32 {
|
||||
ebb0(v40: i32):
|
||||
v41 = popcnt v40;
|
||||
; check: ushr_imm
|
||||
; check: iconst.i32
|
||||
; check: band
|
||||
; check: isub
|
||||
; check: ushr_imm
|
||||
; check: band
|
||||
; check: isub
|
||||
; check: ushr_imm
|
||||
; check: band
|
||||
; check: isub
|
||||
; check: ushr_imm
|
||||
; check: iadd
|
||||
; check: iconst.i32
|
||||
; check: band
|
||||
; check: iconst.i32
|
||||
; check: imul
|
||||
; check: ushr_imm
|
||||
return v41;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
test binemit
|
||||
set opt_level=best
|
||||
target x86_64 baseline
|
||||
|
||||
; The binary encodings can be verified with the command:
|
||||
;
|
||||
; sed -ne 's/^ *; asm: *//p' filetests/isa/x86/baseline_clz_ctz_popcount_encoding.clif | llvm-mc -show-encoding -triple=x86_64
|
||||
;
|
||||
|
||||
function %Foo() {
|
||||
ebb0:
|
||||
; 64-bit wide bsf
|
||||
|
||||
[-,%r11] v10 = iconst.i64 0x1234
|
||||
; asm: bsfq %r11, %rcx
|
||||
[-,%rcx,%rflags] v11, v12 = x86_bsf v10 ; bin: 49 0f bc cb
|
||||
|
||||
[-,%rdx] v14 = iconst.i64 0x5678
|
||||
; asm: bsfq %rdx, %r12
|
||||
[-,%r12,%rflags] v15, v16 = x86_bsf v14 ; bin: 4c 0f bc e2
|
||||
|
||||
; asm: bsfq %rdx, %rdi
|
||||
[-,%rdi,%rflags] v17, v18 = x86_bsf v14 ; bin: 48 0f bc fa
|
||||
|
||||
|
||||
; 32-bit wide bsf
|
||||
|
||||
[-,%r11] v20 = iconst.i32 0x1234
|
||||
; asm: bsfl %r11d, %ecx
|
||||
[-,%rcx,%rflags] v21, v22 = x86_bsf v20 ; bin: 41 0f bc cb
|
||||
|
||||
[-,%rdx] v24 = iconst.i32 0x5678
|
||||
; asm: bsfl %edx, %r12d
|
||||
[-,%r12,%rflags] v25, v26 = x86_bsf v24 ; bin: 44 0f bc e2
|
||||
|
||||
; asm: bsfl %edx, %esi
|
||||
[-,%rsi,%rflags] v27, v28 = x86_bsf v24 ; bin: 0f bc f2
|
||||
|
||||
|
||||
; 64-bit wide bsr
|
||||
|
||||
[-,%r11] v30 = iconst.i64 0x1234
|
||||
; asm: bsrq %r11, %rcx
|
||||
[-,%rcx,%rflags] v31, v32 = x86_bsr v30 ; bin: 49 0f bd cb
|
||||
|
||||
[-,%rdx] v34 = iconst.i64 0x5678
|
||||
; asm: bsrq %rdx, %r12
|
||||
[-,%r12,%rflags] v35, v36 = x86_bsr v34 ; bin: 4c 0f bd e2
|
||||
|
||||
; asm: bsrq %rdx, %rdi
|
||||
[-,%rdi,%rflags] v37, v38 = x86_bsr v34 ; bin: 48 0f bd fa
|
||||
|
||||
|
||||
; 32-bit wide bsr
|
||||
|
||||
[-,%r11] v40 = iconst.i32 0x1234
|
||||
; asm: bsrl %r11d, %ecx
|
||||
[-,%rcx,%rflags] v41, v42 = x86_bsr v40 ; bin: 41 0f bd cb
|
||||
|
||||
[-,%rdx] v44 = iconst.i32 0x5678
|
||||
; asm: bsrl %edx, %r12d
|
||||
[-,%r12,%rflags] v45, v46 = x86_bsr v44 ; bin: 44 0f bd e2
|
||||
|
||||
; asm: bsrl %edx, %esi
|
||||
[-,%rsi,%rflags] v47, v48 = x86_bsr v44 ; bin: 0f bd f2
|
||||
|
||||
|
||||
; 64-bit wide cmov
|
||||
|
||||
; asm: cmoveq %r11, %rdx
|
||||
[-,%rdx] v51 = selectif.i64 eq v48, v30, v34 ; bin: 49 0f 44 d3
|
||||
|
||||
; asm: cmoveq %rdi, %rdx
|
||||
[-,%rdx] v52 = selectif.i64 eq v48, v37, v34 ; bin: 48 0f 44 d7
|
||||
|
||||
|
||||
; 32-bit wide cmov
|
||||
|
||||
; asm: cmovnel %r11d, %edx
|
||||
[-,%rdx] v60 = selectif.i32 ne v48, v40, v44 ; bin: 41 0f 45 d3
|
||||
|
||||
; asm: cmovlel %esi, %edx
|
||||
[-,%rdx] v61 = selectif.i32 sle v48, v27, v44 ; bin: 0f 4e d6
|
||||
|
||||
|
||||
trap user0
|
||||
}
|
||||
534
cranelift/filetests/filetests/isa/x86/binary32-float.clif
Normal file
534
cranelift/filetests/filetests/isa/x86/binary32-float.clif
Normal file
@@ -0,0 +1,534 @@
|
||||
; Binary emission of 32-bit floating point code.
|
||||
test binemit
|
||||
target i686 haswell
|
||||
|
||||
; The binary encodings can be verified with the command:
|
||||
;
|
||||
; sed -ne 's/^ *; asm: *//p' filetests/isa/x86/binary32-float.clif | llvm-mc -show-encoding -triple=i386
|
||||
;
|
||||
|
||||
function %F32() {
|
||||
ss0 = incoming_arg 8, offset 0
|
||||
ss1 = incoming_arg 1024, offset -1024
|
||||
ss2 = incoming_arg 1024, offset -2048
|
||||
ss3 = incoming_arg 8, offset -2056
|
||||
|
||||
ebb0:
|
||||
[-,%rcx] v0 = iconst.i32 1
|
||||
[-,%rsi] v1 = iconst.i32 2
|
||||
|
||||
; asm: cvtsi2ss %ecx, %xmm5
|
||||
[-,%xmm5] v10 = fcvt_from_sint.f32 v0 ; bin: f3 0f 2a e9
|
||||
; asm: cvtsi2ss %esi, %xmm2
|
||||
[-,%xmm2] v11 = fcvt_from_sint.f32 v1 ; bin: f3 0f 2a d6
|
||||
|
||||
; asm: cvtss2sd %xmm2, %xmm5
|
||||
[-,%xmm5] v12 = fpromote.f64 v11 ; bin: f3 0f 5a ea
|
||||
; asm: cvtss2sd %xmm5, %xmm2
|
||||
[-,%xmm2] v13 = fpromote.f64 v10 ; bin: f3 0f 5a d5
|
||||
|
||||
; asm: movd %ecx, %xmm5
|
||||
[-,%xmm5] v14 = bitcast.f32 v0 ; bin: 66 0f 6e e9
|
||||
; asm: movd %esi, %xmm2
|
||||
[-,%xmm2] v15 = bitcast.f32 v1 ; bin: 66 0f 6e d6
|
||||
|
||||
; asm: movd %xmm5, %ecx
|
||||
[-,%rcx] v16 = bitcast.i32 v10 ; bin: 66 0f 7e e9
|
||||
; asm: movd %xmm2, %esi
|
||||
[-,%rsi] v17 = bitcast.i32 v11 ; bin: 66 0f 7e d6
|
||||
|
||||
; asm: movaps %xmm2, %xmm5
|
||||
[-,%xmm5] v18 = copy v11 ; bin: 0f 28 ea
|
||||
; asm: movaps %xmm5, %xmm2
|
||||
[-,%xmm2] v19 = copy v10 ; bin: 0f 28 d5
|
||||
|
||||
; asm: movaps %xmm2, %xmm5
|
||||
regmove v19, %xmm2 -> %xmm5 ; bin: 0f 28 ea
|
||||
; asm: movaps %xmm5, %xmm2
|
||||
regmove v19, %xmm5 -> %xmm2 ; bin: 0f 28 d5
|
||||
|
||||
; Binary arithmetic.
|
||||
|
||||
; asm: addss %xmm2, %xmm5
|
||||
[-,%xmm5] v20 = fadd v10, v11 ; bin: f3 0f 58 ea
|
||||
; asm: addss %xmm5, %xmm2
|
||||
[-,%xmm2] v21 = fadd v11, v10 ; bin: f3 0f 58 d5
|
||||
|
||||
; asm: subss %xmm2, %xmm5
|
||||
[-,%xmm5] v22 = fsub v10, v11 ; bin: f3 0f 5c ea
|
||||
; asm: subss %xmm5, %xmm2
|
||||
[-,%xmm2] v23 = fsub v11, v10 ; bin: f3 0f 5c d5
|
||||
|
||||
; asm: mulss %xmm2, %xmm5
|
||||
[-,%xmm5] v24 = fmul v10, v11 ; bin: f3 0f 59 ea
|
||||
; asm: mulss %xmm5, %xmm2
|
||||
[-,%xmm2] v25 = fmul v11, v10 ; bin: f3 0f 59 d5
|
||||
|
||||
; asm: divss %xmm2, %xmm5
|
||||
[-,%xmm5] v26 = fdiv v10, v11 ; bin: f3 0f 5e ea
|
||||
; asm: divss %xmm5, %xmm2
|
||||
[-,%xmm2] v27 = fdiv v11, v10 ; bin: f3 0f 5e d5
|
||||
|
||||
; Bitwise ops.
|
||||
; We use the *ps SSE instructions for everything because they are smaller.
|
||||
|
||||
; asm: andps %xmm2, %xmm5
|
||||
[-,%xmm5] v30 = band v10, v11 ; bin: 0f 54 ea
|
||||
; asm: andps %xmm5, %xmm2
|
||||
[-,%xmm2] v31 = band v11, v10 ; bin: 0f 54 d5
|
||||
|
||||
; asm: andnps %xmm2, %xmm5
|
||||
[-,%xmm5] v32 = band_not v11, v10 ; bin: 0f 55 ea
|
||||
; asm: andnps %xmm5, %xmm2
|
||||
[-,%xmm2] v33 = band_not v10, v11 ; bin: 0f 55 d5
|
||||
|
||||
; asm: orps %xmm2, %xmm5
|
||||
[-,%xmm5] v34 = bor v10, v11 ; bin: 0f 56 ea
|
||||
; asm: orps %xmm5, %xmm2
|
||||
[-,%xmm2] v35 = bor v11, v10 ; bin: 0f 56 d5
|
||||
|
||||
; asm: xorps %xmm2, %xmm5
|
||||
[-,%xmm5] v36 = bxor v10, v11 ; bin: 0f 57 ea
|
||||
; asm: xorps %xmm5, %xmm2
|
||||
[-,%xmm2] v37 = bxor v11, v10 ; bin: 0f 57 d5
|
||||
|
||||
; Convert float to int. (No i64 dest on i386).
|
||||
|
||||
; asm: cvttss2si %xmm5, %ecx
|
||||
[-,%rcx] v40 = x86_cvtt2si.i32 v10 ; bin: f3 0f 2c cd
|
||||
; asm: cvttss2si %xmm2, %esi
|
||||
[-,%rsi] v41 = x86_cvtt2si.i32 v11 ; bin: f3 0f 2c f2
|
||||
|
||||
; Min/max.
|
||||
|
||||
; asm: minss %xmm2, %xmm5
|
||||
[-,%xmm5] v42 = x86_fmin v10, v11 ; bin: f3 0f 5d ea
|
||||
; asm: minss %xmm5, %xmm2
|
||||
[-,%xmm2] v43 = x86_fmin v11, v10 ; bin: f3 0f 5d d5
|
||||
; asm: maxss %xmm2, %xmm5
|
||||
[-,%xmm5] v44 = x86_fmax v10, v11 ; bin: f3 0f 5f ea
|
||||
; asm: maxss %xmm5, %xmm2
|
||||
[-,%xmm2] v45 = x86_fmax v11, v10 ; bin: f3 0f 5f d5
|
||||
|
||||
; Unary arithmetic.
|
||||
|
||||
; asm: sqrtss %xmm5, %xmm2
|
||||
[-,%xmm2] v50 = sqrt v10 ; bin: f3 0f 51 d5
|
||||
; asm: sqrtss %xmm2, %xmm5
|
||||
[-,%xmm5] v51 = sqrt v11 ; bin: f3 0f 51 ea
|
||||
|
||||
; asm: roundss $0, %xmm5, %xmm4
|
||||
[-,%xmm4] v52 = nearest v10 ; bin: 66 0f 3a 0a e5 00
|
||||
; asm: roundss $0, %xmm2, %xmm5
|
||||
[-,%xmm5] v53 = nearest v11 ; bin: 66 0f 3a 0a ea 00
|
||||
; asm: roundss $0, %xmm5, %xmm2
|
||||
[-,%xmm2] v54 = nearest v10 ; bin: 66 0f 3a 0a d5 00
|
||||
|
||||
; asm: roundss $1, %xmm5, %xmm4
|
||||
[-,%xmm4] v55 = floor v10 ; bin: 66 0f 3a 0a e5 01
|
||||
; asm: roundss $1, %xmm2, %xmm5
|
||||
[-,%xmm5] v56 = floor v11 ; bin: 66 0f 3a 0a ea 01
|
||||
; asm: roundss $1, %xmm5, %xmm2
|
||||
[-,%xmm2] v57 = floor v10 ; bin: 66 0f 3a 0a d5 01
|
||||
|
||||
; asm: roundss $2, %xmm5, %xmm4
|
||||
[-,%xmm4] v58 = ceil v10 ; bin: 66 0f 3a 0a e5 02
|
||||
; asm: roundss $2, %xmm2, %xmm5
|
||||
[-,%xmm5] v59 = ceil v11 ; bin: 66 0f 3a 0a ea 02
|
||||
; asm: roundss $2, %xmm5, %xmm2
|
||||
[-,%xmm2] v60 = ceil v10 ; bin: 66 0f 3a 0a d5 02
|
||||
|
||||
; asm: roundss $3, %xmm5, %xmm4
|
||||
[-,%xmm4] v61 = trunc v10 ; bin: 66 0f 3a 0a e5 03
|
||||
; asm: roundss $3, %xmm2, %xmm5
|
||||
[-,%xmm5] v62 = trunc v11 ; bin: 66 0f 3a 0a ea 03
|
||||
; asm: roundss $3, %xmm5, %xmm2
|
||||
[-,%xmm2] v63 = trunc v10 ; bin: 66 0f 3a 0a d5 03
|
||||
|
||||
; Load/Store
|
||||
|
||||
; asm: movss (%ecx), %xmm5
|
||||
[-,%xmm5] v100 = load.f32 v0 ; bin: heap_oob f3 0f 10 29
|
||||
; asm: movss (%esi), %xmm2
|
||||
[-,%xmm2] v101 = load.f32 v1 ; bin: heap_oob f3 0f 10 16
|
||||
; asm: movss 50(%ecx), %xmm5
|
||||
[-,%xmm5] v110 = load.f32 v0+50 ; bin: heap_oob f3 0f 10 69 32
|
||||
; asm: movss -50(%esi), %xmm2
|
||||
[-,%xmm2] v111 = load.f32 v1-50 ; bin: heap_oob f3 0f 10 56 ce
|
||||
; asm: movss 10000(%ecx), %xmm5
|
||||
[-,%xmm5] v120 = load.f32 v0+10000 ; bin: heap_oob f3 0f 10 a9 00002710
|
||||
; asm: movss -10000(%esi), %xmm2
|
||||
[-,%xmm2] v121 = load.f32 v1-10000 ; bin: heap_oob f3 0f 10 96 ffffd8f0
|
||||
|
||||
; asm: movss %xmm5, (%ecx)
|
||||
[-] store.f32 v100, v0 ; bin: heap_oob f3 0f 11 29
|
||||
; asm: movss %xmm2, (%esi)
|
||||
[-] store.f32 v101, v1 ; bin: heap_oob f3 0f 11 16
|
||||
; asm: movss %xmm5, 50(%ecx)
|
||||
[-] store.f32 v100, v0+50 ; bin: heap_oob f3 0f 11 69 32
|
||||
; asm: movss %xmm2, -50(%esi)
|
||||
[-] store.f32 v101, v1-50 ; bin: heap_oob f3 0f 11 56 ce
|
||||
; asm: movss %xmm5, 10000(%ecx)
|
||||
[-] store.f32 v100, v0+10000 ; bin: heap_oob f3 0f 11 a9 00002710
|
||||
; asm: movss %xmm2, -10000(%esi)
|
||||
[-] store.f32 v101, v1-10000 ; bin: heap_oob f3 0f 11 96 ffffd8f0
|
||||
|
||||
; Spill / Fill.
|
||||
|
||||
; asm: movss %xmm5, 1032(%esp)
|
||||
[-,ss1] v200 = spill v100 ; bin: stk_ovf f3 0f 11 ac 24 00000408
|
||||
; asm: movss %xmm2, 1032(%esp)
|
||||
[-,ss1] v201 = spill v101 ; bin: stk_ovf f3 0f 11 94 24 00000408
|
||||
|
||||
; asm: movss 1032(%esp), %xmm5
|
||||
[-,%xmm5] v210 = fill v200 ; bin: f3 0f 10 ac 24 00000408
|
||||
; asm: movss 1032(%esp), %xmm2
|
||||
[-,%xmm2] v211 = fill v201 ; bin: f3 0f 10 94 24 00000408
|
||||
|
||||
; asm: movss %xmm5, 1032(%esp)
|
||||
regspill v100, %xmm5 -> ss1 ; bin: stk_ovf f3 0f 11 ac 24 00000408
|
||||
; asm: movss 1032(%esp), %xmm5
|
||||
regfill v100, ss1 -> %xmm5 ; bin: f3 0f 10 ac 24 00000408
|
||||
|
||||
; Comparisons.
|
||||
;
|
||||
; Only `supported_floatccs` are tested here. Others are handled by
|
||||
; legalization patterns.
|
||||
|
||||
; asm: ucomiss %xmm2, %xmm5
|
||||
; asm: setnp %bl
|
||||
[-,%rbx] v300 = fcmp ord v10, v11 ; bin: 0f 2e ea 0f 9b c3
|
||||
; asm: ucomiss %xmm5, %xmm2
|
||||
; asm: setp %bl
|
||||
[-,%rbx] v301 = fcmp uno v11, v10 ; bin: 0f 2e d5 0f 9a c3
|
||||
; asm: ucomiss %xmm2, %xmm5
|
||||
; asm: setne %dl
|
||||
[-,%rdx] v302 = fcmp one v10, v11 ; bin: 0f 2e ea 0f 95 c2
|
||||
; asm: ucomiss %xmm5, %xmm2
|
||||
; asm: sete %dl
|
||||
[-,%rdx] v303 = fcmp ueq v11, v10 ; bin: 0f 2e d5 0f 94 c2
|
||||
; asm: ucomiss %xmm2, %xmm5
|
||||
; asm: seta %bl
|
||||
[-,%rbx] v304 = fcmp gt v10, v11 ; bin: 0f 2e ea 0f 97 c3
|
||||
; asm: ucomiss %xmm5, %xmm2
|
||||
; asm: setae %bl
|
||||
[-,%rbx] v305 = fcmp ge v11, v10 ; bin: 0f 2e d5 0f 93 c3
|
||||
; asm: ucomiss %xmm2, %xmm5
|
||||
; asm: setb %dl
|
||||
[-,%rdx] v306 = fcmp ult v10, v11 ; bin: 0f 2e ea 0f 92 c2
|
||||
; asm: ucomiss %xmm5, %xmm2
|
||||
; asm: setbe %dl
|
||||
[-,%rdx] v307 = fcmp ule v11, v10 ; bin: 0f 2e d5 0f 96 c2
|
||||
|
||||
; asm: ucomiss %xmm2, %xmm5
|
||||
[-,%rflags] v310 = ffcmp v10, v11 ; bin: 0f 2e ea
|
||||
; asm: ucomiss %xmm2, %xmm5
|
||||
[-,%rflags] v311 = ffcmp v11, v10 ; bin: 0f 2e d5
|
||||
; asm: ucomiss %xmm5, %xmm5
|
||||
[-,%rflags] v312 = ffcmp v10, v10 ; bin: 0f 2e ed
|
||||
|
||||
; Load/Store Complex
|
||||
|
||||
[-,%rax] v350 = iconst.i32 1
|
||||
[-,%rbx] v351 = iconst.i32 2
|
||||
|
||||
; asm: movss (%rax,%rbx,1),%xmm5
|
||||
[-,%xmm5] v352 = load_complex.f32 v350+v351 ; bin: heap_oob f3 0f 10 2c 18
|
||||
; asm: movss 0x32(%rax,%rbx,1),%xmm5
|
||||
[-,%xmm5] v353 = load_complex.f32 v350+v351+50 ; bin: heap_oob f3 0f 10 6c 18 32
|
||||
; asm: movss -0x32(%rax,%rbx,1),%xmm5
|
||||
[-,%xmm5] v354 = load_complex.f32 v350+v351-50 ; bin: heap_oob f3 0f 10 6c 18 ce
|
||||
; asm: movss 0x2710(%rax,%rbx,1),%xmm5
|
||||
[-,%xmm5] v355 = load_complex.f32 v350+v351+10000 ; bin: heap_oob f3 0f 10 ac 18 00002710
|
||||
; asm: movss -0x2710(%rax,%rbx,1),%xmm5
|
||||
[-,%xmm5] v356 = load_complex.f32 v350+v351-10000 ; bin: heap_oob f3 0f 10 ac 18 ffffd8f0
|
||||
; asm: movss %xmm5,(%rax,%rbx,1)
|
||||
[-] store_complex.f32 v100, v350+v351 ; bin: heap_oob f3 0f 11 2c 18
|
||||
; asm: movss %xmm5,0x32(%rax,%rbx,1)
|
||||
[-] store_complex.f32 v100, v350+v351+50 ; bin: heap_oob f3 0f 11 6c 18 32
|
||||
; asm: movss %xmm2,-0x32(%rax,%rbx,1)
|
||||
[-] store_complex.f32 v101, v350+v351-50 ; bin: heap_oob f3 0f 11 54 18 ce
|
||||
; asm: movss %xmm5,0x2710(%rax,%rbx,1)
|
||||
[-] store_complex.f32 v100, v350+v351+10000 ; bin: heap_oob f3 0f 11 ac 18 00002710
|
||||
; asm: movss %xmm2,-0x2710(%rax,%rbx,1)
|
||||
[-] store_complex.f32 v101, v350+v351-10000 ; bin: heap_oob f3 0f 11 94 18 ffffd8f0
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
function %F64() {
|
||||
ss0 = incoming_arg 8, offset 0
|
||||
ss1 = incoming_arg 1024, offset -1024
|
||||
ss2 = incoming_arg 1024, offset -2048
|
||||
ss3 = incoming_arg 8, offset -2056
|
||||
|
||||
ebb0:
|
||||
[-,%rcx] v0 = iconst.i32 1
|
||||
[-,%rsi] v1 = iconst.i32 2
|
||||
|
||||
; asm: cvtsi2sd %ecx, %xmm5
|
||||
[-,%xmm5] v10 = fcvt_from_sint.f64 v0 ; bin: f2 0f 2a e9
|
||||
; asm: cvtsi2sd %esi, %xmm2
|
||||
[-,%xmm2] v11 = fcvt_from_sint.f64 v1 ; bin: f2 0f 2a d6
|
||||
|
||||
; asm: cvtsd2ss %xmm2, %xmm5
|
||||
[-,%xmm5] v12 = fdemote.f32 v11 ; bin: f2 0f 5a ea
|
||||
; asm: cvtsd2ss %xmm5, %xmm2
|
||||
[-,%xmm2] v13 = fdemote.f32 v10 ; bin: f2 0f 5a d5
|
||||
|
||||
; No i64 <-> f64 bitcasts in 32-bit mode.
|
||||
|
||||
; asm: movaps %xmm2, %xmm5
|
||||
[-,%xmm5] v18 = copy v11 ; bin: 0f 28 ea
|
||||
; asm: movaps %xmm5, %xmm2
|
||||
[-,%xmm2] v19 = copy v10 ; bin: 0f 28 d5
|
||||
|
||||
; asm: movaps %xmm2, %xmm5
|
||||
regmove v19, %xmm2 -> %xmm5 ; bin: 0f 28 ea
|
||||
; asm: movaps %xmm5, %xmm2
|
||||
regmove v19, %xmm5 -> %xmm2 ; bin: 0f 28 d5
|
||||
|
||||
; Binary arithmetic.
|
||||
|
||||
; asm: addsd %xmm2, %xmm5
|
||||
[-,%xmm5] v20 = fadd v10, v11 ; bin: f2 0f 58 ea
|
||||
; asm: addsd %xmm5, %xmm2
|
||||
[-,%xmm2] v21 = fadd v11, v10 ; bin: f2 0f 58 d5
|
||||
|
||||
; asm: subsd %xmm2, %xmm5
|
||||
[-,%xmm5] v22 = fsub v10, v11 ; bin: f2 0f 5c ea
|
||||
; asm: subsd %xmm5, %xmm2
|
||||
[-,%xmm2] v23 = fsub v11, v10 ; bin: f2 0f 5c d5
|
||||
|
||||
; asm: mulsd %xmm2, %xmm5
|
||||
[-,%xmm5] v24 = fmul v10, v11 ; bin: f2 0f 59 ea
|
||||
; asm: mulsd %xmm5, %xmm2
|
||||
[-,%xmm2] v25 = fmul v11, v10 ; bin: f2 0f 59 d5
|
||||
|
||||
; asm: divsd %xmm2, %xmm5
|
||||
[-,%xmm5] v26 = fdiv v10, v11 ; bin: f2 0f 5e ea
|
||||
; asm: divsd %xmm5, %xmm2
|
||||
[-,%xmm2] v27 = fdiv v11, v10 ; bin: f2 0f 5e d5
|
||||
|
||||
; Bitwise ops.
|
||||
; We use the *ps SSE instructions for everything because they are smaller.
|
||||
|
||||
; asm: andps %xmm2, %xmm5
|
||||
[-,%xmm5] v30 = band v10, v11 ; bin: 0f 54 ea
|
||||
; asm: andps %xmm5, %xmm2
|
||||
[-,%xmm2] v31 = band v11, v10 ; bin: 0f 54 d5
|
||||
|
||||
; asm: andnps %xmm2, %xmm5
|
||||
[-,%xmm5] v32 = band_not v11, v10 ; bin: 0f 55 ea
|
||||
; asm: andnps %xmm5, %xmm2
|
||||
[-,%xmm2] v33 = band_not v10, v11 ; bin: 0f 55 d5
|
||||
|
||||
; asm: orps %xmm2, %xmm5
|
||||
[-,%xmm5] v34 = bor v10, v11 ; bin: 0f 56 ea
|
||||
; asm: orps %xmm5, %xmm2
|
||||
[-,%xmm2] v35 = bor v11, v10 ; bin: 0f 56 d5
|
||||
|
||||
; asm: xorps %xmm2, %xmm5
|
||||
[-,%xmm5] v36 = bxor v10, v11 ; bin: 0f 57 ea
|
||||
; asm: xorps %xmm5, %xmm2
|
||||
[-,%xmm2] v37 = bxor v11, v10 ; bin: 0f 57 d5
|
||||
|
||||
; Convert float to int. (No i64 dest on i386).
|
||||
|
||||
; asm: cvttsd2si %xmm5, %ecx
|
||||
[-,%rcx] v40 = x86_cvtt2si.i32 v10 ; bin: f2 0f 2c cd
|
||||
; asm: cvttsd2si %xmm2, %esi
|
||||
[-,%rsi] v41 = x86_cvtt2si.i32 v11 ; bin: f2 0f 2c f2
|
||||
|
||||
; Min/max.
|
||||
|
||||
; asm: minsd %xmm2, %xmm5
|
||||
[-,%xmm5] v42 = x86_fmin v10, v11 ; bin: f2 0f 5d ea
|
||||
; asm: minsd %xmm5, %xmm2
|
||||
[-,%xmm2] v43 = x86_fmin v11, v10 ; bin: f2 0f 5d d5
|
||||
; asm: maxsd %xmm2, %xmm5
|
||||
[-,%xmm5] v44 = x86_fmax v10, v11 ; bin: f2 0f 5f ea
|
||||
; asm: maxsd %xmm5, %xmm2
|
||||
[-,%xmm2] v45 = x86_fmax v11, v10 ; bin: f2 0f 5f d5
|
||||
|
||||
; Unary arithmetic.
|
||||
|
||||
; asm: sqrtsd %xmm5, %xmm2
|
||||
[-,%xmm2] v50 = sqrt v10 ; bin: f2 0f 51 d5
|
||||
; asm: sqrtsd %xmm2, %xmm5
|
||||
[-,%xmm5] v51 = sqrt v11 ; bin: f2 0f 51 ea
|
||||
|
||||
; asm: roundsd $0, %xmm5, %xmm4
|
||||
[-,%xmm4] v52 = nearest v10 ; bin: 66 0f 3a 0b e5 00
|
||||
; asm: roundsd $0, %xmm2, %xmm5
|
||||
[-,%xmm5] v53 = nearest v11 ; bin: 66 0f 3a 0b ea 00
|
||||
; asm: roundsd $0, %xmm5, %xmm2
|
||||
[-,%xmm2] v54 = nearest v10 ; bin: 66 0f 3a 0b d5 00
|
||||
|
||||
; asm: roundsd $1, %xmm5, %xmm4
|
||||
[-,%xmm4] v55 = floor v10 ; bin: 66 0f 3a 0b e5 01
|
||||
; asm: roundsd $1, %xmm2, %xmm5
|
||||
[-,%xmm5] v56 = floor v11 ; bin: 66 0f 3a 0b ea 01
|
||||
; asm: roundsd $1, %xmm5, %xmm2
|
||||
[-,%xmm2] v57 = floor v10 ; bin: 66 0f 3a 0b d5 01
|
||||
|
||||
; asm: roundsd $2, %xmm5, %xmm4
|
||||
[-,%xmm4] v58 = ceil v10 ; bin: 66 0f 3a 0b e5 02
|
||||
; asm: roundsd $2, %xmm2, %xmm5
|
||||
[-,%xmm5] v59 = ceil v11 ; bin: 66 0f 3a 0b ea 02
|
||||
; asm: roundsd $2, %xmm5, %xmm2
|
||||
[-,%xmm2] v60 = ceil v10 ; bin: 66 0f 3a 0b d5 02
|
||||
|
||||
; asm: roundsd $3, %xmm5, %xmm4
|
||||
[-,%xmm4] v61 = trunc v10 ; bin: 66 0f 3a 0b e5 03
|
||||
; asm: roundsd $3, %xmm2, %xmm5
|
||||
[-,%xmm5] v62 = trunc v11 ; bin: 66 0f 3a 0b ea 03
|
||||
; asm: roundsd $3, %xmm5, %xmm2
|
||||
[-,%xmm2] v63 = trunc v10 ; bin: 66 0f 3a 0b d5 03
|
||||
|
||||
; Load/Store
|
||||
|
||||
; asm: movsd (%ecx), %xmm5
|
||||
[-,%xmm5] v100 = load.f64 v0 ; bin: heap_oob f2 0f 10 29
|
||||
; asm: movsd (%esi), %xmm2
|
||||
[-,%xmm2] v101 = load.f64 v1 ; bin: heap_oob f2 0f 10 16
|
||||
; asm: movsd 50(%ecx), %xmm5
|
||||
[-,%xmm5] v110 = load.f64 v0+50 ; bin: heap_oob f2 0f 10 69 32
|
||||
; asm: movsd -50(%esi), %xmm2
|
||||
[-,%xmm2] v111 = load.f64 v1-50 ; bin: heap_oob f2 0f 10 56 ce
|
||||
; asm: movsd 10000(%ecx), %xmm5
|
||||
[-,%xmm5] v120 = load.f64 v0+10000 ; bin: heap_oob f2 0f 10 a9 00002710
|
||||
; asm: movsd -10000(%esi), %xmm2
|
||||
[-,%xmm2] v121 = load.f64 v1-10000 ; bin: heap_oob f2 0f 10 96 ffffd8f0
|
||||
|
||||
; asm: movsd %xmm5, (%ecx)
|
||||
[-] store.f64 v100, v0 ; bin: heap_oob f2 0f 11 29
|
||||
; asm: movsd %xmm2, (%esi)
|
||||
[-] store.f64 v101, v1 ; bin: heap_oob f2 0f 11 16
|
||||
; asm: movsd %xmm5, 50(%ecx)
|
||||
[-] store.f64 v100, v0+50 ; bin: heap_oob f2 0f 11 69 32
|
||||
; asm: movsd %xmm2, -50(%esi)
|
||||
[-] store.f64 v101, v1-50 ; bin: heap_oob f2 0f 11 56 ce
|
||||
; asm: movsd %xmm5, 10000(%ecx)
|
||||
[-] store.f64 v100, v0+10000 ; bin: heap_oob f2 0f 11 a9 00002710
|
||||
; asm: movsd %xmm2, -10000(%esi)
|
||||
[-] store.f64 v101, v1-10000 ; bin: heap_oob f2 0f 11 96 ffffd8f0
|
||||
|
||||
; Spill / Fill.
|
||||
|
||||
; asm: movsd %xmm5, 1032(%esp)
|
||||
[-,ss1] v200 = spill v100 ; bin: stk_ovf f2 0f 11 ac 24 00000408
|
||||
; asm: movsd %xmm2, 1032(%esp)
|
||||
[-,ss1] v201 = spill v101 ; bin: stk_ovf f2 0f 11 94 24 00000408
|
||||
|
||||
; asm: movsd 1032(%esp), %xmm5
|
||||
[-,%xmm5] v210 = fill v200 ; bin: f2 0f 10 ac 24 00000408
|
||||
; asm: movsd 1032(%esp), %xmm2
|
||||
[-,%xmm2] v211 = fill v201 ; bin: f2 0f 10 94 24 00000408
|
||||
|
||||
; asm: movsd %xmm5, 1032(%esp)
|
||||
regspill v100, %xmm5 -> ss1 ; bin: stk_ovf f2 0f 11 ac 24 00000408
|
||||
; asm: movsd 1032(%esp), %xmm5
|
||||
regfill v100, ss1 -> %xmm5 ; bin: f2 0f 10 ac 24 00000408
|
||||
|
||||
; Comparisons.
|
||||
;
|
||||
; Only `supported_floatccs` are tested here. Others are handled by
|
||||
; legalization patterns.
|
||||
|
||||
; asm: ucomisd %xmm2, %xmm5
|
||||
; asm: setnp %bl
|
||||
[-,%rbx] v300 = fcmp ord v10, v11 ; bin: 66 0f 2e ea 0f 9b c3
|
||||
; asm: ucomisd %xmm5, %xmm2
|
||||
; asm: setp %bl
|
||||
[-,%rbx] v301 = fcmp uno v11, v10 ; bin: 66 0f 2e d5 0f 9a c3
|
||||
; asm: ucomisd %xmm2, %xmm5
|
||||
; asm: setne %dl
|
||||
[-,%rdx] v302 = fcmp one v10, v11 ; bin: 66 0f 2e ea 0f 95 c2
|
||||
; asm: ucomisd %xmm5, %xmm2
|
||||
; asm: sete %dl
|
||||
[-,%rdx] v303 = fcmp ueq v11, v10 ; bin: 66 0f 2e d5 0f 94 c2
|
||||
; asm: ucomisd %xmm2, %xmm5
|
||||
; asm: seta %bl
|
||||
[-,%rbx] v304 = fcmp gt v10, v11 ; bin: 66 0f 2e ea 0f 97 c3
|
||||
; asm: ucomisd %xmm5, %xmm2
|
||||
; asm: setae %bl
|
||||
[-,%rbx] v305 = fcmp ge v11, v10 ; bin: 66 0f 2e d5 0f 93 c3
|
||||
; asm: ucomisd %xmm2, %xmm5
|
||||
; asm: setb %dl
|
||||
[-,%rdx] v306 = fcmp ult v10, v11 ; bin: 66 0f 2e ea 0f 92 c2
|
||||
; asm: ucomisd %xmm5, %xmm2
|
||||
; asm: setbe %dl
|
||||
[-,%rdx] v307 = fcmp ule v11, v10 ; bin: 66 0f 2e d5 0f 96 c2
|
||||
|
||||
; asm: ucomisd %xmm2, %xmm5
|
||||
[-,%rflags] v310 = ffcmp v10, v11 ; bin: 66 0f 2e ea
|
||||
; asm: ucomisd %xmm2, %xmm5
|
||||
[-,%rflags] v311 = ffcmp v11, v10 ; bin: 66 0f 2e d5
|
||||
; asm: ucomisd %xmm5, %xmm5
|
||||
[-,%rflags] v312 = ffcmp v10, v10 ; bin: 66 0f 2e ed
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
function %cpuflags_float(f32 [%xmm0]) {
|
||||
ebb0(v0: f32 [%xmm0]):
|
||||
; asm: ucomiss %xmm0, %xmm0
|
||||
[-,%rflags] v1 = ffcmp v0, v0 ; bin: 0f 2e c0
|
||||
|
||||
jump ebb1
|
||||
|
||||
ebb1:
|
||||
; asm: jnp ebb1
|
||||
brff ord v1, ebb1 ; bin: 7b fe
|
||||
; asm: jp ebb1
|
||||
brff uno v1, ebb1 ; bin: 7a fc
|
||||
; asm: jne ebb1
|
||||
brff one v1, ebb1 ; bin: 75 fa
|
||||
; asm: je ebb1
|
||||
brff ueq v1, ebb1 ; bin: 74 f8
|
||||
; asm: ja ebb1
|
||||
brff gt v1, ebb1 ; bin: 77 f6
|
||||
; asm: jae ebb1
|
||||
brff ge v1, ebb1 ; bin: 73 f4
|
||||
; asm: jb ebb1
|
||||
brff ult v1, ebb1 ; bin: 72 f2
|
||||
; asm: jbe ebb1
|
||||
brff ule v1, ebb1 ; bin: 76 f0
|
||||
|
||||
; asm: jp .+4; ud2
|
||||
trapff ord v1, user0 ; bin: 7a 02 user0 0f 0b
|
||||
; asm: jnp .+4; ud2
|
||||
trapff uno v1, user0 ; bin: 7b 02 user0 0f 0b
|
||||
; asm: je .+4; ud2
|
||||
trapff one v1, user0 ; bin: 74 02 user0 0f 0b
|
||||
; asm: jne .+4; ud2
|
||||
trapff ueq v1, user0 ; bin: 75 02 user0 0f 0b
|
||||
; asm: jna .+4; ud2
|
||||
trapff gt v1, user0 ; bin: 76 02 user0 0f 0b
|
||||
; asm: jnae .+4; ud2
|
||||
trapff ge v1, user0 ; bin: 72 02 user0 0f 0b
|
||||
; asm: jnb .+4; ud2
|
||||
trapff ult v1, user0 ; bin: 73 02 user0 0f 0b
|
||||
; asm: jnbe .+4; ud2
|
||||
trapff ule v1, user0 ; bin: 77 02 user0 0f 0b
|
||||
|
||||
; asm: setnp %bl
|
||||
[-,%rbx] v10 = trueff ord v1 ; bin: 0f 9b c3
|
||||
; asm: setp %bl
|
||||
[-,%rbx] v11 = trueff uno v1 ; bin: 0f 9a c3
|
||||
; asm: setne %dl
|
||||
[-,%rdx] v12 = trueff one v1 ; bin: 0f 95 c2
|
||||
; asm: sete %dl
|
||||
[-,%rdx] v13 = trueff ueq v1 ; bin: 0f 94 c2
|
||||
; asm: seta %al
|
||||
[-,%rax] v14 = trueff gt v1 ; bin: 0f 97 c0
|
||||
; asm: setae %al
|
||||
[-,%rax] v15 = trueff ge v1 ; bin: 0f 93 c0
|
||||
; asm: setb %cl
|
||||
[-,%rcx] v16 = trueff ult v1 ; bin: 0f 92 c1
|
||||
; asm: setbe %cl
|
||||
[-,%rcx] v17 = trueff ule v1 ; bin: 0f 96 c1
|
||||
|
||||
return
|
||||
}
|
||||
645
cranelift/filetests/filetests/isa/x86/binary32.clif
Normal file
645
cranelift/filetests/filetests/isa/x86/binary32.clif
Normal file
@@ -0,0 +1,645 @@
|
||||
; binary emission of x86-32 code.
|
||||
test binemit
|
||||
set opt_level=best
|
||||
target i686 haswell
|
||||
|
||||
; The binary encodings can be verified with the command:
|
||||
;
|
||||
; sed -ne 's/^ *; asm: *//p' filetests/isa/x86/binary32.clif | llvm-mc -show-encoding -triple=i386
|
||||
;
|
||||
|
||||
function %I32() {
|
||||
sig0 = ()
|
||||
fn0 = %foo()
|
||||
|
||||
gv0 = symbol %some_gv
|
||||
|
||||
ss0 = incoming_arg 8, offset 0
|
||||
ss1 = incoming_arg 1024, offset -1024
|
||||
ss2 = incoming_arg 1024, offset -2048
|
||||
ss3 = incoming_arg 8, offset -2056
|
||||
|
||||
ebb0:
|
||||
; asm: movl $1, %ecx
|
||||
[-,%rcx] v1 = iconst.i32 1 ; bin: b9 00000001
|
||||
; asm: movl $2, %esi
|
||||
[-,%rsi] v2 = iconst.i32 2 ; bin: be 00000002
|
||||
|
||||
; asm: movb $1, %cl
|
||||
[-,%rcx] v9007 = bconst.b1 true ; bin: b9 00000001
|
||||
|
||||
; Integer Register-Register Operations.
|
||||
|
||||
; asm: addl %esi, %ecx
|
||||
[-,%rcx] v10 = iadd v1, v2 ; bin: 01 f1
|
||||
; asm: addl %ecx, %esi
|
||||
[-,%rsi] v11 = iadd v2, v1 ; bin: 01 ce
|
||||
; asm: subl %esi, %ecx
|
||||
[-,%rcx] v12 = isub v1, v2 ; bin: 29 f1
|
||||
; asm: subl %ecx, %esi
|
||||
[-,%rsi] v13 = isub v2, v1 ; bin: 29 ce
|
||||
|
||||
; asm: andl %esi, %ecx
|
||||
[-,%rcx] v14 = band v1, v2 ; bin: 21 f1
|
||||
; asm: andl %ecx, %esi
|
||||
[-,%rsi] v15 = band v2, v1 ; bin: 21 ce
|
||||
; asm: orl %esi, %ecx
|
||||
[-,%rcx] v16 = bor v1, v2 ; bin: 09 f1
|
||||
; asm: orl %ecx, %esi
|
||||
[-,%rsi] v17 = bor v2, v1 ; bin: 09 ce
|
||||
; asm: xorl %esi, %ecx
|
||||
[-,%rcx] v18 = bxor v1, v2 ; bin: 31 f1
|
||||
; asm: xorl %ecx, %esi
|
||||
[-,%rsi] v19 = bxor v2, v1 ; bin: 31 ce
|
||||
|
||||
; Dynamic shifts take the shift amount in %rcx.
|
||||
|
||||
; asm: shll %cl, %esi
|
||||
[-,%rsi] v20 = ishl v2, v1 ; bin: d3 e6
|
||||
; asm: shll %cl, %ecx
|
||||
[-,%rcx] v21 = ishl v1, v1 ; bin: d3 e1
|
||||
; asm: shrl %cl, %esi
|
||||
[-,%rsi] v22 = ushr v2, v1 ; bin: d3 ee
|
||||
; asm: shrl %cl, %ecx
|
||||
[-,%rcx] v23 = ushr v1, v1 ; bin: d3 e9
|
||||
; asm: sarl %cl, %esi
|
||||
[-,%rsi] v24 = sshr v2, v1 ; bin: d3 fe
|
||||
; asm: sarl %cl, %ecx
|
||||
[-,%rcx] v25 = sshr v1, v1 ; bin: d3 f9
|
||||
; asm: roll %cl, %esi
|
||||
[-,%rsi] v26 = rotl v2, v1 ; bin: d3 c6
|
||||
; asm: roll %cl, %ecx
|
||||
[-,%rcx] v27 = rotl v1, v1 ; bin: d3 c1
|
||||
; asm: rorl %cl, %esi
|
||||
[-,%rsi] v28 = rotr v2, v1 ; bin: d3 ce
|
||||
; asm: rorl %cl, %ecx
|
||||
[-,%rcx] v29 = rotr v1, v1 ; bin: d3 c9
|
||||
|
||||
; Integer Register - Immediate 8-bit operations.
|
||||
; The 8-bit immediate is sign-extended.
|
||||
|
||||
; asm: addl $-128, %ecx
|
||||
[-,%rcx] v30 = iadd_imm v1, -128 ; bin: 83 c1 80
|
||||
; asm: addl $10, %esi
|
||||
[-,%rsi] v31 = iadd_imm v2, 10 ; bin: 83 c6 0a
|
||||
|
||||
; asm: andl $-128, %ecx
|
||||
[-,%rcx] v32 = band_imm v1, -128 ; bin: 83 e1 80
|
||||
; asm: andl $10, %esi
|
||||
[-,%rsi] v33 = band_imm v2, 10 ; bin: 83 e6 0a
|
||||
; asm: orl $-128, %ecx
|
||||
[-,%rcx] v34 = bor_imm v1, -128 ; bin: 83 c9 80
|
||||
; asm: orl $10, %esi
|
||||
[-,%rsi] v35 = bor_imm v2, 10 ; bin: 83 ce 0a
|
||||
; asm: xorl $-128, %ecx
|
||||
[-,%rcx] v36 = bxor_imm v1, -128 ; bin: 83 f1 80
|
||||
; asm: xorl $10, %esi
|
||||
[-,%rsi] v37 = bxor_imm v2, 10 ; bin: 83 f6 0a
|
||||
|
||||
; Integer Register - Immediate 32-bit operations.
|
||||
|
||||
; asm: addl $-128000, %ecx
|
||||
[-,%rcx] v40 = iadd_imm v1, -128000 ; bin: 81 c1 fffe0c00
|
||||
; asm: addl $1000000, %esi
|
||||
[-,%rsi] v41 = iadd_imm v2, 1000000 ; bin: 81 c6 000f4240
|
||||
|
||||
; asm: andl $-128000, %ecx
|
||||
[-,%rcx] v42 = band_imm v1, -128000 ; bin: 81 e1 fffe0c00
|
||||
; asm: andl $1000000, %esi
|
||||
[-,%rsi] v43 = band_imm v2, 1000000 ; bin: 81 e6 000f4240
|
||||
; asm: orl $-128000, %ecx
|
||||
[-,%rcx] v44 = bor_imm v1, -128000 ; bin: 81 c9 fffe0c00
|
||||
; asm: orl $1000000, %esi
|
||||
[-,%rsi] v45 = bor_imm v2, 1000000 ; bin: 81 ce 000f4240
|
||||
; asm: xorl $-128000, %ecx
|
||||
[-,%rcx] v46 = bxor_imm v1, -128000 ; bin: 81 f1 fffe0c00
|
||||
; asm: xorl $1000000, %esi
|
||||
[-,%rsi] v47 = bxor_imm v2, 1000000 ; bin: 81 f6 000f4240
|
||||
|
||||
; More arithmetic.
|
||||
|
||||
; asm: imull %esi, %ecx
|
||||
[-,%rcx] v50 = imul v1, v2 ; bin: 0f af ce
|
||||
; asm: imull %ecx, %esi
|
||||
[-,%rsi] v51 = imul v2, v1 ; bin: 0f af f1
|
||||
|
||||
; asm: movl $1, %eax
|
||||
[-,%rax] v52 = iconst.i32 1 ; bin: b8 00000001
|
||||
; asm: movl $2, %edx
|
||||
[-,%rdx] v53 = iconst.i32 2 ; bin: ba 00000002
|
||||
; asm: idivl %ecx
|
||||
[-,%rax,%rdx] v54, v55 = x86_sdivmodx v52, v53, v1 ; bin: int_divz f7 f9
|
||||
; asm: idivl %esi
|
||||
[-,%rax,%rdx] v56, v57 = x86_sdivmodx v52, v53, v2 ; bin: int_divz f7 fe
|
||||
; asm: divl %ecx
|
||||
[-,%rax,%rdx] v58, v59 = x86_udivmodx v52, v53, v1 ; bin: int_divz f7 f1
|
||||
; asm: divl %esi
|
||||
[-,%rax,%rdx] v60, v61 = x86_udivmodx v52, v53, v2 ; bin: int_divz f7 f6
|
||||
|
||||
; Register copies.
|
||||
|
||||
; asm: movl %esi, %ecx
|
||||
[-,%rcx] v80 = copy v2 ; bin: 89 f1
|
||||
; asm: movl %ecx, %esi
|
||||
[-,%rsi] v81 = copy v1 ; bin: 89 ce
|
||||
|
||||
; Copy Special
|
||||
; asm: movl %esp, %ebp
|
||||
copy_special %rsp -> %rbp ; bin: 89 e5
|
||||
; asm: movl %ebp, %esp
|
||||
copy_special %rbp -> %rsp ; bin: 89 ec
|
||||
|
||||
|
||||
; Load/Store instructions.
|
||||
|
||||
; Register indirect addressing with no displacement.
|
||||
|
||||
; asm: movl %ecx, (%esi)
|
||||
store v1, v2 ; bin: heap_oob 89 0e
|
||||
; asm: movl %esi, (%ecx)
|
||||
store v2, v1 ; bin: heap_oob 89 31
|
||||
; asm: movw %cx, (%esi)
|
||||
istore16 v1, v2 ; bin: heap_oob 66 89 0e
|
||||
; asm: movw %si, (%ecx)
|
||||
istore16 v2, v1 ; bin: heap_oob 66 89 31
|
||||
; asm: movb %cl, (%esi)
|
||||
istore8 v1, v2 ; bin: heap_oob 88 0e
|
||||
; Can't store %sil in 32-bit mode (needs REX prefix).
|
||||
|
||||
; asm: movl (%ecx), %edi
|
||||
[-,%rdi] v100 = load.i32 v1 ; bin: heap_oob 8b 39
|
||||
; asm: movl (%esi), %edx
|
||||
[-,%rdx] v101 = load.i32 v2 ; bin: heap_oob 8b 16
|
||||
; asm: movzwl (%ecx), %edi
|
||||
[-,%rdi] v102 = uload16.i32 v1 ; bin: heap_oob 0f b7 39
|
||||
; asm: movzwl (%esi), %edx
|
||||
[-,%rdx] v103 = uload16.i32 v2 ; bin: heap_oob 0f b7 16
|
||||
; asm: movswl (%ecx), %edi
|
||||
[-,%rdi] v104 = sload16.i32 v1 ; bin: heap_oob 0f bf 39
|
||||
; asm: movswl (%esi), %edx
|
||||
[-,%rdx] v105 = sload16.i32 v2 ; bin: heap_oob 0f bf 16
|
||||
; asm: movzbl (%ecx), %edi
|
||||
[-,%rdi] v106 = uload8.i32 v1 ; bin: heap_oob 0f b6 39
|
||||
; asm: movzbl (%esi), %edx
|
||||
[-,%rdx] v107 = uload8.i32 v2 ; bin: heap_oob 0f b6 16
|
||||
; asm: movsbl (%ecx), %edi
|
||||
[-,%rdi] v108 = sload8.i32 v1 ; bin: heap_oob 0f be 39
|
||||
; asm: movsbl (%esi), %edx
|
||||
[-,%rdx] v109 = sload8.i32 v2 ; bin: heap_oob 0f be 16
|
||||
|
||||
; Register-indirect with 8-bit signed displacement.
|
||||
|
||||
; asm: movl %ecx, 100(%esi)
|
||||
store v1, v2+100 ; bin: heap_oob 89 4e 64
|
||||
; asm: movl %esi, -100(%ecx)
|
||||
store v2, v1-100 ; bin: heap_oob 89 71 9c
|
||||
; asm: movw %cx, 100(%esi)
|
||||
istore16 v1, v2+100 ; bin: heap_oob 66 89 4e 64
|
||||
; asm: movw %si, -100(%ecx)
|
||||
istore16 v2, v1-100 ; bin: heap_oob 66 89 71 9c
|
||||
; asm: movb %cl, 100(%esi)
|
||||
istore8 v1, v2+100 ; bin: heap_oob 88 4e 64
|
||||
|
||||
; asm: movl 50(%ecx), %edi
|
||||
[-,%rdi] v110 = load.i32 v1+50 ; bin: heap_oob 8b 79 32
|
||||
; asm: movl -50(%esi), %edx
|
||||
[-,%rdx] v111 = load.i32 v2-50 ; bin: heap_oob 8b 56 ce
|
||||
; asm: movzwl 50(%ecx), %edi
|
||||
[-,%rdi] v112 = uload16.i32 v1+50 ; bin: heap_oob 0f b7 79 32
|
||||
; asm: movzwl -50(%esi), %edx
|
||||
[-,%rdx] v113 = uload16.i32 v2-50 ; bin: heap_oob 0f b7 56 ce
|
||||
; asm: movswl 50(%ecx), %edi
|
||||
[-,%rdi] v114 = sload16.i32 v1+50 ; bin: heap_oob 0f bf 79 32
|
||||
; asm: movswl -50(%esi), %edx
|
||||
[-,%rdx] v115 = sload16.i32 v2-50 ; bin: heap_oob 0f bf 56 ce
|
||||
; asm: movzbl 50(%ecx), %edi
|
||||
[-,%rdi] v116 = uload8.i32 v1+50 ; bin: heap_oob 0f b6 79 32
|
||||
; asm: movzbl -50(%esi), %edx
|
||||
[-,%rdx] v117 = uload8.i32 v2-50 ; bin: heap_oob 0f b6 56 ce
|
||||
; asm: movsbl 50(%ecx), %edi
|
||||
[-,%rdi] v118 = sload8.i32 v1+50 ; bin: heap_oob 0f be 79 32
|
||||
; asm: movsbl -50(%esi), %edx
|
||||
[-,%rdx] v119 = sload8.i32 v2-50 ; bin: heap_oob 0f be 56 ce
|
||||
|
||||
; Register-indirect with 32-bit signed displacement.
|
||||
|
||||
; asm: movl %ecx, 10000(%esi)
|
||||
store v1, v2+10000 ; bin: heap_oob 89 8e 00002710
|
||||
; asm: movl %esi, -10000(%ecx)
|
||||
store v2, v1-10000 ; bin: heap_oob 89 b1 ffffd8f0
|
||||
; asm: movw %cx, 10000(%esi)
|
||||
istore16 v1, v2+10000 ; bin: heap_oob 66 89 8e 00002710
|
||||
; asm: movw %si, -10000(%ecx)
|
||||
istore16 v2, v1-10000 ; bin: heap_oob 66 89 b1 ffffd8f0
|
||||
; asm: movb %cl, 10000(%esi)
|
||||
istore8 v1, v2+10000 ; bin: heap_oob 88 8e 00002710
|
||||
|
||||
; asm: movl 50000(%ecx), %edi
|
||||
[-,%rdi] v120 = load.i32 v1+50000 ; bin: heap_oob 8b b9 0000c350
|
||||
; asm: movl -50000(%esi), %edx
|
||||
[-,%rdx] v121 = load.i32 v2-50000 ; bin: heap_oob 8b 96 ffff3cb0
|
||||
; asm: movzwl 50000(%ecx), %edi
|
||||
[-,%rdi] v122 = uload16.i32 v1+50000 ; bin: heap_oob 0f b7 b9 0000c350
|
||||
; asm: movzwl -50000(%esi), %edx
|
||||
[-,%rdx] v123 = uload16.i32 v2-50000 ; bin: heap_oob 0f b7 96 ffff3cb0
|
||||
; asm: movswl 50000(%ecx), %edi
|
||||
[-,%rdi] v124 = sload16.i32 v1+50000 ; bin: heap_oob 0f bf b9 0000c350
|
||||
; asm: movswl -50000(%esi), %edx
|
||||
[-,%rdx] v125 = sload16.i32 v2-50000 ; bin: heap_oob 0f bf 96 ffff3cb0
|
||||
; asm: movzbl 50000(%ecx), %edi
|
||||
[-,%rdi] v126 = uload8.i32 v1+50000 ; bin: heap_oob 0f b6 b9 0000c350
|
||||
; asm: movzbl -50000(%esi), %edx
|
||||
[-,%rdx] v127 = uload8.i32 v2-50000 ; bin: heap_oob 0f b6 96 ffff3cb0
|
||||
; asm: movsbl 50000(%ecx), %edi
|
||||
[-,%rdi] v128 = sload8.i32 v1+50000 ; bin: heap_oob 0f be b9 0000c350
|
||||
; asm: movsbl -50000(%esi), %edx
|
||||
[-,%rdx] v129 = sload8.i32 v2-50000 ; bin: heap_oob 0f be 96 ffff3cb0
|
||||
|
||||
; Bit-counting instructions.
|
||||
|
||||
; asm: popcntl %esi, %ecx
|
||||
[-,%rcx] v200 = popcnt v2 ; bin: f3 0f b8 ce
|
||||
; asm: popcntl %ecx, %esi
|
||||
[-,%rsi] v201 = popcnt v1 ; bin: f3 0f b8 f1
|
||||
|
||||
; asm: lzcntl %esi, %ecx
|
||||
[-,%rcx] v202 = clz v2 ; bin: f3 0f bd ce
|
||||
; asm: lzcntl %ecx, %esi
|
||||
[-,%rsi] v203 = clz v1 ; bin: f3 0f bd f1
|
||||
|
||||
; asm: tzcntl %esi, %ecx
|
||||
[-,%rcx] v204 = ctz v2 ; bin: f3 0f bc ce
|
||||
; asm: tzcntl %ecx, %esi
|
||||
[-,%rsi] v205 = ctz v1 ; bin: f3 0f bc f1
|
||||
|
||||
; Integer comparisons.
|
||||
|
||||
; asm: cmpl %esi, %ecx
|
||||
; asm: sete %bl
|
||||
[-,%rbx] v300 = icmp eq v1, v2 ; bin: 39 f1 0f 94 c3
|
||||
; asm: cmpl %ecx, %esi
|
||||
; asm: sete %dl
|
||||
[-,%rdx] v301 = icmp eq v2, v1 ; bin: 39 ce 0f 94 c2
|
||||
|
||||
; asm: cmpl %esi, %ecx
|
||||
; asm: setne %bl
|
||||
[-,%rbx] v302 = icmp ne v1, v2 ; bin: 39 f1 0f 95 c3
|
||||
; asm: cmpl %ecx, %esi
|
||||
; asm: setne %dl
|
||||
[-,%rdx] v303 = icmp ne v2, v1 ; bin: 39 ce 0f 95 c2
|
||||
|
||||
; asm: cmpl %esi, %ecx
|
||||
; asm: setl %bl
|
||||
[-,%rbx] v304 = icmp slt v1, v2 ; bin: 39 f1 0f 9c c3
|
||||
; asm: cmpl %ecx, %esi
|
||||
; asm: setl %dl
|
||||
[-,%rdx] v305 = icmp slt v2, v1 ; bin: 39 ce 0f 9c c2
|
||||
|
||||
; asm: cmpl %esi, %ecx
|
||||
; asm: setge %bl
|
||||
[-,%rbx] v306 = icmp sge v1, v2 ; bin: 39 f1 0f 9d c3
|
||||
; asm: cmpl %ecx, %esi
|
||||
; asm: setge %dl
|
||||
[-,%rdx] v307 = icmp sge v2, v1 ; bin: 39 ce 0f 9d c2
|
||||
|
||||
; asm: cmpl %esi, %ecx
|
||||
; asm: setg %bl
|
||||
[-,%rbx] v308 = icmp sgt v1, v2 ; bin: 39 f1 0f 9f c3
|
||||
; asm: cmpl %ecx, %esi
|
||||
; asm: setg %dl
|
||||
[-,%rdx] v309 = icmp sgt v2, v1 ; bin: 39 ce 0f 9f c2
|
||||
|
||||
; asm: cmpl %esi, %ecx
|
||||
; asm: setle %bl
|
||||
[-,%rbx] v310 = icmp sle v1, v2 ; bin: 39 f1 0f 9e c3
|
||||
; asm: cmpl %ecx, %esi
|
||||
; asm: setle %dl
|
||||
[-,%rdx] v311 = icmp sle v2, v1 ; bin: 39 ce 0f 9e c2
|
||||
|
||||
; asm: cmpl %esi, %ecx
|
||||
; asm: setb %bl
|
||||
[-,%rbx] v312 = icmp ult v1, v2 ; bin: 39 f1 0f 92 c3
|
||||
; asm: cmpl %ecx, %esi
|
||||
; asm: setb %dl
|
||||
[-,%rdx] v313 = icmp ult v2, v1 ; bin: 39 ce 0f 92 c2
|
||||
|
||||
; asm: cmpl %esi, %ecx
|
||||
; asm: setae %bl
|
||||
[-,%rbx] v314 = icmp uge v1, v2 ; bin: 39 f1 0f 93 c3
|
||||
; asm: cmpl %ecx, %esi
|
||||
; asm: setae %dl
|
||||
[-,%rdx] v315 = icmp uge v2, v1 ; bin: 39 ce 0f 93 c2
|
||||
|
||||
; asm: cmpl %esi, %ecx
|
||||
; asm: seta %bl
|
||||
[-,%rbx] v316 = icmp ugt v1, v2 ; bin: 39 f1 0f 97 c3
|
||||
; asm: cmpl %ecx, %esi
|
||||
; asm: seta %dl
|
||||
[-,%rdx] v317 = icmp ugt v2, v1 ; bin: 39 ce 0f 97 c2
|
||||
|
||||
; asm: cmpl %esi, %ecx
|
||||
; asm: setbe %bl
|
||||
[-,%rbx] v318 = icmp ule v1, v2 ; bin: 39 f1 0f 96 c3
|
||||
; asm: cmpl %ecx, %esi
|
||||
; asm: setbe %dl
|
||||
[-,%rdx] v319 = icmp ule v2, v1 ; bin: 39 ce 0f 96 c2
|
||||
|
||||
; Bool-to-int conversions.
|
||||
|
||||
; asm: movzbl %bl, %ecx
|
||||
[-,%rcx] v350 = bint.i32 v300 ; bin: 0f b6 cb
|
||||
; asm: movzbl %dl, %esi
|
||||
[-,%rsi] v351 = bint.i32 v301 ; bin: 0f b6 f2
|
||||
|
||||
; asm: call foo
|
||||
call fn0() ; bin: stk_ovf e8 CallPCRel4(%foo-4) 00000000
|
||||
|
||||
; asm: movl $0, %ecx
|
||||
[-,%rcx] v400 = func_addr.i32 fn0 ; bin: b9 Abs4(%foo) 00000000
|
||||
; asm: movl $0, %esi
|
||||
[-,%rsi] v401 = func_addr.i32 fn0 ; bin: be Abs4(%foo) 00000000
|
||||
|
||||
; asm: call *%ecx
|
||||
call_indirect sig0, v400() ; bin: stk_ovf ff d1
|
||||
; asm: call *%esi
|
||||
call_indirect sig0, v401() ; bin: stk_ovf ff d6
|
||||
|
||||
; asm: movl $0, %ecx
|
||||
[-,%rcx] v450 = symbol_value.i32 gv0 ; bin: b9 Abs4(%some_gv) 00000000
|
||||
; asm: movl $0, %esi
|
||||
[-,%rsi] v451 = symbol_value.i32 gv0 ; bin: be Abs4(%some_gv) 00000000
|
||||
|
||||
; Spill / Fill.
|
||||
|
||||
; asm: movl %ecx, 1032(%esp)
|
||||
[-,ss1] v500 = spill v1 ; bin: stk_ovf 89 8c 24 00000408
|
||||
; asm: movl %esi, 1032(%esp)
|
||||
[-,ss1] v501 = spill v2 ; bin: stk_ovf 89 b4 24 00000408
|
||||
|
||||
; asm: movl 1032(%esp), %ecx
|
||||
[-,%rcx] v510 = fill v500 ; bin: 8b 8c 24 00000408
|
||||
; asm: movl 1032(%esp), %esi
|
||||
[-,%rsi] v511 = fill v501 ; bin: 8b b4 24 00000408
|
||||
|
||||
; asm: movl %ecx, 1032(%esp)
|
||||
regspill v1, %rcx -> ss1 ; bin: stk_ovf 89 8c 24 00000408
|
||||
; asm: movl 1032(%esp), %ecx
|
||||
regfill v1, ss1 -> %rcx ; bin: 8b 8c 24 00000408
|
||||
|
||||
; Push and Pop
|
||||
; asm: pushl %ecx
|
||||
x86_push v1 ; bin: stk_ovf 51
|
||||
; asm: popl %ecx
|
||||
[-,%rcx] v512 = x86_pop.i32 ; bin: 59
|
||||
|
||||
; Adjust Stack Pointer Up
|
||||
; asm: addl $64, %esp
|
||||
adjust_sp_up_imm 64 ; bin: 83 c4 40
|
||||
; asm: addl $-64, %esp
|
||||
adjust_sp_up_imm -64 ; bin: 83 c4 c0
|
||||
; asm: addl $1024, %esp
|
||||
adjust_sp_up_imm 1024 ; bin: 81 c4 00000400
|
||||
; asm: addl $-1024, %esp
|
||||
adjust_sp_up_imm -1024 ; bin: 81 c4 fffffc00
|
||||
; asm: addl $2147483647, %esp
|
||||
adjust_sp_up_imm 2147483647 ; bin: 81 c4 7fffffff
|
||||
; asm: addl $-2147483648, %esp
|
||||
adjust_sp_up_imm -2147483648 ; bin: 81 c4 80000000
|
||||
|
||||
; Adjust Stack Pointer Down
|
||||
; asm: subl %ecx, %esp
|
||||
adjust_sp_down v1 ; bin: 29 cc
|
||||
; asm: subl %esi, %esp
|
||||
adjust_sp_down v2 ; bin: 29 f4
|
||||
; asm: addl $64, %esp
|
||||
adjust_sp_down_imm 64 ; bin: 83 ec 40
|
||||
; asm: addl $-64, %esp
|
||||
adjust_sp_down_imm -64 ; bin: 83 ec c0
|
||||
; asm: addl $1024, %esp
|
||||
adjust_sp_down_imm 1024 ; bin: 81 ec 00000400
|
||||
; asm: addl $-1024, %esp
|
||||
adjust_sp_down_imm -1024 ; bin: 81 ec fffffc00
|
||||
; asm: addl $2147483647, %esp
|
||||
adjust_sp_down_imm 2147483647 ; bin: 81 ec 7fffffff
|
||||
; asm: addl $-2147483648, %esp
|
||||
adjust_sp_down_imm -2147483648 ; bin: 81 ec 80000000
|
||||
|
||||
; Shift immediates
|
||||
; asm: shll $2, %esi
|
||||
[-,%rsi] v513 = ishl_imm v2, 2 ; bin: c1 e6 02
|
||||
; asm: sarl $5, %esi
|
||||
[-,%rsi] v514 = sshr_imm v2, 5 ; bin: c1 fe 05
|
||||
; asm: shrl $8, %esi
|
||||
[-,%rsi] v515 = ushr_imm v2, 8 ; bin: c1 ee 08
|
||||
|
||||
; Load Complex
|
||||
[-,%rax] v521 = iconst.i32 1
|
||||
[-,%rbx] v522 = iconst.i32 1
|
||||
; asm: movl (%eax,%ebx,1), %ecx
|
||||
[-,%rcx] v526 = load_complex.i32 v521+v522 ; bin: heap_oob 8b 0c 18
|
||||
; asm: movl 1(%eax,%ebx,1), %ecx
|
||||
[-,%rcx] v528 = load_complex.i32 v521+v522+1 ; bin: heap_oob 8b 4c 18 01
|
||||
; asm: mov 0x100000(%eax,%ebx,1),%ecx
|
||||
[-,%rcx] v530 = load_complex.i32 v521+v522+0x1000 ; bin: heap_oob 8b 8c 18 00001000
|
||||
; asm: movzbl (%eax,%ebx,1),%ecx
|
||||
[-,%rcx] v532 = uload8_complex.i32 v521+v522 ; bin: heap_oob 0f b6 0c 18
|
||||
; asm: movsbl (%eax,%ebx,1),%ecx
|
||||
[-,%rcx] v534 = sload8_complex.i32 v521+v522 ; bin: heap_oob 0f be 0c 18
|
||||
; asm: movzwl (%eax,%ebx,1),%ecx
|
||||
[-,%rcx] v536 = uload16_complex.i32 v521+v522 ; bin: heap_oob 0f b7 0c 18
|
||||
; asm: movswl (%eax,%ebx,1),%ecx
|
||||
[-,%rcx] v538 = sload16_complex.i32 v521+v522 ; bin: heap_oob 0f bf 0c 18
|
||||
|
||||
; Store Complex
|
||||
[-,%rcx] v601 = iconst.i32 1
|
||||
; asm: mov %ecx,(%eax,%ebx,1)
|
||||
store_complex v601, v521+v522 ; bin: heap_oob 89 0c 18
|
||||
; asm: mov %ecx,0x1(%eax,%ebx,1)
|
||||
store_complex v601, v521+v522+1 ; bin: heap_oob 89 4c 18 01
|
||||
; asm: mov %ecx,0x100000(%eax,%ebx,1)
|
||||
store_complex v601, v521+v522+0x1000 ; bin: heap_oob 89 8c 18 00001000
|
||||
; asm: mov %cx,(%eax,%ebx,1)
|
||||
istore16_complex v601, v521+v522 ; bin: heap_oob 66 89 0c 18
|
||||
; asm: mov %cl,(%eax,%ebx,1)
|
||||
istore8_complex v601, v521+v522 ; bin: heap_oob 88 0c 18
|
||||
|
||||
; asm: testl %ecx, %ecx
|
||||
; asm: je ebb1
|
||||
brz v1, ebb1 ; bin: 85 c9 74 0e
|
||||
; asm: testl %esi, %esi
|
||||
; asm: je ebb1
|
||||
brz v2, ebb1 ; bin: 85 f6 74 0a
|
||||
; asm: testl %ecx, %ecx
|
||||
; asm: jne ebb1
|
||||
brnz v1, ebb1 ; bin: 85 c9 75 06
|
||||
; asm: testl %esi, %esi
|
||||
; asm: jne ebb1
|
||||
brnz v2, ebb1 ; bin: 85 f6 75 02
|
||||
|
||||
; asm: jmp ebb2
|
||||
jump ebb2 ; bin: eb 01
|
||||
|
||||
; asm: ebb1:
|
||||
ebb1:
|
||||
; asm: ret
|
||||
return ; bin: c3
|
||||
|
||||
; asm: ebb2:
|
||||
ebb2:
|
||||
trap user0 ; bin: user0 0f 0b
|
||||
}
|
||||
|
||||
; Special branch encodings only for I32 mode.
|
||||
function %special_branches() {
|
||||
ebb0:
|
||||
[-,%rcx] v1 = iconst.i32 1
|
||||
[-,%rsi] v2 = iconst.i32 2
|
||||
[-,%rdi] v3 = icmp eq v1, v2
|
||||
[-,%rbx] v4 = icmp ugt v1, v2
|
||||
|
||||
; asm: testl $0xff, %edi
|
||||
; asm: je ebb1
|
||||
brz v3, ebb1 ; bin: f7 c7 000000ff 0f 84 00000015
|
||||
; asm: testb %bl, %bl
|
||||
; asm: je ebb1
|
||||
brz v4, ebb1 ; bin: 84 db 74 11
|
||||
; asm: testl $0xff, %edi
|
||||
; asm: jne ebb1
|
||||
brnz v3, ebb1 ; bin: f7 c7 000000ff 0f 85 00000005
|
||||
; asm: testb %bl, %bl
|
||||
; asm: jne ebb1
|
||||
brnz v4, ebb1 ; bin: 84 db 75 01
|
||||
|
||||
return
|
||||
|
||||
ebb1:
|
||||
return
|
||||
}
|
||||
|
||||
; CPU flag instructions.
|
||||
function %cpu_flags() {
|
||||
ebb0:
|
||||
[-,%rcx] v1 = iconst.i32 1
|
||||
[-,%rsi] v2 = iconst.i32 2
|
||||
jump ebb1
|
||||
|
||||
ebb1:
|
||||
; asm: cmpl %esi, %ecx
|
||||
[-,%rflags] v10 = ifcmp v1, v2 ; bin: 39 f1
|
||||
; asm: cmpl %ecx, %esi
|
||||
[-,%rflags] v11 = ifcmp v2, v1 ; bin: 39 ce
|
||||
|
||||
; asm: je ebb1
|
||||
brif eq v11, ebb1 ; bin: 74 fa
|
||||
; asm: jne ebb1
|
||||
brif ne v11, ebb1 ; bin: 75 f8
|
||||
; asm: jl ebb1
|
||||
brif slt v11, ebb1 ; bin: 7c f6
|
||||
; asm: jge ebb1
|
||||
brif sge v11, ebb1 ; bin: 7d f4
|
||||
; asm: jg ebb1
|
||||
brif sgt v11, ebb1 ; bin: 7f f2
|
||||
; asm: jle ebb1
|
||||
brif sle v11, ebb1 ; bin: 7e f0
|
||||
; asm: jb ebb1
|
||||
brif ult v11, ebb1 ; bin: 72 ee
|
||||
; asm: jae ebb1
|
||||
brif uge v11, ebb1 ; bin: 73 ec
|
||||
; asm: ja ebb1
|
||||
brif ugt v11, ebb1 ; bin: 77 ea
|
||||
; asm: jbe ebb1
|
||||
brif ule v11, ebb1 ; bin: 76 e8
|
||||
|
||||
; asm: sete %bl
|
||||
[-,%rbx] v20 = trueif eq v11 ; bin: 0f 94 c3
|
||||
; asm: setne %bl
|
||||
[-,%rbx] v21 = trueif ne v11 ; bin: 0f 95 c3
|
||||
; asm: setl %dl
|
||||
[-,%rdx] v22 = trueif slt v11 ; bin: 0f 9c c2
|
||||
; asm: setge %dl
|
||||
[-,%rdx] v23 = trueif sge v11 ; bin: 0f 9d c2
|
||||
; asm: setg %bl
|
||||
[-,%rbx] v24 = trueif sgt v11 ; bin: 0f 9f c3
|
||||
; asm: setle %bl
|
||||
[-,%rbx] v25 = trueif sle v11 ; bin: 0f 9e c3
|
||||
; asm: setb %dl
|
||||
[-,%rdx] v26 = trueif ult v11 ; bin: 0f 92 c2
|
||||
; asm: setae %dl
|
||||
[-,%rdx] v27 = trueif uge v11 ; bin: 0f 93 c2
|
||||
; asm: seta %bl
|
||||
[-,%rbx] v28 = trueif ugt v11 ; bin: 0f 97 c3
|
||||
; asm: setbe %bl
|
||||
[-,%rbx] v29 = trueif ule v11 ; bin: 0f 96 c3
|
||||
|
||||
; The trapif instructions are encoded as macros: a conditional jump over a ud2.
|
||||
; asm: jne .+4; ud2
|
||||
trapif eq v11, user0 ; bin: 75 02 user0 0f 0b
|
||||
; asm: je .+4; ud2
|
||||
trapif ne v11, user0 ; bin: 74 02 user0 0f 0b
|
||||
; asm: jnl .+4; ud2
|
||||
trapif slt v11, user0 ; bin: 7d 02 user0 0f 0b
|
||||
; asm: jnge .+4; ud2
|
||||
trapif sge v11, user0 ; bin: 7c 02 user0 0f 0b
|
||||
; asm: jng .+4; ud2
|
||||
trapif sgt v11, user0 ; bin: 7e 02 user0 0f 0b
|
||||
; asm: jnle .+4; ud2
|
||||
trapif sle v11, user0 ; bin: 7f 02 user0 0f 0b
|
||||
; asm: jnb .+4; ud2
|
||||
trapif ult v11, user0 ; bin: 73 02 user0 0f 0b
|
||||
; asm: jnae .+4; ud2
|
||||
trapif uge v11, user0 ; bin: 72 02 user0 0f 0b
|
||||
; asm: jna .+4; ud2
|
||||
trapif ugt v11, user0 ; bin: 76 02 user0 0f 0b
|
||||
; asm: jnbe .+4; ud2
|
||||
trapif ule v11, user0 ; bin: 77 02 user0 0f 0b
|
||||
|
||||
; Stack check.
|
||||
; asm: cmpl %esp, %ecx
|
||||
[-,%rflags] v40 = ifcmp_sp v1 ; bin: 39 e1
|
||||
; asm: cmpl %esp, %esi
|
||||
[-,%rflags] v41 = ifcmp_sp v2 ; bin: 39 e6
|
||||
|
||||
; asm: cmpl $-100, %ecx
|
||||
[-,%rflags] v42 = ifcmp_imm v1, -100 ; bin: 83 f9 9c
|
||||
; asm: cmpl $100, %esi
|
||||
[-,%rflags] v43 = ifcmp_imm v2, 100 ; bin: 83 fe 64
|
||||
|
||||
; asm: cmpl $-10000, %ecx
|
||||
[-,%rflags] v44 = ifcmp_imm v1, -10000 ; bin: 81 f9 ffffd8f0
|
||||
; asm: cmpl $10000, %esi
|
||||
[-,%rflags] v45 = ifcmp_imm v2, 10000 ; bin: 81 fe 00002710
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
; Tests for i32/i8 conversion instructions.
|
||||
function %I32_I8() {
|
||||
ebb0:
|
||||
[-,%rcx] v1 = iconst.i32 1
|
||||
|
||||
[-,%rcx] v11 = ireduce.i8 v1 ; bin:
|
||||
|
||||
; asm: movsbl %cl, %esi
|
||||
[-,%rsi] v20 = sextend.i32 v11 ; bin: 0f be f1
|
||||
|
||||
; asm: movzbl %cl, %esi
|
||||
[-,%rsi] v30 = uextend.i32 v11 ; bin: 0f b6 f1
|
||||
|
||||
trap user0 ; bin: user0 0f 0b
|
||||
}
|
||||
|
||||
; Tests for i32/i16 conversion instructions.
|
||||
function %I32_I16() {
|
||||
ebb0:
|
||||
[-,%rcx] v1 = iconst.i32 1
|
||||
|
||||
[-,%rcx] v11 = ireduce.i16 v1 ; bin:
|
||||
|
||||
; asm: movswl %cx, %esi
|
||||
[-,%rsi] v20 = sextend.i32 v11 ; bin: 0f bf f1
|
||||
|
||||
; asm: movzwl %cx, %esi
|
||||
[-,%rsi] v30 = uextend.i32 v11 ; bin: 0f b7 f1
|
||||
|
||||
trap user0 ; bin: user0 0f 0b
|
||||
}
|
||||
595
cranelift/filetests/filetests/isa/x86/binary64-float.clif
Normal file
595
cranelift/filetests/filetests/isa/x86/binary64-float.clif
Normal file
@@ -0,0 +1,595 @@
|
||||
; Binary emission of 64-bit floating point code.
|
||||
test binemit
|
||||
set opt_level=best
|
||||
target x86_64 haswell
|
||||
|
||||
; The binary encodings can be verified with the command:
|
||||
;
|
||||
; sed -ne 's/^ *; asm: *//p' filetests/isa/x86/binary64-float.clif | llvm-mc -show-encoding -triple=x86_64
|
||||
;
|
||||
|
||||
function %F32() {
|
||||
ss0 = incoming_arg 8, offset 0
|
||||
ss1 = incoming_arg 1024, offset -1024
|
||||
ss2 = incoming_arg 1024, offset -2048
|
||||
ss3 = incoming_arg 8, offset -2056
|
||||
|
||||
ebb0:
|
||||
[-,%r11] v0 = iconst.i32 1
|
||||
[-,%rsi] v1 = iconst.i32 2
|
||||
[-,%rax] v2 = iconst.i64 11
|
||||
[-,%r14] v3 = iconst.i64 12
|
||||
[-,%r13] v4 = iconst.i64 13
|
||||
|
||||
; asm: cvtsi2ssl %r11d, %xmm5
|
||||
[-,%xmm5] v10 = fcvt_from_sint.f32 v0 ; bin: f3 41 0f 2a eb
|
||||
; asm: cvtsi2ssl %esi, %xmm10
|
||||
[-,%xmm10] v11 = fcvt_from_sint.f32 v1 ; bin: f3 44 0f 2a d6
|
||||
|
||||
; asm: cvtsi2ssq %rax, %xmm5
|
||||
[-,%xmm5] v12 = fcvt_from_sint.f32 v2 ; bin: f3 48 0f 2a e8
|
||||
; asm: cvtsi2ssq %r14, %xmm10
|
||||
[-,%xmm10] v13 = fcvt_from_sint.f32 v3 ; bin: f3 4d 0f 2a d6
|
||||
|
||||
; asm: cvtss2sd %xmm10, %xmm5
|
||||
[-,%xmm5] v14 = fpromote.f64 v11 ; bin: f3 41 0f 5a ea
|
||||
; asm: cvtss2sd %xmm5, %xmm10
|
||||
[-,%xmm10] v15 = fpromote.f64 v10 ; bin: f3 44 0f 5a d5
|
||||
|
||||
; asm: movd %r11d, %xmm5
|
||||
[-,%xmm5] v16 = bitcast.f32 v0 ; bin: 66 41 0f 6e eb
|
||||
; asm: movd %esi, %xmm10
|
||||
[-,%xmm10] v17 = bitcast.f32 v1 ; bin: 66 44 0f 6e d6
|
||||
|
||||
; asm: movd %xmm5, %ecx
|
||||
[-,%rcx] v18 = bitcast.i32 v10 ; bin: 66 0f 7e e9
|
||||
; asm: movd %xmm10, %esi
|
||||
[-,%rsi] v19 = bitcast.i32 v11 ; bin: 66 44 0f 7e d6
|
||||
|
||||
; Binary arithmetic.
|
||||
|
||||
; asm: addss %xmm10, %xmm5
|
||||
[-,%xmm5] v20 = fadd v10, v11 ; bin: f3 41 0f 58 ea
|
||||
; asm: addss %xmm5, %xmm10
|
||||
[-,%xmm10] v21 = fadd v11, v10 ; bin: f3 44 0f 58 d5
|
||||
|
||||
; asm: subss %xmm10, %xmm5
|
||||
[-,%xmm5] v22 = fsub v10, v11 ; bin: f3 41 0f 5c ea
|
||||
; asm: subss %xmm5, %xmm10
|
||||
[-,%xmm10] v23 = fsub v11, v10 ; bin: f3 44 0f 5c d5
|
||||
|
||||
; asm: mulss %xmm10, %xmm5
|
||||
[-,%xmm5] v24 = fmul v10, v11 ; bin: f3 41 0f 59 ea
|
||||
; asm: mulss %xmm5, %xmm10
|
||||
[-,%xmm10] v25 = fmul v11, v10 ; bin: f3 44 0f 59 d5
|
||||
|
||||
; asm: divss %xmm10, %xmm5
|
||||
[-,%xmm5] v26 = fdiv v10, v11 ; bin: f3 41 0f 5e ea
|
||||
; asm: divss %xmm5, %xmm10
|
||||
[-,%xmm10] v27 = fdiv v11, v10 ; bin: f3 44 0f 5e d5
|
||||
|
||||
; Bitwise ops.
|
||||
; We use the *ps SSE instructions for everything because they are smaller.
|
||||
|
||||
; asm: andps %xmm10, %xmm5
|
||||
[-,%xmm5] v30 = band v10, v11 ; bin: 41 0f 54 ea
|
||||
; asm: andps %xmm5, %xmm10
|
||||
[-,%xmm10] v31 = band v11, v10 ; bin: 44 0f 54 d5
|
||||
|
||||
; asm: andnps %xmm10, %xmm5
|
||||
[-,%xmm5] v32 = band_not v11, v10 ; bin: 41 0f 55 ea
|
||||
; asm: andnps %xmm5, %xmm10
|
||||
[-,%xmm10] v33 = band_not v10, v11 ; bin: 44 0f 55 d5
|
||||
|
||||
; asm: orps %xmm10, %xmm5
|
||||
[-,%xmm5] v34 = bor v10, v11 ; bin: 41 0f 56 ea
|
||||
; asm: orps %xmm5, %xmm10
|
||||
[-,%xmm10] v35 = bor v11, v10 ; bin: 44 0f 56 d5
|
||||
|
||||
; asm: xorps %xmm10, %xmm5
|
||||
[-,%xmm5] v36 = bxor v10, v11 ; bin: 41 0f 57 ea
|
||||
; asm: xorps %xmm5, %xmm10
|
||||
[-,%xmm10] v37 = bxor v11, v10 ; bin: 44 0f 57 d5
|
||||
|
||||
; asm: movaps %xmm10, %xmm5
|
||||
[-,%xmm5] v38 = copy v11 ; bin: 41 0f 28 ea
|
||||
; asm: movaps %xmm5, %xmm10
|
||||
[-,%xmm10] v39 = copy v10 ; bin: 44 0f 28 d5
|
||||
|
||||
; Convert float to int.
|
||||
|
||||
; asm: cvttss2si %xmm5, %ecx
|
||||
[-,%rcx] v40 = x86_cvtt2si.i32 v10 ; bin: f3 0f 2c cd
|
||||
; asm: cvttss2si %xmm10, %esi
|
||||
[-,%rsi] v41 = x86_cvtt2si.i32 v11 ; bin: f3 41 0f 2c f2
|
||||
|
||||
; asm: cvttss2si %xmm5, %rcx
|
||||
[-,%rcx] v42 = x86_cvtt2si.i64 v10 ; bin: f3 48 0f 2c cd
|
||||
; asm: cvttss2si %xmm10, %rsi
|
||||
[-,%rsi] v43 = x86_cvtt2si.i64 v11 ; bin: f3 49 0f 2c f2
|
||||
|
||||
; Min/max.
|
||||
|
||||
; asm: minss %xmm10, %xmm5
|
||||
[-,%xmm5] v44 = x86_fmin v10, v11 ; bin: f3 41 0f 5d ea
|
||||
; asm: minss %xmm5, %xmm10
|
||||
[-,%xmm10] v45 = x86_fmin v11, v10 ; bin: f3 44 0f 5d d5
|
||||
; asm: maxss %xmm10, %xmm5
|
||||
[-,%xmm5] v46 = x86_fmax v10, v11 ; bin: f3 41 0f 5f ea
|
||||
; asm: maxss %xmm5, %xmm10
|
||||
[-,%xmm10] v47 = x86_fmax v11, v10 ; bin: f3 44 0f 5f d5
|
||||
|
||||
; Unary arithmetic.
|
||||
|
||||
; asm: sqrtss %xmm5, %xmm10
|
||||
[-,%xmm10] v50 = sqrt v10 ; bin: f3 44 0f 51 d5
|
||||
; asm: sqrtss %xmm10, %xmm5
|
||||
[-,%xmm5] v51 = sqrt v11 ; bin: f3 41 0f 51 ea
|
||||
|
||||
; asm: roundss $0, %xmm5, %xmm10
|
||||
[-,%xmm10] v52 = nearest v10 ; bin: 66 44 0f 3a 0a d5 00
|
||||
; asm: roundss $0, %xmm10, %xmm5
|
||||
[-,%xmm5] v53 = nearest v11 ; bin: 66 41 0f 3a 0a ea 00
|
||||
; asm: roundss $0, %xmm5, %xmm2
|
||||
[-,%xmm2] v54 = nearest v10 ; bin: 66 0f 3a 0a d5 00
|
||||
|
||||
; asm: roundss $1, %xmm5, %xmm10
|
||||
[-,%xmm10] v55 = floor v10 ; bin: 66 44 0f 3a 0a d5 01
|
||||
; asm: roundss $1, %xmm10, %xmm5
|
||||
[-,%xmm5] v56 = floor v11 ; bin: 66 41 0f 3a 0a ea 01
|
||||
; asm: roundss $1, %xmm5, %xmm2
|
||||
[-,%xmm2] v57 = floor v10 ; bin: 66 0f 3a 0a d5 01
|
||||
|
||||
; asm: roundss $2, %xmm5, %xmm10
|
||||
[-,%xmm10] v58 = ceil v10 ; bin: 66 44 0f 3a 0a d5 02
|
||||
; asm: roundss $2, %xmm10, %xmm5
|
||||
[-,%xmm5] v59 = ceil v11 ; bin: 66 41 0f 3a 0a ea 02
|
||||
; asm: roundss $2, %xmm5, %xmm2
|
||||
[-,%xmm2] v60 = ceil v10 ; bin: 66 0f 3a 0a d5 02
|
||||
|
||||
; asm: roundss $3, %xmm5, %xmm10
|
||||
[-,%xmm10] v61 = trunc v10 ; bin: 66 44 0f 3a 0a d5 03
|
||||
; asm: roundss $3, %xmm10, %xmm5
|
||||
[-,%xmm5] v62 = trunc v11 ; bin: 66 41 0f 3a 0a ea 03
|
||||
; asm: roundss $3, %xmm5, %xmm2
|
||||
[-,%xmm2] v63 = trunc v10 ; bin: 66 0f 3a 0a d5 03
|
||||
|
||||
; Load/Store
|
||||
|
||||
; asm: movss (%r14), %xmm5
|
||||
[-,%xmm5] v100 = load.f32 v3 ; bin: heap_oob f3 41 0f 10 2e
|
||||
; asm: movss (%rax), %xmm10
|
||||
[-,%xmm10] v101 = load.f32 v2 ; bin: heap_oob f3 44 0f 10 10
|
||||
; asm: movss 50(%r14), %xmm5
|
||||
[-,%xmm5] v110 = load.f32 v3+50 ; bin: heap_oob f3 41 0f 10 6e 32
|
||||
; asm: movss -50(%rax), %xmm10
|
||||
[-,%xmm10] v111 = load.f32 v2-50 ; bin: heap_oob f3 44 0f 10 50 ce
|
||||
; asm: movss 10000(%r14), %xmm5
|
||||
[-,%xmm5] v120 = load.f32 v3+10000 ; bin: heap_oob f3 41 0f 10 ae 00002710
|
||||
; asm: movss -10000(%rax), %xmm10
|
||||
[-,%xmm10] v121 = load.f32 v2-10000 ; bin: heap_oob f3 44 0f 10 90 ffffd8f0
|
||||
|
||||
; asm: movss %xmm5, (%r14)
|
||||
[-] store.f32 v100, v3 ; bin: heap_oob f3 41 0f 11 2e
|
||||
; asm: movss %xmm10, (%rax)
|
||||
[-] store.f32 v101, v2 ; bin: heap_oob f3 44 0f 11 10
|
||||
; asm: movss %xmm5, (%r13)
|
||||
[-] store.f32 v100, v4 ; bin: heap_oob f3 41 0f 11 6d 00
|
||||
; asm: movss %xmm10, (%r13)
|
||||
[-] store.f32 v101, v4 ; bin: heap_oob f3 45 0f 11 55 00
|
||||
; asm: movss %xmm5, 50(%r14)
|
||||
[-] store.f32 v100, v3+50 ; bin: heap_oob f3 41 0f 11 6e 32
|
||||
; asm: movss %xmm10, -50(%rax)
|
||||
[-] store.f32 v101, v2-50 ; bin: heap_oob f3 44 0f 11 50 ce
|
||||
; asm: movss %xmm5, 10000(%r14)
|
||||
[-] store.f32 v100, v3+10000 ; bin: heap_oob f3 41 0f 11 ae 00002710
|
||||
; asm: movss %xmm10, -10000(%rax)
|
||||
[-] store.f32 v101, v2-10000 ; bin: heap_oob f3 44 0f 11 90 ffffd8f0
|
||||
|
||||
; Spill / Fill.
|
||||
|
||||
; asm: movss %xmm5, 1032(%rsp)
|
||||
[-,ss1] v200 = spill v100 ; bin: stk_ovf f3 0f 11 ac 24 00000408
|
||||
; asm: movss %xmm10, 1032(%rsp)
|
||||
[-,ss1] v201 = spill v101 ; bin: stk_ovf f3 44 0f 11 94 24 00000408
|
||||
|
||||
; asm: movss 1032(%rsp), %xmm5
|
||||
[-,%xmm5] v210 = fill v200 ; bin: f3 0f 10 ac 24 00000408
|
||||
; asm: movss 1032(%rsp), %xmm10
|
||||
[-,%xmm10] v211 = fill v201 ; bin: f3 44 0f 10 94 24 00000408
|
||||
|
||||
; asm: movss %xmm5, 1032(%rsp)
|
||||
regspill v100, %xmm5 -> ss1 ; bin: stk_ovf f3 0f 11 ac 24 00000408
|
||||
; asm: movss 1032(%rsp), %xmm5
|
||||
regfill v100, ss1 -> %xmm5 ; bin: f3 0f 10 ac 24 00000408
|
||||
|
||||
; Comparisons.
|
||||
;
|
||||
; Only `supported_floatccs` are tested here. Others are handled by
|
||||
; legalization patterns.
|
||||
|
||||
; asm: ucomiss %xmm10, %xmm5
|
||||
; asm: setnp %bl
|
||||
[-,%rbx] v300 = fcmp ord v10, v11 ; bin: 41 0f 2e ea 0f 9b c3
|
||||
; asm: ucomiss %xmm5, %xmm10
|
||||
; asm: setp %bl
|
||||
[-,%rbx] v301 = fcmp uno v11, v10 ; bin: 44 0f 2e d5 0f 9a c3
|
||||
; asm: ucomiss %xmm10, %xmm5
|
||||
; asm: setne %dl
|
||||
[-,%rdx] v302 = fcmp one v10, v11 ; bin: 41 0f 2e ea 0f 95 c2
|
||||
; asm: ucomiss %xmm5, %xmm10
|
||||
; asm: sete %dl
|
||||
[-,%rdx] v303 = fcmp ueq v11, v10 ; bin: 44 0f 2e d5 0f 94 c2
|
||||
; asm: ucomiss %xmm10, %xmm5
|
||||
; asm: seta %bl
|
||||
[-,%rbx] v304 = fcmp gt v10, v11 ; bin: 41 0f 2e ea 0f 97 c3
|
||||
; asm: ucomiss %xmm5, %xmm10
|
||||
; asm: setae %bl
|
||||
[-,%rbx] v305 = fcmp ge v11, v10 ; bin: 44 0f 2e d5 0f 93 c3
|
||||
; asm: ucomiss %xmm10, %xmm5
|
||||
; asm: setb %dl
|
||||
[-,%rdx] v306 = fcmp ult v10, v11 ; bin: 41 0f 2e ea 0f 92 c2
|
||||
; asm: ucomiss %xmm5, %xmm10
|
||||
; asm: setbe %dl
|
||||
[-,%rdx] v307 = fcmp ule v11, v10 ; bin: 44 0f 2e d5 0f 96 c2
|
||||
|
||||
; asm: ucomiss %xmm10, %xmm5
|
||||
[-,%rflags] v310 = ffcmp v10, v11 ; bin: 41 0f 2e ea
|
||||
; asm: ucomiss %xmm10, %xmm5
|
||||
[-,%rflags] v311 = ffcmp v11, v10 ; bin: 44 0f 2e d5
|
||||
; asm: ucomiss %xmm5, %xmm5
|
||||
[-,%rflags] v312 = ffcmp v10, v10 ; bin: 0f 2e ed
|
||||
|
||||
|
||||
; Load/Store Complex
|
||||
|
||||
[-,%rax] v350 = iconst.i64 1
|
||||
[-,%rbx] v351 = iconst.i64 2
|
||||
|
||||
; asm: movss (%rax,%rbx,1),%xmm5
|
||||
[-,%xmm5] v352 = load_complex.f32 v350+v351 ; bin: heap_oob f3 0f 10 2c 18
|
||||
; asm: movss 0x32(%rax,%rbx,1),%xmm5
|
||||
[-,%xmm5] v353 = load_complex.f32 v350+v351+50 ; bin: heap_oob f3 0f 10 6c 18 32
|
||||
; asm: movss -0x32(%rax,%rbx,1),%xmm10
|
||||
[-,%xmm10] v354 = load_complex.f32 v350+v351-50 ; bin: heap_oob f3 44 0f 10 54 18 ce
|
||||
; asm: 0x2710(%rax,%rbx,1),%xmm5
|
||||
[-,%xmm5] v355 = load_complex.f32 v350+v351+10000 ; bin: heap_oob f3 0f 10 ac 18 00002710
|
||||
; asm: -0x2710(%rax,%rbx,1),%xmm10
|
||||
[-,%xmm10] v356 = load_complex.f32 v350+v351-10000 ; bin: heap_oob f3 44 0f 10 94 18 ffffd8f0
|
||||
|
||||
; asm: movsd %xmm5, (%rax,%rbx,1)
|
||||
[-] store_complex.f32 v100, v350+v351 ; bin: heap_oob f3 0f 11 2c 18
|
||||
; asm: movsd %xmm5, 50(%rax,%rbx,1)
|
||||
[-] store_complex.f32 v100, v350+v351+50 ; bin: heap_oob f3 0f 11 6c 18 32
|
||||
; asm: movsd %xmm10, -50(%rax,%rbx,1)
|
||||
[-] store_complex.f32 v101, v350+v351-50 ; bin: heap_oob f3 44 0f 11 54 18 ce
|
||||
; asm: movsd %xmm5, 10000(%rax,%rbx,1)
|
||||
[-] store_complex.f32 v100, v350+v351+10000 ; bin: heap_oob f3 0f 11 ac 18 00002710
|
||||
; asm: movsd %xmm10, -10000(%rax,%rbx,1)
|
||||
[-] store_complex.f32 v101, v350+v351-10000 ; bin: heap_oob f3 44 0f 11 94 18 ffffd8f0
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
function %F64() {
|
||||
ss0 = incoming_arg 8, offset 0
|
||||
ss1 = incoming_arg 1024, offset -1024
|
||||
ss2 = incoming_arg 1024, offset -2048
|
||||
ss3 = incoming_arg 8, offset -2056
|
||||
|
||||
ebb0:
|
||||
[-,%r11] v0 = iconst.i32 1
|
||||
[-,%rsi] v1 = iconst.i32 2
|
||||
[-,%rax] v2 = iconst.i64 11
|
||||
[-,%r14] v3 = iconst.i64 12
|
||||
[-,%r13] v4 = iconst.i64 13
|
||||
|
||||
; asm: cvtsi2sdl %r11d, %xmm5
|
||||
[-,%xmm5] v10 = fcvt_from_sint.f64 v0 ; bin: f2 41 0f 2a eb
|
||||
; asm: cvtsi2sdl %esi, %xmm10
|
||||
[-,%xmm10] v11 = fcvt_from_sint.f64 v1 ; bin: f2 44 0f 2a d6
|
||||
|
||||
; asm: cvtsi2sdq %rax, %xmm5
|
||||
[-,%xmm5] v12 = fcvt_from_sint.f64 v2 ; bin: f2 48 0f 2a e8
|
||||
; asm: cvtsi2sdq %r14, %xmm10
|
||||
[-,%xmm10] v13 = fcvt_from_sint.f64 v3 ; bin: f2 4d 0f 2a d6
|
||||
|
||||
; asm: cvtsd2ss %xmm10, %xmm5
|
||||
[-,%xmm5] v14 = fdemote.f32 v11 ; bin: f2 41 0f 5a ea
|
||||
; asm: cvtsd2ss %xmm5, %xmm10
|
||||
[-,%xmm10] v15 = fdemote.f32 v10 ; bin: f2 44 0f 5a d5
|
||||
|
||||
; asm: movq %rax, %xmm5
|
||||
[-,%xmm5] v16 = bitcast.f64 v2 ; bin: 66 48 0f 6e e8
|
||||
; asm: movq %r14, %xmm10
|
||||
[-,%xmm10] v17 = bitcast.f64 v3 ; bin: 66 4d 0f 6e d6
|
||||
|
||||
; asm: movq %xmm5, %rcx
|
||||
[-,%rcx] v18 = bitcast.i64 v10 ; bin: 66 48 0f 7e e9
|
||||
; asm: movq %xmm10, %rsi
|
||||
[-,%rsi] v19 = bitcast.i64 v11 ; bin: 66 4c 0f 7e d6
|
||||
|
||||
; Binary arithmetic.
|
||||
|
||||
; asm: addsd %xmm10, %xmm5
|
||||
[-,%xmm5] v20 = fadd v10, v11 ; bin: f2 41 0f 58 ea
|
||||
; asm: addsd %xmm5, %xmm10
|
||||
[-,%xmm10] v21 = fadd v11, v10 ; bin: f2 44 0f 58 d5
|
||||
|
||||
; asm: subsd %xmm10, %xmm5
|
||||
[-,%xmm5] v22 = fsub v10, v11 ; bin: f2 41 0f 5c ea
|
||||
; asm: subsd %xmm5, %xmm10
|
||||
[-,%xmm10] v23 = fsub v11, v10 ; bin: f2 44 0f 5c d5
|
||||
|
||||
; asm: mulsd %xmm10, %xmm5
|
||||
[-,%xmm5] v24 = fmul v10, v11 ; bin: f2 41 0f 59 ea
|
||||
; asm: mulsd %xmm5, %xmm10
|
||||
[-,%xmm10] v25 = fmul v11, v10 ; bin: f2 44 0f 59 d5
|
||||
|
||||
; asm: divsd %xmm10, %xmm5
|
||||
[-,%xmm5] v26 = fdiv v10, v11 ; bin: f2 41 0f 5e ea
|
||||
; asm: divsd %xmm5, %xmm10
|
||||
[-,%xmm10] v27 = fdiv v11, v10 ; bin: f2 44 0f 5e d5
|
||||
|
||||
; Bitwise ops.
|
||||
; We use the *ps SSE instructions for everything because they are smaller.
|
||||
|
||||
; asm: andps %xmm10, %xmm5
|
||||
[-,%xmm5] v30 = band v10, v11 ; bin: 41 0f 54 ea
|
||||
; asm: andps %xmm5, %xmm10
|
||||
[-,%xmm10] v31 = band v11, v10 ; bin: 44 0f 54 d5
|
||||
|
||||
; asm: andnps %xmm10, %xmm5
|
||||
[-,%xmm5] v32 = band_not v11, v10 ; bin: 41 0f 55 ea
|
||||
; asm: andnps %xmm5, %xmm10
|
||||
[-,%xmm10] v33 = band_not v10, v11 ; bin: 44 0f 55 d5
|
||||
|
||||
; asm: orps %xmm10, %xmm5
|
||||
[-,%xmm5] v34 = bor v10, v11 ; bin: 41 0f 56 ea
|
||||
; asm: orps %xmm5, %xmm10
|
||||
[-,%xmm10] v35 = bor v11, v10 ; bin: 44 0f 56 d5
|
||||
|
||||
; asm: xorps %xmm10, %xmm5
|
||||
[-,%xmm5] v36 = bxor v10, v11 ; bin: 41 0f 57 ea
|
||||
; asm: xorps %xmm5, %xmm10
|
||||
[-,%xmm10] v37 = bxor v11, v10 ; bin: 44 0f 57 d5
|
||||
|
||||
; asm: movaps %xmm10, %xmm5
|
||||
[-,%xmm5] v38 = copy v11 ; bin: 41 0f 28 ea
|
||||
; asm: movaps %xmm5, %xmm10
|
||||
[-,%xmm10] v39 = copy v10 ; bin: 44 0f 28 d5
|
||||
|
||||
; Convert float to int.
|
||||
|
||||
; asm: cvttsd2si %xmm5, %ecx
|
||||
[-,%rcx] v40 = x86_cvtt2si.i32 v10 ; bin: f2 0f 2c cd
|
||||
; asm: cvttsd2si %xmm10, %esi
|
||||
[-,%rsi] v41 = x86_cvtt2si.i32 v11 ; bin: f2 41 0f 2c f2
|
||||
|
||||
; asm: cvttsd2si %xmm5, %rcx
|
||||
[-,%rcx] v42 = x86_cvtt2si.i64 v10 ; bin: f2 48 0f 2c cd
|
||||
; asm: cvttsd2si %xmm10, %rsi
|
||||
[-,%rsi] v43 = x86_cvtt2si.i64 v11 ; bin: f2 49 0f 2c f2
|
||||
|
||||
; Min/max.
|
||||
|
||||
; asm: minsd %xmm10, %xmm5
|
||||
[-,%xmm5] v44 = x86_fmin v10, v11 ; bin: f2 41 0f 5d ea
|
||||
; asm: minsd %xmm5, %xmm10
|
||||
[-,%xmm10] v45 = x86_fmin v11, v10 ; bin: f2 44 0f 5d d5
|
||||
; asm: maxsd %xmm10, %xmm5
|
||||
[-,%xmm5] v46 = x86_fmax v10, v11 ; bin: f2 41 0f 5f ea
|
||||
; asm: maxsd %xmm5, %xmm10
|
||||
[-,%xmm10] v47 = x86_fmax v11, v10 ; bin: f2 44 0f 5f d5
|
||||
|
||||
; Unary arithmetic.
|
||||
|
||||
; asm: sqrtsd %xmm5, %xmm10
|
||||
[-,%xmm10] v50 = sqrt v10 ; bin: f2 44 0f 51 d5
|
||||
; asm: sqrtsd %xmm10, %xmm5
|
||||
[-,%xmm5] v51 = sqrt v11 ; bin: f2 41 0f 51 ea
|
||||
|
||||
; asm: roundsd $0, %xmm5, %xmm10
|
||||
[-,%xmm10] v52 = nearest v10 ; bin: 66 44 0f 3a 0b d5 00
|
||||
; asm: roundsd $0, %xmm10, %xmm5
|
||||
[-,%xmm5] v53 = nearest v11 ; bin: 66 41 0f 3a 0b ea 00
|
||||
; asm: roundsd $0, %xmm5, %xmm2
|
||||
[-,%xmm2] v54 = nearest v10 ; bin: 66 0f 3a 0b d5 00
|
||||
|
||||
; asm: roundsd $1, %xmm5, %xmm10
|
||||
[-,%xmm10] v55 = floor v10 ; bin: 66 44 0f 3a 0b d5 01
|
||||
; asm: roundsd $1, %xmm10, %xmm5
|
||||
[-,%xmm5] v56 = floor v11 ; bin: 66 41 0f 3a 0b ea 01
|
||||
; asm: roundsd $1, %xmm5, %xmm2
|
||||
[-,%xmm2] v57 = floor v10 ; bin: 66 0f 3a 0b d5 01
|
||||
|
||||
; asm: roundsd $2, %xmm5, %xmm10
|
||||
[-,%xmm10] v58 = ceil v10 ; bin: 66 44 0f 3a 0b d5 02
|
||||
; asm: roundsd $2, %xmm10, %xmm5
|
||||
[-,%xmm5] v59 = ceil v11 ; bin: 66 41 0f 3a 0b ea 02
|
||||
; asm: roundsd $2, %xmm5, %xmm2
|
||||
[-,%xmm2] v60 = ceil v10 ; bin: 66 0f 3a 0b d5 02
|
||||
|
||||
; asm: roundsd $3, %xmm5, %xmm10
|
||||
[-,%xmm10] v61 = trunc v10 ; bin: 66 44 0f 3a 0b d5 03
|
||||
; asm: roundsd $3, %xmm10, %xmm5
|
||||
[-,%xmm5] v62 = trunc v11 ; bin: 66 41 0f 3a 0b ea 03
|
||||
; asm: roundsd $3, %xmm5, %xmm2
|
||||
[-,%xmm2] v63 = trunc v10 ; bin: 66 0f 3a 0b d5 03
|
||||
|
||||
; Load/Store
|
||||
|
||||
; asm: movsd (%r14), %xmm5
|
||||
[-,%xmm5] v100 = load.f64 v3 ; bin: heap_oob f2 41 0f 10 2e
|
||||
; asm: movsd (%rax), %xmm10
|
||||
[-,%xmm10] v101 = load.f64 v2 ; bin: heap_oob f2 44 0f 10 10
|
||||
; asm: movsd 50(%r14), %xmm5
|
||||
[-,%xmm5] v110 = load.f64 v3+50 ; bin: heap_oob f2 41 0f 10 6e 32
|
||||
; asm: movsd -50(%rax), %xmm10
|
||||
[-,%xmm10] v111 = load.f64 v2-50 ; bin: heap_oob f2 44 0f 10 50 ce
|
||||
; asm: movsd 10000(%r14), %xmm5
|
||||
[-,%xmm5] v120 = load.f64 v3+10000 ; bin: heap_oob f2 41 0f 10 ae 00002710
|
||||
; asm: movsd -10000(%rax), %xmm10
|
||||
[-,%xmm10] v121 = load.f64 v2-10000 ; bin: heap_oob f2 44 0f 10 90 ffffd8f0
|
||||
|
||||
; asm: movsd %xmm5, (%r14)
|
||||
[-] store.f64 v100, v3 ; bin: heap_oob f2 41 0f 11 2e
|
||||
; asm: movsd %xmm10, (%rax)
|
||||
[-] store.f64 v101, v2 ; bin: heap_oob f2 44 0f 11 10
|
||||
; asm: movsd %xmm5, (%r13)
|
||||
[-] store.f64 v100, v4 ; bin: heap_oob f2 41 0f 11 6d 00
|
||||
; asm: movsd %xmm10, (%r13)
|
||||
[-] store.f64 v101, v4 ; bin: heap_oob f2 45 0f 11 55 00
|
||||
; asm: movsd %xmm5, 50(%r14)
|
||||
[-] store.f64 v100, v3+50 ; bin: heap_oob f2 41 0f 11 6e 32
|
||||
; asm: movsd %xmm10, -50(%rax)
|
||||
[-] store.f64 v101, v2-50 ; bin: heap_oob f2 44 0f 11 50 ce
|
||||
; asm: movsd %xmm5, 10000(%r14)
|
||||
[-] store.f64 v100, v3+10000 ; bin: heap_oob f2 41 0f 11 ae 00002710
|
||||
; asm: movsd %xmm10, -10000(%rax)
|
||||
[-] store.f64 v101, v2-10000 ; bin: heap_oob f2 44 0f 11 90 ffffd8f0
|
||||
|
||||
; Spill / Fill.
|
||||
|
||||
; asm: movsd %xmm5, 1032(%rsp)
|
||||
[-,ss1] v200 = spill v100 ; bin: stk_ovf f2 0f 11 ac 24 00000408
|
||||
; asm: movsd %xmm10, 1032(%rsp)
|
||||
[-,ss1] v201 = spill v101 ; bin: stk_ovf f2 44 0f 11 94 24 00000408
|
||||
|
||||
; asm: movsd 1032(%rsp), %xmm5
|
||||
[-,%xmm5] v210 = fill v200 ; bin: f2 0f 10 ac 24 00000408
|
||||
; asm: movsd 1032(%rsp), %xmm10
|
||||
[-,%xmm10] v211 = fill v201 ; bin: f2 44 0f 10 94 24 00000408
|
||||
|
||||
; asm: movsd %xmm5, 1032(%rsp)
|
||||
regspill v100, %xmm5 -> ss1 ; bin: stk_ovf f2 0f 11 ac 24 00000408
|
||||
; asm: movsd 1032(%rsp), %xmm5
|
||||
regfill v100, ss1 -> %xmm5 ; bin: f2 0f 10 ac 24 00000408
|
||||
|
||||
; Comparisons.
|
||||
;
|
||||
; Only `supported_floatccs` are tested here. Others are handled by
|
||||
; legalization patterns.
|
||||
|
||||
; asm: ucomisd %xmm10, %xmm5
|
||||
; asm: setnp %bl
|
||||
[-,%rbx] v300 = fcmp ord v10, v11 ; bin: 66 41 0f 2e ea 0f 9b c3
|
||||
; asm: ucomisd %xmm5, %xmm10
|
||||
; asm: setp %bl
|
||||
[-,%rbx] v301 = fcmp uno v11, v10 ; bin: 66 44 0f 2e d5 0f 9a c3
|
||||
; asm: ucomisd %xmm10, %xmm5
|
||||
; asm: setne %dl
|
||||
[-,%rdx] v302 = fcmp one v10, v11 ; bin: 66 41 0f 2e ea 0f 95 c2
|
||||
; asm: ucomisd %xmm5, %xmm10
|
||||
; asm: sete %dl
|
||||
[-,%rdx] v303 = fcmp ueq v11, v10 ; bin: 66 44 0f 2e d5 0f 94 c2
|
||||
; asm: ucomisd %xmm10, %xmm5
|
||||
; asm: seta %bl
|
||||
[-,%rbx] v304 = fcmp gt v10, v11 ; bin: 66 41 0f 2e ea 0f 97 c3
|
||||
; asm: ucomisd %xmm5, %xmm10
|
||||
; asm: setae %bl
|
||||
[-,%rbx] v305 = fcmp ge v11, v10 ; bin: 66 44 0f 2e d5 0f 93 c3
|
||||
; asm: ucomisd %xmm10, %xmm5
|
||||
; asm: setb %dl
|
||||
[-,%rdx] v306 = fcmp ult v10, v11 ; bin: 66 41 0f 2e ea 0f 92 c2
|
||||
; asm: ucomisd %xmm5, %xmm10
|
||||
; asm: setbe %dl
|
||||
[-,%rdx] v307 = fcmp ule v11, v10 ; bin: 66 44 0f 2e d5 0f 96 c2
|
||||
|
||||
; asm: ucomisd %xmm10, %xmm5
|
||||
[-,%rflags] v310 = ffcmp v10, v11 ; bin: 66 41 0f 2e ea
|
||||
; asm: ucomisd %xmm10, %xmm5
|
||||
[-,%rflags] v311 = ffcmp v11, v10 ; bin: 66 44 0f 2e d5
|
||||
; asm: ucomisd %xmm5, %xmm5
|
||||
[-,%rflags] v312 = ffcmp v10, v10 ; bin: 66 0f 2e ed
|
||||
|
||||
; Load/Store Complex
|
||||
|
||||
[-,%rax] v350 = iconst.i64 1
|
||||
[-,%rbx] v351 = iconst.i64 2
|
||||
; asm: movsd (%rax,%rbx,1),%xmm5
|
||||
[-,%xmm5] v352 = load_complex.f64 v350+v351 ; bin: heap_oob f2 0f 10 2c 18
|
||||
; asm: movsd 0x32(%rax,%rbx,1),%xmm5
|
||||
[-,%xmm5] v353 = load_complex.f64 v350+v351+50 ; bin: heap_oob f2 0f 10 6c 18 32
|
||||
; asm: movsd -0x32(%rax,%rbx,1),%xmm10
|
||||
[-,%xmm10] v354 = load_complex.f64 v350+v351-50 ; bin: heap_oob f2 44 0f 10 54 18 ce
|
||||
; asm: movsd 0x2710(%rax,%rbx,1),%xmm5
|
||||
[-,%xmm5] v355 = load_complex.f64 v350+v351+10000 ; bin: heap_oob f2 0f 10 ac 18 00002710
|
||||
; asm: movsd -0x2710(%rax,%rbx,1),%xmm10
|
||||
[-,%xmm10] v356 = load_complex.f64 v350+v351-10000 ; bin: heap_oob f2 44 0f 10 94 18 ffffd8f0
|
||||
|
||||
; asm: movsd %xmm5, (%rax,%rbx,1)
|
||||
[-] store_complex.f64 v100, v350+v351 ; bin: heap_oob f2 0f 11 2c 18
|
||||
; asm: movsd %xmm5, 50(%rax,%rbx,1)
|
||||
[-] store_complex.f64 v100, v350+v351+50 ; bin: heap_oob f2 0f 11 6c 18 32
|
||||
; asm: movsd %xmm10, -50(%rax,%rbx,1)
|
||||
[-] store_complex.f64 v101, v350+v351-50 ; bin: heap_oob f2 44 0f 11 54 18 ce
|
||||
; asm: movsd %xmm5, 10000(%rax,%rbx,1)
|
||||
[-] store_complex.f64 v100, v350+v351+10000 ; bin: heap_oob f2 0f 11 ac 18 00002710
|
||||
; asm: movsd %xmm10, -10000(%rax,%rbx,1)
|
||||
[-] store_complex.f64 v101, v350+v351-10000 ; bin: heap_oob f2 44 0f 11 94 18 ffffd8f0
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
function %cpuflags_float(f32 [%xmm0]) {
|
||||
ebb0(v0: f32 [%xmm0]):
|
||||
; asm: ucomiss %xmm0, %xmm0
|
||||
[-,%rflags] v1 = ffcmp v0, v0 ; bin: 0f 2e c0
|
||||
|
||||
jump ebb1
|
||||
|
||||
ebb1:
|
||||
; asm: jnp ebb1
|
||||
brff ord v1, ebb1 ; bin: 7b fe
|
||||
; asm: jp ebb1
|
||||
brff uno v1, ebb1 ; bin: 7a fc
|
||||
; asm: jne ebb1
|
||||
brff one v1, ebb1 ; bin: 75 fa
|
||||
; asm: je ebb1
|
||||
brff ueq v1, ebb1 ; bin: 74 f8
|
||||
; asm: ja ebb1
|
||||
brff gt v1, ebb1 ; bin: 77 f6
|
||||
; asm: jae ebb1
|
||||
brff ge v1, ebb1 ; bin: 73 f4
|
||||
; asm: jb ebb1
|
||||
brff ult v1, ebb1 ; bin: 72 f2
|
||||
; asm: jbe ebb1
|
||||
brff ule v1, ebb1 ; bin: 76 f0
|
||||
|
||||
; asm: jp .+4; ud2
|
||||
trapff ord v1, user0 ; bin: 7a 02 user0 0f 0b
|
||||
; asm: jnp .+4; ud2
|
||||
trapff uno v1, user0 ; bin: 7b 02 user0 0f 0b
|
||||
; asm: je .+4; ud2
|
||||
trapff one v1, user0 ; bin: 74 02 user0 0f 0b
|
||||
; asm: jne .+4; ud2
|
||||
trapff ueq v1, user0 ; bin: 75 02 user0 0f 0b
|
||||
; asm: jna .+4; ud2
|
||||
trapff gt v1, user0 ; bin: 76 02 user0 0f 0b
|
||||
; asm: jnae .+4; ud2
|
||||
trapff ge v1, user0 ; bin: 72 02 user0 0f 0b
|
||||
; asm: jnb .+4; ud2
|
||||
trapff ult v1, user0 ; bin: 73 02 user0 0f 0b
|
||||
; asm: jnbe .+4; ud2
|
||||
trapff ule v1, user0 ; bin: 77 02 user0 0f 0b
|
||||
|
||||
; asm: setnp %bl
|
||||
[-,%rbx] v10 = trueff ord v1 ; bin: 0f 9b c3
|
||||
; asm: setp %bl
|
||||
[-,%rbx] v11 = trueff uno v1 ; bin: 0f 9a c3
|
||||
; asm: setne %dl
|
||||
[-,%rdx] v12 = trueff one v1 ; bin: 0f 95 c2
|
||||
; asm: sete %dl
|
||||
[-,%rdx] v13 = trueff ueq v1 ; bin: 0f 94 c2
|
||||
; asm: seta %r10b
|
||||
[-,%r10] v14 = trueff gt v1 ; bin: 41 0f 97 c2
|
||||
; asm: setae %r10b
|
||||
[-,%r10] v15 = trueff ge v1 ; bin: 41 0f 93 c2
|
||||
; asm: setb %r14b
|
||||
[-,%r14] v16 = trueff ult v1 ; bin: 41 0f 92 c6
|
||||
; asm: setbe %r14b
|
||||
[-,%r14] v17 = trueff ule v1 ; bin: 41 0f 96 c6
|
||||
|
||||
return
|
||||
}
|
||||
83
cranelift/filetests/filetests/isa/x86/binary64-pic.clif
Normal file
83
cranelift/filetests/filetests/isa/x86/binary64-pic.clif
Normal file
@@ -0,0 +1,83 @@
|
||||
; binary emission of 64-bit code.
|
||||
test binemit
|
||||
set opt_level=best
|
||||
set is_pic
|
||||
target x86_64 haswell
|
||||
|
||||
; The binary encodings can be verified with the command:
|
||||
;
|
||||
; sed -ne 's/^ *; asm: *//p' filetests/isa/x86/binary64-pic.clif | llvm-mc -show-encoding -triple=x86_64
|
||||
;
|
||||
|
||||
; Tests for i64 instructions.
|
||||
function %I64() {
|
||||
sig0 = ()
|
||||
fn0 = %foo()
|
||||
fn1 = colocated %bar()
|
||||
|
||||
gv0 = symbol %some_gv
|
||||
gv1 = symbol colocated %some_gv
|
||||
|
||||
; Use incoming_arg stack slots because they won't be relocated by the frame
|
||||
; layout.
|
||||
ss0 = incoming_arg 8, offset 0
|
||||
ss1 = incoming_arg 1024, offset -1024
|
||||
ss2 = incoming_arg 1024, offset -2048
|
||||
ss3 = incoming_arg 8, offset -2056
|
||||
|
||||
ebb0:
|
||||
|
||||
; Colocated functions.
|
||||
|
||||
; asm: call foo
|
||||
call fn1() ; bin: stk_ovf e8 CallPCRel4(%bar-4) 00000000
|
||||
|
||||
; asm: lea 0x0(%rip), %rax
|
||||
[-,%rax] v0 = func_addr.i64 fn1 ; bin: 48 8d 05 PCRel4(%bar-4) 00000000
|
||||
; asm: lea 0x0(%rip), %rsi
|
||||
[-,%rsi] v1 = func_addr.i64 fn1 ; bin: 48 8d 35 PCRel4(%bar-4) 00000000
|
||||
; asm: lea 0x0(%rip), %r10
|
||||
[-,%r10] v2 = func_addr.i64 fn1 ; bin: 4c 8d 15 PCRel4(%bar-4) 00000000
|
||||
|
||||
; asm: call *%rax
|
||||
call_indirect sig0, v0() ; bin: stk_ovf ff d0
|
||||
; asm: call *%rsi
|
||||
call_indirect sig0, v1() ; bin: stk_ovf ff d6
|
||||
; asm: call *%r10
|
||||
call_indirect sig0, v2() ; bin: stk_ovf 41 ff d2
|
||||
|
||||
; Non-colocated functions.
|
||||
|
||||
; asm: call foo@PLT
|
||||
call fn0() ; bin: stk_ovf e8 CallPLTRel4(%foo-4) 00000000
|
||||
|
||||
; asm: mov 0x0(%rip), %rax
|
||||
[-,%rax] v100 = func_addr.i64 fn0 ; bin: 48 8b 05 GOTPCRel4(%foo-4) 00000000
|
||||
; asm: mov 0x0(%rip), %rsi
|
||||
[-,%rsi] v101 = func_addr.i64 fn0 ; bin: 48 8b 35 GOTPCRel4(%foo-4) 00000000
|
||||
; asm: mov 0x0(%rip), %r10
|
||||
[-,%r10] v102 = func_addr.i64 fn0 ; bin: 4c 8b 15 GOTPCRel4(%foo-4) 00000000
|
||||
|
||||
; asm: call *%rax
|
||||
call_indirect sig0, v100() ; bin: stk_ovf ff d0
|
||||
; asm: call *%rsi
|
||||
call_indirect sig0, v101() ; bin: stk_ovf ff d6
|
||||
; asm: call *%r10
|
||||
call_indirect sig0, v102() ; bin: stk_ovf 41 ff d2
|
||||
|
||||
; asm: mov 0x0(%rip), %rcx
|
||||
[-,%rcx] v3 = symbol_value.i64 gv0 ; bin: 48 8b 0d GOTPCRel4(%some_gv-4) 00000000
|
||||
; asm: mov 0x0(%rip), %rsi
|
||||
[-,%rsi] v4 = symbol_value.i64 gv0 ; bin: 48 8b 35 GOTPCRel4(%some_gv-4) 00000000
|
||||
; asm: mov 0x0(%rip), %r10
|
||||
[-,%r10] v5 = symbol_value.i64 gv0 ; bin: 4c 8b 15 GOTPCRel4(%some_gv-4) 00000000
|
||||
|
||||
; asm: lea 0x0(%rip), %rcx
|
||||
[-,%rcx] v6 = symbol_value.i64 gv1 ; bin: 48 8d 0d PCRel4(%some_gv-4) 00000000
|
||||
; asm: lea 0x0(%rip), %rsi
|
||||
[-,%rsi] v7 = symbol_value.i64 gv1 ; bin: 48 8d 35 PCRel4(%some_gv-4) 00000000
|
||||
; asm: lea 0x0(%rip), %r10
|
||||
[-,%r10] v8 = symbol_value.i64 gv1 ; bin: 4c 8d 15 PCRel4(%some_gv-4) 00000000
|
||||
|
||||
return
|
||||
}
|
||||
1573
cranelift/filetests/filetests/isa/x86/binary64.clif
Normal file
1573
cranelift/filetests/filetests/isa/x86/binary64.clif
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,8 @@
|
||||
test compile
|
||||
target x86_64
|
||||
|
||||
function u0:0(i16) -> i8 fast {
|
||||
ebb0(v0: i16):
|
||||
v1 = ireduce.i8 v0
|
||||
return v1
|
||||
}
|
||||
13
cranelift/filetests/filetests/isa/x86/isub_imm-i8.clif
Normal file
13
cranelift/filetests/filetests/isa/x86/isub_imm-i8.clif
Normal file
@@ -0,0 +1,13 @@
|
||||
test compile
|
||||
target x86_64
|
||||
|
||||
function u0:0(i8) -> i8 fast {
|
||||
ebb0(v0: i8):
|
||||
v1 = iconst.i8 0
|
||||
v2 = isub v1, v0
|
||||
; check: v4 = uextend.i32 v0
|
||||
; nextln: v6 = iconst.i32 0
|
||||
; nextln = isub v6, v4
|
||||
; nextln = ireduce.i8 v5
|
||||
return v2
|
||||
}
|
||||
10
cranelift/filetests/filetests/isa/x86/legalize-bint-i8.clif
Normal file
10
cranelift/filetests/filetests/isa/x86/legalize-bint-i8.clif
Normal file
@@ -0,0 +1,10 @@
|
||||
test compile
|
||||
|
||||
target x86_64
|
||||
|
||||
function u0:0() -> i8 fast {
|
||||
ebb0:
|
||||
v14 = bconst.b1 false
|
||||
v15 = bint.i8 v14
|
||||
return v15
|
||||
}
|
||||
28
cranelift/filetests/filetests/isa/x86/legalize-bnot.clif
Normal file
28
cranelift/filetests/filetests/isa/x86/legalize-bnot.clif
Normal file
@@ -0,0 +1,28 @@
|
||||
test compile
|
||||
|
||||
target x86_64
|
||||
|
||||
function u0:51(i64, i64) system_v {
|
||||
ss0 = explicit_slot 0
|
||||
ss1 = explicit_slot 1
|
||||
ss2 = explicit_slot 1
|
||||
ss3 = explicit_slot 1
|
||||
|
||||
ebb0(v0: i64, v1: i64):
|
||||
v2 = stack_addr.i64 ss1
|
||||
v3 = load.i8 v1
|
||||
store v3, v2
|
||||
v4 = stack_addr.i64 ss2
|
||||
v5 = stack_addr.i64 ss3
|
||||
jump ebb1
|
||||
|
||||
ebb1:
|
||||
v6 = load.i8 v2
|
||||
store v6, v5
|
||||
v7 = load.i8 v5
|
||||
v8 = bnot v7
|
||||
store v8, v4
|
||||
v9 = load.i8 v4
|
||||
store v9, v0
|
||||
return
|
||||
}
|
||||
46
cranelift/filetests/filetests/isa/x86/legalize-br-icmp.clif
Normal file
46
cranelift/filetests/filetests/isa/x86/legalize-br-icmp.clif
Normal file
@@ -0,0 +1,46 @@
|
||||
test legalizer
|
||||
|
||||
target x86_64
|
||||
|
||||
function %br_icmp(i64) fast {
|
||||
ebb0(v0: i64):
|
||||
v1 = iconst.i64 0
|
||||
br_icmp eq v0, v1, ebb1
|
||||
jump ebb1
|
||||
|
||||
ebb1:
|
||||
return
|
||||
}
|
||||
|
||||
; sameln: function %br_icmp(i64 [%rdi]) fast {
|
||||
; nextln: ebb0(v0: i64):
|
||||
; nextln: [RexOp1pu_id#b8] v1 = iconst.i64 0
|
||||
; nextln: [RexOp1icscc#8039] v2 = icmp eq v0, v1
|
||||
; nextln: [RexOp1t8jccb#75] brnz v2, ebb1
|
||||
; nextln: [RexOp1jmpb#eb] jump ebb1
|
||||
; nextln:
|
||||
; nextln: ebb1:
|
||||
; nextln: [Op1ret#c3] return
|
||||
; nextln: }
|
||||
|
||||
|
||||
function %br_icmp_ebb_args(i64) fast {
|
||||
ebb0(v0: i64):
|
||||
v1 = iconst.i64 0
|
||||
br_icmp eq v0, v1, ebb1(v0)
|
||||
jump ebb1(v0)
|
||||
|
||||
ebb1(v2: i64):
|
||||
return
|
||||
}
|
||||
|
||||
; sameln: function %br_icmp_ebb_args(i64 [%rdi]) fast {
|
||||
; nextln: ebb0(v0: i64):
|
||||
; nextln: [RexOp1pu_id#b8] v1 = iconst.i64 0
|
||||
; nextln: [RexOp1icscc#8039] v3 = icmp eq v0, v1
|
||||
; nextln: [RexOp1t8jccb#75] brnz v3, ebb1(v0)
|
||||
; nextln: [RexOp1jmpb#eb] jump ebb1(v0)
|
||||
; nextln:
|
||||
; nextln: ebb1(v2: i64):
|
||||
; nextln: [Op1ret#c3] return
|
||||
; nextln: }
|
||||
19
cranelift/filetests/filetests/isa/x86/legalize-br-table.clif
Normal file
19
cranelift/filetests/filetests/isa/x86/legalize-br-table.clif
Normal file
@@ -0,0 +1,19 @@
|
||||
test compile
|
||||
|
||||
target x86_64
|
||||
|
||||
function u0:0(i64) system_v {
|
||||
ss0 = explicit_slot 1
|
||||
jt0 = jump_table [ebb1]
|
||||
|
||||
ebb0(v0: i64):
|
||||
v1 = stack_addr.i64 ss0
|
||||
v2 = load.i8 v1
|
||||
br_table v2, ebb2, jt0
|
||||
|
||||
ebb2:
|
||||
jump ebb1
|
||||
|
||||
ebb1:
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
test compile
|
||||
target x86_64
|
||||
|
||||
; regex: V=v\d+
|
||||
|
||||
function u0:0(i8, i8) fast {
|
||||
fn0 = %black_box(i8)
|
||||
ss0 = explicit_slot 1 ; black box
|
||||
|
||||
ebb0(v0: i8, v1: i8):
|
||||
v99 = stack_addr.i64 ss0
|
||||
|
||||
; check: istore8 $(V), $(V)
|
||||
|
||||
v2 = band v0, v1
|
||||
store v2, v99
|
||||
v3 = bor v0, v1
|
||||
store v3, v99
|
||||
v4 = bxor v0, v1
|
||||
store v4, v99
|
||||
v5 = bnot v0
|
||||
store v5, v99
|
||||
v6 = band_not v0, v1
|
||||
store v6, v99
|
||||
v7 = bor_not v0, v1
|
||||
store v7, v99
|
||||
v8 = bxor_not v0, v1
|
||||
store v8, v99
|
||||
v9 = band_imm v0, 42
|
||||
store v9, v99
|
||||
v10 = bor_imm v0, 42
|
||||
store v10, v99
|
||||
v11 = bxor_imm v0, 42
|
||||
store v11, v99
|
||||
return
|
||||
}
|
||||
14
cranelift/filetests/filetests/isa/x86/legalize-call.clif
Normal file
14
cranelift/filetests/filetests/isa/x86/legalize-call.clif
Normal file
@@ -0,0 +1,14 @@
|
||||
; Test legalization of a non-colocated call in 64-bit non-PIC mode.
|
||||
test legalizer
|
||||
set opt_level=best
|
||||
target x86_64 haswell
|
||||
|
||||
function %call() {
|
||||
fn0 = %foo()
|
||||
ebb0:
|
||||
call fn0()
|
||||
return
|
||||
}
|
||||
|
||||
; check: v0 = func_addr.i64 fn0
|
||||
; nextln: call_indirect sig0, v0()
|
||||
@@ -0,0 +1,25 @@
|
||||
test compile
|
||||
target x86_64
|
||||
|
||||
; regex: V=v\d+
|
||||
|
||||
function u0:0(i8) -> i8, i8 fast {
|
||||
ebb0(v0: i8):
|
||||
v1 = clz v0
|
||||
; check: v3 = uextend.i32 v0
|
||||
; nextln: v6 = iconst.i32 -1
|
||||
; nextln: v7 = iconst.i32 31
|
||||
; nextln: v8, v9 = x86_bsr v3
|
||||
; nextln: v10 = selectif.i32 eq v9, v6, v8
|
||||
; nextln: v4 = isub v7, v10
|
||||
; nextln: v5 = iadd_imm v4, -24
|
||||
; nextln: v1 = ireduce.i8 v5
|
||||
v2 = ctz v0
|
||||
; nextln: v11 = uextend.i32 v0
|
||||
; nextln: v12 = bor_imm v11, 256
|
||||
; nextln: v14 = iconst.i32 32
|
||||
; nextln: v15, v16 = x86_bsf v12
|
||||
; nextln: v13 = selectif.i32 eq v16, v14, v15
|
||||
; nextln: v2 = ireduce.i8 v13
|
||||
return v1, v2
|
||||
}
|
||||
96
cranelift/filetests/filetests/isa/x86/legalize-custom.clif
Normal file
96
cranelift/filetests/filetests/isa/x86/legalize-custom.clif
Normal file
@@ -0,0 +1,96 @@
|
||||
; Test the custom legalizations.
|
||||
test legalizer
|
||||
target i686
|
||||
target x86_64
|
||||
|
||||
; regex: V=v\d+
|
||||
; regex: EBB=ebb\d+
|
||||
|
||||
function %cond_trap(i32) {
|
||||
ebb0(v1: i32):
|
||||
trapz v1, user67
|
||||
return
|
||||
; check: ebb0(v1: i32
|
||||
; nextln: $(f=$V) = ifcmp_imm v1, 0
|
||||
; nextln: trapif eq $f, user67
|
||||
; nextln: return
|
||||
}
|
||||
|
||||
function %cond_trap2(i32) {
|
||||
ebb0(v1: i32):
|
||||
trapnz v1, int_ovf
|
||||
return
|
||||
; check: ebb0(v1: i32
|
||||
; nextln: $(f=$V) = ifcmp_imm v1, 0
|
||||
; nextln: trapif ne $f, int_ovf
|
||||
; nextln: return
|
||||
}
|
||||
|
||||
function %cond_trap_b1(i32) {
|
||||
ebb0(v1: i32):
|
||||
v2 = icmp_imm eq v1, 6
|
||||
trapz v2, user7
|
||||
return
|
||||
; check: ebb0(v1: i32
|
||||
; check: brnz v2, $(new=$EBB)
|
||||
; nextln: trap user7
|
||||
; check: $new:
|
||||
; nextln: return
|
||||
}
|
||||
|
||||
function %cond_trap2_b1(i32) {
|
||||
ebb0(v1: i32):
|
||||
v2 = icmp_imm eq v1, 6
|
||||
trapnz v2, user9
|
||||
return
|
||||
; check: ebb0(v1: i32
|
||||
; check: brz v2, $(new=$EBB)
|
||||
; nextln: trap user9
|
||||
; check: $new:
|
||||
; nextln: return
|
||||
}
|
||||
|
||||
function %f32const() -> f32 {
|
||||
ebb0:
|
||||
v1 = f32const 0x1.0p1
|
||||
; check: $(tmp=$V) = iconst.i32
|
||||
; check: v1 = bitcast.f32 $tmp
|
||||
return v1
|
||||
}
|
||||
|
||||
function %f64const() -> f64 {
|
||||
ebb0:
|
||||
v1 = f64const 0x1.0p1
|
||||
; check: $(tmp=$V) = iconst.i64
|
||||
; check: v1 = bitcast.f64 $tmp
|
||||
return v1
|
||||
}
|
||||
|
||||
function %select_f64(f64, f64, i32) -> f64 {
|
||||
ebb0(v0: f64, v1: f64, v2: i32):
|
||||
v3 = select v2, v0, v1
|
||||
; check: brnz v2, $(new=$EBB)(v0)
|
||||
; nextln: jump $new(v1)
|
||||
; check: $new(v3: f64):
|
||||
; nextln: return v3
|
||||
return v3
|
||||
}
|
||||
|
||||
function %f32_min(f32, f32) -> f32 {
|
||||
ebb0(v0: f32, v1: f32):
|
||||
v2 = fmin v0, v1
|
||||
return v2
|
||||
; check: $(vnat=$V) = x86_fmin v0, v1
|
||||
; nextln: jump $(done=$EBB)($vnat)
|
||||
|
||||
; check: $(uno=$EBB):
|
||||
; nextln: $(vuno=$V) = fadd.f32 v0, v1
|
||||
; nextln: jump $(done=$EBB)($vuno)
|
||||
|
||||
; check: $(ueq=$EBB):
|
||||
; check: $(veq=$V) = bor.f32 v0, v1
|
||||
; nextln: jump $(done=$EBB)($veq)
|
||||
|
||||
; check: $done(v2: f32):
|
||||
; nextln: return v2
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
; Test the division legalizations.
|
||||
test legalizer
|
||||
; See also legalize-div.clif.
|
||||
set avoid_div_traps=1
|
||||
target x86_64
|
||||
|
||||
; regex: V=v\d+
|
||||
; regex: EBB=ebb\d+
|
||||
|
||||
function %udiv(i64, i64) -> i64 {
|
||||
ebb0(v0: i64, v1: i64):
|
||||
; check: ebb0(
|
||||
v2 = udiv v0, v1
|
||||
; nextln: $(fz=$V) = ifcmp_imm v1, 0
|
||||
; nextln: trapif eq $fz, int_divz
|
||||
; nextln: $(hi=$V) = iconst.i64 0
|
||||
; nextln: $(d=$V), $(r=$V) = x86_udivmodx v0, $hi, v1
|
||||
return v2
|
||||
; nextln: return $d
|
||||
}
|
||||
|
||||
function %urem(i64, i64) -> i64 {
|
||||
ebb0(v0: i64, v1: i64):
|
||||
; check: ebb0(
|
||||
v2 = urem v0, v1
|
||||
; nextln: $(fz=$V) = ifcmp_imm v1, 0
|
||||
; nextln: trapif eq $fz, int_divz
|
||||
; nextln: $(hi=$V) = iconst.i64 0
|
||||
; nextln: $(d=$V), $(r=$V) = x86_udivmodx v0, $hi, v1
|
||||
return v2
|
||||
; nextln: return $r
|
||||
}
|
||||
|
||||
function %sdiv(i64, i64) -> i64 {
|
||||
ebb0(v0: i64, v1: i64):
|
||||
; check: ebb0(
|
||||
v2 = sdiv v0, v1
|
||||
; nextln: $(fm1=$V) = ifcmp_imm v1, -1
|
||||
; nextln: brif eq $fm1, $(m1=$EBB)
|
||||
; nextln: $(fz=$V) = ifcmp_imm v1, 0
|
||||
; nextln: trapif eq $fz, int_divz
|
||||
; check: $(hi=$V) = sshr_imm
|
||||
; nextln: $(q=$V), $(r=$V) = x86_sdivmodx v0, $hi, v1
|
||||
; nextln: jump $(done=$EBB)($q)
|
||||
; check: $m1:
|
||||
; nextln: $(imin=$V) = iconst.i64 0x8000_0000_0000_0000
|
||||
; nextln: $(fm=$V) = ifcmp.i64 v0, $imin
|
||||
; nextln: trapif eq $fm, int_ovf
|
||||
; check: $done(v2: i64):
|
||||
return v2
|
||||
; nextln: return v2
|
||||
}
|
||||
|
||||
; The srem expansion needs to special-case x % -1 since x86_sdivmodx traps on INT_MIN/-1.
|
||||
; TODO: Add more explicit pattern matching once we've cleaned up the ifcmp+brif pattern.
|
||||
function %srem(i64, i64) -> i64 {
|
||||
ebb0(v0: i64, v1: i64):
|
||||
; check: ebb0(
|
||||
v2 = srem v0, v1
|
||||
; nextln: $(fm1=$V) = ifcmp_imm v1, -1
|
||||
; nextln: brif eq $fm1, $(m1=$EBB)
|
||||
; check: $(hi=$V) = sshr_imm
|
||||
; nextln: $(d=$V), $(r=$V) = x86_sdivmodx v0, $hi, v1
|
||||
; nextln: jump $(done=$EBB)($r)
|
||||
; check: $m1:
|
||||
; nextln: $(zero=$V) = iconst.i64 0
|
||||
; nextln: jump $(done=$EBB)($zero)
|
||||
; check: $done(v2: i64):
|
||||
return v2
|
||||
; nextln: return v2
|
||||
}
|
||||
57
cranelift/filetests/filetests/isa/x86/legalize-div.clif
Normal file
57
cranelift/filetests/filetests/isa/x86/legalize-div.clif
Normal file
@@ -0,0 +1,57 @@
|
||||
; Test the division legalizations.
|
||||
test legalizer
|
||||
; See also legalize-div-traps.clif.
|
||||
set avoid_div_traps=0
|
||||
target x86_64
|
||||
|
||||
; regex: V=v\d+
|
||||
; regex: EBB=ebb\d+
|
||||
|
||||
function %udiv(i64, i64) -> i64 {
|
||||
ebb0(v0: i64, v1: i64):
|
||||
; check: ebb0(
|
||||
v2 = udiv v0, v1
|
||||
; nextln: $(hi=$V) = iconst.i64 0
|
||||
; nextln: $(d=$V), $(r=$V) = x86_udivmodx v0, $hi, v1
|
||||
return v2
|
||||
; nextln: return $d
|
||||
}
|
||||
|
||||
function %urem(i64, i64) -> i64 {
|
||||
ebb0(v0: i64, v1: i64):
|
||||
; check: ebb0(
|
||||
v2 = urem v0, v1
|
||||
; nextln: $(hi=$V) = iconst.i64 0
|
||||
; nextln: $(d=$V), $(r=$V) = x86_udivmodx v0, $hi, v1
|
||||
return v2
|
||||
; nextln: return $r
|
||||
}
|
||||
|
||||
function %sdiv(i64, i64) -> i64 {
|
||||
ebb0(v0: i64, v1: i64):
|
||||
; check: ebb0(
|
||||
v2 = sdiv v0, v1
|
||||
; check: $(hi=$V) = sshr_imm
|
||||
; nextln: $(d=$V), $(r=$V) = x86_sdivmodx v0, $hi, v1
|
||||
return v2
|
||||
; nextln: return $d
|
||||
}
|
||||
|
||||
; The srem expansion needs to special-case x % -1 since x86_sdivmodx traps on INT_MIN/-1.
|
||||
; TODO: Add more explicit pattern matching once we've cleaned up the ifcmp+brif pattern.
|
||||
function %srem(i64, i64) -> i64 {
|
||||
ebb0(v0: i64, v1: i64):
|
||||
; check: ebb0(
|
||||
v2 = srem v0, v1
|
||||
; nextln: $(fm1=$V) = ifcmp_imm v1, -1
|
||||
; nextln: brif eq $fm1, $(m1=$EBB)
|
||||
; check: $(hi=$V) = sshr_imm
|
||||
; nextln: $(d=$V), $(r=$V) = x86_sdivmodx v0, $hi, v1
|
||||
; nextln: jump $(done=$EBB)($r)
|
||||
; check: $m1:
|
||||
; nextln: $(zero=$V) = iconst.i64 0
|
||||
; nextln: jump $(done=$EBB)($zero)
|
||||
; check: $done(v2: i64):
|
||||
return v2
|
||||
; nextln: return v2
|
||||
}
|
||||
107
cranelift/filetests/filetests/isa/x86/legalize-heaps.clif
Normal file
107
cranelift/filetests/filetests/isa/x86/legalize-heaps.clif
Normal file
@@ -0,0 +1,107 @@
|
||||
test legalizer
|
||||
target x86_64
|
||||
|
||||
; Test legalization for various forms of heap addresses.
|
||||
|
||||
function %heap_addrs(i32, i64, i64 vmctx) {
|
||||
gv4 = vmctx
|
||||
gv0 = iadd_imm.i64 gv4, 64
|
||||
gv1 = iadd_imm.i64 gv4, 72
|
||||
gv2 = iadd_imm.i64 gv4, 80
|
||||
gv3 = load.i32 notrap aligned gv4+88
|
||||
|
||||
heap0 = static gv0, min 0x1_0000, bound 0x1_0000_0000, offset_guard 0x8000_0000, index_type i32
|
||||
heap1 = static gv0, offset_guard 0x1000, bound 0x1_0000, index_type i32
|
||||
heap2 = static gv0, min 0x1_0000, bound 0x1_0000_0000, offset_guard 0x8000_0000, index_type i64
|
||||
heap3 = static gv0, offset_guard 0x1000, bound 0x1_0000, index_type i64
|
||||
heap4 = dynamic gv1, min 0x1_0000, bound gv3, offset_guard 0x8000_0000, index_type i32
|
||||
heap5 = dynamic gv1, bound gv3, offset_guard 0x1000, index_type i32
|
||||
heap6 = dynamic gv1, min 0x1_0000, bound gv2, offset_guard 0x8000_0000, index_type i64
|
||||
heap7 = dynamic gv1, bound gv2, offset_guard 0x1000, index_type i64
|
||||
|
||||
; check: heap0 = static gv0, min 0x0001_0000, bound 0x0001_0000_0000, offset_guard 0x8000_0000, index_type i32
|
||||
; check: heap1 = static gv0, min 0, bound 0x0001_0000, offset_guard 4096, index_type i32
|
||||
; check: heap2 = static gv0, min 0x0001_0000, bound 0x0001_0000_0000, offset_guard 0x8000_0000, index_type i64
|
||||
; check: heap3 = static gv0, min 0, bound 0x0001_0000, offset_guard 4096, index_type i64
|
||||
; check: heap4 = dynamic gv1, min 0x0001_0000, bound gv3, offset_guard 0x8000_0000, index_type i32
|
||||
; check: heap5 = dynamic gv1, min 0, bound gv3, offset_guard 4096, index_type i32
|
||||
; check: heap6 = dynamic gv1, min 0x0001_0000, bound gv2, offset_guard 0x8000_0000, index_type i64
|
||||
; check: heap7 = dynamic gv1, min 0, bound gv2, offset_guard 4096, index_type i64
|
||||
|
||||
ebb0(v0: i32, v1: i64, v3: i64):
|
||||
; The fast-path; 32-bit index, static heap with a sufficient bound, no bounds check needed!
|
||||
v4 = heap_addr.i64 heap0, v0, 0
|
||||
; check: v12 = uextend.i64 v0
|
||||
; check: v13 = iadd_imm v3, 64
|
||||
; check: v4 = iadd v13, v12
|
||||
|
||||
v5 = heap_addr.i64 heap1, v0, 0
|
||||
; check: v14 = icmp_imm ugt v0, 0x0001_0000
|
||||
; check: brz v14, ebb1
|
||||
; check: trap heap_oob
|
||||
; check: ebb1:
|
||||
; check: v15 = uextend.i64 v0
|
||||
; check: v16 = iadd_imm.i64 v3, 64
|
||||
; check: v5 = iadd v16, v15
|
||||
|
||||
v6 = heap_addr.i64 heap2, v1, 0
|
||||
; check: v19 = iconst.i64 0x0001_0000_0000
|
||||
; check: v17 = icmp.i64 ugt v1, v19
|
||||
; check: brz v17, ebb2
|
||||
; check: trap heap_oob
|
||||
; check: ebb2:
|
||||
; check: v18 = iadd_imm.i64 v3, 64
|
||||
; check: v6 = iadd v18, v1
|
||||
|
||||
v7 = heap_addr.i64 heap3, v1, 0
|
||||
; check: v20 = icmp_imm.i64 ugt v1, 0x0001_0000
|
||||
; check: brz v20, ebb3
|
||||
; check: trap heap_oob
|
||||
; check: ebb3:
|
||||
; check: v21 = iadd_imm.i64 v3, 64
|
||||
; check: v7 = iadd v21, v1
|
||||
|
||||
v8 = heap_addr.i64 heap4, v0, 0
|
||||
; check: v22 = load.i32 notrap aligned v3+88
|
||||
; check: v23 = iadd_imm v22, 0
|
||||
; check: v24 = icmp.i32 ugt v0, v23
|
||||
; check: brz v24, ebb4
|
||||
; check: trap heap_oob
|
||||
; check: ebb4:
|
||||
; check: v25 = uextend.i64 v0
|
||||
; check: v26 = iadd_imm.i64 v3, 72
|
||||
; check: v8 = iadd v26, v25
|
||||
|
||||
v9 = heap_addr.i64 heap5, v0, 0
|
||||
; check: v27 = load.i32 notrap aligned v3+88
|
||||
; check: v28 = iadd_imm v27, 0
|
||||
; check: v29 = icmp.i32 ugt v0, v28
|
||||
; check: brz v29, ebb5
|
||||
; check: trap heap_oob
|
||||
; check: ebb5:
|
||||
; check: v30 = uextend.i64 v0
|
||||
; check: v31 = iadd_imm.i64 v3, 72
|
||||
; check: v9 = iadd v31, v30
|
||||
|
||||
v10 = heap_addr.i64 heap6, v1, 0
|
||||
; check: v32 = iadd_imm.i64 v3, 80
|
||||
; check: v33 = iadd_imm v32, 0
|
||||
; check: v34 = icmp.i64 ugt v1, v33
|
||||
; check: brz v34, ebb6
|
||||
; check: trap heap_oob
|
||||
; check: ebb6:
|
||||
; check: v35 = iadd_imm.i64 v3, 72
|
||||
; check: v10 = iadd v35, v1
|
||||
|
||||
v11 = heap_addr.i64 heap7, v1, 0
|
||||
; check: v36 = iadd_imm.i64 v3, 80
|
||||
; check: v37 = iadd_imm v36, 0
|
||||
; check: v38 = icmp.i64 ugt v1, v37
|
||||
; check: brz v38, ebb7
|
||||
; check: trap heap_oob
|
||||
; check: ebb7:
|
||||
; check: v39 = iadd_imm.i64 v3, 72
|
||||
; check: v11 = iadd v39, v1
|
||||
|
||||
return
|
||||
}
|
||||
19
cranelift/filetests/filetests/isa/x86/legalize-icmp-i8.clif
Normal file
19
cranelift/filetests/filetests/isa/x86/legalize-icmp-i8.clif
Normal file
@@ -0,0 +1,19 @@
|
||||
test compile
|
||||
target x86_64
|
||||
|
||||
; regex: V=v\d+
|
||||
|
||||
function u0:0(i8, i8) -> i8 fast {
|
||||
ebb0(v0: i8, v1: i8):
|
||||
v2 = icmp_imm sle v0, 0
|
||||
; check: $(e1=$V) = sextend.i32 v0
|
||||
; nextln: v2 = icmp_imm sle $e1, 0
|
||||
v3 = bint.i8 v2
|
||||
v4 = icmp eq v0, v1
|
||||
; check: $(e2=$V) = uextend.i32 v0
|
||||
; nextln: $(e3=$V) = uextend.i32 v1
|
||||
; nextln: v4 = icmp eq $e2, $e3
|
||||
v5 = bint.i8 v4
|
||||
v6 = iadd v3, v5
|
||||
return v6
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
test compile
|
||||
|
||||
target x86_64
|
||||
|
||||
function u0:0(i64) system_v {
|
||||
ss0 = explicit_slot 0
|
||||
|
||||
ebb0(v0: i64):
|
||||
jump ebb1
|
||||
|
||||
ebb1:
|
||||
; _0 = const 42u8
|
||||
v1 = iconst.i8 42
|
||||
store v1, v0
|
||||
;
|
||||
; return
|
||||
return
|
||||
}
|
||||
11
cranelift/filetests/filetests/isa/x86/legalize-imul-i8.clif
Normal file
11
cranelift/filetests/filetests/isa/x86/legalize-imul-i8.clif
Normal file
@@ -0,0 +1,11 @@
|
||||
test compile
|
||||
|
||||
target x86_64
|
||||
|
||||
function u0:0(i64, i8, i8) system_v {
|
||||
|
||||
ebb0(v0: i64, v1: i8, v2: i8):
|
||||
v11 = imul v1, v2
|
||||
store v11, v0
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
test compile
|
||||
|
||||
target x86_64
|
||||
|
||||
function u0:0(i64, i8) system_v {
|
||||
ss0 = explicit_slot 1
|
||||
|
||||
ebb0(v0: i64, v1: i8):
|
||||
v3 = stack_addr.i64 ss0
|
||||
v5 = load.i8 v3
|
||||
v6 = iconst.i8 2
|
||||
v7 = imul_imm v5, 42
|
||||
store v7, v0
|
||||
return
|
||||
}
|
||||
15
cranelift/filetests/filetests/isa/x86/legalize-libcall.clif
Normal file
15
cranelift/filetests/filetests/isa/x86/legalize-libcall.clif
Normal file
@@ -0,0 +1,15 @@
|
||||
test legalizer
|
||||
|
||||
; Pre-SSE 4.1, we need to use runtime library calls for floating point rounding operations.
|
||||
set is_pic
|
||||
target x86_64
|
||||
|
||||
function %floor(f32) -> f32 {
|
||||
ebb0(v0: f32):
|
||||
v1 = floor v0
|
||||
return v1
|
||||
}
|
||||
; check: function %floor(f32 [%xmm0]) -> f32 [%xmm0] fast {
|
||||
; check: sig0 = (f32 [%xmm0]) -> f32 [%xmm0] system_v
|
||||
; check: fn0 = %FloorF32 sig0
|
||||
; check: v1 = call fn0(v0)
|
||||
@@ -0,0 +1,31 @@
|
||||
test compile
|
||||
|
||||
target x86_64
|
||||
|
||||
function u0:0(i64, i8, i8) system_v {
|
||||
ss0 = explicit_slot 0
|
||||
ss1 = explicit_slot 1
|
||||
ss2 = explicit_slot 1
|
||||
ss3 = explicit_slot 1
|
||||
ss4 = explicit_slot 1
|
||||
|
||||
ebb0(v0: i64, v1: i8, v2: i8):
|
||||
v3 = stack_addr.i64 ss1
|
||||
store v1, v3
|
||||
v4 = stack_addr.i64 ss2
|
||||
store v2, v4
|
||||
v5 = stack_addr.i64 ss3
|
||||
v6 = stack_addr.i64 ss4
|
||||
jump ebb1
|
||||
|
||||
ebb1:
|
||||
v7 = load.i8 v3
|
||||
store v7, v5
|
||||
v8 = load.i8 v4
|
||||
store v8, v6
|
||||
v9 = load.i8 v5
|
||||
v10 = load.i8 v6
|
||||
v11 = imul v9, v10
|
||||
store v11, v0
|
||||
return
|
||||
}
|
||||
112
cranelift/filetests/filetests/isa/x86/legalize-memory.clif
Normal file
112
cranelift/filetests/filetests/isa/x86/legalize-memory.clif
Normal file
@@ -0,0 +1,112 @@
|
||||
; Test the legalization of memory objects.
|
||||
test legalizer
|
||||
target x86_64
|
||||
|
||||
; regex: V=v\d+
|
||||
; regex: EBB=ebb\d+
|
||||
|
||||
function %vmctx(i64 vmctx) -> i64 {
|
||||
gv0 = vmctx
|
||||
gv1 = iadd_imm.i64 gv0, -16
|
||||
|
||||
ebb1(v1: i64):
|
||||
v2 = global_value.i64 gv1
|
||||
; check: v2 = iadd_imm v1, -16
|
||||
return v2
|
||||
; check: return v2
|
||||
}
|
||||
|
||||
function %load(i64 vmctx) -> i64 {
|
||||
gv0 = vmctx
|
||||
gv1 = load.i64 notrap aligned gv0-16
|
||||
gv2 = iadd_imm.i64 gv1, 32
|
||||
|
||||
ebb1(v1: i64):
|
||||
v2 = global_value.i64 gv2
|
||||
; check: $(p1=$V) = load.i64 notrap aligned v1-16
|
||||
; check: v2 = iadd_imm $p1, 32
|
||||
return v2
|
||||
; check: return v2
|
||||
}
|
||||
|
||||
function %symbol() -> i64 {
|
||||
gv0 = symbol %something
|
||||
gv1 = symbol u123:456
|
||||
|
||||
ebb1:
|
||||
v0 = global_value.i64 gv0
|
||||
; check: v0 = symbol_value.i64 gv0
|
||||
v1 = global_value.i64 gv1
|
||||
; check: v1 = symbol_value.i64 gv1
|
||||
v2 = bxor v0, v1
|
||||
return v2
|
||||
}
|
||||
|
||||
; SpiderMonkey VM-style static 4+2 GB heap.
|
||||
; This eliminates bounds checks completely for offsets < 2GB.
|
||||
function %staticheap_sm64(i32, i64 vmctx) -> f32 baldrdash {
|
||||
gv0 = vmctx
|
||||
gv1 = iadd_imm.i64 gv0, 64
|
||||
heap0 = static gv1, min 0x1000, bound 0x1_0000_0000, offset_guard 0x8000_0000
|
||||
|
||||
ebb0(v0: i32, v999: i64):
|
||||
; check: ebb0(
|
||||
v1 = heap_addr.i64 heap0, v0, 1
|
||||
; Boundscheck should be eliminated.
|
||||
; Checks here are assuming that no pipehole opts fold the load offsets.
|
||||
; nextln: $(xoff=$V) = uextend.i64 v0
|
||||
; nextln: $(hbase=$V) = iadd_imm v999, 64
|
||||
; nextln: v1 = iadd $hbase, $xoff
|
||||
v2 = load.f32 v1+16
|
||||
; nextln: v2 = load.f32 v1+16
|
||||
v3 = load.f32 v1+20
|
||||
; nextln: v3 = load.f32 v1+20
|
||||
v4 = fadd v2, v3
|
||||
return v4
|
||||
}
|
||||
|
||||
function %staticheap_static_oob_sm64(i32, i64 vmctx) -> f32 baldrdash {
|
||||
gv0 = vmctx
|
||||
gv1 = iadd_imm.i64 gv0, 64
|
||||
heap0 = static gv1, min 0x1000, bound 0x1000_0000, offset_guard 0x8000_0000
|
||||
|
||||
ebb0(v0: i32, v999: i64):
|
||||
; Everything after the obviously OOB access should be eliminated, leaving
|
||||
; the `trap heap_oob` instruction as the terminator of the Ebb and moving
|
||||
; the remainder of the instructions into an inaccessible Ebb.
|
||||
; check: ebb0(
|
||||
; nextln: trap heap_oob
|
||||
; check: ebb1:
|
||||
; nextln: v1 = iconst.i64 0
|
||||
; nextln: v2 = load.f32 v1+16
|
||||
; nextln: return v2
|
||||
; nextln: }
|
||||
v1 = heap_addr.i64 heap0, v0, 0x1000_0001
|
||||
v2 = load.f32 v1+16
|
||||
return v2
|
||||
}
|
||||
|
||||
|
||||
; SpiderMonkey VM-style static 4+2 GB heap.
|
||||
; Offsets >= 2 GB do require a boundscheck.
|
||||
function %staticheap_sm64(i32, i64 vmctx) -> f32 baldrdash {
|
||||
gv0 = vmctx
|
||||
gv1 = iadd_imm.i64 gv0, 64
|
||||
heap0 = static gv1, min 0x1000, bound 0x1_0000_0000, offset_guard 0x8000_0000
|
||||
|
||||
ebb0(v0: i32, v999: i64):
|
||||
; check: ebb0(
|
||||
v1 = heap_addr.i64 heap0, v0, 0x8000_0000
|
||||
; Boundscheck code
|
||||
; check: $(oob=$V) = icmp
|
||||
; nextln: brz $oob, $(ok=$EBB)
|
||||
; nextln: trap heap_oob
|
||||
; check: $ok:
|
||||
; Checks here are assuming that no pipehole opts fold the load offsets.
|
||||
; nextln: $(xoff=$V) = uextend.i64 v0
|
||||
; nextln: $(hbase=$V) = iadd_imm.i64 v999, 64
|
||||
; nextln: v1 = iadd $hbase, $xoff
|
||||
v2 = load.f32 v1+0x7fff_ffff
|
||||
; nextln: v2 = load.f32 v1+0x7fff_ffff
|
||||
return v2
|
||||
}
|
||||
43
cranelift/filetests/filetests/isa/x86/legalize-mulhi.clif
Normal file
43
cranelift/filetests/filetests/isa/x86/legalize-mulhi.clif
Normal file
@@ -0,0 +1,43 @@
|
||||
test compile
|
||||
target x86_64 baseline
|
||||
|
||||
; umulhi/smulhi on 64 bit operands
|
||||
|
||||
function %i64_umulhi(i64, i64) -> i64 {
|
||||
ebb0(v10: i64, v11: i64):
|
||||
v12 = umulhi v10, v11
|
||||
; check: %rdi -> %rax
|
||||
; check: x86_umulx
|
||||
; check: %rdx -> %rax
|
||||
return v12
|
||||
}
|
||||
|
||||
function %i64_smulhi(i64, i64) -> i64 {
|
||||
ebb0(v20: i64, v21: i64):
|
||||
v22 = smulhi v20, v21
|
||||
; check: %rdi -> %rax
|
||||
; check: x86_smulx
|
||||
; check: %rdx -> %rax
|
||||
return v22
|
||||
}
|
||||
|
||||
|
||||
; umulhi/smulhi on 32 bit operands
|
||||
|
||||
function %i32_umulhi(i32, i32) -> i32 {
|
||||
ebb0(v30: i32, v31: i32):
|
||||
v32 = umulhi v30, v31
|
||||
; check: %rdi -> %rax
|
||||
; check: x86_umulx
|
||||
; check: %rdx -> %rax
|
||||
return v32
|
||||
}
|
||||
|
||||
function %i32_smulhi(i32, i32) -> i32 {
|
||||
ebb0(v40: i32, v41: i32):
|
||||
v42 = smulhi v40, v41
|
||||
; check: %rdi -> %rax
|
||||
; check: x86_smulx
|
||||
; check: %rdx -> %rax
|
||||
return v42
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
test compile
|
||||
target x86_64
|
||||
|
||||
function u0:0(i8) -> i8 fast {
|
||||
ebb0(v0: i8):
|
||||
v1 = popcnt v0
|
||||
; check-not: sextend.i32 v0
|
||||
return v1
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
test compile
|
||||
|
||||
target x86_64
|
||||
|
||||
function u0:0(i64, i64, i64) system_v {
|
||||
ss0 = explicit_slot 0
|
||||
ss1 = explicit_slot 8
|
||||
ss2 = explicit_slot 8
|
||||
ss3 = explicit_slot 2
|
||||
ss4 = explicit_slot 8
|
||||
sig0 = (i64, i16, i64) system_v
|
||||
fn0 = colocated u0:11 sig0
|
||||
|
||||
ebb0(v0: i64, v1: i64, v2: i64):
|
||||
v3 = stack_addr.i64 ss1
|
||||
store v1, v3
|
||||
v4 = stack_addr.i64 ss2
|
||||
store v2, v4
|
||||
v5 = stack_addr.i64 ss3
|
||||
v6 = stack_addr.i64 ss4
|
||||
jump ebb1
|
||||
|
||||
ebb1:
|
||||
v7 = load.i64 v3
|
||||
v8 = load.i16 v7
|
||||
store v8, v5
|
||||
v9 = load.i64 v4
|
||||
store v9, v6
|
||||
v10 = load.i16 v5
|
||||
v11 = load.i64 v6
|
||||
call fn0(v0, v10, v11)
|
||||
jump ebb2
|
||||
|
||||
ebb2:
|
||||
return
|
||||
}
|
||||
24
cranelift/filetests/filetests/isa/x86/legalize-shlr-i8.clif
Normal file
24
cranelift/filetests/filetests/isa/x86/legalize-shlr-i8.clif
Normal file
@@ -0,0 +1,24 @@
|
||||
test compile
|
||||
target x86_64
|
||||
|
||||
; regex: V=v\d+
|
||||
|
||||
function u0:0(i8, i8) -> i8 fast {
|
||||
ebb0(v0: i8, v1: i8):
|
||||
v2 = ishl v0, v1
|
||||
; check: $(e1=$V) = uextend.i32 v0
|
||||
; check: $(r1=$V) = ishl $e1, v1
|
||||
; check v2 = ireduce.i8 $r1
|
||||
v3 = ushr v0, v1
|
||||
; check: $(e2=$V) = uextend.i32 v0
|
||||
; check: $(r2=$V) = ushr $e2, v1
|
||||
; check v2 = ireduce.i8 $r2
|
||||
v4 = sshr v0, v1
|
||||
; check: $(e3=$V) = sextend.i32 v0
|
||||
; check: $(r3=$V) = sshr $e3, v1
|
||||
; check v2 = ireduce.i8 $r3
|
||||
|
||||
v5 = iadd v2, v3
|
||||
v6 = iadd v4, v5
|
||||
return v6
|
||||
}
|
||||
64
cranelift/filetests/filetests/isa/x86/legalize-tables.clif
Normal file
64
cranelift/filetests/filetests/isa/x86/legalize-tables.clif
Normal file
@@ -0,0 +1,64 @@
|
||||
test legalizer
|
||||
target x86_64
|
||||
|
||||
; Test legalization for various forms of table addresses.
|
||||
|
||||
function %table_addrs(i32, i64, i64 vmctx) {
|
||||
gv4 = vmctx
|
||||
gv0 = iadd_imm.i64 gv4, 72
|
||||
gv1 = iadd_imm.i64 gv4, 80
|
||||
gv2 = load.i32 notrap aligned gv4+88
|
||||
|
||||
table0 = dynamic gv0, min 0x1_0000, bound gv2, element_size 1, index_type i32
|
||||
table1 = dynamic gv0, bound gv2, element_size 16, index_type i32
|
||||
table2 = dynamic gv0, min 0x1_0000, bound gv1, element_size 1, index_type i64
|
||||
table3 = dynamic gv0, bound gv1, element_size 16, index_type i64
|
||||
|
||||
; check: table0 = dynamic gv0, min 0x0001_0000, bound gv2, element_size 1, index_type i32
|
||||
; check: table1 = dynamic gv0, min 0, bound gv2, element_size 16, index_type i32
|
||||
; check: table2 = dynamic gv0, min 0x0001_0000, bound gv1, element_size 1, index_type i64
|
||||
; check: table3 = dynamic gv0, min 0, bound gv1, element_size 16, index_type i64
|
||||
|
||||
ebb0(v0: i32, v1: i64, v3: i64):
|
||||
v4 = table_addr.i64 table0, v0, +0
|
||||
; check: v8 = load.i32 notrap aligned v3+88
|
||||
; check: v9 = icmp uge v0, v8
|
||||
; check: brz v9, ebb1
|
||||
; check: trap table_oob
|
||||
; check: ebb1:
|
||||
; check: v10 = uextend.i64 v0
|
||||
; check: v11 = iadd_imm.i64 v3, 72
|
||||
; check: v4 = iadd v11, v10
|
||||
|
||||
v5 = table_addr.i64 table1, v0, +0
|
||||
; check: v12 = load.i32 notrap aligned v3+88
|
||||
; check: v13 = icmp.i32 uge v0, v12
|
||||
; check: brz v13, ebb2
|
||||
; check: trap table_oob
|
||||
; check: ebb2:
|
||||
; check: v14 = uextend.i64 v0
|
||||
; check: v15 = iadd_imm.i64 v3, 72
|
||||
; check: v16 = ishl_imm v14, 4
|
||||
; check: v5 = iadd v15, v16
|
||||
|
||||
v6 = table_addr.i64 table2, v1, +0
|
||||
; check: v17 = iadd_imm.i64 v3, 80
|
||||
; check: v18 = icmp.i64 uge v1, v17
|
||||
; check: brz v18, ebb3
|
||||
; check: trap table_oob
|
||||
; check: ebb3:
|
||||
; check: v19 = iadd_imm.i64 v3, 72
|
||||
; check: v6 = iadd v19, v1
|
||||
|
||||
v7 = table_addr.i64 table3, v1, +0
|
||||
; check: v20 = iadd_imm.i64 v3, 80
|
||||
; check: v21 = icmp.i64 uge v1, v20
|
||||
; check: brz v21, ebb4
|
||||
; check: trap table_oob
|
||||
; check: ebb4:
|
||||
; check: v22 = iadd_imm.i64 v3, 72
|
||||
; check: v23 = ishl_imm.i64 v1, 4
|
||||
; check: v7 = iadd v22, v23
|
||||
|
||||
return
|
||||
}
|
||||
15
cranelift/filetests/filetests/isa/x86/legalize-urem-i8.clif
Normal file
15
cranelift/filetests/filetests/isa/x86/legalize-urem-i8.clif
Normal file
@@ -0,0 +1,15 @@
|
||||
test compile
|
||||
target x86_64
|
||||
|
||||
; regex: V=v\d+
|
||||
|
||||
function u0:0(i8, i8) -> i8 fast {
|
||||
ebb0(v0: i8, v1: i8):
|
||||
v2 = urem v0, v1
|
||||
; check: $(a=$V) = uextend.i32 v0
|
||||
; nextln: $(b=$V) = uextend.i32 v1
|
||||
; nextln: $(c=$V) = iconst.i32 0
|
||||
; nextln: $(V), $(r=$V) = x86_udivmodx $a, $c, $b
|
||||
; nextln: v2 = ireduce.i8 $r
|
||||
return v2
|
||||
}
|
||||
10
cranelift/filetests/filetests/isa/x86/nop.clif
Normal file
10
cranelift/filetests/filetests/isa/x86/nop.clif
Normal file
@@ -0,0 +1,10 @@
|
||||
test compile
|
||||
|
||||
target x86_64
|
||||
|
||||
function %test(i32) -> i32 system_v {
|
||||
ebb0(v0: i32):
|
||||
nop
|
||||
v1 = iconst.i32 42
|
||||
return v1
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
; Check that floating-point constants equal to zero are optimized correctly.
|
||||
test binemit
|
||||
target i686
|
||||
|
||||
function %foo() -> f32 fast {
|
||||
ebb0:
|
||||
; asm: xorps %xmm0, %xmm0
|
||||
[-,%xmm0] v0 = f32const 0.0 ; bin: 0f 57 c0
|
||||
return v0
|
||||
}
|
||||
|
||||
function %bar() -> f64 fast {
|
||||
ebb0:
|
||||
; asm: xorpd %xmm0, %xmm0
|
||||
[-,%xmm0] v1 = f64const 0.0 ; bin: 66 0f 57 c0
|
||||
return v1
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
; Check that floating-point constants equal to zero are optimized correctly.
|
||||
test binemit
|
||||
target x86_64
|
||||
|
||||
function %zero_const_32bit_no_rex() -> f32 fast {
|
||||
ebb0:
|
||||
; asm: xorps %xmm0, %xmm0
|
||||
[-,%xmm0] v0 = f32const 0.0 ; bin: 40 0f 57 c0
|
||||
return v0
|
||||
}
|
||||
|
||||
function %zero_const_32bit_rex() -> f32 fast {
|
||||
ebb0:
|
||||
; asm: xorps %xmm8, %xmm8
|
||||
[-,%xmm8] v1 = f32const 0.0 ; bin: 45 0f 57 c0
|
||||
return v1
|
||||
}
|
||||
|
||||
function %zero_const_64bit_no_rex() -> f64 fast {
|
||||
ebb0:
|
||||
; asm: xorpd %xmm0, %xmm0
|
||||
[-,%xmm0] v0 = f64const 0.0 ; bin: 66 40 0f 57 c0
|
||||
return v0
|
||||
}
|
||||
|
||||
function %zero_const_64bit_rex() -> f64 fast {
|
||||
ebb0:
|
||||
; asm: xorpd %xmm8, %xmm8
|
||||
[-,%xmm8] v1 = f64const 0.0 ; bin: 66 45 0f 57 c0
|
||||
return v1
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
test compile
|
||||
set colocated_libcalls=1
|
||||
set probestack_func_adjusts_sp=1
|
||||
target x86_64
|
||||
|
||||
; Like %big in probestack.clif, but with the probestack function adjusting
|
||||
; the stack pointer itself.
|
||||
|
||||
function %big() system_v {
|
||||
ss0 = explicit_slot 300000
|
||||
ebb0:
|
||||
return
|
||||
}
|
||||
; check: function %big(i64 fp [%rbp]) -> i64 fp [%rbp] system_v {
|
||||
; nextln: ss0 = explicit_slot 300000, offset -300016
|
||||
; nextln: ss1 = incoming_arg 16, offset -16
|
||||
; nextln: sig0 = (i64 [%rax]) probestack
|
||||
; nextln: fn0 = colocated %Probestack sig0
|
||||
; nextln:
|
||||
; nextln: ebb0(v0: i64 [%rbp]):
|
||||
; nextln: [RexOp1pushq#50] x86_push v0
|
||||
; nextln: [RexOp1copysp#8089] copy_special %rsp -> %rbp
|
||||
; nextln: [RexOp1pu_id#b8,%rax] v1 = iconst.i64 0x0004_93e0
|
||||
; nextln: [Op1call_id#e8] call fn0(v1)
|
||||
; nextln: [RexOp1adjustsp_id#8081] adjust_sp_up_imm 0x0004_93e0
|
||||
; nextln: [RexOp1popq#58,%rbp] v2 = x86_pop.i64
|
||||
; nextln: [Op1ret#c3] return v2
|
||||
; nextln: }
|
||||
@@ -0,0 +1,24 @@
|
||||
test compile
|
||||
set colocated_libcalls=1
|
||||
set probestack_enabled=0
|
||||
target x86_64
|
||||
|
||||
; Like %big in probestack.clif, but with probes disabled.
|
||||
|
||||
function %big() system_v {
|
||||
ss0 = explicit_slot 300000
|
||||
ebb0:
|
||||
return
|
||||
}
|
||||
; check: function %big(i64 fp [%rbp]) -> i64 fp [%rbp] system_v {
|
||||
; nextln: ss0 = explicit_slot 300000, offset -300016
|
||||
; nextln: ss1 = incoming_arg 16, offset -16
|
||||
; nextln:
|
||||
; nextln: ebb0(v0: i64 [%rbp]):
|
||||
; nextln: [RexOp1pushq#50] x86_push v0
|
||||
; nextln: [RexOp1copysp#8089] copy_special %rsp -> %rbp
|
||||
; nextln: [RexOp1adjustsp_id#d081] adjust_sp_down_imm 0x0004_93e0
|
||||
; nextln: [RexOp1adjustsp_id#8081] adjust_sp_up_imm 0x0004_93e0
|
||||
; nextln: [RexOp1popq#58,%rbp] v1 = x86_pop.i64
|
||||
; nextln: [Op1ret#c3] return v1
|
||||
; nextln: }
|
||||
@@ -0,0 +1,27 @@
|
||||
test compile
|
||||
target x86_64
|
||||
|
||||
; Like %big in probestack.clif, but without a colocated libcall.
|
||||
|
||||
function %big() system_v {
|
||||
ss0 = explicit_slot 300000
|
||||
ebb0:
|
||||
return
|
||||
}
|
||||
; check: function %big(i64 fp [%rbp]) -> i64 fp [%rbp] system_v {
|
||||
; nextln: ss0 = explicit_slot 300000, offset -300016
|
||||
; nextln: ss1 = incoming_arg 16, offset -16
|
||||
; nextln: sig0 = (i64 [%rax]) -> i64 [%rax] probestack
|
||||
; nextln: fn0 = %Probestack sig0
|
||||
; nextln:
|
||||
; nextln: ebb0(v0: i64 [%rbp]):
|
||||
; nextln: [RexOp1pushq#50] x86_push v0
|
||||
; nextln: [RexOp1copysp#8089] copy_special %rsp -> %rbp
|
||||
; nextln: [RexOp1pu_id#b8,%rax] v1 = iconst.i64 0x0004_93e0
|
||||
; nextln: [RexOp1fnaddr8#80b8,%r11] v2 = func_addr.i64 fn0
|
||||
; nextln: [RexOp1call_r#20ff,%rax] v3 = call_indirect sig0, v2(v1)
|
||||
; nextln: [RexOp1adjustsp#8029] adjust_sp_down v3
|
||||
; nextln: [RexOp1adjustsp_id#8081] adjust_sp_up_imm 0x0004_93e0
|
||||
; nextln: [RexOp1popq#58,%rbp] v4 = x86_pop.i64
|
||||
; nextln: [Op1ret#c3] return v4
|
||||
; nextln: }
|
||||
74
cranelift/filetests/filetests/isa/x86/probestack-size.clif
Normal file
74
cranelift/filetests/filetests/isa/x86/probestack-size.clif
Normal file
@@ -0,0 +1,74 @@
|
||||
test compile
|
||||
set colocated_libcalls=1
|
||||
set probestack_size_log2=13
|
||||
target x86_64
|
||||
|
||||
; Like %big in probestack.clif, but now the probestack size is bigger
|
||||
; and it no longer needs a probe.
|
||||
|
||||
function %big() system_v {
|
||||
ss0 = explicit_slot 4097
|
||||
ebb0:
|
||||
return
|
||||
}
|
||||
|
||||
; check: function %big(i64 fp [%rbp]) -> i64 fp [%rbp] system_v {
|
||||
; nextln: ss0 = explicit_slot 4097, offset -4113
|
||||
; nextln: ss1 = incoming_arg 16, offset -16
|
||||
; nextln:
|
||||
; nextln: ebb0(v0: i64 [%rbp]):
|
||||
; nextln: [RexOp1pushq#50] x86_push v0
|
||||
; nextln: [RexOp1copysp#8089] copy_special %rsp -> %rbp
|
||||
; nextln: [RexOp1adjustsp_id#d081] adjust_sp_down_imm 4112
|
||||
; nextln: [RexOp1adjustsp_id#8081] adjust_sp_up_imm 4112
|
||||
; nextln: [RexOp1popq#58,%rbp] v1 = x86_pop.i64
|
||||
; nextln: [Op1ret#c3] return v1
|
||||
; nextln: }
|
||||
|
||||
|
||||
; Like %big; still doesn't need a probe.
|
||||
|
||||
function %bigger() system_v {
|
||||
ss0 = explicit_slot 8192
|
||||
ebb0:
|
||||
return
|
||||
}
|
||||
|
||||
; check: function %bigger(i64 fp [%rbp]) -> i64 fp [%rbp] system_v {
|
||||
; nextln: ss0 = explicit_slot 8192, offset -8208
|
||||
; nextln: ss1 = incoming_arg 16, offset -16
|
||||
; nextln:
|
||||
; nextln: ebb0(v0: i64 [%rbp]):
|
||||
; nextln: [RexOp1pushq#50] x86_push v0
|
||||
; nextln: [RexOp1copysp#8089] copy_special %rsp -> %rbp
|
||||
; nextln: [RexOp1adjustsp_id#d081] adjust_sp_down_imm 8192
|
||||
; nextln: [RexOp1adjustsp_id#8081] adjust_sp_up_imm 8192
|
||||
; nextln: [RexOp1popq#58,%rbp] v1 = x86_pop.i64
|
||||
; nextln: [Op1ret#c3] return v1
|
||||
; nextln: }
|
||||
|
||||
|
||||
; Like %bigger; this needs a probe.
|
||||
|
||||
function %biggest() system_v {
|
||||
ss0 = explicit_slot 8193
|
||||
ebb0:
|
||||
return
|
||||
}
|
||||
|
||||
; check: function %biggest(i64 fp [%rbp]) -> i64 fp [%rbp] system_v {
|
||||
; nextln: ss0 = explicit_slot 8193, offset -8209
|
||||
; nextln: ss1 = incoming_arg 16, offset -16
|
||||
; nextln: sig0 = (i64 [%rax]) -> i64 [%rax] probestack
|
||||
; nextln: fn0 = colocated %Probestack sig0
|
||||
; nextln:
|
||||
; nextln: ebb0(v0: i64 [%rbp]):
|
||||
; nextln: [RexOp1pushq#50] x86_push v0
|
||||
; nextln: [RexOp1copysp#8089] copy_special %rsp -> %rbp
|
||||
; nextln: [RexOp1pu_id#b8,%rax] v1 = iconst.i64 8208
|
||||
; nextln: [Op1call_id#e8,%rax] v2 = call fn0(v1)
|
||||
; nextln: [RexOp1adjustsp#8029] adjust_sp_down v2
|
||||
; nextln: [RexOp1adjustsp_id#8081] adjust_sp_up_imm 8208
|
||||
; nextln: [RexOp1popq#58,%rbp] v3 = x86_pop.i64
|
||||
; nextln: [Op1ret#c3] return v3
|
||||
; nextln: }
|
||||
49
cranelift/filetests/filetests/isa/x86/probestack.clif
Normal file
49
cranelift/filetests/filetests/isa/x86/probestack.clif
Normal file
@@ -0,0 +1,49 @@
|
||||
test compile
|
||||
set colocated_libcalls=1
|
||||
target x86_64
|
||||
|
||||
; A function with a big stack frame. This should have a stack probe.
|
||||
|
||||
function %big() system_v {
|
||||
ss0 = explicit_slot 4097
|
||||
ebb0:
|
||||
return
|
||||
}
|
||||
; check: function %big(i64 fp [%rbp]) -> i64 fp [%rbp] system_v {
|
||||
; nextln: ss0 = explicit_slot 4097, offset -4113
|
||||
; nextln: ss1 = incoming_arg 16, offset -16
|
||||
; nextln: sig0 = (i64 [%rax]) -> i64 [%rax] probestack
|
||||
; nextln: fn0 = colocated %Probestack sig0
|
||||
; nextln:
|
||||
; nextln: ebb0(v0: i64 [%rbp]):
|
||||
; nextln: [RexOp1pushq#50] x86_push v0
|
||||
; nextln: [RexOp1copysp#8089] copy_special %rsp -> %rbp
|
||||
; nextln: [RexOp1pu_id#b8,%rax] v1 = iconst.i64 4112
|
||||
; nextln: [Op1call_id#e8,%rax] v2 = call fn0(v1)
|
||||
; nextln: [RexOp1adjustsp#8029] adjust_sp_down v2
|
||||
; nextln: [RexOp1adjustsp_id#8081] adjust_sp_up_imm 4112
|
||||
; nextln: [RexOp1popq#58,%rbp] v3 = x86_pop.i64
|
||||
; nextln: [Op1ret#c3] return v3
|
||||
; nextln: }
|
||||
|
||||
|
||||
; A function with a small enough stack frame. This shouldn't have a stack probe.
|
||||
|
||||
function %small() system_v {
|
||||
ss0 = explicit_slot 4096
|
||||
ebb0:
|
||||
return
|
||||
}
|
||||
|
||||
; check: function %small(i64 fp [%rbp]) -> i64 fp [%rbp] system_v {
|
||||
; nextln: ss0 = explicit_slot 4096, offset -4112
|
||||
; nextln: ss1 = incoming_arg 16, offset -16
|
||||
; nextln:
|
||||
; nextln: ebb0(v0: i64 [%rbp]):
|
||||
; nextln: [RexOp1pushq#50] x86_push v0
|
||||
; nextln: [RexOp1copysp#8089] copy_special %rsp -> %rbp
|
||||
; nextln: [RexOp1adjustsp_id#d081] adjust_sp_down_imm 4096
|
||||
; nextln: [RexOp1adjustsp_id#8081] adjust_sp_up_imm 4096
|
||||
; nextln: [RexOp1popq#58,%rbp] v1 = x86_pop.i64
|
||||
; nextln: [Op1ret#c3] return v1
|
||||
; nextln: }
|
||||
255
cranelift/filetests/filetests/isa/x86/prologue-epilogue.clif
Normal file
255
cranelift/filetests/filetests/isa/x86/prologue-epilogue.clif
Normal file
@@ -0,0 +1,255 @@
|
||||
test compile
|
||||
set opt_level=best
|
||||
set is_pic
|
||||
target x86_64 haswell
|
||||
|
||||
; An empty function.
|
||||
|
||||
function %empty() {
|
||||
ebb0:
|
||||
return
|
||||
}
|
||||
|
||||
; check: function %empty(i64 fp [%rbp]) -> i64 fp [%rbp] fast {
|
||||
; nextln: ss0 = incoming_arg 16, offset -16
|
||||
; nextln:
|
||||
; nextln: ebb0(v0: i64 [%rbp]):
|
||||
; nextln: x86_push v0
|
||||
; nextln: copy_special %rsp -> %rbp
|
||||
; nextln: v1 = x86_pop.i64
|
||||
; nextln: return v1
|
||||
; nextln: }
|
||||
|
||||
; A function with a single stack slot.
|
||||
|
||||
function %one_stack_slot() {
|
||||
ss0 = explicit_slot 168
|
||||
ebb0:
|
||||
return
|
||||
}
|
||||
|
||||
; check: function %one_stack_slot(i64 fp [%rbp]) -> i64 fp [%rbp] fast {
|
||||
; nextln: ss0 = explicit_slot 168, offset -184
|
||||
; nextln: ss1 = incoming_arg 16, offset -16
|
||||
; nextln:
|
||||
; nextln: ebb0(v0: i64 [%rbp]):
|
||||
; nextln: x86_push v0
|
||||
; nextln: copy_special %rsp -> %rbp
|
||||
; nextln: adjust_sp_down_imm 176
|
||||
; nextln: adjust_sp_up_imm 176
|
||||
; nextln: v1 = x86_pop.i64
|
||||
; nextln: return v1
|
||||
; nextln: }
|
||||
|
||||
; A function performing a call.
|
||||
|
||||
function %call() {
|
||||
fn0 = %foo()
|
||||
|
||||
ebb0:
|
||||
call fn0()
|
||||
return
|
||||
}
|
||||
|
||||
; check: function %call(i64 fp [%rbp]) -> i64 fp [%rbp] fast {
|
||||
; nextln: ss0 = incoming_arg 16, offset -16
|
||||
; nextln: sig0 = () fast
|
||||
; nextln: fn0 = %foo sig0
|
||||
; nextln:
|
||||
; nextln: ebb0(v0: i64 [%rbp]):
|
||||
; nextln: x86_push v0
|
||||
; nextln: copy_special %rsp -> %rbp
|
||||
; nextln: call fn0()
|
||||
; nextln: v1 = x86_pop.i64
|
||||
; nextln: return v1
|
||||
; nextln: }
|
||||
|
||||
; A function that uses a lot of registers but doesn't quite need to spill.
|
||||
|
||||
function %no_spill(i64, i64) {
|
||||
ebb0(v0: i64, v1: i64):
|
||||
v2 = load.i32 v0+0
|
||||
v3 = load.i32 v0+8
|
||||
v4 = load.i32 v0+16
|
||||
v5 = load.i32 v0+24
|
||||
v6 = load.i32 v0+32
|
||||
v7 = load.i32 v0+40
|
||||
v8 = load.i32 v0+48
|
||||
v9 = load.i32 v0+56
|
||||
v10 = load.i32 v0+64
|
||||
v11 = load.i32 v0+72
|
||||
v12 = load.i32 v0+80
|
||||
v13 = load.i32 v0+88
|
||||
v14 = load.i32 v0+96
|
||||
store.i32 v2, v1+0
|
||||
store.i32 v3, v1+8
|
||||
store.i32 v4, v1+16
|
||||
store.i32 v5, v1+24
|
||||
store.i32 v6, v1+32
|
||||
store.i32 v7, v1+40
|
||||
store.i32 v8, v1+48
|
||||
store.i32 v9, v1+56
|
||||
store.i32 v10, v1+64
|
||||
store.i32 v11, v1+72
|
||||
store.i32 v12, v1+80
|
||||
store.i32 v13, v1+88
|
||||
store.i32 v14, v1+96
|
||||
return
|
||||
}
|
||||
|
||||
; check: function %no_spill(i64 [%rdi], i64 [%rsi], i64 fp [%rbp], i64 csr [%rbx], i64 csr [%r12], i64 csr [%r13], i64 csr [%r14], i64 csr [%r15]) -> i64 fp [%rbp], i64 csr [%rbx], i64 csr [%r12], i64 csr [%r13], i64 csr [%r14], i64 csr [%r15] fast {
|
||||
; nextln: ss0 = incoming_arg 56, offset -56
|
||||
; nextln:
|
||||
; nextln: ebb0(v0: i64 [%rdi], v1: i64 [%rsi], v15: i64 [%rbp], v16: i64 [%rbx], v17: i64 [%r12], v18: i64 [%r13], v19: i64 [%r14], v20: i64 [%r15]):
|
||||
; nextln: x86_push v15
|
||||
; nextln: copy_special %rsp -> %rbp
|
||||
; nextln: x86_push v16
|
||||
; nextln: x86_push v17
|
||||
; nextln: x86_push v18
|
||||
; nextln: x86_push v19
|
||||
; nextln: x86_push v20
|
||||
; nextln: adjust_sp_down_imm 8
|
||||
; nextln: v2 = load.i32 v0
|
||||
; nextln: v3 = load.i32 v0+8
|
||||
; nextln: v4 = load.i32 v0+16
|
||||
; nextln: v5 = load.i32 v0+24
|
||||
; nextln: v6 = load.i32 v0+32
|
||||
; nextln: v7 = load.i32 v0+40
|
||||
; nextln: v8 = load.i32 v0+48
|
||||
; nextln: v9 = load.i32 v0+56
|
||||
; nextln: v10 = load.i32 v0+64
|
||||
; nextln: v11 = load.i32 v0+72
|
||||
; nextln: v12 = load.i32 v0+80
|
||||
; nextln: v13 = load.i32 v0+88
|
||||
; nextln: v14 = load.i32 v0+96
|
||||
; nextln: store v2, v1
|
||||
; nextln: store v3, v1+8
|
||||
; nextln: store v4, v1+16
|
||||
; nextln: store v5, v1+24
|
||||
; nextln: store v6, v1+32
|
||||
; nextln: store v7, v1+40
|
||||
; nextln: store v8, v1+48
|
||||
; nextln: store v9, v1+56
|
||||
; nextln: store v10, v1+64
|
||||
; nextln: store v11, v1+72
|
||||
; nextln: store v12, v1+80
|
||||
; nextln: store v13, v1+88
|
||||
; nextln: store v14, v1+96
|
||||
; nextln: adjust_sp_up_imm 8
|
||||
; nextln: v26 = x86_pop.i64
|
||||
; nextln: v25 = x86_pop.i64
|
||||
; nextln: v24 = x86_pop.i64
|
||||
; nextln: v23 = x86_pop.i64
|
||||
; nextln: v22 = x86_pop.i64
|
||||
; nextln: v21 = x86_pop.i64
|
||||
; nextln: return v21, v22, v23, v24, v25, v26
|
||||
; nextln: }
|
||||
|
||||
; This function requires too many registers and must spill.
|
||||
|
||||
function %yes_spill(i64, i64) {
|
||||
ebb0(v0: i64, v1: i64):
|
||||
v2 = load.i32 v0+0
|
||||
v3 = load.i32 v0+8
|
||||
v4 = load.i32 v0+16
|
||||
v5 = load.i32 v0+24
|
||||
v6 = load.i32 v0+32
|
||||
v7 = load.i32 v0+40
|
||||
v8 = load.i32 v0+48
|
||||
v9 = load.i32 v0+56
|
||||
v10 = load.i32 v0+64
|
||||
v11 = load.i32 v0+72
|
||||
v12 = load.i32 v0+80
|
||||
v13 = load.i32 v0+88
|
||||
v14 = load.i32 v0+96
|
||||
v15 = load.i32 v0+104
|
||||
store.i32 v2, v1+0
|
||||
store.i32 v3, v1+8
|
||||
store.i32 v4, v1+16
|
||||
store.i32 v5, v1+24
|
||||
store.i32 v6, v1+32
|
||||
store.i32 v7, v1+40
|
||||
store.i32 v8, v1+48
|
||||
store.i32 v9, v1+56
|
||||
store.i32 v10, v1+64
|
||||
store.i32 v11, v1+72
|
||||
store.i32 v12, v1+80
|
||||
store.i32 v13, v1+88
|
||||
store.i32 v14, v1+96
|
||||
store.i32 v15, v1+104
|
||||
return
|
||||
}
|
||||
|
||||
; check: function %yes_spill(i64 [%rdi], i64 [%rsi], i64 fp [%rbp], i64 csr [%rbx], i64 csr [%r12], i64 csr [%r13], i64 csr [%r14], i64 csr [%r15]) -> i64 fp [%rbp], i64 csr [%rbx], i64 csr [%r12], i64 csr [%r13], i64 csr [%r14], i64 csr [%r15] fast {
|
||||
; check: ss0 = spill_slot
|
||||
|
||||
; check: ebb0(v16: i64 [%rdi], v17: i64 [%rsi], v48: i64 [%rbp], v49: i64 [%rbx], v50: i64 [%r12], v51: i64 [%r13], v52: i64 [%r14], v53: i64 [%r15]):
|
||||
; nextln: x86_push v48
|
||||
; nextln: copy_special %rsp -> %rbp
|
||||
; nextln: x86_push v49
|
||||
; nextln: x86_push v50
|
||||
; nextln: x86_push v51
|
||||
; nextln: x86_push v52
|
||||
; nextln: x86_push v53
|
||||
; nextln: adjust_sp_down_imm
|
||||
|
||||
; check: spill
|
||||
|
||||
; check: fill
|
||||
|
||||
; check: adjust_sp_up_imm
|
||||
; nextln: v59 = x86_pop.i64
|
||||
; nextln: v58 = x86_pop.i64
|
||||
; nextln: v57 = x86_pop.i64
|
||||
; nextln: v56 = x86_pop.i64
|
||||
; nextln: v55 = x86_pop.i64
|
||||
; nextln: v54 = x86_pop.i64
|
||||
; nextln: return v54, v55, v56, v57, v58, v59
|
||||
; nextln: }
|
||||
|
||||
; A function which uses diverted registers.
|
||||
|
||||
function %divert(i32) -> i32 system_v {
|
||||
ebb0(v0: i32):
|
||||
v2 = iconst.i32 0
|
||||
v3 = iconst.i32 1
|
||||
jump ebb3(v0, v3, v2)
|
||||
|
||||
ebb3(v4: i32, v5: i32, v6: i32):
|
||||
brz v4, ebb4
|
||||
v7 = iadd v5, v6
|
||||
v8 = iadd_imm v4, -1
|
||||
jump ebb3(v8, v7, v5)
|
||||
|
||||
ebb4:
|
||||
return v5
|
||||
}
|
||||
|
||||
; check: function %divert
|
||||
; check: regmove v5, %rcx -> %rbx
|
||||
; check: [Op1popq#58,%rbx] v15 = x86_pop.i64
|
||||
|
||||
; Stack limit checking
|
||||
|
||||
function %stack_limit(i64 stack_limit) {
|
||||
ss0 = explicit_slot 168
|
||||
ebb0(v0: i64):
|
||||
return
|
||||
}
|
||||
|
||||
; check: function %stack_limit(i64 stack_limit [%rdi], i64 fp [%rbp]) -> i64 fp [%rbp] fast {
|
||||
; nextln: ss0 = explicit_slot 168, offset -184
|
||||
; nextln: ss1 = incoming_arg 16, offset -16
|
||||
; nextln:
|
||||
; nextln: ebb0(v0: i64 [%rdi], v4: i64 [%rbp]):
|
||||
; nextln: v1 = copy v0
|
||||
; nextln: v2 = iadd_imm v1, 16
|
||||
; nextln: v3 = ifcmp_sp v2
|
||||
; nextln: trapif uge v3, stk_ovf
|
||||
; nextln: x86_push v4
|
||||
; nextln: copy_special %rsp -> %rbp
|
||||
; nextln: adjust_sp_down_imm 176
|
||||
; nextln: adjust_sp_up_imm 176
|
||||
; nextln: v5 = x86_pop.i64
|
||||
; nextln: return v5
|
||||
; nextln: }
|
||||
@@ -0,0 +1,15 @@
|
||||
test shrink
|
||||
set opt_level=best
|
||||
target x86_64
|
||||
|
||||
function %test_multiple_uses(i32 [%rdi]) -> i32 {
|
||||
ebb0(v0: i32 [%rdi]):
|
||||
[Op1rcmp_ib#7083,%rflags] v3 = ifcmp_imm v0, 0
|
||||
[Op2seti_abcd#490,%rax] v1 = trueif eq v3
|
||||
[RexOp2urm_noflags#4b6,%rax] v2 = bint.i32 v1
|
||||
[Op1brib#70] brif eq v3, ebb1
|
||||
[Op1ret#c3] return v2
|
||||
|
||||
ebb1:
|
||||
[Op2trap#40b] trap user0
|
||||
}
|
||||
28
cranelift/filetests/filetests/isa/x86/shrink.clif
Normal file
28
cranelift/filetests/filetests/isa/x86/shrink.clif
Normal file
@@ -0,0 +1,28 @@
|
||||
test binemit
|
||||
set opt_level=best
|
||||
target x86_64
|
||||
|
||||
; Test that instruction shrinking eliminates REX prefixes when possible.
|
||||
|
||||
; The binary encodings can be verified with the command:
|
||||
;
|
||||
; sed -ne 's/^ *; asm: *//p' filetests/isa/x86/shrink.clif | llvm-mc -show-encoding -triple=x86_64
|
||||
;
|
||||
|
||||
function %test_shrinking(i32) -> i32 {
|
||||
ebb0(v0: i32 [ %rdi ]):
|
||||
; asm: movl $0x2,%eax
|
||||
[-,%rcx] v1 = iconst.i32 2 ; bin: b9 00000002
|
||||
; asm: subl %ecx,%edi
|
||||
[-,%rdi] v2 = isub v0, v1 ; bin: 29 cf
|
||||
return v2
|
||||
}
|
||||
|
||||
function %test_not_shrinking(i32) -> i32 {
|
||||
ebb0(v0: i32 [ %r8 ]):
|
||||
; asm: movl $0x2,%eax
|
||||
[-,%rcx] v1 = iconst.i32 2 ; bin: b9 00000002
|
||||
; asm: subl %ecx,%edi
|
||||
[-,%r8] v2 = isub v0, v1 ; bin: 41 29 c8
|
||||
return v2
|
||||
}
|
||||
45
cranelift/filetests/filetests/isa/x86/stack-addr64.clif
Normal file
45
cranelift/filetests/filetests/isa/x86/stack-addr64.clif
Normal file
@@ -0,0 +1,45 @@
|
||||
; binary emission of stack address instructions on x86-64.
|
||||
test binemit
|
||||
set opt_level=fastest
|
||||
target x86_64 haswell
|
||||
|
||||
; The binary encodings can be verified with the command:
|
||||
;
|
||||
; sed -ne 's/^ *; asm: *//p' filetests/isa/x86/stack-addr64.clif | llvm-mc -show-encoding -triple=x86_64
|
||||
;
|
||||
|
||||
function %stack_addr() {
|
||||
ss0 = incoming_arg 8, offset 0
|
||||
ss1 = incoming_arg 1024, offset -1024
|
||||
ss2 = incoming_arg 1024, offset -2048
|
||||
ss3 = incoming_arg 8, offset -2056
|
||||
ss4 = explicit_slot 8, offset 0
|
||||
ss5 = explicit_slot 8, offset 1024
|
||||
|
||||
ebb0:
|
||||
[-,%rcx] v0 = stack_addr.i64 ss0 ; bin: 48 8d 8c 24 00000808
|
||||
[-,%rcx] v1 = stack_addr.i64 ss1 ; bin: 48 8d 8c 24 00000408
|
||||
[-,%rcx] v2 = stack_addr.i64 ss2 ; bin: 48 8d 8c 24 00000008
|
||||
[-,%rcx] v3 = stack_addr.i64 ss3 ; bin: 48 8d 8c 24 00000000
|
||||
[-,%rcx] v4 = stack_addr.i64 ss4 ; bin: 48 8d 8c 24 00000808
|
||||
[-,%rcx] v5 = stack_addr.i64 ss5 ; bin: 48 8d 8c 24 00000c08
|
||||
|
||||
[-,%rcx] v20 = stack_addr.i64 ss4+1 ; bin: 48 8d 8c 24 00000809
|
||||
[-,%rcx] v21 = stack_addr.i64 ss4+2 ; bin: 48 8d 8c 24 0000080a
|
||||
[-,%rcx] v22 = stack_addr.i64 ss4+2048 ; bin: 48 8d 8c 24 00001008
|
||||
[-,%rcx] v23 = stack_addr.i64 ss4-4096 ; bin: 48 8d 8c 24 fffff808
|
||||
|
||||
[-,%r8] v50 = stack_addr.i64 ss0 ; bin: 4c 8d 84 24 00000808
|
||||
[-,%r8] v51 = stack_addr.i64 ss1 ; bin: 4c 8d 84 24 00000408
|
||||
[-,%r8] v52 = stack_addr.i64 ss2 ; bin: 4c 8d 84 24 00000008
|
||||
[-,%r8] v53 = stack_addr.i64 ss3 ; bin: 4c 8d 84 24 00000000
|
||||
[-,%r8] v54 = stack_addr.i64 ss4 ; bin: 4c 8d 84 24 00000808
|
||||
[-,%r8] v55 = stack_addr.i64 ss5 ; bin: 4c 8d 84 24 00000c08
|
||||
|
||||
[-,%r8] v70 = stack_addr.i64 ss4+1 ; bin: 4c 8d 84 24 00000809
|
||||
[-,%r8] v71 = stack_addr.i64 ss4+2 ; bin: 4c 8d 84 24 0000080a
|
||||
[-,%r8] v72 = stack_addr.i64 ss4+2048 ; bin: 4c 8d 84 24 00001008
|
||||
[-,%r8] v73 = stack_addr.i64 ss4-4096 ; bin: 4c 8d 84 24 fffff808
|
||||
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
; legalization of stack load and store instructions on x86-64.
|
||||
test legalizer
|
||||
set opt_level=fastest
|
||||
target x86_64 haswell
|
||||
|
||||
function %stack_load_and_store() {
|
||||
ss0 = explicit_slot 8, offset 0
|
||||
|
||||
ebb0:
|
||||
v0 = stack_load.i64 ss0
|
||||
|
||||
; check: v1 = stack_addr.i64 ss0
|
||||
; check: v0 = load.i64 notrap aligned v1
|
||||
|
||||
stack_store.i64 v0, ss0
|
||||
|
||||
; check: v2 = stack_addr.i64 ss0
|
||||
; check: store notrap aligned v0, v2
|
||||
|
||||
return
|
||||
}
|
||||
14
cranelift/filetests/filetests/isa/x86/uextend-i8-to-i16.clif
Normal file
14
cranelift/filetests/filetests/isa/x86/uextend-i8-to-i16.clif
Normal file
@@ -0,0 +1,14 @@
|
||||
test compile
|
||||
target x86_64
|
||||
|
||||
function u0:0(i8) -> i16 fast {
|
||||
ebb0(v0: i8):
|
||||
v1 = uextend.i16 v0
|
||||
return v1
|
||||
}
|
||||
|
||||
function u0:1(i8) -> i16 fast {
|
||||
ebb0(v0: i8):
|
||||
v1 = sextend.i16 v0
|
||||
return v1
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
test compile
|
||||
set opt_level=best
|
||||
set is_pic
|
||||
target x86_64 haswell
|
||||
|
||||
; check if for one arg we use the right register
|
||||
function %one_arg(i64) windows_fastcall {
|
||||
ebb0(v0: i64):
|
||||
return
|
||||
}
|
||||
; check: function %one_arg(i64 [%rcx], i64 fp [%rbp]) -> i64 fp [%rbp] windows_fastcall {
|
||||
; nextln: ss0 = incoming_arg 16, offset -48
|
||||
|
||||
; check if we still use registers for 4 arguments
|
||||
function %four_args(i64, i64, i64, i64) windows_fastcall {
|
||||
ebb0(v0: i64, v1: i64, v2: i64, v3: i64):
|
||||
return
|
||||
}
|
||||
; check: function %four_args(i64 [%rcx], i64 [%rdx], i64 [%r8], i64 [%r9], i64 fp [%rbp]) -> i64 fp [%rbp] windows_fastcall {
|
||||
|
||||
; check if float arguments are passed through XMM registers
|
||||
function %four_float_args(f64, f64, f64, f64) windows_fastcall {
|
||||
ebb0(v0: f64, v1: f64, v2: f64, v3: f64):
|
||||
return
|
||||
}
|
||||
; check: function %four_float_args(f64 [%xmm0], f64 [%xmm1], f64 [%xmm2], f64 [%xmm3], i64 fp [%rbp]) -> i64 fp [%rbp] windows_fastcall {
|
||||
|
||||
; check if we use stack space for > 4 arguments
|
||||
function %five_args(i64, i64, i64, i64, i64) windows_fastcall {
|
||||
ebb0(v0: i64, v1: i64, v2: i64, v3: i64, v4: i64):
|
||||
return
|
||||
}
|
||||
; check: function %five_args(i64 [%rcx], i64 [%rdx], i64 [%r8], i64 [%r9], i64 [32], i64 fp [%rbp]) -> i64 fp [%rbp] windows_fastcall {
|
||||
206
cranelift/filetests/filetests/legalizer/bitrev.clif
Normal file
206
cranelift/filetests/filetests/legalizer/bitrev.clif
Normal file
@@ -0,0 +1,206 @@
|
||||
test legalizer
|
||||
target x86_64
|
||||
|
||||
function %reverse_bits_8(i8) -> i8 {
|
||||
ebb0(v0: i8):
|
||||
v1 = bitrev.i8 v0
|
||||
return v1
|
||||
}
|
||||
; check: v16 = uextend.i32 v0
|
||||
; check: v17 = band_imm v16, 170
|
||||
; check: v2 = ireduce.i8 v17
|
||||
; check: v18 = uextend.i32 v2
|
||||
; check: v19 = ushr_imm v18, 1
|
||||
; check: v3 = ireduce.i8 v19
|
||||
; check: v20 = uextend.i32 v0
|
||||
; check: v21 = band_imm v20, 85
|
||||
; check: v4 = ireduce.i8 v21
|
||||
; check: v22 = uextend.i32 v4
|
||||
; check: v23 = ishl_imm v22, 1
|
||||
; check: v5 = ireduce.i8 v23
|
||||
; check: v24 = uextend.i32 v3
|
||||
; check: v25 = uextend.i32 v5
|
||||
; check: v26 = bor v24, v25
|
||||
; check: v6 = ireduce.i8 v26
|
||||
; check: v27 = uextend.i32 v6
|
||||
; check: v28 = band_imm v27, 204
|
||||
; check: v7 = ireduce.i8 v28
|
||||
; check: v29 = uextend.i32 v7
|
||||
; check: v30 = ushr_imm v29, 2
|
||||
; check: v8 = ireduce.i8 v30
|
||||
; check: v31 = uextend.i32 v6
|
||||
; check: v32 = band_imm v31, 51
|
||||
; check: v9 = ireduce.i8 v32
|
||||
; check: v33 = uextend.i32 v9
|
||||
; check: v34 = ushr_imm v33, 2
|
||||
; check: v10 = ireduce.i8 v34
|
||||
; check: v35 = uextend.i32 v8
|
||||
; check: v36 = uextend.i32 v10
|
||||
; check: v37 = bor v35, v36
|
||||
; check: v11 = ireduce.i8 v37
|
||||
; check: v38 = uextend.i32 v11
|
||||
; check: v39 = band_imm v38, 240
|
||||
; check: v12 = ireduce.i8 v39
|
||||
; check: v40 = uextend.i32 v12
|
||||
; check: v41 = ushr_imm v40, 4
|
||||
; check: v13 = ireduce.i8 v41
|
||||
; check: v42 = uextend.i32 v11
|
||||
; check: v43 = band_imm v42, 15
|
||||
; check: v14 = ireduce.i8 v43
|
||||
; check: v44 = uextend.i32 v14
|
||||
; check: v45 = ishl_imm v44, 4
|
||||
; check: v15 = ireduce.i8 v45
|
||||
; check: v46 = uextend.i32 v13
|
||||
; check: v47 = uextend.i32 v15
|
||||
; check: v48 = bor v46, v47
|
||||
; check: v1 = ireduce.i8 v48
|
||||
; check: return v1
|
||||
|
||||
function %reverse_bits_16(i16) -> i16 {
|
||||
ebb0(v0: i16):
|
||||
v1 = bitrev.i16 v0
|
||||
return v1
|
||||
}
|
||||
; check: v21 = uextend.i32 v0
|
||||
; check: v22 = band_imm v21, 0xaaaa
|
||||
; check: v2 = ireduce.i16 v22
|
||||
; check: v23 = uextend.i32 v2
|
||||
; check: v24 = ushr_imm v23, 1
|
||||
; check: v3 = ireduce.i16 v24
|
||||
; check: v25 = uextend.i32 v0
|
||||
; check: v26 = band_imm v25, 0x5555
|
||||
; check: v4 = ireduce.i16 v26
|
||||
; check: v27 = uextend.i32 v4
|
||||
; check: v28 = ishl_imm v27, 1
|
||||
; check: v5 = ireduce.i16 v28
|
||||
; check: v29 = uextend.i32 v3
|
||||
; check: v30 = uextend.i32 v5
|
||||
; check: v31 = bor v29, v30
|
||||
; check: v6 = ireduce.i16 v31
|
||||
; check: v32 = uextend.i32 v6
|
||||
; check: v33 = band_imm v32, 0xcccc
|
||||
; check: v7 = ireduce.i16 v33
|
||||
; check: v34 = uextend.i32 v7
|
||||
; check: v35 = ushr_imm v34, 2
|
||||
; check: v8 = ireduce.i16 v35
|
||||
; check: v36 = uextend.i32 v6
|
||||
; check: v37 = band_imm v36, 0x3333
|
||||
; check: v9 = ireduce.i16 v37
|
||||
; check: v38 = uextend.i32 v9
|
||||
; check: v39 = ushr_imm v38, 2
|
||||
; check: v10 = ireduce.i16 v39
|
||||
; check: v40 = uextend.i32 v8
|
||||
; check: v41 = uextend.i32 v10
|
||||
; check: v42 = bor v40, v41
|
||||
; check: v11 = ireduce.i16 v42
|
||||
; check: v43 = uextend.i32 v11
|
||||
; check: v44 = band_imm v43, 0xf0f0
|
||||
; check: v12 = ireduce.i16 v44
|
||||
; check: v45 = uextend.i32 v12
|
||||
; check: v46 = ushr_imm v45, 4
|
||||
; check: v13 = ireduce.i16 v46
|
||||
; check: v47 = uextend.i32 v11
|
||||
; check: v48 = band_imm v47, 3855
|
||||
; check: v14 = ireduce.i16 v48
|
||||
; check: v49 = uextend.i32 v14
|
||||
; check: v50 = ishl_imm v49, 4
|
||||
; check: v15 = ireduce.i16 v50
|
||||
; check: v51 = uextend.i32 v13
|
||||
; check: v52 = uextend.i32 v15
|
||||
; check: v53 = bor v51, v52
|
||||
; check: v16 = ireduce.i16 v53
|
||||
; check: v54 = uextend.i32 v16
|
||||
; check: v55 = band_imm v54, 0xff00
|
||||
; check: v17 = ireduce.i16 v55
|
||||
; check: v56 = uextend.i32 v17
|
||||
; check: v57 = ushr_imm v56, 8
|
||||
; check: v18 = ireduce.i16 v57
|
||||
; check: v58 = uextend.i32 v16
|
||||
; check: v59 = band_imm v58, 255
|
||||
; check: v19 = ireduce.i16 v59
|
||||
; check: v60 = uextend.i32 v19
|
||||
; check: v61 = ishl_imm v60, 8
|
||||
; check: v20 = ireduce.i16 v61
|
||||
; check: v62 = uextend.i32 v18
|
||||
; check: v63 = uextend.i32 v20
|
||||
; check: v64 = bor v62, v63
|
||||
; check: v1 = ireduce.i16 v64
|
||||
; check: return v1
|
||||
|
||||
function %reverse_bits_32(i32) -> i32 {
|
||||
ebb0(v0: i32):
|
||||
v1 = bitrev.i32 v0
|
||||
return v1
|
||||
}
|
||||
; check: v24 = iconst.i32 0xaaaa_aaaa
|
||||
; check: v2 = band v0, v24
|
||||
; check: v3 = ushr_imm v2, 1
|
||||
; check: v4 = band_imm v0, 0x5555_5555
|
||||
; check: v5 = ishl_imm v4, 1
|
||||
; check: v6 = bor v3, v5
|
||||
; check: v25 = iconst.i32 0xcccc_cccc
|
||||
; check: v7 = band v6, v25
|
||||
; check: v8 = ushr_imm v7, 2
|
||||
; check: v9 = band_imm v6, 0x3333_3333
|
||||
; check: v10 = ushr_imm v9, 2
|
||||
; check: v11 = bor v8, v10
|
||||
; check: v26 = iconst.i32 0xf0f0_f0f0
|
||||
; check: v12 = band v11, v26
|
||||
; check: v13 = ushr_imm v12, 4
|
||||
; check: v14 = band_imm v11, 0x0f0f_0f0f
|
||||
; check: v15 = ishl_imm v14, 4
|
||||
; check: v16 = bor v13, v15
|
||||
; check: v27 = iconst.i32 0xff00_ff00
|
||||
; check: v17 = band v16, v27
|
||||
; check: v18 = ushr_imm v17, 8
|
||||
; check: v19 = band_imm v16, 0x00ff_00ff
|
||||
; check: v20 = ishl_imm v19, 8
|
||||
; check: v21 = bor v18, v20
|
||||
; check: v22 = ushr_imm v21, 16
|
||||
; check: v23 = ishl_imm v21, 16
|
||||
; check: v1 = bor v22, v23
|
||||
|
||||
|
||||
function %reverse_bits_64(i64) -> i64 {
|
||||
ebb0(v0: i64):
|
||||
v1 = bitrev.i64 v0
|
||||
return v1
|
||||
}
|
||||
; check: v29 = iconst.i64 0xaaaa_aaaa_aaaa_aaaa
|
||||
; check: v2 = band v0, v29
|
||||
; check: v3 = ushr_imm v2, 1
|
||||
; check: v30 = iconst.i64 0x5555_5555_5555_5555
|
||||
; check: v4 = band v0, v30
|
||||
; check: v5 = ishl_imm v4, 1
|
||||
; check: v6 = bor v3, v5
|
||||
; check: v31 = iconst.i64 0xcccc_cccc_cccc_cccc
|
||||
; check: v7 = band v6, v31
|
||||
; check: v8 = ushr_imm v7, 2
|
||||
; check: v32 = iconst.i64 0x3333_3333_3333_3333
|
||||
; check: v9 = band v6, v32
|
||||
; check: v10 = ushr_imm v9, 2
|
||||
; check: v11 = bor v8, v10
|
||||
; check: v33 = iconst.i64 0xf0f0_f0f0_f0f0_f0f0
|
||||
; check: v12 = band v11, v33
|
||||
; check: v13 = ushr_imm v12, 4
|
||||
; check: v34 = iconst.i64 0x0f0f_0f0f_0f0f_0f0f
|
||||
; check: v14 = band v11, v34
|
||||
; check: v15 = ishl_imm v14, 4
|
||||
; check: v16 = bor v13, v15
|
||||
; check: v35 = iconst.i64 0xff00_ff00_ff00_ff00
|
||||
; check: v17 = band v16, v35
|
||||
; check: v18 = ushr_imm v17, 8
|
||||
; check: v36 = iconst.i64 0x00ff_00ff_00ff_00ff
|
||||
; check: v19 = band v16, v36
|
||||
; check: v20 = ishl_imm v19, 8
|
||||
; check: v21 = bor v18, v20
|
||||
; check: v37 = iconst.i64 0xffff_0000_ffff_0000
|
||||
; check: v22 = band v21, v37
|
||||
; check: v23 = ushr_imm v22, 16
|
||||
; check: v38 = iconst.i64 0xffff_0000_ffff
|
||||
; check: v24 = band v21, v38
|
||||
; check: v25 = ishl_imm v24, 16
|
||||
; check: v26 = bor v23, v25
|
||||
; check: v27 = ushr_imm v26, 32
|
||||
; check: v28 = ishl_imm v26, 32
|
||||
; check: v1 = bor v27, v28
|
||||
40
cranelift/filetests/filetests/legalizer/br_table_cond.clif
Normal file
40
cranelift/filetests/filetests/legalizer/br_table_cond.clif
Normal file
@@ -0,0 +1,40 @@
|
||||
test legalizer
|
||||
set probestack_enabled=false
|
||||
set jump_tables_enabled=false
|
||||
target x86_64
|
||||
|
||||
; Test that when jump_tables_enables is false, all jump tables are eliminated.
|
||||
|
||||
function u0:0(i64 vmctx) baldrdash {
|
||||
gv0 = vmctx
|
||||
gv1 = iadd_imm.i64 gv0, 48
|
||||
jt0 = jump_table [ebb2, ebb2, ebb7]
|
||||
jt1 = jump_table [ebb8, ebb8]
|
||||
|
||||
ebb0(v0: i64):
|
||||
jump ebb5
|
||||
|
||||
ebb5:
|
||||
v1 = global_value.i64 gv1
|
||||
v2 = load.i64 v1
|
||||
trapnz v2, interrupt
|
||||
v3 = iconst.i32 0
|
||||
br_table v3, ebb3, jt0
|
||||
|
||||
ebb7:
|
||||
v4 = iconst.i32 0
|
||||
br_table v4, ebb3, jt1
|
||||
|
||||
ebb8:
|
||||
jump ebb5
|
||||
|
||||
ebb3:
|
||||
jump ebb2
|
||||
|
||||
ebb2:
|
||||
jump ebb1
|
||||
|
||||
ebb1:
|
||||
fallthrough_return
|
||||
}
|
||||
; not: jump_table
|
||||
11
cranelift/filetests/filetests/legalizer/bxor_imm.clif
Normal file
11
cranelift/filetests/filetests/legalizer/bxor_imm.clif
Normal file
@@ -0,0 +1,11 @@
|
||||
test legalizer
|
||||
target x86_64
|
||||
|
||||
function %foo(i64, i64) -> i64 {
|
||||
ebb0(v0: i64, v1: i64):
|
||||
v2 = bxor_imm.i64 v0, 0x100000000
|
||||
return v2
|
||||
}
|
||||
|
||||
; check: v3 = iconst.i64 0x0001_0000_0000
|
||||
; check: v2 = bxor v0, v3
|
||||
35
cranelift/filetests/filetests/licm/basic.clif
Normal file
35
cranelift/filetests/filetests/licm/basic.clif
Normal file
@@ -0,0 +1,35 @@
|
||||
test licm
|
||||
target riscv32
|
||||
|
||||
function %simple_loop(i32) -> i32 {
|
||||
|
||||
ebb0(v0: i32):
|
||||
jump ebb1(v0)
|
||||
|
||||
ebb1(v1: i32):
|
||||
v2 = iconst.i32 1
|
||||
v3 = iconst.i32 2
|
||||
v4 = iadd v2, v3
|
||||
brz v1, ebb2(v1)
|
||||
v5 = isub v1, v2
|
||||
jump ebb1(v5)
|
||||
|
||||
ebb2(v6: i32):
|
||||
return v6
|
||||
|
||||
}
|
||||
; sameln: function %simple_loop
|
||||
; nextln: ebb0(v0: i32):
|
||||
; nextln: v2 = iconst.i32 1
|
||||
; nextln: v3 = iconst.i32 2
|
||||
; nextln: v4 = iadd v2, v3
|
||||
; nextln: jump ebb1(v0)
|
||||
; nextln:
|
||||
; nextln: ebb1(v1: i32):
|
||||
; nextln: brz v1, ebb2(v1)
|
||||
; nextln: v5 = isub v1, v2
|
||||
; nextln: jump ebb1(v5)
|
||||
; nextln:
|
||||
; nextln: ebb2(v6: i32):
|
||||
; nextln: return v6
|
||||
; nextln: }
|
||||
90
cranelift/filetests/filetests/licm/complex.clif
Normal file
90
cranelift/filetests/filetests/licm/complex.clif
Normal file
@@ -0,0 +1,90 @@
|
||||
test licm
|
||||
target riscv32
|
||||
|
||||
function %complex(i32) -> i32 system_v {
|
||||
ebb0(v0: i32):
|
||||
[UJ#1b] jump ebb1(v0)
|
||||
|
||||
ebb1(v1: i32):
|
||||
v2 = iconst.i32 1
|
||||
v3 = iconst.i32 4
|
||||
v4 = iadd v2, v1
|
||||
[SBzero#18] brz v1, ebb2(v2)
|
||||
[UJ#1b] jump ebb4(v4)
|
||||
|
||||
ebb2(v5: i32):
|
||||
v6 = iconst.i32 2
|
||||
v7 = iadd v5, v4
|
||||
v8 = iadd v6, v1
|
||||
[UJ#1b] jump ebb3(v8)
|
||||
|
||||
ebb3(v9: i32):
|
||||
v10 = iadd v9, v5
|
||||
v11 = iadd.i32 v1, v4
|
||||
[SBzero#18] brz.i32 v1, ebb2(v9)
|
||||
[UJ#1b] jump ebb6(v10)
|
||||
|
||||
ebb4(v12: i32):
|
||||
v13 = iconst.i32 3
|
||||
v14 = iadd v12, v13
|
||||
v15 = iadd.i32 v4, v13
|
||||
[UJ#1b] jump ebb5(v13)
|
||||
|
||||
ebb5(v16: i32):
|
||||
v17 = iadd.i32 v14, v4
|
||||
[SBzero#18] brz.i32 v1, ebb4(v16)
|
||||
[UJ#1b] jump ebb6(v16)
|
||||
|
||||
ebb6(v18: i32):
|
||||
v19 = iadd v18, v2
|
||||
v20 = iadd.i32 v2, v3
|
||||
[SBzero#18] brz.i32 v1, ebb1(v20)
|
||||
[Iret#19] return v19
|
||||
}
|
||||
|
||||
; sameln: function %complex
|
||||
; nextln: ebb0(v0: i32):
|
||||
; nextln: v2 = iconst.i32 1
|
||||
; nextln: v3 = iconst.i32 4
|
||||
; nextln: v6 = iconst.i32 2
|
||||
; nextln: v13 = iconst.i32 3
|
||||
; nextln: v20 = iadd v2, v3
|
||||
; nextln: jump ebb1(v0)
|
||||
; nextln:
|
||||
; nextln: ebb1(v1: i32):
|
||||
; nextln: v4 = iadd.i32 v2, v1
|
||||
; nextln: brz v1, ebb7(v2)
|
||||
; nextln: jump ebb8(v4)
|
||||
; nextln:
|
||||
; nextln: ebb7(v21: i32):
|
||||
; nextln: v8 = iadd.i32 v6, v1
|
||||
; nextln: v11 = iadd.i32 v1, v4
|
||||
; nextln: jump ebb2(v21)
|
||||
; nextln:
|
||||
; nextln: ebb2(v5: i32):
|
||||
; nextln: v7 = iadd v5, v4
|
||||
; nextln: jump ebb3(v8)
|
||||
; nextln:
|
||||
; nextln: ebb3(v9: i32):
|
||||
; nextln: v10 = iadd v9, v5
|
||||
; nextln: brz.i32 v1, ebb2(v9)
|
||||
; nextln: jump ebb6(v10)
|
||||
; nextln:
|
||||
; nextln: ebb8(v22: i32):
|
||||
; nextln: v15 = iadd.i32 v4, v13
|
||||
; nextln: jump ebb4(v22)
|
||||
; nextln:
|
||||
; nextln: ebb4(v12: i32):
|
||||
; nextln: v14 = iadd v12, v13
|
||||
; nextln: jump ebb5(v13)
|
||||
; nextln:
|
||||
; nextln: ebb5(v16: i32):
|
||||
; nextln: v17 = iadd.i32 v14, v4
|
||||
; nextln: brz.i32 v1, ebb4(v16)
|
||||
; nextln: jump ebb6(v16)
|
||||
; nextln:
|
||||
; nextln: ebb6(v18: i32):
|
||||
; nextln: v19 = iadd v18, v2
|
||||
; nextln: brz.i32 v1, ebb1(v20)
|
||||
; nextln: return v19
|
||||
; nextln: }
|
||||
42
cranelift/filetests/filetests/licm/critical-edge.clif
Normal file
42
cranelift/filetests/filetests/licm/critical-edge.clif
Normal file
@@ -0,0 +1,42 @@
|
||||
test licm
|
||||
target riscv32
|
||||
|
||||
; The loop in this function is entered from a critical edge.
|
||||
|
||||
function %critical_edge(i32, i32) -> i32 {
|
||||
|
||||
ebb0(v0: i32, v7: i32):
|
||||
[SBzero#38] brnz v7, ebb1(v0)
|
||||
[Iret#19] return v0
|
||||
|
||||
ebb1(v1: i32):
|
||||
v2 = iconst.i32 1
|
||||
v3 = iconst.i32 2
|
||||
v4 = iadd v2, v3
|
||||
[SBzero#18] brz v1, ebb2(v1)
|
||||
v5 = isub v1, v2
|
||||
[UJ#1b] jump ebb1(v5)
|
||||
|
||||
ebb2(v6: i32):
|
||||
[Iret#19] return v6
|
||||
|
||||
}
|
||||
; sameln: function %critical_edge
|
||||
; nextln: ebb0(v0: i32, v7: i32):
|
||||
; nextln: brnz v7, ebb3(v0)
|
||||
; nextln: return v0
|
||||
; nextln:
|
||||
; nextln: ebb3(v8: i32):
|
||||
; nextln: v2 = iconst.i32 1
|
||||
; nextln: v3 = iconst.i32 2
|
||||
; nextln: v4 = iadd v2, v3
|
||||
; nextln: jump ebb1(v8)
|
||||
; nextln:
|
||||
; nextln: ebb1(v1: i32):
|
||||
; nextln: brz v1, ebb2(v1)
|
||||
; nextln: v5 = isub v1, v2
|
||||
; nextln: jump ebb1(v5)
|
||||
; nextln:
|
||||
; nextln: ebb2(v6: i32):
|
||||
; nextln: return v6
|
||||
; nextln: }
|
||||
36
cranelift/filetests/filetests/licm/encoding.clif
Normal file
36
cranelift/filetests/filetests/licm/encoding.clif
Normal file
@@ -0,0 +1,36 @@
|
||||
test licm
|
||||
target riscv32
|
||||
|
||||
; Ensure that instructions emitted by LICM get encodings.
|
||||
|
||||
function %simple_loop(i32) -> i32 {
|
||||
ebb0(v0: i32):
|
||||
[UJ#1b] jump ebb1(v0)
|
||||
|
||||
ebb1(v1: i32):
|
||||
[Iz#04,%x0] v2 = iconst.i32 1
|
||||
[Iz#04,%x1] v3 = iconst.i32 2
|
||||
[R#0c,%x2] v4 = iadd v2, v3
|
||||
[SBzero#18] brz v1, ebb2(v1)
|
||||
[R#200c,%x5] v5 = isub v1, v2
|
||||
[UJ#1b] jump ebb1(v5)
|
||||
|
||||
ebb2(v6: i32):
|
||||
[Iret#19] return v6
|
||||
}
|
||||
|
||||
; check: function
|
||||
; nextln: ebb0(v0: i32):
|
||||
; nextln: [Iz#04,%x0] v2 = iconst.i32 1
|
||||
; nextln: [Iz#04,%x1] v3 = iconst.i32 2
|
||||
; nextln: [R#0c,%x2] v4 = iadd v2, v3
|
||||
; nextln: [UJ#1b] jump ebb1(v0)
|
||||
; nextln:
|
||||
; nextln: ebb1(v1: i32):
|
||||
; nextln: [SBzero#18] brz v1, ebb2(v1)
|
||||
; nextln: [R#200c,%x5] v5 = isub v1, v2
|
||||
; nextln: [UJ#1b] jump ebb1(v5)
|
||||
; nextln:
|
||||
; nextln: ebb2(v6: i32):
|
||||
; nextln: [Iret#19] return v6
|
||||
; nextln: }
|
||||
47
cranelift/filetests/filetests/licm/multiple-blocks.clif
Normal file
47
cranelift/filetests/filetests/licm/multiple-blocks.clif
Normal file
@@ -0,0 +1,47 @@
|
||||
test licm
|
||||
target riscv32
|
||||
|
||||
function %multiple_blocks(i32) -> i32 {
|
||||
|
||||
ebb0(v0: i32):
|
||||
jump ebb1(v0)
|
||||
|
||||
ebb1(v10: i32):
|
||||
v11 = iconst.i32 1
|
||||
v12 = iconst.i32 2
|
||||
v13 = iadd v11, v12
|
||||
brz v10, ebb2(v10)
|
||||
v15 = isub v10, v11
|
||||
brz v15, ebb3(v15)
|
||||
v14 = isub v10, v11
|
||||
jump ebb1(v14)
|
||||
|
||||
ebb2(v20: i32):
|
||||
return v20
|
||||
|
||||
ebb3(v30: i32):
|
||||
v31 = iadd v11, v13
|
||||
jump ebb1(v30)
|
||||
|
||||
}
|
||||
; sameln:function %multiple_blocks(i32) -> i32 {
|
||||
; nextln: ebb0(v0: i32):
|
||||
; nextln: v11 = iconst.i32 1
|
||||
; nextln: v12 = iconst.i32 2
|
||||
; nextln: v13 = iadd v11, v12
|
||||
; nextln: v31 = iadd v11, v13
|
||||
; nextln: jump ebb1(v0)
|
||||
; nextln:
|
||||
; nextln: ebb1(v10: i32):
|
||||
; nextln: brz v10, ebb2(v10)
|
||||
; nextln: v15 = isub v10, v11
|
||||
; nextln: brz v15, ebb3(v15)
|
||||
; nextln: v14 = isub v10, v11
|
||||
; nextln: jump ebb1(v14)
|
||||
; nextln:
|
||||
; nextln: ebb2(v20: i32):
|
||||
; nextln: return v20
|
||||
; nextln:
|
||||
; nextln: ebb3(v30: i32):
|
||||
; nextln: jump ebb1(v30)
|
||||
; nextln: }
|
||||
56
cranelift/filetests/filetests/licm/nested_loops.clif
Normal file
56
cranelift/filetests/filetests/licm/nested_loops.clif
Normal file
@@ -0,0 +1,56 @@
|
||||
test licm
|
||||
target riscv32
|
||||
|
||||
function %nested_loops(i32) -> i32 {
|
||||
|
||||
ebb0(v0: i32):
|
||||
jump ebb1(v0)
|
||||
|
||||
ebb1(v1: i32):
|
||||
v2 = iconst.i32 1
|
||||
v3 = iconst.i32 2
|
||||
v4 = iadd v2, v3
|
||||
v5 = isub v1, v2
|
||||
jump ebb2(v5, v5)
|
||||
|
||||
ebb2(v10: i32, v11: i32):
|
||||
brz v11, ebb3(v10)
|
||||
v12 = iconst.i32 1
|
||||
v15 = iadd v12, v5
|
||||
v13 = isub v11, v12
|
||||
jump ebb2(v10,v13)
|
||||
|
||||
ebb3(v20: i32):
|
||||
brz v20, ebb4(v20)
|
||||
jump ebb1(v20)
|
||||
|
||||
ebb4(v30: i32):
|
||||
return v30
|
||||
|
||||
}
|
||||
|
||||
; sameln:function %nested_loops(i32) -> i32 {
|
||||
; nextln: ebb0(v0: i32):
|
||||
; nextln: v2 = iconst.i32 1
|
||||
; nextln: v3 = iconst.i32 2
|
||||
; nextln: v4 = iadd v2, v3
|
||||
; nextln: v12 = iconst.i32 1
|
||||
; nextln: jump ebb1(v0)
|
||||
; nextln:
|
||||
; nextln: ebb1(v1: i32):
|
||||
; nextln: v5 = isub v1, v2
|
||||
; nextln: v15 = iadd.i32 v12, v5
|
||||
; nextln: jump ebb2(v5, v5)
|
||||
; nextln:
|
||||
; nextln: ebb2(v10: i32, v11: i32):
|
||||
; nextln: brz v11, ebb3(v10)
|
||||
; nextln: v13 = isub v11, v12
|
||||
; nextln: jump ebb2(v10, v13)
|
||||
; nextln:
|
||||
; nextln: ebb3(v20: i32):
|
||||
; nextln: brz v20, ebb4(v20)
|
||||
; nextln: jump ebb1(v20)
|
||||
; nextln:
|
||||
; nextln: ebb4(v30: i32):
|
||||
; nextln: return v30
|
||||
; nextln: }
|
||||
82
cranelift/filetests/filetests/licm/reject.clif
Normal file
82
cranelift/filetests/filetests/licm/reject.clif
Normal file
@@ -0,0 +1,82 @@
|
||||
test licm
|
||||
target riscv32
|
||||
|
||||
function %other_side_effects(i32) -> i32 {
|
||||
|
||||
ebb0(v0: i32):
|
||||
jump ebb1(v0)
|
||||
|
||||
ebb1(v1: i32):
|
||||
regmove.i32 v0, %x10 -> %x20
|
||||
; check: ebb1(v1: i32):
|
||||
; check: regmove.i32 v0, %x10 -> %x20
|
||||
v2 = iconst.i32 1
|
||||
brz v1, ebb2(v1)
|
||||
v5 = isub v1, v2
|
||||
jump ebb1(v5)
|
||||
|
||||
ebb2(v6: i32):
|
||||
return v6
|
||||
|
||||
}
|
||||
|
||||
function %cpu_flags(i32, i32) -> i32 {
|
||||
ebb0(v0: i32, v1: i32):
|
||||
jump ebb1(v0, v1)
|
||||
|
||||
ebb1(v2: i32, v3: i32):
|
||||
v4 = ifcmp.i32 v0, v1
|
||||
v5 = selectif.i32 eq v4, v2, v3
|
||||
; check: ebb1(v2: i32, v3: i32):
|
||||
; check: ifcmp.i32 v0, v1
|
||||
; check: v5 = selectif.i32 eq v4, v2, v3
|
||||
v8 = iconst.i32 1
|
||||
brz v1, ebb2(v1)
|
||||
v9 = isub v1, v8
|
||||
v10 = iadd v1, v8
|
||||
jump ebb1(v9, v10)
|
||||
|
||||
ebb2(v6: i32):
|
||||
return v6
|
||||
}
|
||||
|
||||
function %spill(i32, i32) -> i32 {
|
||||
ebb0(v0: i32, v1: i32):
|
||||
v2 = spill.i32 v0
|
||||
jump ebb1(v0, v1)
|
||||
|
||||
ebb1(v3: i32, v4: i32):
|
||||
v5 = spill.i32 v1
|
||||
v6 = fill.i32 v2
|
||||
v7 = fill.i32 v5
|
||||
; check: ebb1(v3: i32, v4: i32):
|
||||
; check: v5 = spill.i32 v1
|
||||
; check: v6 = fill.i32 v2
|
||||
; check: v7 = fill v5
|
||||
brz v1, ebb2(v1)
|
||||
v9 = isub v1, v4
|
||||
jump ebb1(v9, v3)
|
||||
|
||||
ebb2(v10: i32):
|
||||
return v10
|
||||
}
|
||||
|
||||
function %non_invariant_aliases(i32) -> i32 {
|
||||
|
||||
ebb0(v0: i32):
|
||||
jump ebb1(v0)
|
||||
|
||||
ebb1(v1: i32):
|
||||
v8 -> v1
|
||||
v9 -> v1
|
||||
v2 = iadd v8, v9
|
||||
; check: ebb1(v1: i32):
|
||||
; check: v2 = iadd v8, v9
|
||||
brz v1, ebb2(v1)
|
||||
v5 = isub v1, v2
|
||||
jump ebb1(v5)
|
||||
|
||||
ebb2(v6: i32):
|
||||
return v6
|
||||
|
||||
}
|
||||
32
cranelift/filetests/filetests/parser/alias.clif
Normal file
32
cranelift/filetests/filetests/parser/alias.clif
Normal file
@@ -0,0 +1,32 @@
|
||||
test cat
|
||||
test verifier
|
||||
|
||||
function %basic(i32, i32) -> i32 {
|
||||
ebb0(v0: i32, v1: i32):
|
||||
v2 -> v0
|
||||
v3 -> v1
|
||||
v4 = iadd.i32 v2, v3
|
||||
return v4
|
||||
}
|
||||
|
||||
function %transitive() -> i32 {
|
||||
ebb0:
|
||||
v0 = iconst.i32 0
|
||||
v1 -> v0
|
||||
v2 -> v1
|
||||
v3 -> v2
|
||||
v4 -> v3
|
||||
return v4
|
||||
}
|
||||
|
||||
function %duplicate(i32, i32) -> i32 {
|
||||
ebb0(v0: i32, v1: i32):
|
||||
v2 -> v0
|
||||
v2 -> v0
|
||||
v2 -> v0
|
||||
v3 -> v1
|
||||
v3 -> v1
|
||||
v3 -> v1
|
||||
v4 = iadd.i32 v2, v3
|
||||
return v4
|
||||
}
|
||||
116
cranelift/filetests/filetests/parser/branch.clif
Normal file
116
cranelift/filetests/filetests/parser/branch.clif
Normal file
@@ -0,0 +1,116 @@
|
||||
; Parsing branches and jumps.
|
||||
test cat
|
||||
|
||||
; Jumps with no arguments. The '()' empty argument list is optional.
|
||||
function %minimal() {
|
||||
ebb0:
|
||||
jump ebb1
|
||||
|
||||
ebb1:
|
||||
jump ebb0()
|
||||
}
|
||||
; sameln: function %minimal() fast {
|
||||
; nextln: ebb0:
|
||||
; nextln: jump ebb1
|
||||
; nextln:
|
||||
; nextln: ebb1:
|
||||
; nextln: jump ebb0
|
||||
; nextln: }
|
||||
|
||||
; Jumps with 1 arg.
|
||||
function %onearg(i32) {
|
||||
ebb0(v90: i32):
|
||||
jump ebb1(v90)
|
||||
|
||||
ebb1(v91: i32):
|
||||
jump ebb0(v91)
|
||||
}
|
||||
; sameln: function %onearg(i32) fast {
|
||||
; nextln: ebb0(v90: i32):
|
||||
; nextln: jump ebb1(v90)
|
||||
; nextln:
|
||||
; nextln: ebb1(v91: i32):
|
||||
; nextln: jump ebb0(v91)
|
||||
; nextln: }
|
||||
|
||||
; Jumps with 2 args.
|
||||
function %twoargs(i32, f32) {
|
||||
ebb0(v90: i32, v91: f32):
|
||||
jump ebb1(v90, v91)
|
||||
|
||||
ebb1(v92: i32, v93: f32):
|
||||
jump ebb0(v92, v93)
|
||||
}
|
||||
; sameln: function %twoargs(i32, f32) fast {
|
||||
; nextln: ebb0(v90: i32, v91: f32):
|
||||
; nextln: jump ebb1(v90, v91)
|
||||
; nextln:
|
||||
; nextln: ebb1(v92: i32, v93: f32):
|
||||
; nextln: jump ebb0(v92, v93)
|
||||
; nextln: }
|
||||
|
||||
; Branches with no arguments. The '()' empty argument list is optional.
|
||||
function %minimal(i32) {
|
||||
ebb0(v90: i32):
|
||||
brz v90, ebb1
|
||||
|
||||
ebb1:
|
||||
brnz v90, ebb1()
|
||||
}
|
||||
; sameln: function %minimal(i32) fast {
|
||||
; nextln: ebb0(v90: i32):
|
||||
; nextln: brz v90, ebb1
|
||||
; nextln:
|
||||
; nextln: ebb1:
|
||||
; nextln: brnz.i32 v90, ebb1
|
||||
; nextln: }
|
||||
|
||||
function %twoargs(i32, f32) {
|
||||
ebb0(v90: i32, v91: f32):
|
||||
brz v90, ebb1(v90, v91)
|
||||
|
||||
ebb1(v92: i32, v93: f32):
|
||||
brnz v90, ebb0(v92, v93)
|
||||
}
|
||||
; sameln: function %twoargs(i32, f32) fast {
|
||||
; nextln: ebb0(v90: i32, v91: f32):
|
||||
; nextln: brz v90, ebb1(v90, v91)
|
||||
; nextln:
|
||||
; nextln: ebb1(v92: i32, v93: f32):
|
||||
; nextln: brnz.i32 v90, ebb0(v92, v93)
|
||||
; nextln: }
|
||||
|
||||
function %jumptable(i32) {
|
||||
jt200 = jump_table []
|
||||
jt2 = jump_table [ebb10, ebb40, ebb20, ebb30]
|
||||
|
||||
ebb10(v3: i32):
|
||||
br_table v3, ebb50, jt2
|
||||
|
||||
ebb20:
|
||||
trap user2
|
||||
ebb30:
|
||||
trap user3
|
||||
ebb40:
|
||||
trap user4
|
||||
ebb50:
|
||||
trap user1
|
||||
}
|
||||
; sameln: function %jumptable(i32) fast {
|
||||
; check: jt2 = jump_table [ebb10, ebb40, ebb20, ebb30]
|
||||
; check: jt200 = jump_table []
|
||||
; check: ebb10(v3: i32):
|
||||
; nextln: br_table v3, ebb50, jt2
|
||||
; nextln:
|
||||
; nextln: ebb20:
|
||||
; nextln: trap user2
|
||||
; nextln:
|
||||
; nextln: ebb30:
|
||||
; nextln: trap user3
|
||||
; nextln:
|
||||
; nextln: ebb40:
|
||||
; nextln: trap user4
|
||||
; nextln:
|
||||
; nextln: ebb50:
|
||||
; nextln: trap user1
|
||||
; nextln: }
|
||||
94
cranelift/filetests/filetests/parser/call.clif
Normal file
94
cranelift/filetests/filetests/parser/call.clif
Normal file
@@ -0,0 +1,94 @@
|
||||
; Parser tests for call and return syntax.
|
||||
test cat
|
||||
|
||||
function %mini() {
|
||||
ebb1:
|
||||
return
|
||||
}
|
||||
; sameln: function %mini() fast {
|
||||
; nextln: ebb1:
|
||||
; nextln: return
|
||||
; nextln: }
|
||||
|
||||
function %r1() -> i32, f32 baldrdash {
|
||||
ebb1:
|
||||
v1 = iconst.i32 3
|
||||
v2 = f32const 0.0
|
||||
return v1, v2
|
||||
}
|
||||
; sameln: function %r1() -> i32, f32 baldrdash {
|
||||
; nextln: ebb1:
|
||||
; nextln: v1 = iconst.i32 3
|
||||
; nextln: v2 = f32const 0.0
|
||||
; nextln: return v1, v2
|
||||
; nextln: }
|
||||
|
||||
function %signatures() {
|
||||
sig10 = ()
|
||||
sig11 = (i32, f64) -> i32, b1 baldrdash
|
||||
fn5 = %foo sig11
|
||||
fn8 = %bar(i32) -> b1
|
||||
}
|
||||
; sameln: function %signatures() fast {
|
||||
; check: sig10 = () fast
|
||||
; check: sig11 = (i32, f64) -> i32, b1 baldrdash
|
||||
; check: sig12 = (i32) -> b1 fast
|
||||
; not: fn0
|
||||
; check: fn5 = %foo sig11
|
||||
; check: fn8 = %bar sig12
|
||||
; check: }
|
||||
|
||||
function %direct() {
|
||||
fn0 = %none()
|
||||
fn1 = %one() -> i32
|
||||
fn2 = %two() -> i32, f32
|
||||
|
||||
ebb0:
|
||||
call fn0()
|
||||
v1 = call fn1()
|
||||
v2, v3 = call fn2()
|
||||
return
|
||||
}
|
||||
; check: call fn0()
|
||||
; check: v1 = call fn1()
|
||||
; check: v2, v3 = call fn2()
|
||||
; check: return
|
||||
|
||||
function %indirect(i64) {
|
||||
sig0 = (i64)
|
||||
sig1 = () -> i32
|
||||
sig2 = () -> i32, f32
|
||||
|
||||
ebb0(v0: i64):
|
||||
v1 = call_indirect sig1, v0()
|
||||
call_indirect sig0, v1(v0)
|
||||
v3, v4 = call_indirect sig2, v1()
|
||||
return
|
||||
}
|
||||
; check: v1 = call_indirect sig1, v0()
|
||||
; check: call_indirect sig0, v1(v0)
|
||||
; check: v3, v4 = call_indirect sig2, v1()
|
||||
; check: return
|
||||
|
||||
function %long_call() {
|
||||
sig0 = ()
|
||||
fn0 = %none sig0
|
||||
|
||||
ebb0:
|
||||
v0 = func_addr.i32 fn0
|
||||
call_indirect sig0, v0()
|
||||
return
|
||||
}
|
||||
; check: v0 = func_addr.i32 fn0
|
||||
; check: call_indirect sig0, v0()
|
||||
; check: return
|
||||
|
||||
; Special purpose function arguments
|
||||
function %special1(i32 sret, i32 fp, i32 csr, i32 link) -> i32 link, i32 fp, i32 csr, i32 sret {
|
||||
ebb0(v1: i32, v2: i32, v3: i32, v4: i32):
|
||||
return v4, v2, v3, v1
|
||||
}
|
||||
; check: function %special1(i32 sret, i32 fp, i32 csr, i32 link) -> i32 link, i32 fp, i32 csr, i32 sret fast {
|
||||
; check: ebb0(v1: i32, v2: i32, v3: i32, v4: i32):
|
||||
; check: return v4, v2, v3, v1
|
||||
; check: }
|
||||
46
cranelift/filetests/filetests/parser/flags.clif
Normal file
46
cranelift/filetests/filetests/parser/flags.clif
Normal file
@@ -0,0 +1,46 @@
|
||||
test cat
|
||||
test verifier
|
||||
|
||||
function %iflags(i32) {
|
||||
ebb200(v0: i32):
|
||||
v1 = ifcmp_imm v0, 17
|
||||
brif eq v1, ebb201
|
||||
brif ugt v1, ebb202
|
||||
v2 = iconst.i32 34
|
||||
v3 = ifcmp v0, v2
|
||||
v4 = trueif eq v3
|
||||
brnz v4, ebb202
|
||||
return
|
||||
|
||||
ebb201:
|
||||
return
|
||||
|
||||
ebb202:
|
||||
trap oob
|
||||
}
|
||||
; check: v1 = ifcmp_imm v0, 17
|
||||
; check: brif eq v1, ebb201
|
||||
; check: brif ugt v1, ebb202
|
||||
; check: v3 = ifcmp v0, v2
|
||||
; check: v4 = trueif eq v3
|
||||
|
||||
function %fflags(f32) {
|
||||
ebb200(v0: f32):
|
||||
v1 = f32const 0x34.0p0
|
||||
v2 = ffcmp v0, v1
|
||||
brff eq v2, ebb201
|
||||
brff ord v2, ebb202
|
||||
v3 = trueff gt v2
|
||||
brnz v3, ebb202
|
||||
return
|
||||
|
||||
ebb201:
|
||||
return
|
||||
|
||||
ebb202:
|
||||
trap oob
|
||||
}
|
||||
; check: v2 = ffcmp v0, v1
|
||||
; check: brff eq v2, ebb201
|
||||
; check: brff ord v2, ebb202
|
||||
; check: v3 = trueff gt v2
|
||||
@@ -0,0 +1,24 @@
|
||||
test cat
|
||||
|
||||
target riscv32
|
||||
|
||||
; regex: WS=[ \t]*
|
||||
|
||||
function %foo(i32, i32) {
|
||||
ebb1(v0: i32 [%x8], v1: i32):
|
||||
[-,-] v2 = iadd v0, v1
|
||||
[-] trap heap_oob
|
||||
[R#1234, %x5, %x11] v6, v7 = iadd_cout v2, v0
|
||||
[Rshamt#beef, %x25] v8 = ishl_imm v6, 2
|
||||
@55 v9 = iadd v8, v7
|
||||
@a5 [Iret#5] return v0, v8
|
||||
}
|
||||
; sameln: function %foo(i32, i32) fast {
|
||||
; nextln: ebb1(v0: i32 [%x8], v1: i32):
|
||||
; nextln: [-,-]$WS v2 = iadd v0, v1
|
||||
; nextln: [-]$WS trap heap_oob
|
||||
; nextln: [R#1234,%x5,%x11]$WS v6, v7 = iadd_cout v2, v0
|
||||
; nextln: [Rshamt#beef,%x25]$WS v8 = ishl_imm v6, 2
|
||||
; nextln: @0055 [-,-]$WS v9 = iadd v8, v7
|
||||
; nextln: @00a5 [Iret#05]$WS return v0, v8
|
||||
; nextln: }
|
||||
5
cranelift/filetests/filetests/parser/keywords.clif
Normal file
5
cranelift/filetests/filetests/parser/keywords.clif
Normal file
@@ -0,0 +1,5 @@
|
||||
test cat
|
||||
|
||||
; 'function' is not a keyword, and can be used as the name of a function too.
|
||||
function %function() {}
|
||||
; check: function %function() fast
|
||||
82
cranelift/filetests/filetests/parser/memory.clif
Normal file
82
cranelift/filetests/filetests/parser/memory.clif
Normal file
@@ -0,0 +1,82 @@
|
||||
test cat
|
||||
test verifier
|
||||
|
||||
function %vmglobal(i64 vmctx) -> i32 {
|
||||
gv3 = vmctx
|
||||
; check: gv3 = vmctx
|
||||
ebb0(v0: i64):
|
||||
v1 = global_value.i32 gv3
|
||||
; check: v1 = global_value.i32 gv3
|
||||
return v1
|
||||
}
|
||||
|
||||
function %load_and_add_imm(i64 vmctx) -> i32 {
|
||||
gv2 = vmctx
|
||||
gv3 = load.i32 notrap aligned gv2-72
|
||||
gv4 = iadd_imm.i32 gv3, -32
|
||||
; check: gv2 = vmctx
|
||||
; check: gv3 = load.i32 notrap aligned gv2-72
|
||||
; check: gv4 = iadd_imm.i32 gv3, -32
|
||||
ebb0(v0: i64):
|
||||
v1 = global_value.i32 gv4
|
||||
; check: v1 = global_value.i32 gv4
|
||||
return v1
|
||||
}
|
||||
|
||||
; Refer to a global value before it's been declared.
|
||||
function %backref(i64 vmctx) -> i32 {
|
||||
gv0 = iadd_imm.i32 gv1, -32
|
||||
; check: gv0 = iadd_imm.i32 gv1, -32
|
||||
gv1 = load.i32 notrap aligned gv2
|
||||
; check: gv1 = load.i32 notrap aligned gv2
|
||||
gv2 = vmctx
|
||||
; check: gv2 = vmctx
|
||||
ebb0(v0: i64):
|
||||
v1 = global_value.i32 gv1
|
||||
return v1
|
||||
}
|
||||
|
||||
function %symbol() -> i32 {
|
||||
gv0 = symbol %something
|
||||
; check: gv0 = symbol %something
|
||||
gv1 = symbol u8:9
|
||||
; check: gv1 = symbol u8:9
|
||||
ebb0:
|
||||
v0 = global_value.i32 gv0
|
||||
; check: v0 = global_value.i32 gv0
|
||||
v1 = global_value.i32 gv1
|
||||
; check: v1 = global_value.i32 gv1
|
||||
v2 = bxor v0, v1
|
||||
return v2
|
||||
}
|
||||
|
||||
; Declare static heaps.
|
||||
function %sheap(i32, i64 vmctx) -> i64 {
|
||||
heap1 = static gv5, min 0x1_0000, bound 0x1_0000_0000, offset_guard 0x8000_0000
|
||||
heap2 = static gv5, offset_guard 0x1000, bound 0x1_0000
|
||||
gv4 = vmctx
|
||||
gv5 = iadd_imm.i64 gv4, 64
|
||||
|
||||
; check: heap1 = static gv5, min 0x0001_0000, bound 0x0001_0000_0000, offset_guard 0x8000_0000
|
||||
; check: heap2 = static gv5, min 0, bound 0x0001_0000, offset_guard 4096
|
||||
ebb0(v1: i32, v2: i64):
|
||||
v3 = heap_addr.i64 heap1, v1, 0
|
||||
; check: v3 = heap_addr.i64 heap1, v1, 0
|
||||
return v3
|
||||
}
|
||||
|
||||
; Declare dynamic heaps.
|
||||
function %dheap(i32, i64 vmctx) -> i64 {
|
||||
heap1 = dynamic gv5, min 0x1_0000, bound gv6, offset_guard 0x8000_0000
|
||||
heap2 = dynamic gv5, bound gv6, offset_guard 0x1000
|
||||
gv4 = vmctx
|
||||
gv5 = iadd_imm.i64 gv4, 64
|
||||
gv6 = iadd_imm.i64 gv4, 72
|
||||
|
||||
; check: heap1 = dynamic gv5, min 0x0001_0000, bound gv6, offset_guard 0x8000_0000
|
||||
; check: heap2 = dynamic gv5, min 0, bound gv6, offset_guard 4096
|
||||
ebb0(v1: i32, v2: i64):
|
||||
v3 = heap_addr.i64 heap2, v1, 0
|
||||
; check: v3 = heap_addr.i64 heap2, v1, 0
|
||||
return v3
|
||||
}
|
||||
31
cranelift/filetests/filetests/parser/rewrite.clif
Normal file
31
cranelift/filetests/filetests/parser/rewrite.clif
Normal file
@@ -0,0 +1,31 @@
|
||||
; It is possible to refer to instructions and EBBs that have not yet been
|
||||
; defined in the lexical order.
|
||||
test cat
|
||||
|
||||
; Defining numbers.
|
||||
function %defs() {
|
||||
ebb100(v20: i32):
|
||||
v1000 = iconst.i32x8 5
|
||||
v9200 = f64const 0x4.0p0
|
||||
trap user4
|
||||
}
|
||||
; sameln: function %defs() fast {
|
||||
; nextln: ebb100(v20: i32):
|
||||
; nextln: v1000 = iconst.i32x8 5
|
||||
; nextln: v9200 = f64const 0x1.0000000000000p2
|
||||
; nextln: trap user4
|
||||
; nextln: }
|
||||
|
||||
; Using values.
|
||||
function %use_value() {
|
||||
ebb100(v20: i32):
|
||||
v1000 = iadd_imm v20, 5
|
||||
v200 = iadd v20, v1000
|
||||
jump ebb100(v1000)
|
||||
}
|
||||
; sameln: function %use_value() fast {
|
||||
; nextln: ebb100(v20: i32):
|
||||
; nextln: v1000 = iadd_imm v20, 5
|
||||
; nextln: v200 = iadd v20, v1000
|
||||
; nextln: jump ebb100(v1000)
|
||||
; nextln: }
|
||||
24
cranelift/filetests/filetests/parser/ternary.clif
Normal file
24
cranelift/filetests/filetests/parser/ternary.clif
Normal file
@@ -0,0 +1,24 @@
|
||||
test cat
|
||||
test verifier
|
||||
|
||||
function %add_i96(i32, i32, i32, i32, i32, i32) -> i32, i32, i32 {
|
||||
ebb1(v1: i32, v2: i32, v3: i32, v4: i32, v5: i32, v6: i32):
|
||||
v10, v11 = iadd_cout v1, v4
|
||||
;check: v10, v11 = iadd_cout v1, v4
|
||||
v20, v21 = iadd_carry v2, v5, v11
|
||||
; check: v20, v21 = iadd_carry v2, v5, v11
|
||||
v30 = iadd_cin v3, v6, v21
|
||||
; check: v30 = iadd_cin v3, v6, v21
|
||||
return v10, v20, v30
|
||||
}
|
||||
|
||||
function %sub_i96(i32, i32, i32, i32, i32, i32) -> i32, i32, i32 {
|
||||
ebb1(v1: i32, v2: i32, v3: i32, v4: i32, v5: i32, v6: i32):
|
||||
v10, v11 = isub_bout v1, v4
|
||||
;check: v10, v11 = isub_bout v1, v4
|
||||
v20, v21 = isub_borrow v2, v5, v11
|
||||
; check: v20, v21 = isub_borrow v2, v5, v11
|
||||
v30 = isub_bin v3, v6, v21
|
||||
; check: v30 = isub_bin v3, v6, v21
|
||||
return v10, v20, v30
|
||||
}
|
||||
241
cranelift/filetests/filetests/parser/tiny.clif
Normal file
241
cranelift/filetests/filetests/parser/tiny.clif
Normal file
@@ -0,0 +1,241 @@
|
||||
test cat
|
||||
|
||||
; The smallest possible function.
|
||||
function %minimal() {
|
||||
ebb0:
|
||||
trap user0
|
||||
}
|
||||
; sameln: function %minimal() fast {
|
||||
; nextln: ebb0:
|
||||
; nextln: trap user0
|
||||
; nextln: }
|
||||
|
||||
; Create and use values.
|
||||
; Polymorphic instructions with type suffix.
|
||||
function %ivalues() {
|
||||
ebb0:
|
||||
v0 = iconst.i32 2
|
||||
v1 = iconst.i8 6
|
||||
v2 = ishl v0, v1
|
||||
}
|
||||
; sameln: function %ivalues() fast {
|
||||
; nextln: ebb0:
|
||||
; nextln: v0 = iconst.i32 2
|
||||
; nextln: v1 = iconst.i8 6
|
||||
; nextln: v2 = ishl v0, v1
|
||||
; nextln: }
|
||||
|
||||
; Create and use values.
|
||||
; Polymorphic instructions with type suffix.
|
||||
function %bvalues() {
|
||||
ebb0:
|
||||
v0 = bconst.b32 true
|
||||
v1 = bconst.b8 false
|
||||
v2 = bextend.b32 v1
|
||||
v3 = bxor v0, v2
|
||||
}
|
||||
; sameln: function %bvalues() fast {
|
||||
; nextln: ebb0:
|
||||
; nextln: v0 = bconst.b32 true
|
||||
; nextln: v1 = bconst.b8 false
|
||||
; nextln: v2 = bextend.b32 v1
|
||||
; nextln: v3 = bxor v0, v2
|
||||
; nextln: }
|
||||
|
||||
; Polymorphic instruction controlled by second operand.
|
||||
function %select() {
|
||||
ebb0(v90: i32, v91: i32, v92: b1):
|
||||
v0 = select v92, v90, v91
|
||||
}
|
||||
; sameln: function %select() fast {
|
||||
; nextln: ebb0(v90: i32, v91: i32, v92: b1):
|
||||
; nextln: v0 = select v92, v90, v91
|
||||
; nextln: }
|
||||
|
||||
; Polymorphic instruction controlled by third operand.
|
||||
function %selectif() system_v {
|
||||
ebb0(v95: i32, v96: i32, v97: b1):
|
||||
v98 = selectif.i32 eq v97, v95, v96
|
||||
}
|
||||
; sameln: function %selectif() system_v {
|
||||
; nextln: ebb0(v95: i32, v96: i32, v97: b1):
|
||||
; nextln: v98 = selectif.i32 eq v97, v95, v96
|
||||
; nextln: }
|
||||
|
||||
; Lane indexes.
|
||||
function %lanes() {
|
||||
ebb0:
|
||||
v0 = iconst.i32x4 2
|
||||
v1 = extractlane v0, 3
|
||||
v2 = insertlane v0, 1, v1
|
||||
}
|
||||
; sameln: function %lanes() fast {
|
||||
; nextln: ebb0:
|
||||
; nextln: v0 = iconst.i32x4 2
|
||||
; nextln: v1 = extractlane v0, 3
|
||||
; nextln: v2 = insertlane v0, 1, v1
|
||||
; nextln: }
|
||||
|
||||
; Integer condition codes.
|
||||
function %icmp(i32, i32) {
|
||||
ebb0(v90: i32, v91: i32):
|
||||
v0 = icmp eq v90, v91
|
||||
v1 = icmp ult v90, v91
|
||||
v2 = icmp_imm sge v90, -12
|
||||
v3 = irsub_imm v91, 45
|
||||
br_icmp eq v90, v91, ebb0(v91, v90)
|
||||
}
|
||||
; sameln: function %icmp(i32, i32) fast {
|
||||
; nextln: ebb0(v90: i32, v91: i32):
|
||||
; nextln: v0 = icmp eq v90, v91
|
||||
; nextln: v1 = icmp ult v90, v91
|
||||
; nextln: v2 = icmp_imm sge v90, -12
|
||||
; nextln: v3 = irsub_imm v91, 45
|
||||
; nextln: br_icmp eq v90, v91, ebb0(v91, v90)
|
||||
; nextln: }
|
||||
|
||||
; Floating condition codes.
|
||||
function %fcmp(f32, f32) {
|
||||
ebb0(v90: f32, v91: f32):
|
||||
v0 = fcmp eq v90, v91
|
||||
v1 = fcmp uno v90, v91
|
||||
v2 = fcmp lt v90, v91
|
||||
}
|
||||
; sameln: function %fcmp(f32, f32) fast {
|
||||
; nextln: ebb0(v90: f32, v91: f32):
|
||||
; nextln: v0 = fcmp eq v90, v91
|
||||
; nextln: v1 = fcmp uno v90, v91
|
||||
; nextln: v2 = fcmp lt v90, v91
|
||||
; nextln: }
|
||||
|
||||
; The bitcast instruction has two type variables: The controlling type variable
|
||||
; controls the outout type, and the input type is a free variable.
|
||||
function %bitcast(i32, f32) {
|
||||
ebb0(v90: i32, v91: f32):
|
||||
v0 = bitcast.i8x4 v90
|
||||
v1 = bitcast.i32 v91
|
||||
}
|
||||
; sameln: function %bitcast(i32, f32) fast {
|
||||
; nextln: ebb0(v90: i32, v91: f32):
|
||||
; nextln: v0 = bitcast.i8x4 v90
|
||||
; nextln: v1 = bitcast.i32 v91
|
||||
; nextln: }
|
||||
|
||||
; Stack slot references
|
||||
function %stack() {
|
||||
ss10 = spill_slot 8
|
||||
ss2 = explicit_slot 4
|
||||
ss3 = incoming_arg 4, offset 8
|
||||
ss4 = outgoing_arg 4
|
||||
ss5 = emergency_slot 4
|
||||
|
||||
ebb0:
|
||||
v1 = stack_load.i32 ss10
|
||||
v2 = stack_load.i32 ss10+4
|
||||
stack_store v1, ss10+2
|
||||
stack_store v2, ss2
|
||||
}
|
||||
; sameln: function %stack() fast {
|
||||
; check: ss2 = explicit_slot 4
|
||||
; check: ss3 = incoming_arg 4, offset 8
|
||||
; check: ss4 = outgoing_arg 4
|
||||
; check: ss5 = emergency_slot 4
|
||||
; check: ss10 = spill_slot 8
|
||||
|
||||
; check: ebb0:
|
||||
; nextln: v1 = stack_load.i32 ss10
|
||||
; nextln: v2 = stack_load.i32 ss10+4
|
||||
; nextln: stack_store v1, ss10+2
|
||||
; nextln: stack_store v2, ss2
|
||||
|
||||
; Memory access instructions.
|
||||
function %memory(i32) {
|
||||
ebb0(v1: i32):
|
||||
v2 = load.i64 v1
|
||||
v3 = load.i64 aligned v1
|
||||
v4 = load.i64 notrap v1
|
||||
v5 = load.i64 notrap aligned v1
|
||||
v6 = load.i64 aligned notrap v1
|
||||
v7 = load.i64 v1-12
|
||||
v8 = load.i64 notrap v1+0x1_0000
|
||||
v9 = load_complex.i64 v1+v2
|
||||
v10 = load_complex.i64 v1+v2+0x1
|
||||
store v2, v1
|
||||
store aligned v3, v1+12
|
||||
store notrap aligned v3, v1-12
|
||||
store_complex v3, v1+v2
|
||||
store_complex v3, v1+v2+0x1
|
||||
}
|
||||
; sameln: function %memory(i32) fast {
|
||||
; nextln: ebb0(v1: i32):
|
||||
; nextln: v2 = load.i64 v1
|
||||
; nextln: v3 = load.i64 aligned v1
|
||||
; nextln: v4 = load.i64 notrap v1
|
||||
; nextln: v5 = load.i64 notrap aligned v1
|
||||
; nextln: v6 = load.i64 notrap aligned v1
|
||||
; nextln: v7 = load.i64 v1-12
|
||||
; nextln: v8 = load.i64 notrap v1+0x0001_0000
|
||||
; nextln: v9 = load_complex.i64 v1+v2
|
||||
; nextln: v10 = load_complex.i64 v1+v2+1
|
||||
; nextln: store v2, v1
|
||||
; nextln: store aligned v3, v1+12
|
||||
; nextln: store notrap aligned v3, v1-12
|
||||
; nextln: store_complex v3, v1+v2
|
||||
; nextln: store_complex v3, v1+v2+1
|
||||
|
||||
; Register diversions.
|
||||
; This test file has no ISA, so we can unly use register unit numbers.
|
||||
function %diversion(i32) {
|
||||
ss0 = spill_slot 4
|
||||
|
||||
ebb0(v1: i32):
|
||||
regmove v1, %10 -> %20
|
||||
regmove v1, %20 -> %10
|
||||
regspill v1, %10 -> ss0
|
||||
regfill v1, ss0 -> %10
|
||||
return
|
||||
}
|
||||
; sameln: function %diversion(i32) fast {
|
||||
; nextln: ss0 = spill_slot 4
|
||||
; check: ebb0(v1: i32):
|
||||
; nextln: regmove v1, %10 -> %20
|
||||
; nextln: regmove v1, %20 -> %10
|
||||
; nextln: regspill v1, %10 -> ss0
|
||||
; nextln: regfill v1, ss0 -> %10
|
||||
; nextln: return
|
||||
; nextln: }
|
||||
|
||||
; Register copies.
|
||||
function %copy_special() {
|
||||
ebb0:
|
||||
copy_special %10 -> %20
|
||||
copy_special %20 -> %10
|
||||
return
|
||||
}
|
||||
; sameln: function %copy_special() fast {
|
||||
; nextln: ebb0:
|
||||
; nextln: copy_special %10 -> %20
|
||||
; nextln: copy_special %20 -> %10
|
||||
; nextln: return
|
||||
; nextln: }
|
||||
|
||||
function %cond_traps(i32) {
|
||||
ebb0(v0: i32):
|
||||
trapz v0, stk_ovf
|
||||
v1 = ifcmp_imm v0, 5
|
||||
trapif ugt v1, oob
|
||||
v2 = bitcast.f32 v1
|
||||
v3 = ffcmp v2, v2
|
||||
trapff uno v3, int_ovf
|
||||
return
|
||||
}
|
||||
; sameln: function %cond_traps(i32)
|
||||
; nextln: ebb0(v0: i32):
|
||||
; nextln: trapz v0, stk_ovf
|
||||
; nextln: v1 = ifcmp_imm v0, 5
|
||||
; nextln: trapif ugt v1, oob
|
||||
; nextln: v2 = bitcast.f32 v1
|
||||
; nextln: v3 = ffcmp v2, v2
|
||||
; nextln: trapff uno v3, int_ovf
|
||||
; nextln: return
|
||||
; nextln: }
|
||||
100
cranelift/filetests/filetests/postopt/basic.clif
Normal file
100
cranelift/filetests/filetests/postopt/basic.clif
Normal file
@@ -0,0 +1,100 @@
|
||||
test postopt
|
||||
target i686
|
||||
|
||||
; Test that compare+branch sequences are folded effectively on x86.
|
||||
|
||||
function %br_icmp(i32, i32) -> i32 {
|
||||
ebb0(v0: i32, v1: i32):
|
||||
[Op1icscc#39,%rdx] v2 = icmp slt v0, v1
|
||||
[Op1t8jccd_long#85] brnz v2, ebb1
|
||||
[Op1ret#c3] return v1
|
||||
|
||||
ebb1:
|
||||
[Op1pu_id#b8,%rax] v8 = iconst.i32 3
|
||||
[Op1ret#c3] return v8
|
||||
}
|
||||
; sameln: function %br_icmp
|
||||
; nextln: ebb0(v0: i32, v1: i32):
|
||||
; nextln: v9 = ifcmp v0, v1
|
||||
; nextln: v2 = trueif slt v9
|
||||
; nextln: brif slt v9, ebb1
|
||||
; nextln: return v1
|
||||
; nextln:
|
||||
; nextln: ebb1:
|
||||
; nextln: v8 = iconst.i32 3
|
||||
; nextln: return v8
|
||||
; nextln: }
|
||||
|
||||
; Use brz instead of brnz, so the condition is inverted.
|
||||
|
||||
function %br_icmp_inverse(i32, i32) -> i32 {
|
||||
ebb0(v0: i32, v1: i32):
|
||||
[Op1icscc#39,%rdx] v2 = icmp slt v0, v1
|
||||
[Op1t8jccd_long#84] brz v2, ebb1
|
||||
[Op1ret#c3] return v1
|
||||
|
||||
ebb1:
|
||||
[Op1pu_id#b8,%rax] v8 = iconst.i32 3
|
||||
[Op1ret#c3] return v8
|
||||
}
|
||||
; sameln: function %br_icmp_inverse
|
||||
; nextln: ebb0(v0: i32, v1: i32):
|
||||
; nextln: v9 = ifcmp v0, v1
|
||||
; nextln: v2 = trueif slt v9
|
||||
; nextln: brif sge v9, ebb1
|
||||
; nextln: return v1
|
||||
; nextln:
|
||||
; nextln: ebb1:
|
||||
; nextln: v8 = iconst.i32 3
|
||||
; nextln: return v8
|
||||
; nextln: }
|
||||
|
||||
; Use icmp_imm instead of icmp.
|
||||
|
||||
function %br_icmp_imm(i32, i32) -> i32 {
|
||||
ebb0(v0: i32, v1: i32):
|
||||
[Op1icscc_ib#7083] v2 = icmp_imm slt v0, 2
|
||||
[Op1t8jccd_long#84] brz v2, ebb1
|
||||
[Op1ret#c3] return v1
|
||||
|
||||
ebb1:
|
||||
[Op1pu_id#b8,%rax] v8 = iconst.i32 3
|
||||
[Op1ret#c3] return v8
|
||||
}
|
||||
; sameln: function %br_icmp_imm
|
||||
; nextln: ebb0(v0: i32, v1: i32):
|
||||
; nextln: v9 = ifcmp_imm v0, 2
|
||||
; nextln: v2 = trueif slt v9
|
||||
; nextln: brif sge v9, ebb1
|
||||
; nextln: return v1
|
||||
; nextln:
|
||||
; nextln: ebb1:
|
||||
; nextln: v8 = iconst.i32 3
|
||||
; nextln: return v8
|
||||
; nextln: }
|
||||
|
||||
; Use fcmp instead of icmp.
|
||||
|
||||
function %br_fcmp(f32, f32) -> f32 {
|
||||
ebb0(v0: f32, v1: f32):
|
||||
[Op2fcscc#42e,%rdx] v2 = fcmp gt v0, v1
|
||||
[Op1t8jccd_long#84] brz v2, ebb1
|
||||
[Op1ret#c3] return v1
|
||||
|
||||
ebb1:
|
||||
[Op1pu_id#b8,%rax] v18 = iconst.i32 0x40a8_0000
|
||||
[Mp2frurm#56e,%xmm0] v8 = bitcast.f32 v18
|
||||
[Op1ret#c3] return v8
|
||||
}
|
||||
; sameln: function %br_fcmp
|
||||
; nextln: ebb0(v0: f32, v1: f32):
|
||||
; nextln: v19 = ffcmp v0, v1
|
||||
; nextln: v2 = trueff gt v19
|
||||
; nextln: brff ule v19, ebb1
|
||||
; nextln: return v1
|
||||
; nextln:
|
||||
; nextln: ebb1:
|
||||
; nextln: v18 = iconst.i32 0x40a8_0000
|
||||
; nextln: v8 = bitcast.f32 v18
|
||||
; nextln: return v8
|
||||
; nextln: }
|
||||
@@ -0,0 +1,94 @@
|
||||
test postopt
|
||||
target x86_64
|
||||
|
||||
function %dual_loads(i64, i64) -> i64 {
|
||||
ebb0(v0: i64, v1: i64):
|
||||
[RexOp1rr#8001] v3 = iadd v0, v1
|
||||
v4 = load.i64 v3
|
||||
v5 = uload8.i64 v3
|
||||
v6 = sload8.i64 v3
|
||||
v7 = uload16.i64 v3
|
||||
v8 = sload16.i64 v3
|
||||
v9 = uload32.i64 v3
|
||||
v10 = sload32.i64 v3
|
||||
[Op1ret#c3] return v10
|
||||
}
|
||||
|
||||
; sameln: function %dual_loads
|
||||
; nextln: ebb0(v0: i64, v1: i64):
|
||||
; nextln: v3 = iadd v0, v1
|
||||
; nextln: v4 = load_complex.i64 v0+v1
|
||||
; nextln: v5 = uload8_complex.i64 v0+v1
|
||||
; nextln: v6 = sload8_complex.i64 v0+v1
|
||||
; nextln: v7 = uload16_complex.i64 v0+v1
|
||||
; nextln: v8 = sload16_complex.i64 v0+v1
|
||||
; nextln: v9 = uload32_complex v0+v1
|
||||
; nextln: v10 = sload32_complex v0+v1
|
||||
; nextln: return v10
|
||||
; nextln: }
|
||||
|
||||
function %dual_loads2(i64, i64) -> i64 {
|
||||
ebb0(v0: i64, v1: i64):
|
||||
[RexOp1rr#8001] v3 = iadd v0, v1
|
||||
v4 = load.i64 v3+1
|
||||
v5 = uload8.i64 v3+1
|
||||
v6 = sload8.i64 v3+1
|
||||
v7 = uload16.i64 v3+1
|
||||
v8 = sload16.i64 v3+1
|
||||
v9 = uload32.i64 v3+1
|
||||
v10 = sload32.i64 v3+1
|
||||
[Op1ret#c3] return v10
|
||||
}
|
||||
|
||||
; sameln: function %dual_loads2
|
||||
; nextln: ebb0(v0: i64, v1: i64):
|
||||
; nextln: v3 = iadd v0, v1
|
||||
; nextln: v4 = load_complex.i64 v0+v1+1
|
||||
; nextln: v5 = uload8_complex.i64 v0+v1+1
|
||||
; nextln: v6 = sload8_complex.i64 v0+v1+1
|
||||
; nextln: v7 = uload16_complex.i64 v0+v1+1
|
||||
; nextln: v8 = sload16_complex.i64 v0+v1+1
|
||||
; nextln: v9 = uload32_complex v0+v1+1
|
||||
; nextln: v10 = sload32_complex v0+v1+1
|
||||
; nextln: return v10
|
||||
; nextln: }
|
||||
|
||||
function %dual_stores(i64, i64, i64) {
|
||||
ebb0(v0: i64, v1: i64, v2: i64):
|
||||
[RexOp1rr#8001] v3 = iadd v0, v1
|
||||
[RexOp1st#8089] store.i64 v2, v3
|
||||
[RexOp1st#88] istore8.i64 v2, v3
|
||||
[RexMp1st#189] istore16.i64 v2, v3
|
||||
[RexOp1st#89] istore32.i64 v2, v3
|
||||
[Op1ret#c3] return
|
||||
}
|
||||
|
||||
; sameln: function %dual_stores
|
||||
; nextln: ebb0(v0: i64, v1: i64, v2: i64):
|
||||
; nextln: v3 = iadd v0, v1
|
||||
; nextln: store_complex v2, v0+v1
|
||||
; nextln: istore8_complex v2, v0+v1
|
||||
; nextln: istore16_complex v2, v0+v1
|
||||
; nextln: istore32_complex v2, v0+v1
|
||||
; nextln: return
|
||||
; nextln: }
|
||||
|
||||
function %dual_stores2(i64, i64, i64) {
|
||||
ebb0(v0: i64, v1: i64, v2: i64):
|
||||
[RexOp1rr#8001] v3 = iadd v0, v1
|
||||
[RexOp1stDisp8#8089] store.i64 v2, v3+1
|
||||
[RexOp1stDisp8#88] istore8.i64 v2, v3+1
|
||||
[RexMp1stDisp8#189] istore16.i64 v2, v3+1
|
||||
[RexOp1stDisp8#89] istore32.i64 v2, v3+1
|
||||
[Op1ret#c3] return
|
||||
}
|
||||
|
||||
; sameln: function %dual_stores2
|
||||
; nextln: ebb0(v0: i64, v1: i64, v2: i64):
|
||||
; nextln: v3 = iadd v0, v1
|
||||
; nextln: store_complex v2, v0+v1+1
|
||||
; nextln: istore8_complex v2, v0+v1+1
|
||||
; nextln: istore16_complex v2, v0+v1+1
|
||||
; nextln: istore32_complex v2, v0+v1+1
|
||||
; nextln: return
|
||||
; nextln: }
|
||||
@@ -0,0 +1,32 @@
|
||||
test postopt
|
||||
target x86_64
|
||||
|
||||
; Fold the immediate of an iadd_imm into an address offset.
|
||||
|
||||
function u0:0(i64 vmctx) -> i64 {
|
||||
ebb0(v0: i64):
|
||||
v1 = iadd_imm.i64 v0, 16
|
||||
[RexOp1ldDisp8#808b] v2 = load.i64 notrap aligned v1
|
||||
[Op1ret#c3] return v2
|
||||
}
|
||||
|
||||
; sameln: function u0:0(i64 vmctx) -> i64 fast {
|
||||
; nextln: ebb0(v0: i64):
|
||||
; nextln: v1 = iadd_imm v0, 16
|
||||
; nextln: [RexOp1ldDisp8#808b] v2 = load.i64 notrap aligned v0+16
|
||||
; nextln: [Op1ret#c3] return v2
|
||||
; nextln: }
|
||||
|
||||
function u0:1(i64, i64 vmctx) {
|
||||
ebb0(v3: i64, v0: i64):
|
||||
v1 = iadd_imm.i64 v0, 16
|
||||
[RexOp1stDisp8#8089] store.i64 notrap aligned v3, v1
|
||||
[Op1ret#c3] return
|
||||
}
|
||||
|
||||
; sameln: function u0:1(i64, i64 vmctx) fast {
|
||||
; nextln: ebb0(v3: i64, v0: i64):
|
||||
; nextln: v1 = iadd_imm v0, 16
|
||||
; nextln: [RexOp1stDisp8#8089] store notrap aligned v3, v0+16
|
||||
; nextln: [Op1ret#c3] return
|
||||
; nextln: }
|
||||
54
cranelift/filetests/filetests/preopt/branch.clif
Normal file
54
cranelift/filetests/filetests/preopt/branch.clif
Normal file
@@ -0,0 +1,54 @@
|
||||
test preopt
|
||||
target x86_64
|
||||
|
||||
function %brz_fold() -> i32 {
|
||||
ebb0:
|
||||
v0 = bconst.b1 false
|
||||
brz v0, ebb2
|
||||
jump ebb1
|
||||
ebb1:
|
||||
v1 = iconst.i32 42
|
||||
return v1
|
||||
ebb2:
|
||||
v2 = iconst.i32 24
|
||||
return v2
|
||||
}
|
||||
; sameln: function %brz_fold
|
||||
; nextln: ebb0:
|
||||
; nextln: v0 = bconst.b1 false
|
||||
; nextln: jump ebb2
|
||||
; nextln:
|
||||
; nextln: ebb1:
|
||||
; nextln: v1 = iconst.i32 42
|
||||
; nextln: return v1
|
||||
; nextln:
|
||||
; nextln: ebb2:
|
||||
; nextln: v2 = iconst.i32 24
|
||||
; nextln: return v2
|
||||
; nextln: }
|
||||
|
||||
function %brnz_fold() -> i32 {
|
||||
ebb0:
|
||||
v0 = bconst.b1 true
|
||||
brnz v0, ebb2
|
||||
jump ebb1
|
||||
ebb1:
|
||||
v1 = iconst.i32 42
|
||||
return v1
|
||||
ebb2:
|
||||
v2 = iconst.i32 24
|
||||
return v2
|
||||
}
|
||||
; sameln: function %brnz_fold
|
||||
; nextln: ebb0:
|
||||
; nextln: v0 = bconst.b1 true
|
||||
; nextln: jump ebb2
|
||||
; nextln:
|
||||
; nextln: ebb1:
|
||||
; nextln: v1 = iconst.i32 42
|
||||
; nextln: return v1
|
||||
; nextln:
|
||||
; nextln: ebb2:
|
||||
; nextln: v2 = iconst.i32 24
|
||||
; nextln: return v2
|
||||
; nextln: }
|
||||
36
cranelift/filetests/filetests/preopt/numerical.clif
Normal file
36
cranelift/filetests/filetests/preopt/numerical.clif
Normal file
@@ -0,0 +1,36 @@
|
||||
test preopt
|
||||
target x86_64
|
||||
|
||||
function %iadd_fold() -> i32 {
|
||||
ebb0:
|
||||
v0 = iconst.i32 37
|
||||
v1 = iconst.i32 5
|
||||
v2 = iadd v0, v1
|
||||
v3 = iconst.i32 8
|
||||
v4 = iadd v2, v3
|
||||
return v4
|
||||
}
|
||||
; sameln: function %iadd_fold
|
||||
; nextln: ebb0:
|
||||
; nextln: v0 = iconst.i32 37
|
||||
; nextln: v1 = iconst.i32 5
|
||||
; nextln: v2 = iconst.i32 42
|
||||
; nextln: v3 = iconst.i32 8
|
||||
; nextln: v4 = iconst.i32 50
|
||||
; nextln: return v4
|
||||
; nextln: }
|
||||
|
||||
function %isub_fold() -> i32 {
|
||||
ebb0:
|
||||
v0 = iconst.i32 42
|
||||
v1 = iconst.i32 1
|
||||
v2 = isub v0, v1
|
||||
return v2
|
||||
}
|
||||
; sameln: function %isub_fold
|
||||
; nextln: ebb0:
|
||||
; nextln: v0 = iconst.i32 42
|
||||
; nextln: v1 = iconst.i32 1
|
||||
; nextln: v2 = iconst.i32 41
|
||||
; nextln: return v2
|
||||
; nextln: }
|
||||
35
cranelift/filetests/filetests/regalloc/aliases.clif
Normal file
35
cranelift/filetests/filetests/regalloc/aliases.clif
Normal file
@@ -0,0 +1,35 @@
|
||||
test regalloc
|
||||
target x86_64 haswell
|
||||
|
||||
function %value_aliases(i32, f32, i64 vmctx) baldrdash {
|
||||
gv0 = vmctx
|
||||
heap0 = static gv0, min 0x0001_0000, bound 0x0001_0000_0000, offset_guard 0x8000_0000
|
||||
|
||||
ebb0(v0: i32, v1: f32, v2: i64):
|
||||
v3 = iconst.i32 0
|
||||
jump ebb3(v3)
|
||||
|
||||
ebb3(v4: i32):
|
||||
v5 = heap_addr.i64 heap0, v4, 1
|
||||
v6 = load.f32 v5
|
||||
v7 -> v1
|
||||
v8 = fdiv v6, v7
|
||||
v9 = heap_addr.i64 heap0, v4, 1
|
||||
store v8, v9
|
||||
v10 = iconst.i32 4
|
||||
v11 = iadd v4, v10
|
||||
v12 -> v0
|
||||
v13 = icmp ult v11, v12
|
||||
v14 = bint.i32 v13
|
||||
brnz v14, ebb3(v11)
|
||||
jump ebb4
|
||||
|
||||
ebb4:
|
||||
jump ebb2
|
||||
|
||||
ebb2:
|
||||
jump ebb1
|
||||
|
||||
ebb1:
|
||||
return
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user