diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Bitcode/LLVMBitCodes.h | 4 | ||||
-rw-r--r-- | include/llvm/InstrTypes.h | 8 | ||||
-rw-r--r-- | include/llvm/Instructions.h | 22 |
3 files changed, 25 insertions, 9 deletions
diff --git a/include/llvm/Bitcode/LLVMBitCodes.h b/include/llvm/Bitcode/LLVMBitCodes.h index 12607dcd32..d1dcc74437 100644 --- a/include/llvm/Bitcode/LLVMBitCodes.h +++ b/include/llvm/Bitcode/LLVMBitCodes.h @@ -205,7 +205,9 @@ namespace bitc { // FIXME: Remove GETRESULT in favor of EXTRACTVAL in LLVM 3.0 FUNC_CODE_INST_GETRESULT = 25, // GETRESULT: [ty, opval, n] FUNC_CODE_INST_EXTRACTVAL = 26, // EXTRACTVAL: [n x operands] - FUNC_CODE_INST_INSERTVAL = 27 // INSERTVAL: [n x operands] + FUNC_CODE_INST_INSERTVAL = 27, // INSERTVAL: [n x operands] + // fcmp/icmp returning vector of Int1Ty, NOT for vicmp/vfcmp + FUNC_CODE_INST_VCMP = 28 // VCMP: [opty, opval, opval, pred] }; } // End bitc namespace } // End llvm namespace diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index 430c772aec..74bb6f53bd 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -18,6 +18,7 @@ #include "llvm/Instruction.h" #include "llvm/OperandTraits.h" +#include "llvm/DerivedTypes.h" namespace llvm { @@ -732,6 +733,13 @@ public: static inline bool classof(const Value *V) { return isa<Instruction>(V) && classof(cast<Instruction>(V)); } + /// @brief Create a result type for fcmp/icmp (but not vicmp/vfcmp) + static const Type* makeCmpResultType(const Type* opnd_type) { + if (const VectorType* vt = dyn_cast<const VectorType>(opnd_type)) { + return VectorType::get(Type::Int1Ty, vt->getNumElements()); + } + return Type::Int1Ty; + } /// Backward-compatible interfaces /// @deprecated in 2.4, do not use, will disappear soon static CmpInst *create(OtherOps Op, unsigned short predicate, Value *S1, diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 355103cfa6..8ae9c375fb 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -621,7 +621,8 @@ public: Value *RHS, ///< The right-hand-side of the expression const std::string &NameStr = "", ///< Name of the instruction Instruction *InsertBefore = 0 ///< Where to insert - ) : CmpInst(Type::Int1Ty, Instruction::ICmp, pred, LHS, RHS, NameStr, + ) : CmpInst(makeCmpResultType(LHS->getType()), + Instruction::ICmp, pred, LHS, RHS, NameStr, InsertBefore) { assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && pred <= CmpInst::LAST_ICMP_PREDICATE && @@ -629,7 +630,7 @@ public: assert(getOperand(0)->getType() == getOperand(1)->getType() && "Both operands to ICmp instruction are not of the same type!"); // Check that the operands are the right type - assert((getOperand(0)->getType()->isInteger() || + assert((getOperand(0)->getType()->isIntOrIntVector() || isa<PointerType>(getOperand(0)->getType())) && "Invalid operand types for ICmp instruction"); } @@ -641,7 +642,8 @@ public: Value *RHS, ///< The right-hand-side of the expression const std::string &NameStr, ///< Name of the instruction BasicBlock *InsertAtEnd ///< Block to insert into. - ) : CmpInst(Type::Int1Ty, Instruction::ICmp, pred, LHS, RHS, NameStr, + ) : CmpInst(makeCmpResultType(LHS->getType()), + Instruction::ICmp, pred, LHS, RHS, NameStr, InsertAtEnd) { assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && pred <= CmpInst::LAST_ICMP_PREDICATE && @@ -649,7 +651,7 @@ public: assert(getOperand(0)->getType() == getOperand(1)->getType() && "Both operands to ICmp instruction are not of the same type!"); // Check that the operands are the right type - assert((getOperand(0)->getType()->isInteger() || + assert((getOperand(0)->getType()->isIntOrIntVector() || isa<PointerType>(getOperand(0)->getType())) && "Invalid operand types for ICmp instruction"); } @@ -754,6 +756,7 @@ public: static inline bool classof(const Value *V) { return isa<Instruction>(V) && classof(cast<Instruction>(V)); } + }; //===----------------------------------------------------------------------===// @@ -773,14 +776,15 @@ public: Value *RHS, ///< The right-hand-side of the expression const std::string &NameStr = "", ///< Name of the instruction Instruction *InsertBefore = 0 ///< Where to insert - ) : CmpInst(Type::Int1Ty, Instruction::FCmp, pred, LHS, RHS, NameStr, + ) : CmpInst(makeCmpResultType(LHS->getType()), + Instruction::FCmp, pred, LHS, RHS, NameStr, InsertBefore) { assert(pred <= FCmpInst::LAST_FCMP_PREDICATE && "Invalid FCmp predicate value"); assert(getOperand(0)->getType() == getOperand(1)->getType() && "Both operands to FCmp instruction are not of the same type!"); // Check that the operands are the right type - assert(getOperand(0)->getType()->isFloatingPoint() && + assert(getOperand(0)->getType()->isFPOrFPVector() && "Invalid operand types for FCmp instruction"); } @@ -791,14 +795,15 @@ public: Value *RHS, ///< The right-hand-side of the expression const std::string &NameStr, ///< Name of the instruction BasicBlock *InsertAtEnd ///< Block to insert into. - ) : CmpInst(Type::Int1Ty, Instruction::FCmp, pred, LHS, RHS, NameStr, + ) : CmpInst(makeCmpResultType(LHS->getType()), + Instruction::FCmp, pred, LHS, RHS, NameStr, InsertAtEnd) { assert(pred <= FCmpInst::LAST_FCMP_PREDICATE && "Invalid FCmp predicate value"); assert(getOperand(0)->getType() == getOperand(1)->getType() && "Both operands to FCmp instruction are not of the same type!"); // Check that the operands are the right type - assert(getOperand(0)->getType()->isFloatingPoint() && + assert(getOperand(0)->getType()->isFPOrFPVector() && "Invalid operand types for FCmp instruction"); } @@ -837,6 +842,7 @@ public: static inline bool classof(const Value *V) { return isa<Instruction>(V) && classof(cast<Instruction>(V)); } + }; //===----------------------------------------------------------------------===// |