-
Notifications
You must be signed in to change notification settings - Fork 5
/
gen.h
49 lines (41 loc) · 1.16 KB
/
gen.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
#ifndef GEN_H
#define GEN_H
// forward declaration
struct tree;
struct xinterface {
void (*label) (struct tree *);
struct tree ** (*nt_kids) (struct tree *, int, struct tree *[]);
int (*rule) (void *, int);
const char **rule_names;
const char **nt_names;
const char **templates;
short **nts;
int max_kids;
int nts_count;
};
struct xsymbol {
const char *name;
int label; // for goto labels
int framesize;
struct {
const char *alias[4];
int mask;
int index;
char kind;
bool preserved;
} reg;
};
enum { IREG, FREG };
enum { B, W, L, Q };
enum { Zero = 0, Byte = 1, Word = 2, Long = 4, Quad = 8 };
extern struct symbol *mkreg(const char *, int, int);
extern struct symbol *mksreg(const char *);
extern void gen(struct symbol *);
extern void emit(struct symbol *);
extern void genglobal(struct symbol *);
extern void genstring(struct symbol *);
#define reg_alias(s, i, name) \
do { (s)->x.reg.alias[i] = name; } while (0)
#define reg_preserved(s) \
do { (s)->x.reg.preserved = true; } while (0)
#endif