Add an IntegerType::getMask() method to get an APInt mask for the type.
authorReid Spencer <rspencer@reidspencer.com>
Thu, 1 Mar 2007 02:25:03 +0000 (02:25 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Thu, 1 Mar 2007 02:25:03 +0000 (02:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34771 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DerivedTypes.h

index 08a7aeffe3bf5768581a6e5c1ac0cf980d08821d..13e127a612ab591a060ee7d95217c4172494aaf1 100644 (file)
@@ -19,6 +19,7 @@
 #define LLVM_DERIVED_TYPES_H
 
 #include "llvm/Type.h"
+#include "llvm/ADT/APInt.h"
 
 namespace llvm {
 
@@ -108,6 +109,13 @@ public:
     return ~uint64_t(0UL) >> (64-getPrimitiveSizeInBits());
   }
 
+  /// For example, this is 0xFF for an 8 bit integer, 0xFFFF for i16, etc.
+  /// @returns a bit mask with ones set for all the bits of this type.
+  /// @brief Get a bit mask for this type.
+  APInt getMask() const {
+    return APInt::getAllOnesValue(getBitWidth());
+  }
+
   /// This method determines if the width of this IntegerType is a power-of-2
   /// in terms of 8 bit bytes. 
   /// @returns true if this is a power-of-2 byte width.