-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecl.h
142 lines (129 loc) · 4.54 KB
/
decl.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// scan.c
void dealing_minus(struct token *t);
int scan(struct token *t);
// tree.c
struct ASTnode *mkastnode(int op, int type,
struct ASTnode *left, struct ASTnode *mid, struct ASTnode *right,
struct symtable *sym, int intvalue);
struct ASTnode *mkastleaf(int op, int type,
struct symtable *sym, int intvalue);
struct ASTnode *mkastunary(int op, int type, struct ASTnode *left,
struct symtable *sym, int intvalue);
// gen.c
int genlabel(void);
int genAST(struct ASTnode *n, int iflabel, int looptoplabel,
int loopendlabel, int parentASTop);
void genpreamble(void);
void genpostamble(void);
void genfreeregs(int keepreg);
void genglobsym(struct symtable *sym);
int genglobstr(char *strvalue);
int genprimsize(int type);
int genalign(int type, int offset, int direction);
// cg.c
void cgtextseg(void);
void cgdataseg(void);
void freeall_registers(int keepreg);
int alloc_register(void);
void cgpreamble(void);
void cgpostamble(void);
void cgfuncpreamble(struct symtable *sym);
void cgfuncpostamble(struct symtable *sym);
int cgstorglob(int r, struct symtable *sym);
int cgstorlocal(int r, struct symtable *sym);
int cgstorderef(int r1, int r2, int type);
int cgor(int r1, int r2);
int cgxor(int r1, int r2);
int cgand(int r1, int r2);
int cgcompare_and_jump(int ASTop, int r1, int r2, int label);
int cgcompare_and_set(int ASTop, int r1, int r2);
int cgshl(int r1, int r2);
int cgshr(int r1, int r2);
int cgadd(int r1, int r2);
int cgsub(int r1, int r2);
int cgmul(int r1, int r2);
int cgdiv(int r1, int r2);
int cgloadint(int value, int type);
int cgloadglobstr(int label);
int cgloadglob(struct symtable* sym, int op);
int cgloadlocal(struct symtable* sym, int op);
int cgnegate(int r);
int cginvert(int r);
int cglognot(int r);
int cgboolean(int r, int op, int label);
void cgreturn(int r, struct symtable *sym); //verified
int cgcall(struct symtable *sym, int numargs); //verified
void cgcopyarg(int r, int argposn); //verified
int cgaddress(struct symtable *sym); //verified
int cgderef(int r, int type); //verified
int cgwiden(int r, int oldtype, int newtype);
int cgshlconst(int r, int val);
void cgglobsym(struct symtable *sym);
void cgglobstr(int l, char *strvalue);
int cgprimsize(int type);
int cglign(int type, int offset, int direction);
void cglabel(int l);
void cgjump(int l);
void cgmove(int r1, int r2);
void cgswitch(int reg, int casecount, int toplabel,
int *caselabel, int *caseval, int defaultlabel);
// expr.c
struct ASTnode *expression_list(int endtoken);
struct ASTnode *binexpr(int ptp);
// stmt.c
struct ASTnode *compound_statement(int inswitch);
// misc.c
void match(int t, char *what);
void semi(void);
void lbrace(void);
void rbrace(void);
void lparen(void);
void rparen(void);
void ident(void);
void comma(void);
void warn(char *s);
void fatal(char *s);
void fatals(char *s1, char *s2);
void fatald(char *s, int d);
void fatalc(char *s, int c);
// sym.c
struct symtable *addglob(char *name, int type, struct symtable *ctype,
int stype, int class, int nelems, int posn);
struct symtable *addlocl(char *name, int type, struct symtable *ctype,
int stype, int nelems) ;
struct symtable *addparm(char *name, int type, struct symtable *ctype,
int stype);
struct symtable *addmemb(char *name, int type, struct symtable *ctype,
int stype, int nelems);
struct symtable *addstruct(char *name);
struct symtable *addunion(char *name);
struct symtable *addenum(char *name, int class, int value);
struct symtable *addtypedef(char *name, int type, struct symtable *ctype);
struct symtable *findglob(char *s);
struct symtable *findlocl(char *s);
struct symtable *findsymbol(char *s);
struct symtable *findmember(char *s);
struct symtable *findstruct(char *s);
struct symtable *findunion(char *s);
struct symtable *findenumtype(char *s);
struct symtable *findenumval(char *s);
struct symtable *findtypedef(char *s);
void clear_symtable(void);
void freeloclsyms(void);
void freestaticsyms(void);
// decl.c
int declaration_list(int class, int et1, int et2, struct ASTnode **gluetree);
void global_declarations(void);
int parse_type(struct symtable **ctype, int *class);
int parse_stars(int type);
int parse_cast(void);
int parse_literal(int type);
// types.c
int inttype(int type);
int ptrtype(int type);
int pointer_to(int type);
int value_at(int type);
int typesize(int type, struct symtable *ctype);
struct ASTnode *modify_type(struct ASTnode *tree, int rtype, int op);
// opt.c
struct ASTnode *optimise(struct ASTnode *n);