use a new Ref type for registers
This might not be a good idea, the problem was that many spurious registers would be added to the Bits data-structures during compilation (and would always remain 0). However, doing the above modification de-uniformizes the handling of temps and regs, this makes the code longer and not really nicer. Also, additional Bits structures are required to track the registers independently. Overall this might be a bad idea to revert.
This commit is contained in:
parent
93601b6d02
commit
9456200d91
9 changed files with 323 additions and 272 deletions
49
lisc/lisc.h
49
lisc/lisc.h
|
@ -12,8 +12,8 @@ typedef struct OpDesc OpDesc;
|
|||
typedef struct Ins Ins;
|
||||
typedef struct Phi Phi;
|
||||
typedef struct Blk Blk;
|
||||
typedef struct Sym Sym;
|
||||
typedef struct Cons Cons;
|
||||
typedef struct Tmp Tmp;
|
||||
typedef struct Con Con;
|
||||
typedef struct Fn Fn;
|
||||
|
||||
typedef enum { U, F, T } B3;
|
||||
|
@ -40,10 +40,28 @@ enum {
|
|||
RBP, /* reserved */
|
||||
RSP,
|
||||
|
||||
EAX, /* 32bits */
|
||||
ECX,
|
||||
EDX,
|
||||
ESI,
|
||||
EDI,
|
||||
R8D,
|
||||
R9D,
|
||||
R10D,
|
||||
R11D,
|
||||
|
||||
EBX,
|
||||
R12D,
|
||||
R13D,
|
||||
R14D,
|
||||
R15D,
|
||||
|
||||
// NReg = R15 - RAX + 1
|
||||
NReg = 3 /* for test purposes */
|
||||
};
|
||||
|
||||
#define LTW(r) (r + (EAX-RAX))
|
||||
|
||||
enum {
|
||||
NString = 32,
|
||||
NPred = 15,
|
||||
|
@ -68,16 +86,16 @@ struct Ref {
|
|||
};
|
||||
|
||||
enum {
|
||||
RSym,
|
||||
RCons,
|
||||
RTmp,
|
||||
RCon,
|
||||
RSlot,
|
||||
RReg,
|
||||
NRef = (1<<14) - 1
|
||||
};
|
||||
|
||||
#define R (Ref){0, 0}
|
||||
#define SYM(x) (Ref){RSym, x}
|
||||
#define CONS(x) (Ref){RCons, x}
|
||||
#define TMP(x) (Ref){RTmp, x}
|
||||
#define CON(x) (Ref){RCon, x}
|
||||
#define SLOT(x) (Ref){RSlot, x}
|
||||
#define REG(x) (Ref){RReg, x}
|
||||
|
||||
|
@ -153,11 +171,11 @@ struct Blk {
|
|||
char name[NString];
|
||||
};
|
||||
|
||||
struct Sym {
|
||||
struct Tmp {
|
||||
enum {
|
||||
SUndef,
|
||||
SWord,
|
||||
SLong,
|
||||
TUndef,
|
||||
TWord,
|
||||
TLong,
|
||||
} type;
|
||||
char name[NString];
|
||||
uint ndef, nuse;
|
||||
|
@ -166,7 +184,7 @@ struct Sym {
|
|||
int hint;
|
||||
};
|
||||
|
||||
struct Cons {
|
||||
struct Con {
|
||||
enum {
|
||||
CUndef,
|
||||
CNum,
|
||||
|
@ -178,9 +196,10 @@ struct Cons {
|
|||
|
||||
struct Fn {
|
||||
Blk *start;
|
||||
Sym *sym;
|
||||
Cons *cons;
|
||||
int nsym;
|
||||
Tmp *tmp;
|
||||
Con *con;
|
||||
int ntmp;
|
||||
int ncon;
|
||||
int nblk;
|
||||
Blk **rpo;
|
||||
uint nspill;
|
||||
|
@ -189,7 +208,7 @@ struct Fn {
|
|||
|
||||
/* main.c */
|
||||
extern char debug['Z'+1];
|
||||
void dumpss(Bits *, Sym *, FILE *);
|
||||
void dumpts(Bits *, Tmp *, FILE *);
|
||||
|
||||
/* parse.c */
|
||||
extern OpDesc opdesc[];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue