From 9ae0ff9fdd9266a6fdf2e463e58204f050a02589 Mon Sep 17 00:00:00 2001 From: Teddy Date: Tue, 29 Apr 2014 15:17:40 +0800 Subject: ... --- ssa.h | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'ssa.h') diff --git a/ssa.h b/ssa.h index 75d166d..bedf7c8 100644 --- a/ssa.h +++ b/ssa.h @@ -22,7 +22,6 @@ typedef struct CInst CInst; typedef CInst *CInst_t; struct CInst { enum { - MOVE, BEQZ, /* conditional jump */ BNEZ, GOTO, /* unconditional jump */ @@ -31,6 +30,7 @@ struct CInst { PUSH, /* push to stack top */ CALL, /* call function */ RET, /* return */ + MOVE, MUL, DIV, MOD, ADD, SUB, SHL, SHR, AND, XOR, OR, LOR, LAND, NEG, NOR, SEQ, @@ -40,17 +40,12 @@ struct CInst { CInst_t next, prev; }; -typedef struct COprList COprList; -typedef COprList *COprList_t; -struct COprList { - COpr opr; - COprList_t next; -}; typedef struct CPhi CPhi; typedef CPhi *CPhi_t; struct CPhi { - COpr dest; - COprList_t params; + COpr_t dest; + COpr_t *oprs; + CPhi_t next, prev; }; typedef struct CBlock CBlock; @@ -63,8 +58,16 @@ struct CBlock { int ref; /* if referenced by any gotos */ }; +typedef struct CBList CBList; +typedef CBList *CBList_t; +struct CBList { + CBlock_t cblk; + CBList_t next; +}; + CBlock_t cblock_create(); void cblock_append(CBlock_t cblk, CInst_t inst); +void cblock_pappend(CBlock_t cblk, CPhi_t phi); CInst_t cblock_getback(CBlock_t cblk); int cblock_isempty(CBlock_t cblk); @@ -76,5 +79,17 @@ typedef struct CGraph { } *head[MAX_BLOCK], *rhead[MAX_BLOCK]; } CGraph; +typedef struct CPNode CPNode; +typedef struct CPSet { + struct CPNode { + long key; + CPNode *next; + } *head[MAX_TABLE_SIZE]; +} CPSet; +typedef CPSet *CPSet_t; + +CPSet_t cpset_create(); +void cpset_insert(CPSet_t cps, long key); + void ssa_generate(CScope_t scope); #endif -- cgit v1.2.3-70-g09d2