10 DECLARE_PTR_LIST(pseudo_ptr_list
, pseudo_t
);
23 enum pseudo_type type
;
24 struct pseudo_ptr_list
*users
;
25 struct instruction_list
*insns
;
28 struct instruction
*def
;
33 extern struct pseudo void_pseudo
;
35 #define VOID (&void_pseudo)
38 struct basic_block
*target
;
44 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
;
62 struct symbol
*orig_type
; /* casts */
63 unsigned int offset
; /* memops */
72 struct /* multijump */ {
76 pseudo_t symbol
; /* Subtle: same offset as "src" !! */
77 struct expression
*val
;
81 struct pseudo_list
*arguments
;
83 struct /* context */ {
93 OP_RET
= OP_TERMINATOR
,
99 OP_TERMINATOR_END
= OP_UNWIND
,
117 OP_BINARY_END
= OP_OR_BOOL
,
119 /* Binary comparison */
121 OP_SET_EQ
= OP_BINCMP
,
131 OP_BINCMP_END
= OP_SET_AE
,
137 /* Setcc - always in combination with a select or conditional branch */
162 /* Sparse tagging (line numbers, context, whatever) */
166 struct basic_block_list
;
167 struct instruction_list
;
171 unsigned long generation
;
173 struct entrypoint
*ep
;
174 struct basic_block_list
*parents
; /* sources */
175 struct basic_block_list
*children
; /* destinations */
176 struct instruction_list
*insns
; /* Linear list of instructions */
179 static inline int is_branch_goto(struct instruction
*br
)
181 return br
&& br
->opcode
==OP_BR
&& (!br
->bb_true
|| !br
->bb_false
);
184 static inline void add_bb(struct basic_block_list
**list
, struct basic_block
*bb
)
186 add_ptr_list(list
, bb
);
189 static inline void add_instruction(struct instruction_list
**list
, struct instruction
*insn
)
191 add_ptr_list(list
, insn
);
194 static inline void add_multijmp(struct multijmp_list
**list
, struct multijmp
*multijmp
)
196 add_ptr_list(list
, multijmp
);
199 static inline void *add_pseudo(struct pseudo_list
**list
, struct pseudo
*pseudo
)
201 return add_ptr_list(list
, pseudo
);
205 static inline int bb_terminated(struct basic_block
*bb
)
207 struct instruction
*insn
;
210 insn
= last_instruction(bb
->insns
);
211 return insn
&& insn
->opcode
>= OP_RET
&& insn
->opcode
<= OP_UNWIND
;
214 static inline int bb_reachable(struct basic_block
*bb
)
219 static inline void add_pseudo_ptr(pseudo_t
*ptr
, struct pseudo_ptr_list
**list
)
221 add_ptr_list(list
, ptr
);
224 static inline int has_use_list(pseudo_t p
)
226 return (p
&& p
->type
!= PSEUDO_VOID
&& p
->type
!= PSEUDO_VAL
);
229 static inline void use_pseudo(pseudo_t p
, pseudo_t
*pp
)
233 add_pseudo_ptr(pp
, &p
->users
);
236 static inline void remove_bb_from_list(struct basic_block_list
**list
, struct basic_block
*entry
, int count
)
238 delete_ptr_list_entry((struct ptr_list
**)list
, entry
, count
);
241 static inline void replace_bb_in_list(struct basic_block_list
**list
,
242 struct basic_block
*old
, struct basic_block
*new, int count
)
244 replace_ptr_list_entry((struct ptr_list
**)list
, old
, new, count
);
249 struct symbol_list
*syms
;
250 struct symbol_list
*accesses
;
251 struct basic_block_list
*bbs
;
252 struct basic_block
*active
;
253 struct basic_block
*entry
;
254 struct pseudo_list
*pseudos
;
257 extern void insert_select(struct basic_block
*bb
, struct instruction
*br
, struct instruction
*phi
, pseudo_t
true, pseudo_t
false);
258 extern void insert_branch(struct basic_block
*bb
, struct instruction
*br
, struct basic_block
*target
);
260 pseudo_t
alloc_phi(struct basic_block
*source
, pseudo_t pseudo
);
261 pseudo_t
alloc_pseudo(struct instruction
*def
);
262 pseudo_t
value_pseudo(long long val
);
264 struct entrypoint
*linearize_symbol(struct symbol
*sym
);
265 void show_entry(struct entrypoint
*ep
);
267 #endif /* LINEARIZE_H */