class Type;
class StructType;
class StructLayout;
+class GlobalVariable;
class TargetData : public ImmutablePass {
bool LittleEndian; // Defaults to false
unsigned char PointerAlignment; // Defaults to 8 bytes
public:
- TargetData(const std::string &TargetName = "",
- bool LittleEndian = false,
- unsigned char PtrSize = 8,
- unsigned char PtrAl = 8, unsigned char DoubleAl = 8,
- unsigned char FloatAl = 4, unsigned char LongAl = 8,
- unsigned char IntAl = 4, unsigned char ShortAl = 2,
- unsigned char ByteAl = 1, unsigned char BoolAl = 1);
-
- // Copy constructor
- TargetData (const TargetData &TD) :
+ /// Default ctor - This has to exist, because this is a pass, but it should
+ /// never be used.
+ TargetData() {
+ assert(0 && "ERROR: Bad TargetData ctor used. "
+ "Tool did not specify a TargetData to use?");
+ abort();
+ }
+
+ /// Constructs a TargetData from a string of the following format:
+ /// "E-p:64:64-d:64-f:32-l:64-i:32-s:16-b:8-B:8"
+ /// The above string is considered the default, and any values not specified
+ /// in the string will be assumed to be as above.
+ TargetData(const std::string &TargetDescription) {
+ init(TargetDescription);
+ }
+
+ /// Initialize target data from properties stored in the module.
+ TargetData(const Module *M);
+
+ TargetData(const TargetData &TD) :
ImmutablePass(),
LittleEndian(TD.isLittleEndian()),
BoolAlignment(TD.getBoolAlignment()),
PointerAlignment(TD.getPointerAlignment()) {
}
- TargetData(const std::string &ToolName, const Module *M);
~TargetData(); // Not virtual, do not subclass this class
+ /// init - Specify configuration if not available at ctor time.
+ ///
+ void init(const std::string &TargetDescription);
+
+
/// Target endianness...
bool isLittleEndian() const { return LittleEndian; }
bool isBigEndian() const { return !LittleEndian; }
unsigned char getPointerSize() const { return PointerSize; }
unsigned char getPointerSizeInBits() const { return 8*PointerSize; }
+ /// getStringRepresentation - Return the string representation of the
+ /// TargetData. This representation is in the same format accepted by the
+ /// string constructor above.
+ std::string getStringRepresentation() const;
+
/// getTypeSize - Return the number of bytes necessary to hold the specified
/// type.
///
/// removed, this method must be called whenever a StructType is removed to
/// avoid a dangling pointer in this cache.
void InvalidateStructLayoutInfo(const StructType *Ty) const;
+
+ /// getPreferredAlignmentLog - Return the preferred alignment of the
+ /// specified global, returned in log form. This includes an explicitly
+ /// requested alignment (if the global has one).
+ unsigned getPreferredAlignmentLog(const GlobalVariable *GV) const;
};
/// StructLayout - used to lazily calculate structure layout information for a