summary refs log tree commit diff
path: root/lisc/lisc.h
blob: dbe4d633454e8ae674910160e561e605146e0012 (plain) (blame)
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
#include <stdio.h>
#include <stdlib.h>

enum {
	R = -1,        /* Invalid reference. */
	Temp0 = 32,    /* First temporary, below are machine registers. */
	MaxPreds = 16, /* Maximum number of predecessors for a block. */
	MaxBlks = 128,
	MaxInss = 128,
	MaxPhis = 128,
};

typedef int Ref;
typedef struct Ins Ins;
typedef struct Phi Phi;
typedef struct Blk Blk;
typedef enum Op Op;
typedef enum Jmp Jmp;

enum Op {
	ONop,
	OAdd,
	OSub,
	OSDiv,
	OMod,
	OParam,
	OCall,

	/* x86 instructions (reserved) */
	XDiv,
};

enum Jmp {
	JRet,
	JJmp,
	JCnd,
};

struct Ins {
	Op op;
	Ref res;
	Ref arg0, arg1;
};

struct Phi {
	Ref res;
	int na;
	Ref args[MaxPreds];
};

struct Blk {
	int np;
	int ni;
	Phi *ps;
	Ins *is;
	struct {
		Jmp ty;
		Ref arg;
	} jmp;
	int suc0, suc1;
	int dpth;
};