-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeGen.h
More file actions
58 lines (52 loc) · 1.17 KB
/
CodeGen.h
File metadata and controls
58 lines (52 loc) · 1.17 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
#include <stdio.h>
extern FILE *asm_file;
/**
* @brief Linked node containing variable stack layout data.
*/
struct variable_t
{
/**
* @brief Variable name within the current scope.
*/
char *name;
/**
* @brief Type data associated with the variable.
*/
struct type_desc_t *type;
/**
* @brief Stored calculated size for offset partial sums.
*/
size_t size;
/**
* @brief Next variable in order in the stack frame.
*/
struct variable_t *next;
};
typedef struct variable_t variable_t;
struct instr_t
{
char *label;
char *op;
char *rd;
char *rs;
char *rt;
struct instr_t *next;
struct variable_t *vars;
struct instr_t *to_free;
};
typedef struct instr_t instr_t;
void init_codegen(char *name);
instr_t *gen_instr(char *Label, char *op, char *rd, char *rs, char *rt);
instr_t *append(instr_t *a, instr_t *b);
void write_seq(instr_t *body);
char *gen_label();
int avail_reg();
char *reg_name(int index);
void free_reg(int index);
void reset_regs();
instr_t *save_seq();
instr_t *restore_seq();
char *imm(int val);
char *reg_off(int offset, char *reg);
void print_reg_claims();