*** empty log message ***
authorVikram S. Adve <vadve@cs.uiuc.edu>
Tue, 28 Aug 2001 22:35:21 +0000 (22:35 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Tue, 28 Aug 2001 22:35:21 +0000 (22:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@390 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Type.cpp

index 90f92efedd8d25ff94dd1029531673046fcaa973..44e59d01fecc90739f7e60ed938dd29aff760dba 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "llvm/DerivedTypes.h"
 #include "llvm/Support/StringExtras.h"
+#include "llvm/CodeGen/TargetMachine.h"
 
 //===----------------------------------------------------------------------===//
 //                         Type Class Implementation
@@ -138,6 +139,49 @@ const Type *Type::VoidTy   = new            Type("void"  , VoidTyID),
 #include "llvm/Assembly/Writer.h"
 #endif
 
+#undef RESURRECT_OLD_LAYOUT_CODE
+#ifdef RESURRECT_OLD_LAYOUT_CODE
+
+unsigned int
+StructType::getStorageSize(const TargetMachine& tmi) const
+{
+  if (layoutCache->targetInfo && layoutCache->targetInfo != &tmi)
+    {// target machine has changed (hey it could happen). discard cached info.
+      ResetCachedInfo();
+      layoutCache->targetInfo = &tmi;
+    }
+  
+  if (layoutCache->storageSize < 0) {
+    layoutCache->storageSize = tmi.findOptimalStorageSize(this);
+    assert(layoutCache->storageSize >= 0);
+  }
+  
+  return layoutCache->storageSize;
+}
+
+unsigned int
+StructType::getElementOffset(int i, const TargetMachine& tmi) const
+{
+  // target machine has changed (hey it could happen). discard cached info.
+  if (layoutCache->targetInfo && layoutCache->targetInfo != &tmi)
+    ResetCachedInfo();
+  
+  if (layoutCache->memberOffsets[i] < 0) {
+    layoutCache->targetInfo = &tmi;  // remember which target was used
+    
+    unsigned int *offsetVec = tmi.findOptimalMemberOffsets(this);
+    for (unsigned i=0, N=layoutCache->memberOffsets.size(); i < N; ++i) {
+      layoutCache->memberOffsets[i] = offsetVec[i];
+      assert(layoutCache->memberOffsets[i] >= 0);
+    }
+    delete[] offsetVec; 
+  }
+  
+  return layoutCache->memberOffsets[i];
+}
+
+#endif
+
 //===----------------------------------------------------------------------===//
 //                          Derived Type Constructors
 //===----------------------------------------------------------------------===//