diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-10-26 06:15:43 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-10-26 06:15:43 +0000 |
commit | 1628cec4d7fce310d9cde0bcc73997e5a71692c4 (patch) | |
tree | 6dff5a70de8406b153e32fdd2d60c782d6202f63 /include/llvm | |
parent | 7043d00750c558a518d08a638638ebe4d241f159 (diff) | |
download | external_llvm-1628cec4d7fce310d9cde0bcc73997e5a71692c4.tar.gz external_llvm-1628cec4d7fce310d9cde0bcc73997e5a71692c4.tar.bz2 external_llvm-1628cec4d7fce310d9cde0bcc73997e5a71692c4.zip |
For PR950:
Make necessary changes to support DIV -> [SUF]Div. This changes llvm to
have three division instructions: signed, unsigned, floating point. The
bytecode and assembler are bacwards compatible, however.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31195 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/Analysis/ScalarEvolutionExpander.h | 2 | ||||
-rw-r--r-- | include/llvm/Analysis/ScalarEvolutionExpressions.h | 2 | ||||
-rw-r--r-- | include/llvm/Constants.h | 4 | ||||
-rw-r--r-- | include/llvm/Instruction.def | 58 | ||||
-rw-r--r-- | include/llvm/Support/PatternMatch.h | 16 |
5 files changed, 47 insertions, 35 deletions
diff --git a/include/llvm/Analysis/ScalarEvolutionExpander.h b/include/llvm/Analysis/ScalarEvolutionExpander.h index 3673112069..391c12b2ba 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpander.h +++ b/include/llvm/Analysis/ScalarEvolutionExpander.h @@ -140,7 +140,7 @@ namespace llvm { const Type *Ty = S->getType(); Value *LHS = expandInTy(S->getLHS(), Ty); Value *RHS = expandInTy(S->getRHS(), Ty); - return BinaryOperator::createDiv(LHS, RHS, "tmp.", InsertPt); + return BinaryOperator::createSDiv(LHS, RHS, "tmp.", InsertPt); } Value *visitAddRecExpr(SCEVAddRecExpr *S); diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h index 2a546c3482..ba1b6d4fec 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -293,7 +293,7 @@ namespace llvm { //===--------------------------------------------------------------------===// - /// SCEVSDivExpr - This class represents a binary unsigned division operation. + /// SCEVSDivExpr - This class represents a binary signed division operation. /// class SCEVSDivExpr : public SCEV { SCEVHandle LHS, RHS; diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 8c244356d4..3bf935bb5b 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -543,7 +543,9 @@ public: static Constant *getAdd(Constant *C1, Constant *C2); static Constant *getSub(Constant *C1, Constant *C2); static Constant *getMul(Constant *C1, Constant *C2); - static Constant *getDiv(Constant *C1, Constant *C2); + static Constant *getUDiv(Constant *C1, Constant *C2); + static Constant *getSDiv(Constant *C1, Constant *C2); + static Constant *getFDiv(Constant *C1, Constant *C2); static Constant *getRem(Constant *C1, Constant *C2); static Constant *getAnd(Constant *C1, Constant *C2); static Constant *getOr(Constant *C1, Constant *C2); diff --git a/include/llvm/Instruction.def b/include/llvm/Instruction.def index e298aa4fbb..91a467cf59 100644 --- a/include/llvm/Instruction.def +++ b/include/llvm/Instruction.def @@ -93,45 +93,43 @@ HANDLE_TERM_INST ( 6, Unreachable, UnreachableInst) HANDLE_BINARY_INST( 7, Add , BinaryOperator) HANDLE_BINARY_INST( 8, Sub , BinaryOperator) HANDLE_BINARY_INST( 9, Mul , BinaryOperator) -HANDLE_BINARY_INST(10, Div , BinaryOperator) -HANDLE_BINARY_INST(11, Rem , BinaryOperator) +HANDLE_BINARY_INST(10, UDiv , BinaryOperator) +HANDLE_BINARY_INST(11, SDiv , BinaryOperator) +HANDLE_BINARY_INST(12, FDiv , BinaryOperator) +HANDLE_BINARY_INST(13, Rem , BinaryOperator) // Logical operators... -HANDLE_BINARY_INST(12, And , BinaryOperator) -HANDLE_BINARY_INST(13, Or , BinaryOperator) -HANDLE_BINARY_INST(14, Xor , BinaryOperator) +HANDLE_BINARY_INST(14, And , BinaryOperator) +HANDLE_BINARY_INST(15, Or , BinaryOperator) +HANDLE_BINARY_INST(16, Xor , BinaryOperator) // Binary comparison operators... -HANDLE_BINARY_INST(15, SetEQ , SetCondInst) -HANDLE_BINARY_INST(16, SetNE , SetCondInst) -HANDLE_BINARY_INST(17, SetLE , SetCondInst) -HANDLE_BINARY_INST(18, SetGE , SetCondInst) -HANDLE_BINARY_INST(19, SetLT , SetCondInst) -HANDLE_BINARY_INST(20, SetGT , SetCondInst) - LAST_BINARY_INST(20) +HANDLE_BINARY_INST(17, SetEQ , SetCondInst) +HANDLE_BINARY_INST(18, SetNE , SetCondInst) +HANDLE_BINARY_INST(19, SetLE , SetCondInst) +HANDLE_BINARY_INST(20, SetGE , SetCondInst) +HANDLE_BINARY_INST(21, SetLT , SetCondInst) +HANDLE_BINARY_INST(22, SetGT , SetCondInst) + LAST_BINARY_INST(22) // Memory operators... - FIRST_MEMORY_INST(21) -HANDLE_MEMORY_INST(21, Malloc, MallocInst) // Heap management instructions -HANDLE_MEMORY_INST(22, Free , FreeInst ) -HANDLE_MEMORY_INST(23, Alloca, AllocaInst) // Stack management -HANDLE_MEMORY_INST(24, Load , LoadInst ) // Memory manipulation instrs -HANDLE_MEMORY_INST(25, Store , StoreInst ) -HANDLE_MEMORY_INST(26, GetElementPtr, GetElementPtrInst) - LAST_MEMORY_INST(26) + FIRST_MEMORY_INST(23) +HANDLE_MEMORY_INST(23, Malloc, MallocInst) // Heap management instructions +HANDLE_MEMORY_INST(24, Free , FreeInst ) +HANDLE_MEMORY_INST(25, Alloca, AllocaInst) // Stack management +HANDLE_MEMORY_INST(26, Load , LoadInst ) // Memory manipulation instrs +HANDLE_MEMORY_INST(27, Store , StoreInst ) +HANDLE_MEMORY_INST(28, GetElementPtr, GetElementPtrInst) + LAST_MEMORY_INST(28) // Other operators... - FIRST_OTHER_INST(27) -HANDLE_OTHER_INST(27, PHI , PHINode ) // PHI node instruction -HANDLE_OTHER_INST(28, Cast , CastInst ) // Type cast -HANDLE_OTHER_INST(29, Call , CallInst ) // Call a function - -HANDLE_OTHER_INST(30, Shl , ShiftInst ) // Shift operations -HANDLE_OTHER_INST(31, Shr , ShiftInst ) -// 32 -> Empty slot used to be used for vanext in llvm 1.5 and before. -// 33 -> Empty slot used to be used for vaarg in llvm 1.5 and before. + FIRST_OTHER_INST(29) +HANDLE_OTHER_INST(29, PHI , PHINode ) // PHI node instruction +HANDLE_OTHER_INST(30, Cast , CastInst ) // Type cast +HANDLE_OTHER_INST(31, Call , CallInst ) // Call a function +HANDLE_OTHER_INST(32, Shl , ShiftInst ) // Shift operations +HANDLE_OTHER_INST(33, Shr , ShiftInst ) HANDLE_OTHER_INST(34, Select , SelectInst ) // select instruction - HANDLE_OTHER_INST(35, UserOp1, Instruction) // May be used internally in a pass HANDLE_OTHER_INST(36, UserOp2, Instruction) HANDLE_OTHER_INST(37, VAArg , VAArgInst ) // vaarg instruction diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h index 4d745d6c2e..f4c9ad5098 100644 --- a/include/llvm/Support/PatternMatch.h +++ b/include/llvm/Support/PatternMatch.h @@ -112,9 +112,21 @@ inline BinaryOp_match<LHS, RHS, Instruction::Mul> m_Mul(const LHS &L, } template<typename LHS, typename RHS> -inline BinaryOp_match<LHS, RHS, Instruction::Div> m_Div(const LHS &L, +inline BinaryOp_match<LHS, RHS, Instruction::UDiv> m_UDiv(const LHS &L, const RHS &R) { - return BinaryOp_match<LHS, RHS, Instruction::Div>(L, R); + return BinaryOp_match<LHS, RHS, Instruction::UDiv>(L, R); +} + +template<typename LHS, typename RHS> +inline BinaryOp_match<LHS, RHS, Instruction::SDiv> m_SDiv(const LHS &L, + const RHS &R) { + return BinaryOp_match<LHS, RHS, Instruction::SDiv>(L, R); +} + +template<typename LHS, typename RHS> +inline BinaryOp_match<LHS, RHS, Instruction::FDiv> m_FDiv(const LHS &L, + const RHS &R) { + return BinaryOp_match<LHS, RHS, Instruction::FDiv>(L, R); } template<typename LHS, typename RHS> |