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, 18 insertions, 0 deletions
diff --git a/include/llvm/ConstantHandling.h b/include/llvm/ConstantHandling.h index 2401ad7596..66719cda8e 100644 --- a/include/llvm/ConstantHandling.h +++ b/include/llvm/ConstantHandling.h @@ -125,6 +125,12 @@ private: ConstRules &operator=(const ConstRules &); // Do not implement }; +// Unary operators... +inline Constant *operator~(const Constant &V) { + assert(V.getType()->isIntegral() && "Cannot invert non-intergral constant!"); + return ConstRules::get(V, V)->op_xor(&V, + ConstantInt::getAllOnesValue(V.getType())); +} // Standard binary operators... inline Constant *operator+(const Constant &V1, const Constant &V2) { diff --git a/lib/VMCore/ConstantFold.h b/lib/VMCore/ConstantFold.h index 2401ad7596..66719cda8e 100644 --- a/lib/VMCore/ConstantFold.h +++ b/lib/VMCore/ConstantFold.h @@ -125,6 +125,12 @@ private: ConstRules &operator=(const ConstRules &); // Do not implement }; +// Unary operators... +inline Constant *operator~(const Constant &V) { + assert(V.getType()->isIntegral() && "Cannot invert non-intergral constant!"); + return ConstRules::get(V, V)->op_xor(&V, + ConstantInt::getAllOnesValue(V.getType())); +} // Standard binary operators... inline Constant *operator+(const Constant &V1, const Constant &V2) { diff --git a/lib/VMCore/ConstantFolding.h b/lib/VMCore/ConstantFolding.h index 2401ad7596..66719cda8e 100644 --- a/lib/VMCore/ConstantFolding.h +++ b/lib/VMCore/ConstantFolding.h @@ -125,6 +125,12 @@ private: ConstRules &operator=(const ConstRules &); // Do not implement }; +// Unary operators... +inline Constant *operator~(const Constant &V) { + assert(V.getType()->isIntegral() && "Cannot invert non-intergral constant!"); + return ConstRules::get(V, V)->op_xor(&V, + ConstantInt::getAllOnesValue(V.getType())); +} // Standard binary operators... inline Constant *operator+(const Constant &V1, const Constant &V2) { |