[llvm-commits] [parallel] CVS: llvm/lib/Target/Makefile Target.td TargetData.cpp TargetInstrInfo.cpp TargetMachine.cpp TargetSchedInfo.cpp

Misha Brukman brukman at cs.uiuc.edu
Mon Mar 1 18:03:06 PST 2004


Changes in directory llvm/lib/Target:

Makefile updated: 1.9 -> 1.9.6.1
Target.td updated: 1.24 -> 1.24.6.1
TargetData.cpp updated: 1.41 -> 1.41.2.1
TargetInstrInfo.cpp updated: 1.11 -> 1.11.2.1
TargetMachine.cpp updated: 1.21 -> 1.21.2.1
TargetSchedInfo.cpp updated: 1.13 -> 1.13.4.1

---
Log message:

Merge from trunk

---
Diffs of the changes:  (+45 -52)

Index: llvm/lib/Target/Makefile
diff -u llvm/lib/Target/Makefile:1.9 llvm/lib/Target/Makefile:1.9.6.1
--- llvm/lib/Target/Makefile:1.9	Mon Oct 20 17:26:56 2003
+++ llvm/lib/Target/Makefile	Mon Mar  1 17:58:13 2004
@@ -7,7 +7,7 @@
 # 
 ##===----------------------------------------------------------------------===##
 LEVEL = ../..
-DIRS = Sparc X86
+DIRS = CBackend X86 SparcV9 SparcV8 PowerPC
 LIBRARYNAME = target
 BUILD_ARCHIVE = 1
 


Index: llvm/lib/Target/Target.td
diff -u llvm/lib/Target/Target.td:1.24 llvm/lib/Target/Target.td:1.24.6.1
--- llvm/lib/Target/Target.td:1.24	Tue Oct 21 10:17:13 2003
+++ llvm/lib/Target/Target.td	Mon Mar  1 17:58:13 2004
@@ -25,6 +25,7 @@
   int Value = value;
 }
 
+def OtherVT: ValueType<0  ,  0>;   // "Other" value
 def i1     : ValueType<1  ,  1>;   // One bit boolean value
 def i8     : ValueType<8  ,  2>;   // 8-bit integer value
 def i16    : ValueType<16 ,  3>;   // 16-bit integer value


Index: llvm/lib/Target/TargetData.cpp
diff -u llvm/lib/Target/TargetData.cpp:1.41 llvm/lib/Target/TargetData.cpp:1.41.2.1
--- llvm/lib/Target/TargetData.cpp:1.41	Sun Dec 21 23:01:15 2003
+++ llvm/lib/Target/TargetData.cpp	Mon Mar  1 17:58:13 2004
@@ -8,8 +8,7 @@
 //===----------------------------------------------------------------------===//
 //
 // This file defines target properties related to datatype size/offset/alignment
-// information.  It uses lazy annotations to cache information about how 
-// structure types are laid out and used.
+// information.
 //
 // This structure should be created once, filled in if the defaults are not
 // correct and then passed around by const&.  None of the members functions
@@ -33,18 +32,16 @@
 			       uint64_t &Size, unsigned char &Alignment);
 
 //===----------------------------------------------------------------------===//
-// Support for StructLayout Annotation
+// Support for StructLayout
 //===----------------------------------------------------------------------===//
 
