From 84651623a5faf7e9b7cdcaa9613598d4864deb3c Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 15 Dec 2013 14:34:41 -0800 Subject: [PATCH] Removing BranchIf. --- src/alloy/backend/ivm/ivm_intcode.cc | 56 ---------------------------- src/alloy/hir/function_builder.cc | 18 --------- src/alloy/hir/function_builder.h | 2 - src/alloy/hir/opcodes.h | 1 - src/alloy/hir/opcodes.inl | 6 --- 5 files changed, 83 deletions(-) diff --git a/src/alloy/backend/ivm/ivm_intcode.cc b/src/alloy/backend/ivm/ivm_intcode.cc index f6c1d3203..d885fb371 100644 --- a/src/alloy/backend/ivm/ivm_intcode.cc +++ b/src/alloy/backend/ivm/ivm_intcode.cc @@ -693,61 +693,6 @@ int Translate_BRANCH(TranslationContext& ctx, Instr* i) { return DispatchToC(ctx, i, IntCode_BRANCH); } -uint32_t IntCode_BRANCH_IF_I8(IntCodeState& ics, const IntCode* i) { - if (ics.rf[i->src1_reg].u8) { - return IntCode_BRANCH_XX(ics, i, i->src2_reg); - } else { - return IntCode_BRANCH_XX(ics, i, i->src3_reg); - } -} -uint32_t IntCode_BRANCH_IF_I16(IntCodeState& ics, const IntCode* i) { - if (ics.rf[i->src1_reg].u16) { - return IntCode_BRANCH_XX(ics, i, i->src2_reg); - } else { - return IntCode_BRANCH_XX(ics, i, i->src3_reg); - } -} -uint32_t IntCode_BRANCH_IF_I32(IntCodeState& ics, const IntCode* i) { - if (ics.rf[i->src1_reg].u32) { - return IntCode_BRANCH_XX(ics, i, i->src2_reg); - } else { - return IntCode_BRANCH_XX(ics, i, i->src3_reg); - } -} -uint32_t IntCode_BRANCH_IF_I64(IntCodeState& ics, const IntCode* i) { - if (ics.rf[i->src1_reg].u64) { - return IntCode_BRANCH_XX(ics, i, i->src2_reg); - } else { - return IntCode_BRANCH_XX(ics, i, i->src3_reg); - } -} -uint32_t IntCode_BRANCH_IF_F32(IntCodeState& ics, const IntCode* i) { - if (ics.rf[i->src1_reg].f32) { - return IntCode_BRANCH_XX(ics, i, i->src2_reg); - } else { - return IntCode_BRANCH_XX(ics, i, i->src3_reg); - } -} -uint32_t IntCode_BRANCH_IF_F64(IntCodeState& ics, const IntCode* i) { - if (ics.rf[i->src1_reg].f64) { - return IntCode_BRANCH_XX(ics, i, i->src2_reg); - } else { - return IntCode_BRANCH_XX(ics, i, i->src3_reg); - } -} -int Translate_BRANCH_IF(TranslationContext& ctx, Instr* i) { - static IntCodeFn fns[] = { - IntCode_BRANCH_IF_I8, - IntCode_BRANCH_IF_I16, - IntCode_BRANCH_IF_I32, - IntCode_BRANCH_IF_I64, - IntCode_BRANCH_IF_F32, - IntCode_BRANCH_IF_F64, - IntCode_INVALID_TYPE, - }; - return DispatchToC(ctx, i, fns[i->src1.value->type]); -} - uint32_t IntCode_BRANCH_TRUE_I8(IntCodeState& ics, const IntCode* i) { if (ics.rf[i->src1_reg].u8) { return IntCode_BRANCH_XX(ics, i, i->src2_reg); @@ -3130,7 +3075,6 @@ static const TranslateFn dispatch_table[] = { Translate_SET_RETURN_ADDRESS, Translate_BRANCH, - Translate_BRANCH_IF, Translate_BRANCH_TRUE, Translate_BRANCH_FALSE, diff --git a/src/alloy/hir/function_builder.cc b/src/alloy/hir/function_builder.cc index 8c909e716..b77c8afe7 100644 --- a/src/alloy/hir/function_builder.cc +++ b/src/alloy/hir/function_builder.cc @@ -472,24 +472,6 @@ void FunctionBuilder::Branch(Label* label, uint32_t branch_flags) { EndBlock(); } -void FunctionBuilder::BranchIf( - Value* cond, Label* true_label, Label* false_label, - uint32_t branch_flags) { - if (cond->IsConstantTrue()) { - Branch(true_label, branch_flags); - return; - } else if (cond->IsConstantFalse()) { - Branch(false_label, branch_flags); - return; - } - - Instr* i = AppendInstr(OPCODE_BRANCH_IF_info, branch_flags); - i->set_src1(cond); - i->src2.label = true_label; - i->src3.label = false_label; - EndBlock(); -} - void FunctionBuilder::BranchTrue( Value* cond, Label* label, uint32_t branch_flags) { if (cond->IsConstantTrue()) { diff --git a/src/alloy/hir/function_builder.h b/src/alloy/hir/function_builder.h index 37d2ae89a..e6ac4c84f 100644 --- a/src/alloy/hir/function_builder.h +++ b/src/alloy/hir/function_builder.h @@ -73,8 +73,6 @@ public: void SetReturnAddress(Value* value); void Branch(Label* label, uint32_t branch_flags = 0); - void BranchIf(Value* cond, Label* true_label, Label* false_label, - uint32_t branch_flags = 0); void BranchTrue(Value* cond, Label* label, uint32_t branch_flags = 0); void BranchFalse(Value* cond, Label* label, diff --git a/src/alloy/hir/opcodes.h b/src/alloy/hir/opcodes.h index 3ee12a0a2..11072aa0b 100644 --- a/src/alloy/hir/opcodes.h +++ b/src/alloy/hir/opcodes.h @@ -83,7 +83,6 @@ enum Opcode { OPCODE_SET_RETURN_ADDRESS, OPCODE_BRANCH, - OPCODE_BRANCH_IF, OPCODE_BRANCH_TRUE, OPCODE_BRANCH_FALSE, diff --git a/src/alloy/hir/opcodes.inl b/src/alloy/hir/opcodes.inl index d09853282..3442dfd1c 100644 --- a/src/alloy/hir/opcodes.inl +++ b/src/alloy/hir/opcodes.inl @@ -86,12 +86,6 @@ DEFINE_OPCODE( OPCODE_SIG_X_L, OPCODE_FLAG_BRANCH); -DEFINE_OPCODE( - OPCODE_BRANCH_IF, - "branch_if", - OPCODE_SIG_X_V_L_L, - OPCODE_FLAG_BRANCH); - DEFINE_OPCODE( OPCODE_BRANCH_TRUE, "branch_true",