some new C

This commit is contained in:
Quentin Carbonneaux 2015-06-11 08:49:34 -04:00
parent fd55a09b7f
commit fae1b41e9d
2 changed files with 144 additions and 0 deletions

62
lisc/lisc.h Normal file
View file

@ -0,0 +1,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;
};