45 typedef std::map<int, MachineReg> GlobalRegMap;
52 std::shared_ptr<InstructionSequence> m_hl_iseq;
53 std::shared_ptr<InstructionSequence> m_ll_iseq;
55 unsigned m_total_local_storage;
56 int m_first_temp_vreg;
58 std::map<int, unsigned> m_vreg_storage_offsets;
60 GlobalRegMap m_global_regs;
85 std::shared_ptr<InstructionSequence>
get_hl_iseq()
const;
89 void set_hl_iseq(
const std::shared_ptr<InstructionSequence> &hl_iseq);
93 std::shared_ptr<InstructionSequence>
get_ll_iseq()
const;
97 void set_ll_iseq(
const std::shared_ptr<InstructionSequence> &ll_iseq);
100 void set_total_local_storage(
unsigned total_local_storage) { m_total_local_storage = total_local_storage; }
101 unsigned get_total_local_storage()
const {
return m_total_local_storage; }
103 void set_first_temp_vreg(
int first_temp_vreg) { m_first_temp_vreg = first_temp_vreg; }
104 int get_first_temp_vreg()
const {
return m_first_temp_vreg; }
106 void set_num_vregs_used(
int num_vregs_used) { m_num_vregs_used = num_vregs_used; }
107 int get_num_vregs_used()
const {
return m_num_vregs_used; }
109 void assign_vreg_storage(
int vreg,
unsigned offset) {
110 assert(!vreg_reqires_storage(vreg));
111 m_vreg_storage_offsets[vreg] = offset;
114 bool vreg_reqires_storage(
int vreg)
const {
115 return m_vreg_storage_offsets.count(vreg) > 0;
118 unsigned get_vreg_storage_offset(
int vreg)
const {
119 auto i = m_vreg_storage_offsets.find(vreg);
120 assert(i != m_vreg_storage_offsets.end());
124 void set_num_spill_locs(
int num_spill_locs) { m_num_spill_locs = num_spill_locs; }
125 int get_num_spill_locs()
const {
return m_num_spill_locs; }
127 void allocate_global_reg(
int vreg, MachineReg mreg) {
128 assert(!has_global_reg(vreg));
129 m_global_regs[vreg] = mreg;
132 bool has_global_reg(
int vreg)
const {
return m_global_regs.count(vreg) > 0; }
134 MachineReg get_global_reg(
int vreg)
const {
135 auto i = m_global_regs.find(vreg);
136 assert(i != m_global_regs.end());
141 GlobalRegMap::const_iterator greg_begin()
const {
return m_global_regs.cbegin(); }
142 GlobalRegMap::const_iterator greg_end()
const {
return m_global_regs.cend(); }
145 GlobalRegMap::const_reverse_iterator greg_rbegin()
const {
return m_global_regs.crbegin(); }
146 GlobalRegMap::const_reverse_iterator greg_rend()
const {
return m_global_regs.crend(); }
148 unsigned get_num_global_regs_assigned()
const {
return unsigned(m_global_regs.size()); }
Function encapsulates all of the information needed to generate and optimize code for a function.
Definition: function.h:42
void set_hl_iseq(const std::shared_ptr< InstructionSequence > &hl_iseq)
Set the high-level InstructionSequence.
Definition: function.cpp:55
void set_ll_iseq(const std::shared_ptr< InstructionSequence > &ll_iseq)
Set the low-level InstructionSequence.
Definition: function.cpp:63
std::string get_name() const
Get the function name.
Definition: function.cpp:39
Node * get_funcdef_ast() const
Get the function definition AST.
Definition: function.cpp:43
std::shared_ptr< InstructionSequence > get_ll_iseq() const
Get the low-level InstructionSequence.
Definition: function.cpp:59
Symbol * get_symbol() const
Get the function's symbol table entry.
Definition: function.cpp:47
std::shared_ptr< InstructionSequence > get_hl_iseq() const
Get the high-level InstructionSequence.
Definition: function.cpp:51
Function(const std::string &name, Node *funcdef_ast, Symbol *symbol)
Constructor.
Definition: function.cpp:23
InstructionSequence and friends.