From 721c201bd55ffb73cb2ba8d39e0570fa38c44e15 Mon Sep 17 00:00:00 2001 From: dim Date: Wed, 15 Aug 2012 19:34:23 +0000 Subject: Vendor import of llvm trunk r161861: http://llvm.org/svn/llvm-project/llvm/trunk@161861 --- lib/ExecutionEngine/Interpreter/CMakeLists.txt | 2 ++ lib/ExecutionEngine/Interpreter/Execution.cpp | 37 +++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 4 deletions(-) (limited to 'lib/ExecutionEngine/Interpreter') diff --git a/lib/ExecutionEngine/Interpreter/CMakeLists.txt b/lib/ExecutionEngine/Interpreter/CMakeLists.txt index d331f83..74df8f0 100644 --- a/lib/ExecutionEngine/Interpreter/CMakeLists.txt +++ b/lib/ExecutionEngine/Interpreter/CMakeLists.txt @@ -15,3 +15,5 @@ add_llvm_library(LLVMInterpreter if( LLVM_ENABLE_FFI ) target_link_libraries( LLVMInterpreter ${FFI_LIBRARY_PATH} ) endif() + +add_dependencies(LLVMInterpreter intrinsics_gen) diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index af47be9..5202b09 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -651,11 +651,40 @@ void Interpreter::visitSwitchInst(SwitchInst &I) { // Check to see if any of the cases match... BasicBlock *Dest = 0; for (SwitchInst::CaseIt i = I.case_begin(), e = I.case_end(); i != e; ++i) { - GenericValue CaseVal = getOperandValue(i.getCaseValue(), SF); - if (executeICMP_EQ(CondVal, CaseVal, ElTy).IntVal != 0) { - Dest = cast(i.getCaseSuccessor()); - break; + IntegersSubset& Case = i.getCaseValueEx(); + if (Case.isSingleNumber()) { + // FIXME: Currently work with ConstantInt based numbers. + const ConstantInt *CI = Case.getSingleNumber(0).toConstantInt(); + GenericValue Val = getOperandValue(const_cast(CI), SF); + if (executeICMP_EQ(Val, CondVal, ElTy).IntVal != 0) { + Dest = cast(i.getCaseSuccessor()); + break; + } } + if (Case.isSingleNumbersOnly()) { + for (unsigned n = 0, en = Case.getNumItems(); n != en; ++n) { + // FIXME: Currently work with ConstantInt based numbers. + const ConstantInt *CI = Case.getSingleNumber(n).toConstantInt(); + GenericValue Val = getOperandValue(const_cast(CI), SF); + if (executeICMP_EQ(Val, CondVal, ElTy).IntVal != 0) { + Dest = cast(i.getCaseSuccessor()); + break; + } + } + } else + for (unsigned n = 0, en = Case.getNumItems(); n != en; ++n) { + IntegersSubset::Range r = Case.getItem(n); + // FIXME: Currently work with ConstantInt based numbers. + const ConstantInt *LowCI = r.getLow().toConstantInt(); + const ConstantInt *HighCI = r.getHigh().toConstantInt(); + GenericValue Low = getOperandValue(const_cast(LowCI), SF); + GenericValue High = getOperandValue(const_cast(HighCI), SF); + if (executeICMP_ULE(Low, CondVal, ElTy).IntVal != 0 && + executeICMP_ULE(CondVal, High, ElTy).IntVal != 0) { + Dest = cast(i.getCaseSuccessor()); + break; + } + } } if (!Dest) Dest = I.getDefaultDest(); // No cases matched: use default SwitchToNewBasicBlock(Dest, SF); -- cgit v1.1