llvm.org GIT mirror llvm / 09e9392
Add support to LLI for switch instruction git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5851 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 17 years ago
1 changed file(s) with 22 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
633633 SF.CurBB = Dest; // Update CurBB to branch destination
634634 SF.CurInst = SF.CurBB->begin(); // Update new instruction ptr...
635635 }
636
637 static void executeSwitch(SwitchInst &I, ExecutionContext &SF) {
638 GenericValue CondVal = getOperandValue(I.getOperand(0), SF);
639 const Type *ElTy = I.getOperand(0)->getType();
640 SF.PrevBB = SF.CurBB; // Update PrevBB so that PHI nodes work...
641 BasicBlock *Dest = 0;
642
643 // Check to see if any of the cases match...
644 for (unsigned i = 2, e = I.getNumOperands(); i != e; i += 2) {
645 if (executeSetEQInst(CondVal,
646 getOperandValue(I.getOperand(i), SF),ElTy,SF).BoolVal){
647 Dest = cast(I.getOperand(i+1));
648 break;
649 }
650 }
651
652 if (!Dest) Dest = I.getDefaultDest(); // No cases matched: use default
653 SF.CurBB = Dest; // Update CurBB to branch destination
654 SF.CurInst = SF.CurBB->begin(); // Update new instruction ptr...
655 }
656
636657
637658 //===----------------------------------------------------------------------===//
638659 // Memory Instruction Implementations
11051126 // Terminators
11061127 case Instruction::Ret: executeRetInst (cast(I), SF); break;
11071128 case Instruction::Br: executeBrInst (cast(I), SF); break;
1129 case Instruction::Switch: executeSwitch (cast(I), SF); break;
11081130 // Memory Instructions
11091131 case Instruction::Alloca:
11101132 case Instruction::Malloc: executeAllocInst((AllocationInst&)I, SF); break;