#[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 pow_f64_symbol: &'static str,
pub pow_f32_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 |
pow_f64_symbol | for an f64 pow | the operands’ bit patterns as two u64 integer arguments; returns the result’s bits as a u64 |
pow_f32_symbol | for an f32 pow | the operands’ bit patterns as two u32 integer arguments; returns the result’s bits as a u32 |
The two pow routines must compute ir-lang’s ls_pow (OPS v2: the same
bits on every tier, never a platform libm); for f32, ls_pow of both
operands widened to f64, rounded once. In Rust, ir_lang::ls_pow( f64::from_bits(x), f64::from_bits(y)).to_bits(). They take bit patterns
in integer registers because this release keeps floats in general-purpose
registers (isa-lang 0.2 encodes no SSE).
§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.
pow_f64_symbol: &'static strThe runtime’s ls_pow for f64 (bit patterns in, bit pattern out).
pow_f32_symbol: &'static strThe runtime’s ls_pow for f32 (bit patterns in, bit pattern out).
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_pow_runtime(
self,
f64_pow: &'static str,
f32_pow: &'static str,
) -> Options
pub const fn with_pow_runtime( self, f64_pow: &'static str, f32_pow: &'static str, ) -> Options
Renames the runtime’s float pow routines (see Options for their
contract).
§Examples
use backend_lang::Options;
let o = Options::sysv().with_pow_runtime("my_pow", "my_powf");
assert_eq!((o.pow_f64_symbol, o.pow_f32_symbol), ("my_pow", "my_powf"));
assert_eq!(Options::sysv().pow_f64_symbol, "__lexersketch_pow_f64");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);