diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 1f8a5ecca66..eaa4cd9b3d8 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -22,7 +22,6 @@ #include "llvm/Constant.h" #include "llvm/Type.h" -#include "llvm/Support/DataTypes.h" namespace llvm { diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h index e4b9136802a..e83679d0468 100644 --- a/include/llvm/DerivedTypes.h +++ b/include/llvm/DerivedTypes.h @@ -19,7 +19,6 @@ #define LLVM_DERIVED_TYPES_H #include "llvm/Type.h" -#include "llvm/Support/DataTypes.h" namespace llvm { diff --git a/include/llvm/Type.h b/include/llvm/Type.h index 0482d127bc2..e4ceb548a4f 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -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 @@ -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