aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-12-07 04:18:31 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-12-07 04:18:31 +0000
commit6b538cfc5c758edc8e05070ab8794bd6c3e8ffb9 (patch)
tree73cc069842d000f0bbfefa116154100f20a7f3ab
parent7d3223eef2982d7acdfb24facde6605fd9a8b5e8 (diff)
Provide a getOpcode() method on CmpInst to ensure the opcode is returned
as the right type. Use this to shorten some code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32300 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/InstrTypes.h5
-rw-r--r--lib/VMCore/Constants.cpp3
-rw-r--r--lib/VMCore/Instructions.cpp3
3 files changed, 7 insertions, 4 deletions
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h
index 0577db3efc..eaf56a301c 100644
--- a/include/llvm/InstrTypes.h
+++ b/include/llvm/InstrTypes.h
@@ -521,6 +521,11 @@ public:
/// @brief Implement superclass method.
virtual CmpInst *clone() const;
+ /// @brief Get the opcode casted to the right type
+ OtherOps getOpcode() const {
+ return static_cast<OtherOps>(Instruction::getOpcode());
+ }
+
/// The predicate for CmpInst is defined by the subclasses but stored in
/// the SubclassData field (see Value.h). We allow it to be fetched here
/// as the predicate but there is no enum type for it, just the raw unsigned
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index f9271178a4..5f1aaea909 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -378,8 +378,7 @@ struct VISIBILITY_HIDDEN CompareConstantExpr : public ConstantExpr {
Use Ops[2];
CompareConstantExpr(Instruction::OtherOps opc, unsigned short pred,
Constant* LHS, Constant* RHS)
- : ConstantExpr(Type::BoolTy, Instruction::OtherOps(opc), Ops, 2),
- predicate(pred) {
+ : ConstantExpr(Type::BoolTy, opc, Ops, 2), predicate(pred) {
OperandList[0].init(LHS, this);
OperandList[1].init(RHS, this);
}
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index 1cc04334cd..57dd5a56b8 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -2252,8 +2252,7 @@ BinaryOperator *BinaryOperator::clone() const {
}
CmpInst* CmpInst::clone() const {
- return create(Instruction::OtherOps(getOpcode()), getPredicate(),
- Ops[0], Ops[1]);
+ return create(getOpcode(), getPredicate(), Ops[0], Ops[1]);
}
MallocInst *MallocInst::clone() const { return new MallocInst(*this); }