-StructLayout::StructLayout(const StructType *ST, const TargetData &TD) 
-  : Annotation(TD.getStructLayoutAID()) {
+StructLayout::StructLayout(const StructType *ST, const TargetData &TD) {
   StructAlignment = 0;
   StructSize = 0;
 
   // Loop over each of the elements, placing them in memory...
-  for (StructType::ElementTypes::const_iterator
-	 TI = ST->getElementTypes().begin(), 
-	 TE = ST->getElementTypes().end(); TI != TE; ++TI) {
+  for (StructType::element_iterator TI = ST->element_begin(), 
+	 TE = ST->element_end(); TI != TE; ++TI) {
     const Type *Ty = *TI;
     unsigned char A;
     unsigned TyAlign;
@@ -72,16 +69,6 @@
     StructSize = (StructSize/StructAlignment + 1) * StructAlignment;
 }
 
-Annotation *TargetData::TypeAnFactory(AnnotationID AID, const Annotable *T,
-				      void *D) {
-  const TargetData &TD = *(const TargetData*)D;
-  assert(AID == TD.AID && "Target data annotation ID mismatch!");
-  const Type *Ty = cast<Type>((const Value *)T);
-  assert(isa<StructType>(Ty) && 
-	 "Can only create StructLayout annotation on structs!");
-  return new StructLayout(cast<StructType>(Ty), TD);
-}
-
 //===----------------------------------------------------------------------===//
 //                       TargetData Class Implementation
 //===----------------------------------------------------------------------===//
@@ -91,9 +78,7 @@
                        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);
+                       unsigned char ByteAl) {
 
   // If this assert triggers, a pass "required" TargetData information, but the
   // top level tool did not provide once for it.  We do not want to default
@@ -115,10 +100,7 @@
   ByteAlignment    = ByteAl;
 }
 
-TargetData::TargetData(const std::string &ToolName, const Module *M)
-  : AID(AnnotationManager::getID("TargetData::" + ToolName)) {
-  AnnotationManager::registerAnnotationFactory(AID, TypeAnFactory, this);
-
+TargetData::TargetData(const std::string &ToolName, const Module *M) {
   LittleEndian     = M->getEndianness() != Module::BigEndian;
   PointerSize      = M->getPointerSize() != Module::Pointer64 ? 4 : 8;
   PointerAlignment = PointerSize;
@@ -130,8 +112,38 @@
   ByteAlignment    = 1;
 }
 
+static std::map<std::pair<const TargetData*,const StructType*>,
+                StructLayout> *Layouts = 0;
+
+
 TargetData::~TargetData() {
-  AnnotationManager::registerAnnotationFactory(AID, 0);   // Deregister factory
+  if (Layouts) {
+    // Remove any layouts for this TD.
+    std::map<std::pair<const TargetData*,
+      const StructType*>, StructLayout>::iterator
+      I = Layouts->lower_bound(std::make_pair(this, (const StructType*)0));
+    while (I != Layouts->end() && I->first.first == this)
+      Layouts->erase(I++);
+    if (Layouts->empty()) {
+      delete Layouts;
+      Layouts = 0;
+    }
+  }
+}
+
+const StructLayout *TargetData::getStructLayout(const StructType *Ty) const {
+  if (Layouts == 0)
+    Layouts = new std::map<std::pair<const TargetData*,const StructType*>,
+                           StructLayout>();
+  std::map<std::pair<const TargetData*,const StructType*>,
+                     StructLayout>::iterator
+    I = Layouts->lower_bound(std::make_pair(this, Ty));
+  if (I != Layouts->end() && I->first.first == this && I->first.second == Ty)
+    return &I->second;
+  else {
+    return &Layouts->insert(I, std::make_pair(std::make_pair(this, Ty),
+                                              StructLayout(Ty, *this)))->second;
+  }
 }
 
 static inline void getTypeInfo(const Type *Ty, const TargetData *TD,
@@ -227,7 +239,7 @@
       Result += Layout->MemberOffsets[FieldNo];
 
       // Update Ty to refer to current element
-      Ty = STy->getElementTypes()[FieldNo];
+      Ty = STy->getElementType(FieldNo);
     }
   }
 


Index: llvm/lib/Target/TargetInstrInfo.cpp
diff -u llvm/lib/Target/TargetInstrInfo.cpp:1.11 llvm/lib/Target/TargetInstrInfo.cpp:1.11.2.1
--- llvm/lib/Target/TargetInstrInfo.cpp:1.11	Thu Jan 15 12:15:58 2004
+++ llvm/lib/Target/TargetInstrInfo.cpp	Mon Mar  1 17:58:13 2004
@@ -24,9 +24,8 @@
 const TargetInstrDescriptor* TargetInstrDescriptors = 0;
 
 TargetInstrInfo::TargetInstrInfo(const TargetInstrDescriptor* Desc,
-				 unsigned DescSize,
-				 unsigned NumRealOpCodes)
-  : desc(Desc), descSize(DescSize), numRealOpCodes(NumRealOpCodes) {
+				 unsigned numOpcodes)
+  : desc(Desc), NumOpcodes(numOpcodes) {
   // FIXME: TargetInstrDescriptors should not be global
   assert(TargetInstrDescriptors == NULL && desc != NULL
          && "TargetMachine data structure corrupt; maybe you tried to create another TargetMachine? (only one may exist in a program)");


Index: llvm/lib/Target/TargetMachine.cpp
diff -u llvm/lib/Target/TargetMachine.cpp:1.21 llvm/lib/Target/TargetMachine.cpp:1.21.2.1
--- llvm/lib/Target/TargetMachine.cpp:1.21	Sun Dec 28 15:23:38 2003
+++ llvm/lib/Target/TargetMachine.cpp	Mon Mar  1 17:58:13 2004
@@ -8,12 +8,10 @@
 //===----------------------------------------------------------------------===//
 //
 // This file describes the general parts of a Target machine.
-// This file also implements TargetCacheInfo.
 //
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Target/TargetMachine.h"
-#include "llvm/Target/TargetCacheInfo.h"
 #include "llvm/Type.h"
 #include "llvm/IntrinsicLowering.h"
 using namespace llvm;
@@ -33,31 +31,14 @@
   IL = il ? il : new DefaultIntrinsicLowering();
 }
 
-
-
 TargetMachine::~TargetMachine() {
   delete IL;
 }
 
-
-
-
 unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const {
   // All integer types smaller than ints promote to 4 byte integers.
   if (Ty->isIntegral() && Ty->getPrimitiveSize() < 4)
     return 4;
 
   return DataLayout.getTypeSize(Ty);
-}
-
-
-//---------------------------------------------------------------------------
-// TargetCacheInfo Class
-//
-
-void TargetCacheInfo::Initialize() {
-  numLevels = 2;
-  cacheLineSizes.push_back(16);  cacheLineSizes.push_back(32); 
-  cacheSizes.push_back(1 << 15); cacheSizes.push_back(1 << 20);
-  cacheAssoc.push_back(1);       cacheAssoc.push_back(4);
 }


Index: llvm/lib/Target/TargetSchedInfo.cpp
diff -u llvm/lib/Target/TargetSchedInfo.cpp:1.13 llvm/lib/Target/TargetSchedInfo.cpp:1.13.4.1
--- llvm/lib/Target/TargetSchedInfo.cpp:1.13	Tue Nov 11 16:41:33 2003
+++ llvm/lib/Target/TargetSchedInfo.cpp	Mon Mar  1 17:58:13 2004
@@ -119,7 +119,7 @@
 TargetSchedInfo::computeInstrResources(const std::vector<InstrRUsage>&
 					instrRUForClasses)
 {
-  int numOpCodes =  mii->getNumRealOpCodes();
+  int numOpCodes =  mii->getNumOpcodes();
   instrRUsages.resize(numOpCodes);
   
   // First get the resource usage information from the class resource usages.
@@ -149,7 +149,7 @@
 TargetSchedInfo::computeIssueGaps(const std::vector<InstrRUsage>&
 				   instrRUForClasses)
 {
-  int numOpCodes =  mii->getNumRealOpCodes();
+  int numOpCodes =  mii->getNumOpcodes();
   issueGaps.resize(numOpCodes);
   conflictLists.resize(numOpCodes);
 





More information about the llvm-commits mailing list