aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Support/PatternMatch.h
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2011-02-01 08:50:33 +0000
committerDuncan Sands <baldrick@free.fr>2011-02-01 08:50:33 +0000
commit93c780288df9631d11f996b010b2212a8b44d4d3 (patch)
tree90e14a9e3f0a19c1bafd39d2e969ad0d34246875 /include/llvm/Support/PatternMatch.h
parent7681c6da606efcc392f76b8acea8301cb5fc7a0a (diff)
Add a m_SignBit pattern for convenience.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124656 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/PatternMatch.h')
-rw-r--r--include/llvm/Support/PatternMatch.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h
index b203c1ee1a..ea065a769e 100644
--- a/include/llvm/Support/PatternMatch.h
+++ b/include/llvm/Support/PatternMatch.h
@@ -116,6 +116,21 @@ struct all_ones_ty {
/// m_AllOnes() - Match an integer or vector with all bits set to true.
inline all_ones_ty m_AllOnes() { return all_ones_ty(); }
+struct signbit_ty {
+ template<typename ITy>
+ bool match(ITy *V) {
+ if (const ConstantInt *CI = dyn_cast<ConstantInt>(V))
+ return CI->getValue().isSignBit();
+ if (const ConstantVector *CV = dyn_cast<ConstantVector>(V))
+ if (ConstantInt *CI = cast_or_null<ConstantInt>(CV->getSplatValue()))
+ return CI->getValue().isSignBit();
+ return false;
+ }
+};
+
+/// m_SignBit() - Match an integer or vector with only the sign bit(s) set.
+inline signbit_ty m_SignBit() { return signbit_ty(); }
+
template<typename Class>
struct bind_ty {