aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorJeff Garzik <jeff@garzik.org>2011-08-27 17:54:19 -0400
committerJeff Garzik <jgarzik@redhat.com>2011-08-27 17:54:19 -0400
commit7c8d8ae6c57c9d4d65c7952c52ea82100d7f6add (patch)
tree2d353d3c7f6ba57304c41fb0a475c6bd29d6329f
parent404705a0c86d910edebb4ad0936f9195f9d6d6b9 (diff)
downloadsparse-dev-7c8d8ae6c57c9d4d65c7952c52ea82100d7f6add.tar.gz
sparse, llvm: move OP_PHI code from switch statement to separate function
Just code movement, no other changes.
-rw-r--r--sparse-llvm.c66
1 files changed, 35 insertions, 31 deletions
diff --git a/sparse-llvm.c b/sparse-llvm.c
index c5077b69..02e3eaef 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -520,6 +520,39 @@ static void output_op_call(struct function *fn, struct instruction *insn)
insn->target->priv = target;
}
+static void output_op_phi(struct function *fn, struct instruction *insn)
+{
+ pseudo_t phi;
+ LLVMValueRef target;
+
+ target = LLVMBuildPhi(fn->builder, symbol_type(insn->type),
+ "phi");
+ int pll = 0;
+ FOR_EACH_PTR(insn->phi_list, phi) {
+ if (pseudo_to_value(fn, phi)) /* skip VOID */
+ pll++;
+ } END_FOR_EACH_PTR(phi);
+
+ LLVMValueRef *phi_vals = calloc(pll, sizeof(LLVMValueRef));
+ LLVMBasicBlockRef *phi_blks = calloc(pll, sizeof(LLVMBasicBlockRef));
+
+ int idx = 0;
+ FOR_EACH_PTR(insn->phi_list, phi) {
+ LLVMValueRef v;
+
+ v = pseudo_to_value(fn, phi);
+ if (v) { /* skip VOID */
+ phi_vals[idx] = v;
+ phi_blks[idx] = phi->def->bb->priv;
+ idx++;
+ }
+ } END_FOR_EACH_PTR(phi);
+
+ LLVMAddIncoming(target, phi_vals, phi_blks, pll);
+
+ insn->target->priv = target;
+}
+
static void output_insn(struct function *fn, struct instruction *insn)
{
switch (insn->opcode) {
@@ -545,38 +578,9 @@ static void output_insn(struct function *fn, struct instruction *insn)
/* target = src */
insn->target->priv = pseudo_to_value(fn, insn->phi_src);
break;
- case OP_PHI: {
- pseudo_t phi;
- LLVMValueRef target;
-
- target = LLVMBuildPhi(fn->builder, symbol_type(insn->type),
- "phi");
- int pll = 0;
- FOR_EACH_PTR(insn->phi_list, phi) {
- if (pseudo_to_value(fn, phi)) /* skip VOID */
- pll++;
- } END_FOR_EACH_PTR(phi);
-
- LLVMValueRef *phi_vals = calloc(pll, sizeof(LLVMValueRef));
- LLVMBasicBlockRef *phi_blks = calloc(pll, sizeof(LLVMBasicBlockRef));
-
- int idx = 0;
- FOR_EACH_PTR(insn->phi_list, phi) {
- LLVMValueRef v;
-
- v = pseudo_to_value(fn, phi);
- if (v) { /* skip VOID */
- phi_vals[idx] = v;
- phi_blks[idx] = phi->def->bb->priv;
- idx++;
- }
- } END_FOR_EACH_PTR(phi);
-
- LLVMAddIncoming(target, phi_vals, phi_blks, pll);
-
- insn->target->priv = target;
+ case OP_PHI:
+ output_op_phi(fn, insn);
break;
- }
case OP_LOAD:
output_op_load(fn, insn);
break;