From 402ace79fcb4bb504cc953ab1598eca7184e7db4 Mon Sep 17 00:00:00 2001 From: "Vikram S. Adve" Date: Tue, 28 Aug 2001 22:35:21 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@390 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/Type.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 90f92efedd8..44e59d01fec 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -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 //===----------------------------------------------------------------------===// -- 2.34.1