@@ -830,26 +830,32 @@ pseudo_t undef_pseudo(void)
return pseudo;
}
-pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, struct symbol *type)
+struct instruction *alloc_phisrc(pseudo_t pseudo, struct symbol *type)
{
- struct instruction *insn;
- pseudo_t phi;
+ struct instruction *insn = alloc_typed_instruction(OP_PHISOURCE, type);
+ pseudo_t phi = __alloc_pseudo(0);
static int nr = 0;
- if (!source)
- return VOID;
-
- insn = alloc_typed_instruction(OP_PHISOURCE, type);
- phi = __alloc_pseudo(0);
phi->type = PSEUDO_PHI;
phi->nr = ++nr;
phi->def = insn;
use_pseudo(insn, pseudo, &insn->phi_src);
- insn->bb = source;
insn->target = phi;
+ return insn;
+}
+
+pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, struct symbol *type)
+{
+ struct instruction *insn;
+
+ if (!source)
+ return VOID;
+
+ insn = alloc_phisrc(pseudo, type);
+ insn->bb = source;
add_instruction(&source->insns, insn);
- return phi;
+ return insn->target;
}
pseudo_t insert_phi_node(struct basic_block *bb, struct symbol *type)
@@ -332,6 +332,7 @@ struct entrypoint {
extern void insert_select(struct basic_block *bb, struct instruction *br, struct instruction *phi, pseudo_t if_true, pseudo_t if_false);
extern void insert_branch(struct basic_block *bb, struct instruction *br, struct basic_block *target);
+struct instruction *alloc_phisrc(pseudo_t pseudo, struct symbol *type);
pseudo_t insert_phi_node(struct basic_block *bb, struct symbol *type);
pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, struct symbol *type);
pseudo_t alloc_pseudo(struct instruction *def);
This give us: - a clearer name (than alloc_phi()) - more flexibility when we need the instruction and not the pseudo. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- linearize.c | 26 ++++++++++++++++---------- linearize.h | 1 + 2 files changed, 17 insertions(+), 10 deletions(-)