A CallConv enum on every function signature makes it possible to
generate calls to functions with different calling conventions within
the same ISA / within a single function.
The calling conventions also serve as a way of customizing Cretonne's
behavior when embedded inside a VM. As an example, the SpiderWASM
calling convention is used to compile WebAssembly functions that run
inside the SpiderMonkey virtual machine.
All function signatures must have a calling convention at the end, so
this changes the textual IL syntax.
Before:
sig1 = signature(i32, f64) -> f64
After
sig1 = (i32, f64) -> f64 native
sig2 = (i32) spiderwasm
When printing functions, the signature goes after the return types:
function %r1() -> i32, f32 spiderwasm {
ebb1:
...
}
In the parser, this calling convention is optional and defaults to
"native". This is mostly to avoid updating all the existing test cases
under filetests/. When printing a function, the calling convention is
always included, including for "native" functions.
82 lines
1.7 KiB
Plaintext
82 lines
1.7 KiB
Plaintext
test licm
|
|
|
|
function %complex(i32) -> i32 {
|
|
|
|
ebb0(v0: i32):
|
|
v1 = iconst.i32 1
|
|
v19 = iconst.i32 4
|
|
v2 = iadd v1, v0
|
|
brz v0, ebb1(v1)
|
|
jump ebb3(v2)
|
|
|
|
ebb1(v3: i32):
|
|
v4 = iconst.i32 2
|
|
v5 = iadd v3, v2
|
|
v6 = iadd v4, v0
|
|
jump ebb2(v6)
|
|
|
|
ebb2(v7: i32):
|
|
v8 = iadd v7, v3
|
|
v9 = iadd v0, v2
|
|
brz v0, ebb1(v7)
|
|
jump ebb5(v8)
|
|
|
|
ebb3(v10: i32):
|
|
v11 = iconst.i32 3
|
|
v12 = iadd v10, v11
|
|
v13 = iadd v2, v11
|
|
jump ebb4(v11)
|
|
|
|
ebb4(v14: i32):
|
|
v15 = iadd v12, v2
|
|
brz v0, ebb3(v14)
|
|
jump ebb5(v14)
|
|
|
|
ebb5(v16: i32):
|
|
v17 = iadd v16, v1
|
|
v18 = iadd v1, v19
|
|
brz v0, ebb0(v18)
|
|
return v17
|
|
}
|
|
|
|
; sameln: function %complex
|
|
; nextln: ebb6(v20: i32):
|
|
; nextln: v1 = iconst.i32 1
|
|
; nextln: v2 = iconst.i32 4
|
|
; nextln: v5 = iconst.i32 2
|
|
; nextln: v12 = iconst.i32 3
|
|
; nextln: v19 = iadd v1, v2
|
|
; nextln: jump ebb0(v20)
|
|
; nextln:
|
|
; nextln: ebb0(v0: i32):
|
|
; nextln: v3 = iadd.i32 v1, v0
|
|
; nextln: v7 = iadd.i32 v5, v0
|
|
; nextln: v10 = iadd v0, v3
|
|
; nextln: brz v0, ebb1(v1)
|
|
; nextln: v14 = iadd v3, v12
|
|
; nextln: jump ebb3(v3)
|
|
; nextln:
|
|
; nextln: ebb1(v4: i32):
|
|
; nextln: v6 = iadd v4, v3
|
|
; nextln: jump ebb2(v7)
|
|
; nextln:
|
|
; nextln: ebb2(v8: i32):
|
|
; nextln: v9 = iadd v8, v4
|
|
; nextln: brz.i32 v0, ebb1(v8)
|
|
; nextln: jump ebb5(v9)
|
|
; nextln:
|
|
; nextln: ebb3(v11: i32):
|
|
; nextln: v13 = iadd v11, v12
|
|
; nextln: jump ebb4(v12)
|
|
; nextln:
|
|
; nextln: ebb4(v15: i32):
|
|
; nextln: v16 = iadd.i32 v13, v3
|
|
; nextln: brz.i32 v0, ebb3(v15)
|
|
; nextln: jump ebb5(v15)
|
|
; nextln:
|
|
; nextln: ebb5(v17: i32):
|
|
; nextln: v18 = iadd v17, v1
|
|
; nextln: brz.i32 v0, ebb0(v19)
|
|
; nextln: return v18
|
|
; nextln: }
|