11 DECLARE_PTR_LIST(pseudo_ptr_list
, pseudo_t
);
14 struct instruction
*insn
;
18 DECLARE_ALLOCATOR(pseudo_user
);
19 DECLARE_PTR_LIST(pseudo_user_list
, struct pseudo_user
);
33 int size
:16; /* OP_SETVAL only */
34 enum pseudo_type type
:8;
35 struct pseudo_user_list
*users
;
39 struct instruction
*def
;
45 extern struct pseudo void_pseudo
;
47 #define VOID (&void_pseudo)
50 struct basic_block
*target
;
54 struct asm_constraint
{
56 const char *constraint
;
57 const struct ident
*ident
;
60 DECLARE_ALLOCATOR(asm_constraint
);
61 DECLARE_PTR_LIST(asm_constraint_list
, struct asm_constraint
);
64 struct asm_constraint_list
*inputs
;
65 struct asm_constraint_list
*outputs
;
66 struct asm_constraint_list
*clobbers
;
69 DECLARE_ALLOCATOR(asm_rules
);
74 struct basic_block
*bb
;
79 pseudo_t cond
; /* for branch and switch */
82 struct /* entrypoint */ {
83 struct pseudo_list
*arg_list
;
86 struct basic_block
*bb_true
, *bb_false
;
89 struct multijmp_list
*multijmp_list
;
91 struct /* phi_node */ {
92 struct pseudo_list
*phi_list
;
94 struct /* phi source */ {
96 struct instruction_list
*phi_users
;
100 struct symbol
*orig_type
; /* casts */
101 unsigned int offset
; /* memops */
103 struct /* binops and sel */ {
104 pseudo_t src1
, src2
, src3
;
110 struct /* setval */ {
111 pseudo_t symbol
; /* Subtle: same offset as "src" !! */
112 struct expression
*val
;
116 struct pseudo_list
*arguments
;
117 struct symbol
*fntype
;
119 struct /* context */ {
122 struct expression
*context_expr
;
126 struct asm_rules
*asm_rules
;
139 OP_RET
= OP_TERMINATOR
,
146 OP_TERMINATOR_END
= OP_UNWIND
,
164 OP_BINARY_END
= OP_OR_BOOL
,
166 /* Binary comparison */
168 OP_SET_EQ
= OP_BINCMP
,
178 OP_BINCMP_END
= OP_SET_AE
,
184 /* Select - three input values */
215 /* Sparse tagging (line numbers, context, whatever) */
219 /* Needed to translate SSA back to normal form */
223 struct basic_block_list
;
224 struct instruction_list
;
228 unsigned long generation
;
230 struct entrypoint
*ep
;
231 struct basic_block_list
*parents
; /* sources */
232 struct basic_block_list
*children
; /* destinations */
233 struct instruction_list
*insns
; /* Linear list of instructions */
234 struct pseudo_list
*needs
, *defines
;
236 unsigned int nr
; /* unique id for label's names */
242 static inline void add_bb(struct basic_block_list
**list
, struct basic_block
*bb
)
244 add_ptr_list(list
, bb
);
247 static inline void add_instruction(struct instruction_list
**list
, struct instruction
*insn
)
249 add_ptr_list(list
, insn
);
252 static inline void add_multijmp(struct multijmp_list
**list
, struct multijmp
*multijmp
)
254 add_ptr_list(list
, multijmp
);
257 static inline pseudo_t
*add_pseudo(struct pseudo_list
**list
, pseudo_t pseudo
)
259 return add_ptr_list(list
, pseudo
);
262 static inline int remove_pseudo(struct pseudo_list
**list
, pseudo_t pseudo
)
264 return delete_ptr_list_entry((struct ptr_list
**)list
, pseudo
, 0) != 0;
267 static inline int bb_terminated(struct basic_block
*bb
)
269 struct instruction
*insn
;
272 insn
= last_instruction(bb
->insns
);
273 return insn
&& insn
->opcode
>= OP_TERMINATOR
274 && insn
->opcode
<= OP_TERMINATOR_END
;
277 static inline int bb_reachable(struct basic_block
*bb
)
282 static inline void add_pseudo_ptr(pseudo_t
*ptr
, struct pseudo_ptr_list
**list
)
284 add_ptr_list(list
, ptr
);
287 static inline void add_pseudo_user_ptr(struct pseudo_user
*user
, struct pseudo_user_list
**list
)
289 add_ptr_list(list
, user
);
292 static inline int has_use_list(pseudo_t p
)
294 return (p
&& p
->type
!= PSEUDO_VOID
&& p
->type
!= PSEUDO_VAL
);
297 static inline struct pseudo_user
*alloc_pseudo_user(struct instruction
*insn
, pseudo_t
*pp
)
299 struct pseudo_user
*user
= __alloc_pseudo_user(0);
305 static inline void use_pseudo(struct instruction
*insn
, pseudo_t p
, pseudo_t
*pp
)
309 add_pseudo_user_ptr(alloc_pseudo_user(insn
, pp
), &p
->users
);
312 static inline void remove_bb_from_list(struct basic_block_list
**list
, struct basic_block
*entry
, int count
)
314 delete_ptr_list_entry((struct ptr_list
**)list
, entry
, count
);
317 static inline void replace_bb_in_list(struct basic_block_list
**list
,
318 struct basic_block
*old
, struct basic_block
*new, int count
)
320 replace_ptr_list_entry((struct ptr_list
**)list
, old
, new, count
);
325 struct symbol_list
*syms
;
326 struct pseudo_list
*accesses
;
327 struct basic_block_list
*bbs
;
328 struct basic_block
*active
;
329 struct instruction
*entry
;
332 extern void insert_select(struct basic_block
*bb
, struct instruction
*br
, struct instruction
*phi
, pseudo_t if_true
, pseudo_t if_false
);
333 extern void insert_branch(struct basic_block
*bb
, struct instruction
*br
, struct basic_block
*target
);
335 pseudo_t
alloc_phi(struct basic_block
*source
, pseudo_t pseudo
, int size
);
336 pseudo_t
alloc_pseudo(struct instruction
*def
);
337 pseudo_t
value_pseudo(struct symbol
*type
, long long val
);
338 unsigned int value_size(long long value
);
340 struct entrypoint
*linearize_symbol(struct symbol
*sym
);
341 int unssa(struct entrypoint
*ep
);
342 void show_entry(struct entrypoint
*ep
);
343 const char *show_pseudo(pseudo_t pseudo
);
344 void show_bb(struct basic_block
*bb
);
345 const char *show_instruction(struct instruction
*insn
);
347 #endif /* LINEARIZE_H */