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.
34 lines
769 B
Plaintext
34 lines
769 B
Plaintext
test verifier
|
|
|
|
function %average(i32, i32) -> f32 native {
|
|
ss1 = local 8 ; Stack slot for ``sum``.
|
|
|
|
ebb1(v1: i32, v2: i32):
|
|
v3 = f64const 0x0.0
|
|
stack_store v3, ss1
|
|
brz v2, ebb3 ; Handle count == 0.
|
|
v4 = iconst.i32 0
|
|
jump ebb2(v4)
|
|
|
|
ebb2(v5: i32):
|
|
v6 = imul_imm v5, 4
|
|
v7 = iadd v1, v6
|
|
v8 = heap_load.f32 v7 ; array[i]
|
|
v9 = fpromote.f64 v8
|
|
v10 = stack_load.f64 ss1
|
|
v11 = fadd v9, v10
|
|
stack_store v11, ss1
|
|
v12 = iadd_imm v5, 1
|
|
v13 = icmp ult v12, v2
|
|
brnz v13, ebb2(v12) ; Loop backedge.
|
|
v14 = stack_load.f64 ss1
|
|
v15 = fcvt_from_uint.f64 v2
|
|
v16 = fdiv v14, v15
|
|
v17 = fdemote.f32 v16
|
|
return v17
|
|
|
|
ebb3:
|
|
v100 = f32const +NaN
|
|
return v100
|
|
}
|