Rename the Target specific passes in the DataLayout class to be Target agnostic.
[oota-llvm.git] / include / llvm / DataLayout.h
index 71dec67779d52cb1668ddd9b1744f86940652b19..609594d20afc153d4548cee62dcc5f3895bea48d 100644 (file)
@@ -1,4 +1,4 @@
-//===-- llvm/Target/TargetData.h - Data size & alignment info ---*- C++ -*-===//
+//===--------- llvm/DataLayout.h - Data size & alignment info ---*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// This file defines target properties related to datatype size/offset/alignment
+// This file defines layout properties related to datatype size/offset/alignment
 // information.  It uses lazy annotations to cache information about how
 // structure types are laid out and used.
 //
@@ -17,8 +17,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_TARGET_TARGETDATA_H
-#define LLVM_TARGET_TARGETDATA_H
+#ifndef LLVM_DATALAYOUT_H
+#define LLVM_DATALAYOUT_H
 
 #include "llvm/Pass.h"
 #include "llvm/ADT/SmallVector.h"
@@ -36,7 +36,7 @@ class LLVMContext;
 template<typename T>
 class ArrayRef;
 
-/// Enum used to categorize the alignment types stored by TargetAlignElem
+/// Enum used to categorize the alignment types stored by LayoutAlignElem
 enum AlignTypeEnum {
   INTEGER_ALIGN = 'i',               ///< Integer type alignment
   VECTOR_ALIGN = 'v',                ///< Vector type alignment
@@ -45,33 +45,33 @@ enum AlignTypeEnum {
   STACK_ALIGN = 's'                  ///< Stack objects alignment
 };
 
-/// Target alignment element.
+/// Layout alignment element.
 ///
 /// Stores the alignment data associated with a given alignment type (pointer,
 /// integer, vector, float) and type bit width.
 ///
 /// @note The unusual order of elements in the structure attempts to reduce
 /// padding and make the structure slightly more cache friendly.
-struct TargetAlignElem {
+struct LayoutAlignElem {
   unsigned AlignType    : 8;  ///< Alignment type (AlignTypeEnum)
   unsigned TypeBitWidth : 24; ///< Type bit width
   unsigned ABIAlign     : 16; ///< ABI alignment for this type/bitw
   unsigned PrefAlign    : 16; ///< Pref. alignment for this type/bitw
 
   /// Initializer
-  static TargetAlignElem get(AlignTypeEnum align_type, unsigned abi_align,
+  static LayoutAlignElem get(AlignTypeEnum align_type, unsigned abi_align,
                              unsigned pref_align, uint32_t bit_width);
   /// Equality predicate
-  bool operator==(const TargetAlignElem &rhs) const;
+  bool operator==(const LayoutAlignElem &rhs) const;
 };
 
-/// TargetData - This class holds a parsed version of the target data layout
+/// DataLayout - This class holds a parsed version of the target data layout
 /// string in a module and provides methods for querying it.  The target data
 /// layout string is specified *by the target* - a frontend generating LLVM IR
 /// is required to generate the right target data for the target being codegen'd
 /// to.  If some measure of portability is desired, an empty string may be
 /// specified in the module.
-class TargetData : public ImmutablePass {
+class DataLayout : public ImmutablePass {
 private:
   bool          LittleEndian;          ///< Defaults to false
   unsigned      PointerMemSize;        ///< Pointer size in bytes
@@ -85,13 +85,13 @@ private:
   ///
   /// @sa init().
   /// @note Could support multiple size pointer alignments, e.g., 32-bit
-  /// pointers vs. 64-bit pointers by extending TargetAlignment, but for now,
+  /// pointers vs. 64-bit pointers by extending LayoutAlignment, but for now,
   /// we don't.
-  SmallVector<TargetAlignElem, 16> Alignments;
+  SmallVector<LayoutAlignElem, 16> Alignments;
 
   /// InvalidAlignmentElem - This member is a signal that a requested alignment
   /// type and bit width were not found in the SmallVector.
-  static const TargetAlignElem InvalidAlignmentElem;
+  static const LayoutAlignElem InvalidAlignmentElem;
 
   // The StructType -> StructLayout map.
   mutable void *LayoutMap;
@@ -106,13 +106,13 @@ private:
 
   /// Valid alignment predicate.
   ///
-  /// Predicate that tests a TargetAlignElem reference returned by get() against
+  /// Predicate that tests a LayoutAlignElem reference returned by get() against
   /// InvalidAlignmentElem.
-  bool validAlignment(const TargetAlignElem &align) const {
+  bool validAlignment(const LayoutAlignElem &align) const {
     return &align != &InvalidAlignmentElem;
   }
 
-  /// Initialise a TargetData object with default values, ensure that the
+  /// Initialise a DataLayout object with default values, ensure that the
   /// target data pass is registered.
   void init();
 
@@ -121,25 +121,26 @@ public:
   ///
   /// @note This has to exist, because this is a pass, but it should never be
   /// used.
-  TargetData();
+  DataLayout();
 
-  /// Constructs a TargetData from a specification string. See init().
-  explicit TargetData(StringRef TargetDescription)
+  /// Constructs a DataLayout from a specification string. See init().
+  explicit DataLayout(StringRef LayoutDescription)
     : ImmutablePass(ID) {
-    std::string errMsg = parseSpecifier(TargetDescription, this);
+    std::string errMsg = parseSpecifier(LayoutDescription, this);
     assert(errMsg == "" && "Invalid target data layout string.");
     (void)errMsg;
   }
 
   /// Parses a target data specification string. Returns an error message
   /// if the string is malformed, or the empty string on success. Optionally
-  /// initialises a TargetData object if passed a non-null pointer.
-  static std::string parseSpecifier(StringRef TargetDescription, TargetData* td = 0);
+  /// 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 TargetData(const Module *M);
+  explicit DataLayout(const Module *M);
 
-  TargetData(const TargetData &TD) :
+  DataLayout(const DataLayout &TD) :
     ImmutablePass(ID),
     LittleEndian(TD.isLittleEndian()),
     PointerMemSize(TD.PointerMemSize),
@@ -150,14 +151,14 @@ public:
     LayoutMap(0)
   { }
 
-  ~TargetData();  // Not virtual, do not subclass this class
+  ~DataLayout();  // Not virtual, do not subclass this class
 
-  /// Target endianness...
+  /// Layout endianness...
   bool isLittleEndian() const { return LittleEndian; }
   bool isBigEndian() const { return !LittleEndian; }
 
   /// getStringRepresentation - Return the string representation of the
-  /// TargetData.  This representation is in the same format accepted by the
+  /// DataLayout.  This representation is in the same format accepted by the
   /// string constructor above.
   std::string getStringRepresentation() const;
 
@@ -195,13 +196,13 @@ public:
     return false;
   }
 
-  /// Target pointer alignment
+  /// Layout pointer alignment
   unsigned getPointerABIAlignment() const { return PointerABIAlign; }
-  /// Return target's alignment for stack-based pointers
+  /// Return layout's alignment for stack-based pointers
   unsigned getPointerPrefAlignment() const { return PointerPrefAlign; }
-  /// Target pointer size
+  /// Layout pointer size
   unsigned getPointerSize()         const { return PointerMemSize; }
-  /// Target pointer size, in bits
+  /// Layout pointer size, in bits
   unsigned getPointerSizeInBits()   const { return 8*PointerMemSize; }
 
   /// Size examples:
@@ -318,7 +319,7 @@ public:
 };
 
 /// StructLayout - used to lazily calculate structure layout information for a
-/// target machine, based on the TargetData structure.
+/// target machine, based on the DataLayout structure.
 ///
 class StructLayout {
   uint64_t StructSize;
@@ -354,8 +355,8 @@ public:
   }
 
 private:
-  friend class TargetData;   // Only TargetData can create this class
-  StructLayout(StructType *ST, const TargetData &TD);
+  friend class DataLayout;   // Only DataLayout can create this class
+  StructLayout(StructType *ST, const DataLayout &TD);
 };
 
 } // End llvm namespace