10 #define ERROR_INVALID_OPCODE 1
11 #define ERROR_DELAY_SLOT 2
12 #define ERROR_TARGET_OUTSIDE_FILE 3
13 #define ERROR_DELAY_SLOT_TARGET 4
14 #define ERROR_ILLEGAL_BRANCH 5
16 #define LOCATION_REACHABLE 1
17 #define LOCATION_DELAY_SLOT 2
19 #define VARIABLES_NUM 32
20 #define VARIABLE_TYPE_REGISTER 1
21 #define VARIABLE_TYPE_STACK 2
23 #define VARDEF_TYPE_LOCATION 1
24 #define VARDEF_TYPE_CALL 2
25 #define VARDEF_TYPE_SUBINPUT 3
26 #define VARDEF_TYPE_SUBOUTPUT 4
27 #define VARDEF_TYPE_PHI 5
35 const struct allegrex_instruction
*insn
;
36 struct location
*target
;
46 struct subroutine
*sub
;
47 struct basicblock
*block
;
48 struct codeswitch
*cswitch
;
52 struct prx_reloc
*jumpreloc
;
53 struct prx_reloc
*switchreloc
;
54 struct location
*location
;
55 struct location
*jumplocation
;
62 struct prx_function
*export
;
63 struct prx_function
*import
;
65 struct location
*begin
;
68 struct basicblock
*endblock
;
69 list blocks
, dfsblocks
, revdfsblocks
;
81 struct basicedge
*edge
;
82 struct subroutine
*sub
;
91 struct basicedge
*edge
;
92 struct subroutine
*sub
;
107 struct location
*begin
;
108 struct location
*end
;
110 struct location
*jumploc
;
112 struct basicblock
*dominator
;
113 struct basicblock
*parent
;
116 struct basicblock
*revdominator
;
117 struct basicblock
*revparent
;
119 list outrefs
, inrefs
;
120 int dfsnum
, revdfsnum
;
122 struct loopstruct
*loop
;
127 struct basicblock
*from
, *to
;
129 struct subroutine
*calltarget
;
132 struct codeswitch
*cswitch
;
137 struct basicblock
*begin
;
138 struct basicblock
*end
;
142 struct basicblock
*start
;
143 struct loopstruct
*parent
;
151 uint32 baddr
, numopc
;
152 struct location
*base
;
153 struct location
*end
;
158 fixedpool switchpool
;
160 fixedpool blockspool
;
168 struct code
* code_analyse (struct prx
*p
);
169 void code_free (struct code
*c
);
171 int decode_instructions (struct code
*c
);
172 uint32
location_gpr_used (struct location
*loc
);
173 uint32
location_gpr_defined (struct location
*loc
);
175 void extract_switches (struct code
*c
);
176 void extract_subroutines (struct code
*c
);
178 void extract_cfg (struct code
*c
, struct subroutine
*sub
);
180 int cfg_dfs (struct subroutine
*sub
);
181 int cfg_revdfs (struct subroutine
*sub
);
182 struct basicblock
*dom_intersect (struct basicblock
*b1
, struct basicblock
*b2
);
183 void cfg_dominance (struct subroutine
*sub
);
184 struct basicblock
*dom_revintersect (struct basicblock
*b1
, struct basicblock
*b2
);
185 void cfg_revdominance (struct subroutine
*sub
);
186 void extract_loops (struct code
*c
, struct subroutine
*sub
);
189 void build_ssa (struct code
*c
, struct subroutine
*sub
);
192 #endif /* __CODE_H */