Struct cretonne::prelude::codegen::Context [−][src]
pub struct Context { pub func: Function, pub cfg: ControlFlowGraph, pub domtree: DominatorTree, pub regalloc: Context, pub loop_analysis: LoopAnalysis, }
Persistent data structures and compilation pipeline.
Fields
func: Function
The function we're compiling.
cfg: ControlFlowGraph
The control flow graph of func
.
domtree: DominatorTree
Dominator tree for func
.
regalloc: Context
Register allocation context.
loop_analysis: LoopAnalysis
Loop analysis of func
.
Methods
impl Context
[src]
impl Context
pub fn new() -> Context
[src]
pub fn new() -> Context
Allocate a new compilation context.
The returned instance should be reused for compiling multiple functions in order to avoid needless allocator thrashing.
pub fn for_function(func: Function) -> Context
[src]
pub fn for_function(func: Function) -> Context
Allocate a new compilation context with an existing Function.
The returned instance should be reused for compiling multiple functions in order to avoid needless allocator thrashing.
pub fn clear(&mut self)
[src]
pub fn clear(&mut self)
Clear all data structures in this context.
pub fn compile_and_emit(
&mut self,
isa: &TargetIsa,
mem: &mut Vec<u8>,
relocs: &mut RelocSink,
traps: &mut TrapSink
) -> Result<(), CodegenError>
[src]
pub fn compile_and_emit(
&mut self,
isa: &TargetIsa,
mem: &mut Vec<u8>,
relocs: &mut RelocSink,
traps: &mut TrapSink
) -> Result<(), CodegenError>
Compile the function, and emit machine code into a Vec<u8>
.
Run the function through all the passes necessary to generate code for the target ISA
represented by isa
, as well as the final step of emitting machine code into a
Vec<u8>
. The machine code is not relocated. Instead, any relocations are emitted
into relocs
.
This function calls compile
and emit_to_memory
, taking care to resize mem
as
needed, so it provides a safe interface.
pub fn compile(&mut self, isa: &TargetIsa) -> Result<u32, CodegenError>
[src]
pub fn compile(&mut self, isa: &TargetIsa) -> Result<u32, CodegenError>
Compile the function.
Run the function through all the passes necessary to generate code for the target ISA
represented by isa
. This does not include the final step of emitting machine code into a
code sink.
Returns the size of the function's code.
pub unsafe fn emit_to_memory(
&self,
isa: &TargetIsa,
mem: *mut u8,
relocs: &mut RelocSink,
traps: &mut TrapSink
)
[src]
pub unsafe fn emit_to_memory(
&self,
isa: &TargetIsa,
mem: *mut u8,
relocs: &mut RelocSink,
traps: &mut TrapSink
)
Emit machine code directly into raw memory.
Write all of the function's machine code to the memory at mem
. The size of the machine
code is returned by compile
above.
The machine code is not relocated. Instead, any relocations are emitted into relocs
.
This function is unsafe since it does not perform bounds checking on the memory buffer,
and it can't guarantee that the mem
pointer is valid.
pub fn verify<'a, FOI>(&self, fisa: FOI) -> Result<(), VerifierError> where
FOI: Into<FlagsOrIsa<'a>>,
[src]
pub fn verify<'a, FOI>(&self, fisa: FOI) -> Result<(), VerifierError> where
FOI: Into<FlagsOrIsa<'a>>,
Run the verifier on the function.
Also check that the dominator tree and control flow graph are consistent with the function.
pub fn verify_if<'a, FOI>(&self, fisa: FOI) -> Result<(), CodegenError> where
FOI: Into<FlagsOrIsa<'a>>,
[src]
pub fn verify_if<'a, FOI>(&self, fisa: FOI) -> Result<(), CodegenError> where
FOI: Into<FlagsOrIsa<'a>>,
Run the verifier only if the enable_verifier
setting is true.
pub fn verify_locations(&self, isa: &TargetIsa) -> Result<(), VerifierError>
[src]
pub fn verify_locations(&self, isa: &TargetIsa) -> Result<(), VerifierError>
Run the locations verifier on the function.
pub fn verify_locations_if(&self, isa: &TargetIsa) -> Result<(), CodegenError>
[src]
pub fn verify_locations_if(&self, isa: &TargetIsa) -> Result<(), CodegenError>
Run the locations verifier only if the enable_verifier
setting is true.
pub fn dce<'a, FOI>(&mut self, fisa: FOI) -> Result<(), CodegenError> where
FOI: Into<FlagsOrIsa<'a>>,
[src]
pub fn dce<'a, FOI>(&mut self, fisa: FOI) -> Result<(), CodegenError> where
FOI: Into<FlagsOrIsa<'a>>,
Perform dead-code elimination on the function.
pub fn preopt(&mut self, isa: &TargetIsa) -> Result<(), CodegenError>
[src]
pub fn preopt(&mut self, isa: &TargetIsa) -> Result<(), CodegenError>
Perform pre-legalization rewrites on the function.
pub fn canonicalize_nans(&mut self, isa: &TargetIsa) -> Result<(), CodegenError>
[src]
pub fn canonicalize_nans(&mut self, isa: &TargetIsa) -> Result<(), CodegenError>
Perform NaN canonicalizing rewrites on the function.
pub fn legalize(&mut self, isa: &TargetIsa) -> Result<(), CodegenError>
[src]
pub fn legalize(&mut self, isa: &TargetIsa) -> Result<(), CodegenError>
Run the legalizer for isa
on the function.
pub fn postopt(&mut self, isa: &TargetIsa) -> Result<(), CodegenError>
[src]
pub fn postopt(&mut self, isa: &TargetIsa) -> Result<(), CodegenError>
Perform post-legalization rewrites on the function.
pub fn compute_cfg(&mut self)
[src]
pub fn compute_cfg(&mut self)
Compute the control flow graph.
pub fn compute_domtree(&mut self)
[src]
pub fn compute_domtree(&mut self)
Compute dominator tree.
pub fn compute_loop_analysis(&mut self)
[src]
pub fn compute_loop_analysis(&mut self)
Compute the loop analysis.
pub fn flowgraph(&mut self)
[src]
pub fn flowgraph(&mut self)
Compute the control flow graph and dominator tree.
pub fn simple_gvn<'a, FOI>(&mut self, fisa: FOI) -> Result<(), CodegenError> where
FOI: Into<FlagsOrIsa<'a>>,
[src]
pub fn simple_gvn<'a, FOI>(&mut self, fisa: FOI) -> Result<(), CodegenError> where
FOI: Into<FlagsOrIsa<'a>>,
Perform simple GVN on the function.
pub fn licm<'a, FOI>(&mut self, fisa: FOI) -> Result<(), CodegenError> where
FOI: Into<FlagsOrIsa<'a>>,
[src]
pub fn licm<'a, FOI>(&mut self, fisa: FOI) -> Result<(), CodegenError> where
FOI: Into<FlagsOrIsa<'a>>,
Perform LICM on the function.
pub fn eliminate_unreachable_code<'a, FOI>(
&mut self,
fisa: FOI
) -> Result<(), CodegenError> where
FOI: Into<FlagsOrIsa<'a>>,
[src]
pub fn eliminate_unreachable_code<'a, FOI>(
&mut self,
fisa: FOI
) -> Result<(), CodegenError> where
FOI: Into<FlagsOrIsa<'a>>,
Perform unreachable code elimination.
pub fn regalloc(&mut self, isa: &TargetIsa) -> Result<(), CodegenError>
[src]
pub fn regalloc(&mut self, isa: &TargetIsa) -> Result<(), CodegenError>
Run the register allocator.
pub fn prologue_epilogue(&mut self, isa: &TargetIsa) -> Result<(), CodegenError>
[src]
pub fn prologue_epilogue(&mut self, isa: &TargetIsa) -> Result<(), CodegenError>
Insert prologue and epilogues after computing the stack frame layout.
pub fn shrink_instructions(
&mut self,
isa: &TargetIsa
) -> Result<(), CodegenError>
[src]
pub fn shrink_instructions(
&mut self,
isa: &TargetIsa
) -> Result<(), CodegenError>
Run the instruction shrinking pass.
pub fn relax_branches(&mut self, isa: &TargetIsa) -> Result<u32, CodegenError>
[src]
pub fn relax_branches(&mut self, isa: &TargetIsa) -> Result<u32, CodegenError>
Run the branch relaxation pass and return the final code size.