Refactor calling convention settings. (#304)
Add a calling-convention setting to the `Flags` used as part of the `TargetIsa`. This allows Cretonne code that generates calls to use the correct convention, such as when emitting libcalls during legalization or when the wasm frontend is decoding functions. This setting can be overridden per-function. This also adds "fast", "cold", and "fastcall" conventions, with "fast" as the new default. Note that "fast" and "cold" are not intended to be ABI-compatible across Cretonne versions. This will also ensure Windows users will get an `unimplemented!` rather than silent calling-convention mismatches, which reflects the fact that Windows calling conventions are not yet implemented. This also renames SpiderWASM, which isn't camel-case, to Baldrdash, which is, and which is also a more relevant name.
This commit is contained in:
@@ -29,6 +29,21 @@ enable_verifier = BoolSetting(
|
||||
|
||||
is_64bit = BoolSetting("Enable 64-bit code generation")
|
||||
|
||||
call_conv = EnumSetting(
|
||||
"""
|
||||
Default calling convention:
|
||||
|
||||
- fast: not-ABI-stable convention for best performance
|
||||
- cold: not-ABI-stable convention for infrequently executed code
|
||||
- system_v: System V-style convention used on many platforms
|
||||
- fastcall: Windows "fastcall" convention, also used for x64 and ARM
|
||||
- baldrdash: SpiderMonkey WebAssembly convention
|
||||
|
||||
The default calling convention may be overridden by individual
|
||||
functions.
|
||||
""",
|
||||
'fast', 'cold', 'system_v', 'fastcall', 'baldrdash')
|
||||
|
||||
# Note that Cretonne doesn't currently need an is_pie flag, because PIE is just
|
||||
# PIC where symbols can't be pre-empted, which can be expressed with the
|
||||
# `colocated` flag on external functions and global variables.
|
||||
@@ -75,13 +90,13 @@ enable_atomics = BoolSetting(
|
||||
default=True)
|
||||
|
||||
#
|
||||
# Settings specific to the `spiderwasm` calling convention.
|
||||
# Settings specific to the `baldrdash` calling convention.
|
||||
#
|
||||
spiderwasm_prologue_words = NumSetting(
|
||||
baldrdash_prologue_words = NumSetting(
|
||||
"""
|
||||
Number of pointer-sized words pushed by the spiderwasm prologue.
|
||||
Number of pointer-sized words pushed by the baldrdash prologue.
|
||||
|
||||
Functions with the `spiderwasm` calling convention don't generate their
|
||||
Functions with the `baldrdash` calling convention don't generate their
|
||||
own prologue and epilogue. They depend on externally generated code
|
||||
that pushes a fixed number of words in the prologue and restores them
|
||||
in the epilogue.
|
||||
|
||||
Reference in New Issue
Block a user