aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-07-23 17:21:17 +0000
committerChris Lattner <sabre@nondot.org>2003-07-23 17:21:17 +0000
commit30780ccf15fd098afe5c47ae8e013dd832ed2dde (patch)
tree649d75141a22c3abe1bf60f996ac1cf39db39184 /lib
parentbc5d41482392d4ebd7fa2b992bbe89980ebd4f6c (diff)
Add support for ~ operator on constants
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7258 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/ConstantFold.h6
-rw-r--r--lib/VMCore/ConstantFolding.h6
2 files changed, 12 insertions, 0 deletions
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) {