- Add an endianness field to the TargetData datastructure

llvm-svn: 4174
This commit is contained in:
Chris Lattner 2002-10-14 22:41:13 +00:00
parent 2b7b6ce296
commit 294eae6735
2 changed files with 16 additions and 7 deletions

View File

@ -23,6 +23,7 @@ class StructType;
class StructLayout; class StructLayout;
class TargetData : public ImmutablePass { class TargetData : public ImmutablePass {
bool LittleEndian; // Defaults to false
unsigned char ByteAlignment; // Defaults to 1 bytes unsigned char ByteAlignment; // Defaults to 1 bytes
unsigned char ShortAlignment; // Defaults to 2 bytes unsigned char ShortAlignment; // Defaults to 2 bytes
unsigned char IntAlignment; // Defaults to 4 bytes unsigned char IntAlignment; // Defaults to 4 bytes
@ -37,6 +38,7 @@ class TargetData : public ImmutablePass {
static Annotation *TypeAnFactory(AnnotationID, const Annotable *, void *); static Annotation *TypeAnFactory(AnnotationID, const Annotable *, void *);
public: public:
TargetData(const std::string &TargetName = "SparcV9", TargetData(const std::string &TargetName = "SparcV9",
bool LittleEndian = false,
unsigned char IntRegSize = 8, unsigned char IntRegSize = 8,
unsigned char PtrSize = 8, unsigned char PtrSize = 8,
unsigned char PtrAl = 8, unsigned char DoubleAl = 8, unsigned char PtrAl = 8, unsigned char DoubleAl = 8,
@ -45,6 +47,11 @@ public:
unsigned char ByteAl = 1); unsigned char ByteAl = 1);
~TargetData(); // Not virtual, do not subclass this class ~TargetData(); // Not virtual, do not subclass this class
/// Target endianness...
bool isLittleEndian() const { return LittleEndian; }
bool isBigEndian() const { return !LittleEndian; }
/// Target alignment constraints
unsigned char getByteAlignment() const { return ByteAlignment; } unsigned char getByteAlignment() const { return ByteAlignment; }
unsigned char getShortAlignment() const { return ShortAlignment; } unsigned char getShortAlignment() const { return ShortAlignment; }
unsigned char getIntAlignment() const { return IntAlignment; } unsigned char getIntAlignment() const { return IntAlignment; }

View File

@ -81,6 +81,7 @@ Annotation *TargetData::TypeAnFactory(AnnotationID AID, const Annotable *T,
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
TargetData::TargetData(const std::string &TargetName, TargetData::TargetData(const std::string &TargetName,
bool isLittleEndian,
unsigned char IntRegSize, unsigned char PtrSize, unsigned char IntRegSize, unsigned char PtrSize,
unsigned char PtrAl, unsigned char DoubleAl, unsigned char PtrAl, unsigned char DoubleAl,
unsigned char FloatAl, unsigned char LongAl, unsigned char FloatAl, unsigned char LongAl,
@ -89,6 +90,7 @@ TargetData::TargetData(const std::string &TargetName,
: AID(AnnotationManager::getID("TargetData::" + TargetName)) { : AID(AnnotationManager::getID("TargetData::" + TargetName)) {
AnnotationManager::registerAnnotationFactory(AID, TypeAnFactory, this); AnnotationManager::registerAnnotationFactory(AID, TypeAnFactory, this);
LittleEndian = isLittleEndian;
IntegerRegSize = IntRegSize; IntegerRegSize = IntRegSize;
PointerSize = PtrSize; PointerSize = PtrSize;
PointerAlignment = PtrAl; PointerAlignment = PtrAl;