-
Notifications
You must be signed in to change notification settings - Fork 0
/
local_storage_allocation.h
44 lines (32 loc) · 1.17 KB
/
local_storage_allocation.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef LOCAL_STORAGE_ALLOCATION_H
#define LOCAL_STORAGE_ALLOCATION_H
#include "storage.h"
#include "ast_visitor.h"
class LocalStorageAllocation : public ASTVisitor {
public:
// vr0 is the return value vreg
static const int VREG_RETVAL = 0;
// vr1 is 1st argument vreg
static const int VREG_FIRST_ARG = 1;
// local variable allocation starts at vr16
static const int VREG_FIRST_LOCAL = 16;
private:
StorageCalculator m_storage_calc;
unsigned m_total_local_storage;
int m_next_vreg;
unsigned vreg_boundary;
public:
LocalStorageAllocation();
virtual ~LocalStorageAllocation();
virtual void visit_declarator_list(Node *n);
virtual void visit_function_definition(Node *n);
virtual void visit_function_parameter(Node *n);
virtual void visit_statement_list(Node *n);
int next();
private:
void assign_variable_storage(Node *declarator, Node *base);
unsigned int assign_array(const std::shared_ptr<Type> &type);
void assign_struct_storage(Node *declarator, const StorageCalculator &calc);
void assign_struct_storage(Node *base, Node *declarator, StorageCalculator calc);
};
#endif // LOCAL_STORAGE_ALLOCATION_H