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
;
45 struct basic_block
*bb
;
48 pseudo_t cond
; /* for branch and switch */
52 struct basic_block
*bb_true
, *bb_false
;
55 struct multijmp_list
*multijmp_list
;
57 struct /* phi_node */ {
58 struct pseudo_list
*phi_list
;
60 struct /* phi source */ {
62 struct instruction_list
*phi_users
;
66 struct symbol
*orig_type
; /* casts */
67 unsigned int offset
; /* memops */
69 struct /* binops and sel */ {
70 pseudo_t src1
, src2
, src3
;
76 struct /* multijump */ {
80 pseudo_t symbol
; /* Subtle: same offset as "src" !! */
81 struct expression
*val
;
85 struct pseudo_list
*arguments
;
87 struct /* context */ {
92 struct pseudo_list
*outputs
;
93 struct pseudo_list
*inputs
;
106 OP_RET
= OP_TERMINATOR
,
112 OP_TERMINATOR_END
= OP_UNWIND
,
130 OP_BINARY_END
= OP_OR_BOOL
,
132 /* Binary comparison */
134 OP_SET_EQ
= OP_BINCMP
,
144 OP_BINCMP_END
= OP_SET_AE
,
150 /* Select - three input values */
177 /* Sparse tagging (line numbers, context, whatever) */
181 struct basic_block_list
;
182 struct instruction_list
;
186 unsigned long generation
;
188 struct entrypoint
*ep
;
189 struct basic_block_list
*parents
; /* sources */
190 struct basic_block_list
*children
; /* destinations */
191 struct instruction_list
*insns
; /* Linear list of instructions */
192 struct pseudo_list
*needs
, *defines
;
195 static inline int is_branch_goto(struct instruction
*br
)
197 return br
&& br
->opcode
==OP_BR
&& (!br
->bb_true
|| !br
->bb_false
);
200 static inline void add_bb(struct basic_block_list
**list
, struct basic_block
*bb
)
202 add_ptr_list(list
, bb
);
205 static inline void add_instruction(struct instruction_list
**list
, struct instruction
*insn
)
207 add_ptr_list(list
, insn
);
210 static inline void add_multijmp(struct multijmp_list
**list
, struct multijmp
*multijmp
)
212 add_ptr_list(list
, multijmp
);
215 static inline void *add_pseudo(struct pseudo_list
**list
, struct pseudo
*pseudo
)
217 return add_ptr_list(list
, pseudo
);
220 static inline int remove_pseudo(struct pseudo_list
**list
, pseudo_t pseudo
)
222 return delete_ptr_list_entry((struct ptr_list
**)list
, pseudo
, 0) != 0;
225 static inline int bb_terminated(struct basic_block
*bb
)
227 struct instruction
*insn
;
230 insn
= last_instruction(bb
->insns
);
231 return insn
&& insn
->opcode
>= OP_RET
&& insn
->opcode
<= OP_UNWIND
;
234 static inline int bb_reachable(struct basic_block
*bb
)
239 static inline void add_pseudo_ptr(pseudo_t
*ptr
, struct pseudo_ptr_list
**list
)
241 add_ptr_list(list
, ptr
);
244 static inline int has_use_list(pseudo_t p
)
246 return (p
&& p
->type
!= PSEUDO_VOID
&& p
->type
!= PSEUDO_VAL
);
249 static inline void use_pseudo(pseudo_t p
, pseudo_t
*pp
)
253 add_pseudo_ptr(pp
, &p
->users
);
256 static inline void remove_bb_from_list(struct basic_block_list
**list
, struct basic_block
*entry
, int count
)
258 delete_ptr_list_entry((struct ptr_list
**)list
, entry
, count
);
261 static inline void replace_bb_in_list(struct basic_block_list
**list
,
262 struct basic_block
*old
, struct basic_block
*new, int count
)
264 replace_ptr_list_entry((struct ptr_list
**)list
, old
, new, count
);
269 struct symbol_list
*syms
;
270 struct symbol_list
*accesses
;
271 struct basic_block_list
*bbs
;
272 struct basic_block
*active
;
273 struct instruction
*entry
;
276 extern void insert_select(struct basic_block
*bb
, struct instruction
*br
, struct instruction
*phi
, pseudo_t
true, pseudo_t
false);
277 extern void insert_branch(struct basic_block
*bb
, struct instruction
*br
, struct basic_block
*target
);
279 pseudo_t
alloc_phi(struct basic_block
*source
, pseudo_t pseudo
, int size
);
280 pseudo_t
alloc_pseudo(struct instruction
*def
);
281 pseudo_t
value_pseudo(long long val
);
283 struct entrypoint
*linearize_symbol(struct symbol
*sym
);
284 void show_entry(struct entrypoint
*ep
);
285 const char *show_pseudo(pseudo_t pseudo
);
286 void show_bb(struct basic_block
*bb
);
287 const char *show_instruction(struct instruction
*insn
);
289 #endif /* LINEARIZE_H */