TPDE
Loading...
Searching...
No Matches
tpde::CompilerBase< Adaptor, Derived, Config > Struct Template Reference

#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 free_assignment (ValLocalIdx local_idx) noexcept
 Frees an assignment, its stack slot and registers.
 
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.
 
AsmReg gval_as_reg (GenericValuePart &gv) noexcept
 
AsmReg gval_as_reg_reuse (GenericValuePart &gv, ScratchReg &dst) noexcept
 
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 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
 

Detailed Description

template<IRAdaptor Adaptor, typename Derived, CompilerConfig Config = CompilerConfigDefault>
struct tpde::CompilerBase< Adaptor, Derived, Config >

The base class for the compiler. It implements the main platform independent compilation logic and houses the analyzer

Definition at line 88 of file CompilerBase.hpp.

Member Function Documentation

◆ compile()

template<IRAdaptor Adaptor, typename Derived , CompilerConfig Config>
bool tpde::CompilerBase< Adaptor, Derived, Config >::compile ( )

Compile the functions returned by Adaptor::funcs

Warning
If you intend to call this multiple times, you must call reset inbetween the calls.
Returns
Whether the compilation was successful

Definition at line 664 of file CompilerBase.hpp.

◆ derived()

template<IRAdaptor Adaptor, typename Derived , CompilerConfig Config = CompilerConfigDefault>
Derived * tpde::CompilerBase< Adaptor, Derived, Config >::derived ( )
inline

shortcut for casting to the Derived class so that overloading works

Definition at line 271 of file CompilerBase.hpp.

◆ gval_as_reg()

template<IRAdaptor Adaptor, typename Derived , CompilerConfig Config>
CompilerBase< Adaptor, Derived, Config >::AsmReg tpde::CompilerBase< Adaptor, Derived, Config >::gval_as_reg ( GenericValuePart &  gv)
noexcept

Get generic value part into a single register, evaluating expressions and materializing immediates as required.

Definition at line 1100 of file CompilerBase.hpp.

◆ gval_as_reg_reuse()

template<IRAdaptor Adaptor, typename Derived , CompilerConfig Config>
CompilerBase< Adaptor, Derived, Config >::AsmReg tpde::CompilerBase< Adaptor, Derived, Config >::gval_as_reg_reuse ( GenericValuePart &  gv,
ScratchReg &  dst 
)
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 1123 of file CompilerBase.hpp.

◆ release_regs_after_return()

template<IRAdaptor Adaptor, typename Derived , CompilerConfig Config>
void tpde::CompilerBase< Adaptor, Derived, Config >::release_regs_after_return ( )
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 1383 of file CompilerBase.hpp.

◆ reset()

template<IRAdaptor Adaptor, typename Derived , CompilerConfig Config>
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 723 of file CompilerBase.hpp.

Member Data Documentation

◆ generating_branch

template<IRAdaptor Adaptor, typename Derived , CompilerConfig Config = CompilerConfigDefault>
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 152 of file CompilerBase.hpp.


The documentation for this struct was generated from the following file: