LRDE Tiger Compiler
1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
|
Abstract a Code Generator. More...
#include <codegen.hh>
Public Member Functions | |
void | emit (assem::Instr *instr) |
Append instr to the list of built instructions. | |
void | emit (assem::Instrs instrs) |
Append instrs to the list of built instructions. | |
Ctor & dtor. | |
Codegen (bool rule_trace_p=false) | |
Construct a Codegen. | |
virtual | ~Codegen () |
Destroy a Codegen. |
Protected Attributes | |
frame::Frame * | frame_ |
Current frame may be resized for function's arguments. | |
bool | rule_trace_p_ |
Print rules when redicing. |
Private Attributes | |
assem::Instrs | instrs_ |
The list of being built instructions. |
Code generation engine. | |
assem::Instrs & | codegen (const tree::rStm &stm, frame::Frame &frame) |
Generate code. | |
virtual void | fragment_entry_exit_build (assem::ProcFrag &frag)=0 |
Build part of the prologue and epilogue of the function. | |
virtual void | frame_build (assem::ProcFrag &frag) const =0 |
Allocate the frame. | |
virtual void | rewrite_program (assem::ProcFrag &frag, const temp::temp_set_type &spilled) const =0 |
Rewrite the code to spill the spilled. | |
virtual void | codegen (const tree::rStm &root)=0 |
Launch code generation on the root statement. |
Accessors. | |
frame::Frame & | frame_get () |
Access the abstract frame. | |
assem::Instrs & | instrs_get () |
Access the list of built/being built instructions. |
Abstract a Code Generator.
|
inline |
Construct a Codegen.
|
virtual |
Destroy a Codegen.
|
protectedpure virtual |
Launch code generation on the root statement.
Referenced by codegen().
assem::Instrs & target::Codegen::codegen | ( | const tree::rStm & | stm, |
frame::Frame & | frame | ||
) |
|
inline |
Append instr to the list of built instructions.
References instrs_.
|
inline |
Append instrs to the list of built instructions.
References instrs_.
|
pure virtual |
Build part of the prologue and epilogue of the function.
Free the callee save registers, and receive the arguments. Called as soon as the function body was translated. This is called "procEntryExit1" by Appel.
References assem::ProcFrag::frame_get(), assem::ProcFrag::instrs_get(), assem::ProcFrag::label_get(), and temp::Identifier< Traits_ >::string_get().
|
pure virtual |
Allocate the frame.
Called at the end, after register allocation, since the frame size depends upon it. This is Appel's "procEntryExit3".
References assertion, assem::ProcFrag::frame_get(), assem::ProcFrag::instrs_get(), and assem::Instrs::label_find().
|
inline |
Access the abstract frame.
References frame_.
|
inlineprotected |
Access the list of built/being built instructions.
References instrs_.
|
pure virtual |
Rewrite the code to spill the spilled.
During register allocation, some temps could not be allocated a register and are spilled: rewrite the code to handle them (load and store where needed).
Referenced by regalloc::RegisterAllocator::operator()().
|
protected |
Current frame may be resized for function's arguments.
Referenced by codegen(), and frame_get().
|
private |
The list of being built instructions.
Referenced by codegen(), emit(), and instrs_get().
|
protected |
Print rules when redicing.