aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/Type.cpp
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2001-08-28 22:35:21 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2001-08-28 22:35:21 +0000
commit402ace79fcb4bb504cc953ab1598eca7184e7db4 (patch)
tree3c671968c0cd2e3aac20e52f074e92fbe160fe01 /lib/VMCore/Type.cpp
parent71fc67c4b1718e8b71c3e4f55d4af53669b5b697 (diff)
downloadexternal_llvm-402ace79fcb4bb504cc953ab1598eca7184e7db4.zip
external_llvm-402ace79fcb4bb504cc953ab1598eca7184e7db4.tar.gz
external_llvm-402ace79fcb4bb504cc953ab1598eca7184e7db4.tar.bz2
*** empty log message ***
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@390 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Type.cpp')
-rw-r--r--lib/VMCore/Type.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp
index 90f92ef..44e59d0 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
//===----------------------------------------------------------------------===//