#[non_exhaustive]pub struct Options {
pub abi: &'static Abi,
pub frame_pointer: bool,
pub trap_symbol: &'static str,
pub gc_poll_symbol: &'static str,
pub resume_symbol: &'static str,
pub jump_table_min_cases: u32,
pub jump_table_max_spread: u32,
pub regalloc: Options,
}Expand description
How to compile: the platform’s C convention, frame and runtime choices, and selection and allocation settings.
The C convention (abi) serves ir-lang’s c tag and its fast tag (the
backend’s own convention for code compiled together is the platform’s C
convention in this release). Runtime entry points are called by name and
left as relocations unless the module defines them:
| Symbol | Called | With |
|---|---|---|
trap_symbol | for trap and every trapping policy | the OPS code (first argument); never returns |
gc_poll_symbol | for a safepoint instruction | nothing; a safepoint with a stack map |
resume_symbol | for resume | the exception payload; never returns |
§Examples
use backend_lang::Options;
let o = Options::sysv().with_frame_pointer(false);
assert_eq!(o.abi.name(), "sysv64");
assert!(!o.frame_pointer);
assert_eq!(Options::win64().abi.name(), "win64");Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.abi: &'static AbiThe platform’s C convention, used for the c and fast tags and for
runtime calls.
frame_pointer: boolWhether functions keep a frame pointer (on by default). Without one,
rbp is one more register for the allocator.
trap_symbol: &'static strThe runtime’s trap handler.
gc_poll_symbol: &'static strThe runtime’s GC poll, called by safepoint.
resume_symbol: &'static strThe runtime’s unwinder entry, called by resume.
jump_table_min_cases: u32The fewest cases a switch needs for a jump table.
jump_table_max_spread: u32A jump table is used when the case values span at most this many table entries per case (3: at least a third of the entries are cases).
regalloc: OptionsRegister-allocation settings.
Implementations§
Source§impl Options
impl Options
Sourcepub const fn sysv() -> Options
pub const fn sysv() -> Options
For System V AMD64 platforms (Linux, the BSDs, macOS).
§Examples
use backend_lang::Options;
assert_eq!(Options::sysv().trap_symbol, "__lexersketch_trap");Sourcepub const fn win64() -> Options
pub const fn win64() -> Options
For Windows x64.
§Examples
use backend_lang::Options;
assert_eq!(Options::win64().abi.name(), "win64");Sourcepub const fn host() -> Options
pub const fn host() -> Options
For the platform this crate is compiled for: Win64 on Windows, System V elsewhere.
§Examples
use backend_lang::Options;
let name = Options::host().abi.name();
assert!(name == "sysv64" || name == "win64");Sourcepub const fn with_abi(abi: &'static Abi) -> Options
pub const fn with_abi(abi: &'static Abi) -> Options
The defaults with abi as the C convention.
§Examples
use backend_lang::Options;
use backend_lang::x86_64::WIN64;
assert_eq!(Options::with_abi(&WIN64).abi.name(), "win64");Sourcepub const fn with_frame_pointer(self, keep: bool) -> Options
pub const fn with_frame_pointer(self, keep: bool) -> Options
Keeps or omits the frame pointer.
§Examples
use backend_lang::Options;
assert!(!Options::sysv().with_frame_pointer(false).frame_pointer);Sourcepub const fn with_runtime(
self,
trap: &'static str,
gc_poll: &'static str,
resume: &'static str,
) -> Options
pub const fn with_runtime( self, trap: &'static str, gc_poll: &'static str, resume: &'static str, ) -> Options
Renames the runtime entry points.
§Examples
use backend_lang::Options;
let o = Options::sysv().with_runtime("my_trap", "my_poll", "my_resume");
assert_eq!(o.gc_poll_symbol, "my_poll");Sourcepub const fn with_jump_tables(self, min_cases: u32, max_spread: u32) -> Options
pub const fn with_jump_tables(self, min_cases: u32, max_spread: u32) -> Options
Sets when a switch becomes a jump table.
§Examples
use backend_lang::Options;
// Never use a jump table.
let o = Options::sysv().with_jump_tables(u32::MAX, 1);
assert_eq!(o.jump_table_min_cases, u32::MAX);Sourcepub const fn with_regalloc(self, regalloc: Options) -> Options
pub const fn with_regalloc(self, regalloc: Options) -> Options
Sets the register-allocation settings.
§Examples
use backend_lang::{regalloc, Options};
let o = Options::sysv().with_regalloc(regalloc::Options::new().with_live_budget(1 << 20));
assert_eq!(o.regalloc.live_budget, 1 << 20);