Trait cranelift_codegen::isa::TargetIsa
source · pub trait TargetIsa: Display + Sync {
Show 20 methods
fn name(&self) -> &'static str;
fn triple(&self) -> &Triple;
fn flags(&self) -> &Flags;
fn register_info(&self) -> RegInfo;
fn legal_encodings<'a>(
&'a self,
func: &'a Function,
inst: &'a InstructionData,
ctrl_typevar: Type
) -> Encodings<'a>;
fn encoding_info(&self) -> EncInfo;
fn legalize_signature(&self, sig: &mut Signature, current: bool);
fn regclass_for_abi_type(&self, ty: Type) -> RegClass;
fn allocatable_registers(&self, func: &Function) -> RegisterSet;
fn emit_function_to_memory(
&self,
func: &Function,
sink: &mut MemoryCodeSink<'_>
);
fn default_call_conv(&self) -> CallConv { ... }
fn pointer_type(&self) -> Type { ... }
fn pointer_width(&self) -> PointerWidth { ... }
fn pointer_bits(&self) -> u8 { ... }
fn pointer_bytes(&self) -> u8 { ... }
fn frontend_config(&self) -> TargetFrontendConfig { ... }
fn uses_cpu_flags(&self) -> bool { ... }
fn uses_complex_addresses(&self) -> bool { ... }
fn encode(
&self,
func: &Function,
inst: &InstructionData,
ctrl_typevar: Type
) -> Result<Encoding, Legalize> { ... }
fn prologue_epilogue(&self, func: &mut Function) -> CodegenResult<()> { ... }
}
Expand description
Methods that are specialized to a target ISA. Implies a Display trait that shows the shared flags, as well as any isa-specific flags.
Required Methods§
sourcefn flags(&self) -> &Flags
fn flags(&self) -> &Flags
Get the ISA-independent flags that were used to make this trait object.
sourcefn register_info(&self) -> RegInfo
fn register_info(&self) -> RegInfo
Get a data structure describing the registers in this ISA.
sourcefn legal_encodings<'a>(
&'a self,
func: &'a Function,
inst: &'a InstructionData,
ctrl_typevar: Type
) -> Encodings<'a>
fn legal_encodings<'a>(
&'a self,
func: &'a Function,
inst: &'a InstructionData,
ctrl_typevar: Type
) -> Encodings<'a>
Returns an iterator over legal encodings for the instruction.
sourcefn encoding_info(&self) -> EncInfo
fn encoding_info(&self) -> EncInfo
Get a data structure describing the instruction encodings in this ISA.
sourcefn legalize_signature(&self, sig: &mut Signature, current: bool)
fn legalize_signature(&self, sig: &mut Signature, current: bool)
Legalize a function signature.
This is used to legalize both the signature of the function being compiled and any called
functions. The signature should be modified by adding ArgumentLoc
annotations to all
arguments and return values.
Arguments with types that are not supported by the ABI can be expanded into multiple arguments:
- Integer types that are too large to fit in a register can be broken into multiple arguments of a smaller integer type.
- Floating point types can be bit-cast to an integer type of the same size, and possible broken into smaller integer types.
- Vector types can be bit-cast and broken down into smaller vectors or scalars.
The legalizer will adapt argument and return values as necessary at all ABI boundaries.
When this function is called to legalize the signature of the function currently being
compiled, current
is true. The legalized signature can then also contain special purpose
arguments and return values such as:
- A
link
argument representing the link registers on RISC architectures that don’t push the return address on the stack. - A
link
return value which will receive the value that was passed to thelink
argument. - An
sret
argument can be added if one wasn’t present already. This is necessary if the signature returns more values than registers are available for returning values. - An
sret
return value can be added if the ABI requires a function to return itssret
argument in a register.
Arguments and return values for the caller’s frame pointer and other callee-saved registers should not be added by this function. These arguments are not added until after register allocation.
sourcefn regclass_for_abi_type(&self, ty: Type) -> RegClass
fn regclass_for_abi_type(&self, ty: Type) -> RegClass
Get the register class that should be used to represent an ABI argument or return value of
type ty
. This should be the top-level register class that contains the argument
registers.
This function can assume that it will only be asked to provide register classes for types
that legalize_signature()
produces in ArgumentLoc::Reg
entries.
sourcefn allocatable_registers(&self, func: &Function) -> RegisterSet
fn allocatable_registers(&self, func: &Function) -> RegisterSet
Get the set of allocatable registers that can be used when compiling func
.
This set excludes reserved registers like the stack pointer and other special-purpose registers.
sourcefn emit_function_to_memory(&self, func: &Function, sink: &mut MemoryCodeSink<'_>)
fn emit_function_to_memory(&self, func: &Function, sink: &mut MemoryCodeSink<'_>)
Emit a whole function into memory.
Provided Methods§
sourcefn default_call_conv(&self) -> CallConv
fn default_call_conv(&self) -> CallConv
Get the default calling convention of this target.
sourcefn pointer_type(&self) -> Type
fn pointer_type(&self) -> Type
Get the pointer type of this ISA.
sourcefn pointer_width(&self) -> PointerWidth
fn pointer_width(&self) -> PointerWidth
Get the width of pointers on this ISA.
sourcefn pointer_bits(&self) -> u8
fn pointer_bits(&self) -> u8
Get the width of pointers on this ISA, in units of bits.
sourcefn pointer_bytes(&self) -> u8
fn pointer_bytes(&self) -> u8
Get the width of pointers on this ISA, in units of bytes.
sourcefn frontend_config(&self) -> TargetFrontendConfig
fn frontend_config(&self) -> TargetFrontendConfig
Get the information needed by frontends producing Cranelift IR.
sourcefn uses_cpu_flags(&self) -> bool
fn uses_cpu_flags(&self) -> bool
Does the CPU implement scalar comparisons using a CPU flags register?
sourcefn uses_complex_addresses(&self) -> bool
fn uses_complex_addresses(&self) -> bool
Does the CPU implement multi-register addressing?
sourcefn encode(
&self,
func: &Function,
inst: &InstructionData,
ctrl_typevar: Type
) -> Result<Encoding, Legalize>
fn encode(
&self,
func: &Function,
inst: &InstructionData,
ctrl_typevar: Type
) -> Result<Encoding, Legalize>
Encode an instruction after determining it is legal.
If inst
can legally be encoded in this ISA, produce the corresponding Encoding
object.
Otherwise, return Legalize
action.
This is also the main entry point for determining if an instruction is legal.
sourcefn prologue_epilogue(&self, func: &mut Function) -> CodegenResult<()>
fn prologue_epilogue(&self, func: &mut Function) -> CodegenResult<()>
Compute the stack layout and insert prologue and epilogue code into func
.
Return an error if the stack frame is too large.