diff options
author | Dan Gohman <gohman@apple.com> | 2009-07-24 18:12:25 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-07-24 18:12:25 +0000 |
commit | 1c393a6815dcaeb544ec6514bb9a1e78a2ae73af (patch) | |
tree | f96fd9ce65ec07a86899c3e928720cec5b4e9b51 /include | |
parent | b388949d967d7b5f512a8aae2e636ebbb44c11f3 (diff) | |
download | external_llvm-1c393a6815dcaeb544ec6514bb9a1e78a2ae73af.zip external_llvm-1c393a6815dcaeb544ec6514bb9a1e78a2ae73af.tar.gz external_llvm-1c393a6815dcaeb544ec6514bb9a1e78a2ae73af.tar.bz2 |
Add specific classes for Add, Sub, and Mul, for convenience.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76981 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Operator.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/include/llvm/Operator.h b/include/llvm/Operator.h index 541f13d..452e129 100644 --- a/include/llvm/Operator.h +++ b/include/llvm/Operator.h @@ -101,6 +101,57 @@ public: } }; +/// AddOperator - Utility class for integer addition operators. +/// +class AddOperator : public OverflowingBinaryOperator { +public: + static inline bool classof(const AddOperator *) { return true; } + static inline bool classof(const Instruction *I) { + return I->getOpcode() == Instruction::Add; + } + static inline bool classof(const ConstantExpr *CE) { + return CE->getOpcode() == Instruction::Add; + } + static inline bool classof(const Value *V) { + return (isa<Instruction>(V) && classof(cast<Instruction>(V))) || + (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V))); + } +}; + +/// SubOperator - Utility class for integer subtraction operators. +/// +class SubOperator : public OverflowingBinaryOperator { +public: + static inline bool classof(const SubOperator *) { return true; } + static inline bool classof(const Instruction *I) { + return I->getOpcode() == Instruction::Sub; + } + static inline bool classof(const ConstantExpr *CE) { + return CE->getOpcode() == Instruction::Sub; + } + static inline bool classof(const Value *V) { + return (isa<Instruction>(V) && classof(cast<Instruction>(V))) || + (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V))); + } +}; + +/// MulOperator - Utility class for integer multiplication operators. +/// +class MulOperator : public OverflowingBinaryOperator { +public: + static inline bool classof(const MulOperator *) { return true; } + static inline bool classof(const Instruction *I) { + return I->getOpcode() == Instruction::Mul; + } + static inline bool classof(const ConstantExpr *CE) { + return CE->getOpcode() == Instruction::Mul; + } + static inline bool classof(const Value *V) { + return (isa<Instruction>(V) && classof(cast<Instruction>(V))) || + (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V))); + } +}; + /// SDivOperator - An Operator with opcode Instruction::SDiv. /// class SDivOperator : public Operator { |