add a new Type::getIntegralTypeMask() method, which is useful for clients that
authorChris Lattner <sabre@nondot.org>
Tue, 7 Feb 2006 06:17:10 +0000 (06:17 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 7 Feb 2006 06:17:10 +0000 (06:17 +0000)
want to do bitwise inspection of integer types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26032 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Constants.h
include/llvm/DerivedTypes.h
include/llvm/Type.h

index 1f8a5ecca66ac657fcf44f074b23a96c2be74d27..eaa4cd9b3d872cffc0990de38fc58d2de34e486d 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "llvm/Constant.h"
 #include "llvm/Type.h"
-#include "llvm/Support/DataTypes.h"
 
 namespace llvm {
 
index e4b9136802a3ff20e57acd30bce74276d70b9a1e..e83679d04685e705690e04327c0e3b4240282f90 100644 (file)
@@ -19,7 +19,6 @@
 #define LLVM_DERIVED_TYPES_H
 
 #include "llvm/Type.h"
-#include "llvm/Support/DataTypes.h"
 
 namespace llvm {
 
index 0482d127bc28899fb4173077e1ac89bb5f40bd02..e4ceb548a4ff631fc3169c4c3f6b11f69ad3b03e 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "AbstractTypeUser.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/DataTypes.h"
 #include "llvm/ADT/GraphTraits.h"
 #include "llvm/ADT/iterator"
 #include <string>
@@ -232,6 +233,14 @@ public:
   /// getSignedVersion - If this is an integer type, return the signed variant
   /// of this type.  For example uint -> int.
   const Type *getSignedVersion() const;
+  
+  /// getIntegralTypeMask - Return a bitmask with ones set for all of the bits
+  /// that can be set by an unsigned version of this type.  This is 0xFF for
+  /// sbyte/ubyte, 0xFFFF for shorts, etc.
+  uint64_t getIntegralTypeMask() const {
+    assert(isIntegral() && "This only works for integral types!");
+    return ~0ULL >> (64-getPrimitiveSizeInBits());
+  }
 
   /// getForwaredType - Return the type that this type has been resolved to if
   /// it has been resolved to anything.  This is used to implement the