Changed CPUResource to allow access to max num users for a resource.
[oota-llvm.git] / include / llvm / Target / TargetData.h
index aac346a34de8b5c64c8438acd0146572861fe78c..1cc7ddb7d1764db683db4954626bb2f591857464 100644 (file)
@@ -1,4 +1,11 @@
-//===-- llvm/Target/TargetData.h - Data size & alignment routines-*- C++ -*-==//
+//===-- llvm/Target/TargetData.h - Data size & alignment info ---*- C++ -*-===//
+// 
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
+//===----------------------------------------------------------------------===//
 //
 // This file defines target properties related to datatype size/offset/alignment
 // information.  It uses lazy annotations to cache information about how 
 #define LLVM_TARGET_TARGETDATA_H
 
 #include "llvm/Pass.h"
-#include "Support/Annotation.h"
 #include "Support/DataTypes.h"
 #include <vector>
+#include <string>
+
+namespace llvm {
+
 class Value;
 class Type;
 class StructType;
@@ -24,7 +34,6 @@ class StructLayout;
 
 class TargetData : public ImmutablePass {
   bool          LittleEndian;          // Defaults to false
-  unsigned char SubWordDataSize;       // Defaults to 1 byte (no rounding up)
   unsigned char ByteAlignment;         // Defaults to 1 bytes
   unsigned char ShortAlignment;        // Defaults to 2 bytes
   unsigned char IntAlignment;          // Defaults to 4 bytes
@@ -32,21 +41,31 @@ class TargetData : public ImmutablePass {
   unsigned char FloatAlignment;        // Defaults to 4 bytes
   unsigned char DoubleAlignment;       // Defaults to 8 bytes
   unsigned char PointerSize;           // Defaults to 8 bytes
-  unsigned char IntegerRegSize;        // Defaults to PointerSize = 8 bytes
   unsigned char PointerAlignment;      // Defaults to 8 bytes
-  AnnotationID  AID;                   // AID for structure layout annotation
-  static Annotation *TypeAnFactory(AnnotationID, const Annotable *, void *);
+
 public:
-  TargetData(const std::string &TargetName = "Default Target",
+  TargetData(const std::string &TargetName = "",
              bool LittleEndian = false,
-             unsigned char SubWordDataSize = 1,
-             unsigned char IntRegSize = 8,
              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);
+
+  // Copy constructor
+  TargetData (const TargetData &TD) :
+    ImmutablePass (),
+    LittleEndian (TD.isLittleEndian ()),
+    ByteAlignment (TD.getByteAlignment ()),
+    ShortAlignment (TD.getShortAlignment ()),
+    IntAlignment (TD.getIntAlignment ()),
+    LongAlignment (TD.getLongAlignment ()),
+    FloatAlignment (TD.getFloatAlignment ()),
+    DoubleAlignment (TD.getDoubleAlignment ()),
+    PointerSize (TD.getPointerSize ()),
+    PointerAlignment (TD.getPointerAlignment ()) {
+  }
+    
   TargetData(const std::string &ToolName, const Module *M);
   ~TargetData();  // Not virtual, do not subclass this class
 
@@ -55,7 +74,6 @@ public:
   bool          isBigEndian()         const { return    !LittleEndian; }
 
   /// Target alignment constraints
-  unsigned char getSubWordDataSize()  const { return  SubWordDataSize; }
   unsigned char getByteAlignment()    const { return    ByteAlignment; }
   unsigned char getShortAlignment()   const { return   ShortAlignment; }
   unsigned char getIntAlignment()     const { return     IntAlignment; }
@@ -64,40 +82,40 @@ public:
   unsigned char getDoubleAlignment()  const { return  DoubleAlignment; }
   unsigned char getPointerAlignment() const { return PointerAlignment; }
   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
-  // type
-  uint64_t      getTypeSize     (const Type *Ty) const;
+  /// getTypeSize - Return the number of bytes necessary to hold the specified
+  /// type
+  uint64_t getTypeSize(const Type *Ty) const;
 
-  // getTypeAlignment - Return the minimum required alignment for the specified
-  // type
+  /// getTypeAlignment - Return the minimum required alignment for the specified
+  /// type
   unsigned char getTypeAlignment(const Type *Ty) const;
 
-  // getIndexOffset - return the offset from the beginning of the type for the
-  // specified indices.  This is used to implement getelementptr.
-  //
-  uint64_t      getIndexedOffset(const Type *Ty, 
-                                const std::vector<Value*> &Indices) const;
+  /// getIntPtrType - Return an unsigned integer type that is the same size or
+  /// greater to the host pointer size.
+  const Type *getIntPtrType() const;
+
+  /// getIndexOffset - return the offset from the beginning of the type for the
+  /// specified indices.  This is used to implement getelementptr.
+  ///
+  uint64_t getIndexedOffset(const Type *Ty, 
+                            const std::vector<Value*> &Indices) const;
   
-  inline const StructLayout *getStructLayout(const StructType *Ty) const {
-    return (const StructLayout*)
-         ((const Annotable*)Ty)->getOrCreateAnnotation(AID);
-  }
+  const StructLayout *getStructLayout(const StructType *Ty) const;
 };
 
-// This annotation (attached ONLY to StructType classes) is used to lazily
-// calculate structure layout information for a target machine, based on the
-// TargetData structure.
+// This object is used to lazily calculate structure layout information for a
+// target machine, based on the TargetData structure.
 //
-struct StructLayout : public Annotation {
+struct StructLayout {
   std::vector<uint64_t> MemberOffsets;
   uint64_t StructSize;
   unsigned StructAlignment;
 private:
   friend class TargetData;   // Only TargetData can create this class
-  inline StructLayout(const StructType *ST, const TargetData &TD);
+  StructLayout(const StructType *ST, const TargetData &TD);
 };
 
+} // End llvm namespace
+
 #endif