Add support for ~ operator on constants

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7258 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-07-23 17:21:17 +00:00
parent bc5d414823
commit 30780ccf15
3 changed files with 18 additions and 0 deletions

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {