#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 {
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.
/// 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);
~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; }
/// 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:
///
/// 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
///
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.
///