diff options
author | Teddy <[email protected]> | 2014-04-27 02:25:48 +0800 |
---|---|---|
committer | Teddy <[email protected]> | 2014-04-27 02:25:48 +0800 |
commit | fbafb96963beae48ca095839ffb17b82f9901e5f (patch) | |
tree | 36a3ec0dde78269ca3e1d5ccd985bfd849370104 /ssa.h | |
parent | 0282e6aa2f3b24a3ffed876b099ec97e6a79a8ff (diff) |
ssa init
Diffstat (limited to 'ssa.h')
-rw-r--r-- | ssa.h | 53 |
1 files changed, 53 insertions, 0 deletions
@@ -0,0 +1,53 @@ +#ifndef SSA_H +#define SSA_H +#include "const.h" +#include "semantics.h" +typedef struct COpr { + enum { + VAR, + TMP, + IMM + } kind; + union { + CVar_t var; + int imm; + } info; +} COpr; + +typedef struct CInst CInst; +typedef CInst *CInst_t; +struct CInst { + enum { + MOVE, + BEQZ, /* conditional jump */ + GOTO, /* unconditional jump */ + ADD + } op; + COpr dest, src1, src2; + CInst_t next, prev; +}; + +typedef struct CBlock CBlock; +typedef CBlock *CBlock_t; +struct CBlock { + CInst_t insts; /* instructions */ + CBlock_t next, prev; + int id; + int ref; /* if referenced by any gotos */ +}; + +CBlock_t cblock_create(); +void cblock_append(CBlock_t cblk, CInst_t inst); +CInst_t cblock_getback(CBlock_t cblk); +int cblock_isempty(CBlock_t cblk); + +typedef struct CEdge CEdge; +typedef struct CGraph { + struct CEdge { + CBlock *to; + CEdge *next; + } *head[MAX_BLOCK], *rhead[MAX_BLOCK]; +} CGraph; + +void ssa_generate(CScope_t scope); +#endif |