Add TargetData::fitsInLegalInteger().
authorCameron Zwarich <zwarich@apple.com>
Wed, 16 Mar 2011 00:13:28 +0000 (00:13 +0000)
committerCameron Zwarich <zwarich@apple.com>
Wed, 16 Mar 2011 00:13:28 +0000 (00:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127714 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetData.h

index 25065d30bb6e37cce0a54607223bd5ad4851e31d..32e3e2b0b61735792715cffb121de2e8f5cd963a 100644 (file)
@@ -160,7 +160,18 @@ public:
   bool isIllegalInteger(unsigned Width) const {
     return !isLegalInteger(Width);
   }
-  
+
+  /// fitsInLegalInteger - This function returns true if the specified type fits
+  /// in a native integer type supported by the CPU.  For example, if the CPU
+  /// only supports i32 as a native integer type, then i27 fits in a legal
+  // integer type but i45 does not.
+  bool fitsInLegalInteger(unsigned Width) const {
+    for (unsigned i = 0, e = (unsigned)LegalIntWidths.size(); i != e; ++i)
+      if (Width <= LegalIntWidths[i])
+        return true;
+    return false;
+  }
+
   /// Target pointer alignment
   unsigned getPointerABIAlignment() const { return PointerABIAlign; }
   /// Return target's alignment for stack-based pointers