- Add an endianness field to the TargetData datastructure
authorChris Lattner <sabre@nondot.org>
Mon, 14 Oct 2002 22:41:13 +0000 (22:41 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 14 Oct 2002 22:41:13 +0000 (22:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4174 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetData.h
lib/Target/TargetData.cpp

index e6eaf503a9c41f1a23481b8883217ea0816d2965..074345023fe73301ec62d7f3570fa2b09a241575 100644 (file)
@@ -23,6 +23,7 @@ class StructType;
 class StructLayout;
 
 class TargetData : public ImmutablePass {
+  bool          LittleEndian;          // Defaults to false
   unsigned char ByteAlignment;         // Defaults to 1 bytes
   unsigned char ShortAlignment;        // Defaults to 2 bytes
   unsigned char IntAlignment;          // Defaults to 4 bytes
@@ -37,6 +38,7 @@ class TargetData : public ImmutablePass {
   static Annotation *TypeAnFactory(AnnotationID, const Annotable *, void *);
 public:
   TargetData(const std::string &TargetName = "SparcV9",
+             bool LittleEndian = false,
              unsigned char IntRegSize = 8,
              unsigned char PtrSize = 8,
             unsigned char PtrAl = 8, unsigned char DoubleAl = 8,
@@ -45,6 +47,11 @@ public:
             unsigned char ByteAl = 1);
   ~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 getShortAlignment()   const { return   ShortAlignment; }
   unsigned char getIntAlignment()     const { return     IntAlignment; }
@@ -52,8 +59,8 @@ public:
   unsigned char getFloatAlignment()   const { return   FloatAlignment; }
   unsigned char getDoubleAlignment()  const { return  DoubleAlignment; }
   unsigned char getPointerAlignment() const { return PointerAlignment; }
-  unsigned char getPointerSize()      const { return PointerSize; }
-  unsigned char getIntegerRegize()    const { return IntegerRegSize; }
+  unsigned char getPointerSize()      const { return      PointerSize; }
+  unsigned char getIntegerRegize()    const { return   IntegerRegSize; }
   AnnotationID  getStructLayoutAID()  const { return AID; }
 
   // getTypeSize - Return the number of bytes neccesary to hold the specified
index fae5e103e6697d903f247e40a79c112fa3d9851c..1207a6eed149d7ffbf144a3c8bd28147e5ac6efa 100644 (file)
@@ -81,14 +81,16 @@ Annotation *TargetData::TypeAnFactory(AnnotationID AID, const Annotable *T,
 //===----------------------------------------------------------------------===//
 
 TargetData::TargetData(const std::string &TargetName,
-             unsigned char IntRegSize, unsigned char PtrSize,
-            unsigned char PtrAl, unsigned char DoubleAl,
-            unsigned char FloatAl, unsigned char LongAl, 
-            unsigned char IntAl, unsigned char ShortAl,
-            unsigned char ByteAl)
+                       bool isLittleEndian,
+                       unsigned char IntRegSize, unsigned char PtrSize,
+                       unsigned char PtrAl, unsigned char DoubleAl,
+                       unsigned char FloatAl, unsigned char LongAl, 
+                       unsigned char IntAl, unsigned char ShortAl,
+                       unsigned char ByteAl)
   : AID(AnnotationManager::getID("TargetData::" + TargetName)) {
   AnnotationManager::registerAnnotationFactory(AID, TypeAnFactory, this);
 
+  LittleEndian     = isLittleEndian;
   IntegerRegSize   = IntRegSize;
   PointerSize      = PtrSize;
   PointerAlignment = PtrAl;