LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
target::Codegen Class Reference

Abstract a Code Generator. More...

#include <codegen.hh>

Collaboration diagram for target::Codegen:

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::Frameframe_
 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::Instrscodegen (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::Frameframe_get ()
 Access the abstract frame.
assem::Instrsinstrs_get ()
 Access the list of built/being built instructions.

Detailed Description

Abstract a Code Generator.

Constructor & Destructor Documentation

target::mips::Codegen::Codegen ( bool  rule_trace_p = false)
inline

Construct a Codegen.

target::mips::Codegen::~Codegen ( )
virtual

Destroy a Codegen.

Member Function Documentation

virtual void target::Codegen::codegen ( const tree::rStm &  root)
protectedpure virtual

Launch code generation on the root statement.

Referenced by codegen().

assem::Instrs & target::Codegen::codegen ( const tree::rStm &  stm,
frame::Frame frame 
)

Generate code.

References assertion, codegen(), frame_, and instrs_.

void target::Codegen::emit ( assem::Instr instr)
inline

Append instr to the list of built instructions.

References instrs_.

void target::Codegen::emit ( assem::Instrs  instrs)
inline

Append instrs to the list of built instructions.

References instrs_.

void target::mips::Codegen::fragment_entry_exit_build ( assem::ProcFrag frag)
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().

void target::mips::Codegen::frame_build ( assem::ProcFrag frag) const
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().

frame::Frame & target::Codegen::frame_get ( )
inline

Access the abstract frame.

References frame_.

assem::Instrs & target::Codegen::instrs_get ( )
inlineprotected

Access the list of built/being built instructions.

References instrs_.

void target::mips::Codegen::rewrite_program ( assem::ProcFrag frag,
const temp::temp_set_type spilled 
) const
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()().

Member Data Documentation

frame::Frame* target::Codegen::frame_
protected

Current frame may be resized for function's arguments.

Referenced by codegen(), and frame_get().

assem::Instrs target::Codegen::instrs_
private

The list of being built instructions.

Referenced by codegen(), emit(), and instrs_get().

bool target::Codegen::rule_trace_p_
protected

Print rules when redicing.


The documentation for this class was generated from the following files: