|
TPDE
|
#include <CompilerBase.hpp>
Classes | |
| struct | ValRefSpecial |
| A default implementation for ValRefSpecial. More... | |
Public Member Functions | |
| CompilerBase (Adaptor *adaptor) | |
| Initialize a CompilerBase, should be called by the derived classes. | |
| Derived * | derived () |
| bool | compile () |
| void | reset () |
| CCAssigner * | cur_cc_assigner () noexcept |
| Get CCAssigner for current function. | |
| void | release_assignment (ValLocalIdx local_idx, ValueAssignment *) noexcept |
| void | init_variable_ref (ValLocalIdx local_idx, u32 var_ref_data) noexcept |
| Init a variable-ref assignment. | |
| void | init_variable_ref (IRValueRef value, u32 var_ref_data) noexcept |
| Init a variable-ref assignment. | |
| ValueRef | result_ref (IRValueRef value) noexcept |
| Get a defining reference to a value. | |
| ValueRef | result_ref_alias (IRValueRef dst, ValueRef &&src) noexcept |
| ValueRef | result_ref_stack_slot (IRValueRef value, AssignmentPartRef base, i32 off) noexcept |
| AsmReg | gval_as_reg (GenericValuePart &gv) noexcept |
| AsmReg | gval_as_reg_reuse (GenericValuePart &gv, ScratchReg &dst) noexcept |
| Reg | select_reg (RegBank bank, u64 exclusion_mask) noexcept |
| Select an available register, evicting loaded values if needed. | |
| void | reload_to_reg (AsmReg dst, AssignmentPartRef ap) noexcept |
| Reload a value part from memory or recompute variable address. | |
| void | spill (AssignmentPartRef ap) noexcept |
| Ensure the value is spilled in its stack slot (except variable refs). | |
| void | evict (AssignmentPartRef ap) noexcept |
| Evict the value from its register, spilling if needed, and free register. | |
| void | evict_reg (Reg reg) noexcept |
| Evict the value from the register, spilling if needed, and free register. | |
| void | free_reg (Reg reg) noexcept |
| Free the register. Requires that the contained value is already spilled. | |
| void | release_regs_after_return () noexcept |
| void | generate_switch (ScratchReg &&cond, u32 width, IRBlockRef default_block, std::span< const std::pair< u64, IRBlockRef > > cases) noexcept |
| void | begin_branch_region () noexcept |
| Indicate beginning of region where value-state must not change. | |
| void | end_branch_region () noexcept |
| Indicate end of region where value-state must not change. | |
Public Attributes | |
| bool | generating_branch = false |
The base class for the compiler. It implements the main platform independent compilation logic and houses the analyzer
Definition at line 102 of file CompilerBase.hpp.
| bool tpde::CompilerBase< Adaptor, Derived, Config >::compile | ( | ) |
Compile the functions returned by Adaptor::funcs
Definition at line 738 of file CompilerBase.hpp.
|
inline |
shortcut for casting to the Derived class so that overloading works
Definition at line 297 of file CompilerBase.hpp.
|
noexcept |
Generate a switch at the end of a basic block. Only the lowest bits of the condition are considered. The condition must be a general-purpose register. The cases must be sorted and every case value must appear at most once.
Definition at line 1569 of file CompilerBase.hpp.
|
noexcept |
Get generic value part into a single register, evaluating expressions and materializing immediates as required.
Definition at line 1236 of file CompilerBase.hpp.
|
noexcept |
Like gval_as_reg; if the GenericValuePart owns a reusable register (either a ScratchReg, possibly due to materialization, or a reusable ValuePartRef), store it in dst.
Definition at line 1259 of file CompilerBase.hpp.
|
noexcept |
Release an assignment when reference count drops to zero, either frees the assignment immediately or delays free to the end of the live range.
Definition at line 942 of file CompilerBase.hpp.
|
noexcept |
When reaching a point in the function where no other blocks will be reached anymore, use this function to release register assignments after the end of that block so the compiler does not accidentally use registers which don't contain any values
Definition at line 1558 of file CompilerBase.hpp.
| void tpde::CompilerBase< Adaptor, Derived, Config >::reset | ( | ) |
Reset any leftover data from the previous compilation such that it will not affect the next compilation
Definition at line 797 of file CompilerBase.hpp.
|
noexcept |
Make dst an alias for src, which must be a non-constant value with an identical part configuration. src must be in its last use (is_owned()), and the assignment will be repurposed for dst, keeping all assigned registers and stack slots.
Definition at line 1163 of file CompilerBase.hpp.
|
noexcept |
Initialize value as a pointer into a stack variable (i.e., a value allocated from cur_static_allocas() or similar) with an offset. The result value will be a stack variable itself.
Definition at line 1217 of file CompilerBase.hpp.
| bool tpde::CompilerBase< Adaptor, Derived, Config >::generated_call |
Whether the function actually includes a call. There are cases, where it is not clear from the beginning whether a function has function calls. If a function has no calls, this will allow using the red zone guaranteed by some ABIs.
Definition at line 142 of file CompilerBase.hpp.
| bool tpde::CompilerBase< Adaptor, Derived, Config >::generating_branch = false |
Whether we are currently in the middle of generating branch-related code and therefore must not change any value-related state.
Definition at line 177 of file CompilerBase.hpp.
| bool tpde::CompilerBase< Adaptor, Derived, Config >::has_dynamic_alloca |
Whether the stack frame might have dynamic alloca. Dynamic allocas may require a different and less efficient frame setup.
Definition at line 134 of file CompilerBase.hpp.
| bool tpde::CompilerBase< Adaptor, Derived, Config >::is_leaf_function |
Whether the function is guaranteed to be a leaf function. Throughout the entire function, the compiler may assume the absence of function calls.
Definition at line 137 of file CompilerBase.hpp.