diff options
-rw-r--r-- | include/llvm/ConstantHandling.h | 6 | ||||
-rw-r--r-- | lib/VMCore/ConstantFold.h | 6 | ||||
-rw-r--r-- | lib/VMCore/ConstantFolding.h | 6 |
3 files changed, 15 insertions, 3 deletions
diff --git a/include/llvm/ConstantHandling.h b/include/llvm/ConstantHandling.h index ef19cd2..a27283c 100644 --- a/include/llvm/ConstantHandling.h +++ b/include/llvm/ConstantHandling.h @@ -134,11 +134,15 @@ private: // Unary operators... inline Constant *operator~(const Constant &V) { - assert(V.getType()->isIntegral() && "Cannot invert non-intergral constant!"); + assert(V.getType()->isIntegral() && "Cannot invert non-integral constant!"); return ConstRules::get(V, V)->op_xor(&V, ConstantInt::getAllOnesValue(V.getType())); } +inline Constant *operator-(const Constant &V) { + return ConstRules::get(V, V)->sub(Constant::getNullValue(V.getType()), &V); +} + // Standard binary operators... inline Constant *operator+(const Constant &V1, const Constant &V2) { assert(V1.getType() == V2.getType() && "Constant types must be identical!"); diff --git a/lib/VMCore/ConstantFold.h b/lib/VMCore/ConstantFold.h index ef19cd2..a27283c 100644 --- a/lib/VMCore/ConstantFold.h +++ b/lib/VMCore/ConstantFold.h @@ -134,11 +134,15 @@ private: // Unary operators... inline Constant *operator~(const Constant &V) { - assert(V.getType()->isIntegral() && "Cannot invert non-intergral constant!"); + assert(V.getType()->isIntegral() && "Cannot invert non-integral constant!"); return ConstRules::get(V, V)->op_xor(&V, ConstantInt::getAllOnesValue(V.getType())); } +inline Constant *operator-(const Constant &V) { + return ConstRules::get(V, V)->sub(Constant::getNullValue(V.getType()), &V); +} + // Standard binary operators... inline Constant *operator+(const Constant &V1, const Constant &V2) { assert(V1.getType() == V2.getType() && "Constant types must be identical!"); diff --git a/lib/VMCore/ConstantFolding.h b/lib/VMCore/ConstantFolding.h index ef19cd2..a27283c 100644 --- a/lib/VMCore/ConstantFolding.h +++ b/lib/VMCore/ConstantFolding.h @@ -134,11 +134,15 @@ private: // Unary operators... inline Constant *operator~(const Constant &V) { - assert(V.getType()->isIntegral() && "Cannot invert non-intergral constant!"); + assert(V.getType()->isIntegral() && "Cannot invert non-integral constant!"); return ConstRules::get(V, V)->op_xor(&V, ConstantInt::getAllOnesValue(V.getType())); } +inline Constant *operator-(const Constant &V) { + return ConstRules::get(V, V)->sub(Constant::getNullValue(V.getType()), &V); +} + // Standard binary operators... inline Constant *operator+(const Constant &V1, const Constant &V2) { assert(V1.getType() == V2.getType() && "Constant types must be identical!"); |