The TargetData is not used for the isPowerOfTwo determination. It has never
[oota-llvm.git] / include / llvm / DataLayout.h
index a24737e842ba1c74dbcac4077dce3eb5e2985615..4cb77663876e3a4dc71d7ed0aa28689ed2e6c2e9 100644 (file)
@@ -20,9 +20,9 @@
 #ifndef LLVM_DATALAYOUT_H
 #define LLVM_DATALAYOUT_H
 
-#include "llvm/Pass.h"
-#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Pass.h"
 #include "llvm/Support/DataTypes.h"
 
 namespace llvm {
@@ -148,9 +148,9 @@ private:
     return &align != &InvalidPointerElem;
   }
 
-  /// Initialise a DataLayout object with default values, ensure that the
-  /// target data pass is registered.
-  void init();
+  /// Parses a target data specification string. Assert if the string is
+  /// malformed.
+  void parseSpecifier(StringRef LayoutDescription);
 
 public:
   /// Default ctor.
@@ -162,17 +162,9 @@ public:
   /// Constructs a DataLayout from a specification string. See init().
   explicit DataLayout(StringRef LayoutDescription)
     : ImmutablePass(ID) {
-    std::string errMsg = parseSpecifier(LayoutDescription, this);
-    assert(errMsg == "" && "Invalid target data layout string.");
-    (void)errMsg;
+    init(LayoutDescription);
   }
 
-  /// Parses a target data specification string. Returns an error message
-  /// if the string is malformed, or the empty string on success. Optionally
-  /// initialises a DataLayout object if passed a non-null pointer.
-  static std::string parseSpecifier(StringRef LayoutDescription,
-                                    DataLayout* td = 0);
-
   /// Initialize target data from properties stored in the module.
   explicit DataLayout(const Module *M);
 
@@ -187,6 +179,10 @@ public:
 
   ~DataLayout();  // Not virtual, do not subclass this class
 
+  /// Parse a data layout string (with fallback to default values). Ensure that
+  /// the data layout pass is registered.
+  void init(StringRef LayoutDescription);
+
   /// Layout endianness...
   bool isLittleEndian() const { return LittleEndian; }
   bool isBigEndian() const { return !LittleEndian; }
@@ -264,11 +260,7 @@ public:
   /// FIXME: The defaults need to be removed once all of
   /// the backends/clients are updated.
   unsigned getPointerSizeInBits(unsigned AS = 0)    const {
-    DenseMap<unsigned, PointerAlignElem>::const_iterator val = Pointers.find(AS);
-    if (val == Pointers.end()) {
-      val = Pointers.find(0);
-    }
-    return 8*val->second.TypeBitWidth;
+    return getPointerSize(AS) * 8;
   }
   /// Size examples:
   ///
@@ -289,6 +281,7 @@ public:
 
   /// getTypeSizeInBits - Return the number of bits necessary to hold the
   /// specified type.  For example, returns 36 for i36 and 80 for x86_fp80.
+  /// The type passed must have a size (Type::isSized() must return true).
   uint64_t getTypeSizeInBits(Type* Ty) const;
 
   /// getTypeStoreSize - Return the maximum number of bytes that may be
@@ -345,12 +338,15 @@ public:
   ///
   unsigned getPreferredTypeAlignmentShift(Type *Ty) const;
 
-  /// getIntPtrType - Return an unsigned integer type that is the same size or
-  /// greater to the host pointer size.
-  /// FIXME: Need to remove the default argument when the rest of the LLVM code
-  /// base has been updated.
+  /// getIntPtrType - Return an integer type with size at least as big as that
+  /// of a pointer in the given address space.
   IntegerType *getIntPtrType(LLVMContext &C, unsigned AddressSpace = 0) const;
 
+  /// getIntPtrType - Return an integer (vector of integer) type with size at
+  /// least as big as that of a pointer of the given pointer (vector of pointer)
+  /// type.
+  Type *getIntPtrType(Type *) const;
+
   /// getIndexedOffset - return the offset from the beginning of the type for
   /// the specified indices.  This is used to implement getelementptr.
   ///