pub struct Context {
    pub func: Function,
    pub cfg: ControlFlowGraph,
    pub domtree: DominatorTree,
    pub loop_analysis: LoopAnalysis,
    pub mach_compile_result: Option<MachCompileResult>,
    pub want_disasm: bool,
}
Expand description

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.

loop_analysis: LoopAnalysis

Loop analysis of func.

mach_compile_result: Option<MachCompileResult>

Result of MachBackend compilation, if computed.

want_disasm: bool

Flag: do we want a disassembly with the MachCompileResult?

Implementations

Allocate a new compilation context.

The returned instance should be reused for compiling multiple functions in order to avoid needless allocator thrashing.

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.

Clear all data structures in this context.

Set the flag to request a disassembly when compiling with a MachBackend backend.

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 can be obtained from mach_compile_result.

This function calls compile and emit_to_memory, taking care to resize mem as needed, so it provides a safe interface.

Returns information about the function’s code and read-only data.

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 information about the function’s code and read-only data.

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 can be obtained from mach_compile_result.

Safety

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.

Returns information about the emitted code and data.

If available, return information about the code layout in the final machine code: the offsets (in bytes) of each basic-block start, and all basic-block edges.

Creates unwind information for the function.

Returns None if the function has no unwind information.

Run the verifier on the function.

Also check that the dominator tree and control flow graph are consistent with the function.

Run the verifier only if the enable_verifier setting is true.

Perform dead-code elimination on the function.

Perform constant-phi removal on the function.

Perform pre-legalization rewrites on the function.

Perform NaN canonicalizing rewrites on the function.

Run the legalizer for isa on the function.

Compute the control flow graph.

Compute dominator tree.

Compute the loop analysis.

Compute the control flow graph and dominator tree.

Perform simple GVN on the function.

Perform LICM on the function.

Perform unreachable code elimination.

Replace all redundant loads with the known values in memory. These are loads whose values were already loaded by other loads earlier, as well as loads whose values were stored by a store instruction to the same instruction (so-called “store-to-load forwarding”).

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.