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
;
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 */
163 /* Sparse tagging (line numbers, context, whatever) */
167 struct basic_block_list
;
168 struct instruction_list
;
172 unsigned long generation
;
174 struct entrypoint
*ep
;
175 struct basic_block_list
*parents
; /* sources */
176 struct basic_block_list
*children
; /* destinations */
177 struct instruction_list
*insns
; /* Linear list of instructions */
178 struct pseudo_list
*needs
, *defines
;
181 static inline int is_branch_goto(struct instruction
*br
)
183 return br
&& br
->opcode
==OP_BR
&& (!br
->bb_true
|| !br
->bb_false
);
186 static inline void add_bb(struct basic_block_list
**list
, struct basic_block
*bb
)
188 add_ptr_list(list
, bb
);
191 static inline void add_instruction(struct instruction_list
**list
, struct instruction
*insn
)
193 add_ptr_list(list
, insn
);
196 static inline void add_multijmp(struct multijmp_list
**list
, struct multijmp
*multijmp
)
198 add_ptr_list(list
, multijmp
);
201 static inline void *add_pseudo(struct pseudo_list
**list
, struct pseudo
*pseudo
)
203 return add_ptr_list(list
, pseudo
);
207 static inline int bb_terminated(struct basic_block
*bb
)
209 struct instruction
*insn
;
212 insn
= last_instruction(bb
->insns
);
213 return insn
&& insn
->opcode
>= OP_RET
&& insn
->opcode
<= OP_UNWIND
;
216 static inline int bb_reachable(struct basic_block
*bb
)
221 static inline void add_pseudo_ptr(pseudo_t
*ptr
, struct pseudo_ptr_list
**list
)
223 add_ptr_list(list
, ptr
);
226 static inline int has_use_list(pseudo_t p
)
228 return (p
&& p
->type
!= PSEUDO_VOID
&& p
->type
!= PSEUDO_VAL
);
231 static inline void use_pseudo(pseudo_t p
, pseudo_t
*pp
)
235 add_pseudo_ptr(pp
, &p
->users
);
238 static inline void remove_bb_from_list(struct basic_block_list
**list
, struct basic_block
*entry
, int count
)
240 delete_ptr_list_entry((struct ptr_list
**)list
, entry
, count
);
243 static inline void replace_bb_in_list(struct basic_block_list
**list
,
244 struct basic_block
*old
, struct basic_block
*new, int count
)
246 replace_ptr_list_entry((struct ptr_list
**)list
, old
, new, count
);
251 struct symbol_list
*syms
;
252 struct symbol_list
*accesses
;
253 struct basic_block_list
*bbs
;
254 struct basic_block
*active
;
255 struct basic_block
*entry
;
258 extern void insert_select(struct basic_block
*bb
, struct instruction
*br
, struct instruction
*phi
, pseudo_t
true, pseudo_t
false);
259 extern void insert_branch(struct basic_block
*bb
, struct instruction
*br
, struct basic_block
*target
);
261 pseudo_t
alloc_phi(struct basic_block
*source
, pseudo_t pseudo
, int size
);
262 pseudo_t
alloc_pseudo(struct instruction
*def
);
263 pseudo_t
value_pseudo(long long val
);
265 struct entrypoint
*linearize_symbol(struct symbol
*sym
);
266 void show_entry(struct entrypoint
*ep
);
268 #endif /* LINEARIZE_H */