10 DECLARE_PTR_LIST(pseudo_ptr_list
, pseudo_t
);
23 enum pseudo_type type
;
24 struct pseudo_ptr_list
*users
;
28 struct instruction
*def
;
33 extern struct pseudo void_pseudo
;
35 #define VOID (&void_pseudo)
38 struct basic_block
*target
;
42 struct asm_constraint
{
44 const char *constraint
;
45 const struct ident
*ident
;
48 DECLARE_PTR_LIST(asm_constraint_list
, struct asm_constraint
);
51 struct asm_constraint_list
*inputs
;
52 struct asm_constraint_list
*outputs
;
53 struct asm_constraint_list
*clobbers
;
59 struct basic_block
*bb
;
63 pseudo_t cond
; /* for branch and switch */
66 struct /* entrypoint */ {
67 struct pseudo_list
*arg_list
;
70 struct basic_block
*bb_true
, *bb_false
;
73 struct multijmp_list
*multijmp_list
;
75 struct /* phi_node */ {
76 struct pseudo_list
*phi_list
;
78 struct /* phi source */ {
80 struct instruction_list
*phi_users
;
84 struct symbol
*orig_type
; /* casts */
85 unsigned int offset
; /* memops */
87 struct /* binops and sel */ {
88 pseudo_t src1
, src2
, src3
;
94 struct /* multijump */ {
98 pseudo_t symbol
; /* Subtle: same offset as "src" !! */
99 struct expression
*val
;
103 struct pseudo_list
*arguments
;
105 struct /* context */ {
111 struct asm_rules
*asm_rules
;
124 OP_RET
= OP_TERMINATOR
,
130 OP_TERMINATOR_END
= OP_UNWIND
,
148 OP_BINARY_END
= OP_OR_BOOL
,
150 /* Binary comparison */
152 OP_SET_EQ
= OP_BINCMP
,
162 OP_BINCMP_END
= OP_SET_AE
,
168 /* Select - three input values */
198 /* Sparse tagging (line numbers, context, whatever) */
202 /* Needed to translate SSA back to normal form */
206 struct basic_block_list
;
207 struct instruction_list
;
211 unsigned long generation
;
213 struct entrypoint
*ep
;
214 struct basic_block_list
*parents
; /* sources */
215 struct basic_block_list
*children
; /* destinations */
216 struct instruction_list
*insns
; /* Linear list of instructions */
217 struct pseudo_list
*needs
, *defines
;
220 static inline int is_branch_goto(struct instruction
*br
)
222 return br
&& br
->opcode
==OP_BR
&& (!br
->bb_true
|| !br
->bb_false
);
225 static inline void add_bb(struct basic_block_list
**list
, struct basic_block
*bb
)
227 add_ptr_list(list
, bb
);
230 static inline void add_instruction(struct instruction_list
**list
, struct instruction
*insn
)
232 add_ptr_list(list
, insn
);
235 static inline void add_multijmp(struct multijmp_list
**list
, struct multijmp
*multijmp
)
237 add_ptr_list(list
, multijmp
);
240 static inline pseudo_t
*add_pseudo(struct pseudo_list
**list
, pseudo_t pseudo
)
242 return add_ptr_list(list
, pseudo
);
245 static inline int remove_pseudo(struct pseudo_list
**list
, pseudo_t pseudo
)
247 return delete_ptr_list_entry((struct ptr_list
**)list
, pseudo
, 0) != 0;
250 static inline int bb_terminated(struct basic_block
*bb
)
252 struct instruction
*insn
;
255 insn
= last_instruction(bb
->insns
);
256 return insn
&& insn
->opcode
>= OP_RET
&& insn
->opcode
<= OP_UNWIND
;
259 static inline int bb_reachable(struct basic_block
*bb
)
264 static inline void add_pseudo_ptr(pseudo_t
*ptr
, struct pseudo_ptr_list
**list
)
266 add_ptr_list(list
, ptr
);
269 static inline int has_use_list(pseudo_t p
)
271 return (p
&& p
->type
!= PSEUDO_VOID
&& p
->type
!= PSEUDO_VAL
);
274 static inline void use_pseudo(pseudo_t p
, pseudo_t
*pp
)
278 add_pseudo_ptr(pp
, &p
->users
);
281 static inline void remove_bb_from_list(struct basic_block_list
**list
, struct basic_block
*entry
, int count
)
283 delete_ptr_list_entry((struct ptr_list
**)list
, entry
, count
);
286 static inline void replace_bb_in_list(struct basic_block_list
**list
,
287 struct basic_block
*old
, struct basic_block
*new, int count
)
289 replace_ptr_list_entry((struct ptr_list
**)list
, old
, new, count
);
294 struct symbol_list
*syms
;
295 struct symbol_list
*accesses
;
296 struct basic_block_list
*bbs
;
297 struct basic_block
*active
;
298 struct instruction
*entry
;
301 extern void insert_select(struct basic_block
*bb
, struct instruction
*br
, struct instruction
*phi
, pseudo_t
true, pseudo_t
false);
302 extern void insert_branch(struct basic_block
*bb
, struct instruction
*br
, struct basic_block
*target
);
304 pseudo_t
alloc_phi(struct basic_block
*source
, pseudo_t pseudo
, int size
);
305 pseudo_t
alloc_pseudo(struct instruction
*def
);
306 pseudo_t
value_pseudo(long long val
);
308 struct entrypoint
*linearize_symbol(struct symbol
*sym
);
309 int unssa(struct entrypoint
*ep
);
310 void show_entry(struct entrypoint
*ep
);
311 const char *show_pseudo(pseudo_t pseudo
);
312 void show_bb(struct basic_block
*bb
);
313 const char *show_instruction(struct instruction
*insn
);
315 #endif /* LINEARIZE_H */