ACSE 2.0.3
Advanced Compiler System for Education
Loading...
Searching...
No Matches
program.h
Go to the documentation of this file.
1
3
4#ifndef PROGRAM_H
5#define PROGRAM_H
6
7#include <stdio.h>
8#include <stdbool.h>
9#include "list.h"
10
26
28typedef int t_regID;
29
31#define REG_INVALID ((t_regID)(-1))
33#define REG_0 ((t_regID)(0))
34
35
41
42
47typedef struct {
49 unsigned int labelID;
52 char *name;
54 bool global;
57 bool isAlias;
58} t_label;
59
68
81
95
106
107
110
112t_program *newProgram(void);
113
116void deleteProgram(t_program *program);
117
119
120
123
127t_label *createLabel(t_program *program);
128
132void assignLabel(t_program *program, t_label *label);
133
140void setLabelName(t_program *program, t_label *label, const char *name);
141
146char *getLabelName(t_label *label);
147
149
150
153
158
179t_instruction *genInstruction(t_program *program, int opcode, t_regID rd,
180 t_regID rs1, t_regID rs2, t_label *label, int immediate);
181
186void removeInstructionAt(t_program *program, t_listNode *instrLi);
187
189
190
193
201 t_program *program, char *ID, t_symbolType type, int arraySize);
202
208t_symbol *getSymbol(t_program *program, char *ID);
209
214bool isArray(t_symbol *symbol);
215
217
218
221
224void genEpilog(t_program *program);
225
229void programDump(t_program *program, FILE *fout);
230
232
236
237#endif
A node belonging a list.
Definition list.h:39
unsigned int firstUnusedLblID
Next unused label ID.
Definition program.h:103
t_label * addressParam
Definition program.h:77
t_symbolType type
A valid data type.
Definition program.h:86
t_listNode * instructions
List of instructions.
Definition program.h:100
t_listNode * mcRegWhitelist
Definition program.h:66
char * comment
A comment string associated with the instruction, or NULL if none.
Definition program.h:79
int arraySize
For arrays only, the size of the array.
Definition program.h:93
t_listNode * labels
List of all labels.
Definition program.h:99
t_listNode * symbols
Symbol table.
Definition program.h:101
t_label * pendingLabel
Next pending label to assign.
Definition program.h:104
char * name
Definition program.h:52
unsigned int labelID
Unique numeric identifier for the label.
Definition program.h:49
char * ID
Symbol name (should never be a NULL pointer or an empty string "").
Definition program.h:88
bool global
True if the label will be defined as 'global'.
Definition program.h:54
t_instrArg * rSrc1
First source argument (or NULL if none).
Definition program.h:74
t_regID firstUnusedReg
Next unused register ID.
Definition program.h:102
t_instrArg * rSrc2
Second source argument (or NULL if none).
Definition program.h:75
int immediate
Immediate argument.
Definition program.h:76
t_regID ID
The register identifier.
Definition program.h:63
t_label * label
Label associated with the instruction, or NULL.
Definition program.h:71
t_instrArg * rDest
Destination argument (or NULL if none).
Definition program.h:73
bool isAlias
Definition program.h:57
int opcode
Instruction opcode.
Definition program.h:72
void setLabelName(t_program *program, t_label *label, const char *name)
Definition program.c:205
void assignLabel(t_program *program, t_label *label)
Definition program.c:253
t_regID getNewRegister(t_program *program)
Definition program.c:398
bool isArray(t_symbol *symbol)
Definition program.c:445
t_symbol * getSymbol(t_program *program, char *ID)
Definition program.c:461
void programDump(t_program *program, FILE *fout)
Definition program.c:493
void genEpilog(t_program *program)
Definition program.c:475
t_label * createLabel(t_program *program)
Definition program.c:173
void removeInstructionAt(t_program *program, t_listNode *instrLi)
Definition program.c:361
t_symbol * createSymbol(t_program *program, char *ID, t_symbolType type, int arraySize)
Definition program.c:406
char * getLabelName(t_label *label)
Definition program.c:297
t_instruction * genInstruction(t_program *program, int opcode, t_regID rd, t_regID rs1, t_regID rs2, t_label *label, int immediate)
Definition program.c:338
int t_regID
Type for register identifiers.
Definition program.h:28
t_program * newProgram(void)
Definition program.c:141
void deleteProgram(t_program *program)
Definition program.c:162
t_symbolType
Definition program.h:37
@ TYPE_INT_ARRAY
‘int’ array type.
Definition program.h:39
@ TYPE_INT
‘int’ scalar type.
Definition program.h:38
A double-linked list.