diff gen/typinf.cpp @ 244:a95056b3c996 trunk

[svn r261] Fixed debug info for integer and floating local variables, can now be inspected in GDB. Did a lot of smaller cleans up here and there. Replaced more llvm::Foo with LLFoo for common stuff. Split up tollvm.cpp.
author lindquist
date Mon, 09 Jun 2008 09:37:08 +0200
parents 7816aafeea3c
children 665b81613475
line wrap: on
line diff
--- a/gen/typinf.cpp	Mon Jun 09 03:02:14 2008 +0200
+++ b/gen/typinf.cpp	Mon Jun 09 09:37:08 2008 +0200
@@ -35,6 +35,7 @@
 #include "gen/logger.h"
 #include "gen/runtime.h"
 #include "gen/tollvm.h"
+#include "gen/llvmhelpers.h"
 #include "gen/arrays.h"
 #include "gen/structs.h"
 #include "gen/classes.h"
@@ -279,7 +280,7 @@
         LLValue* found = gIR->module->getNamedGlobal(mangled);
         if (!found)
         {
-            const LLType* t = llvm::OpaqueType::get();
+            const LLType* t = LLOpaqueType::get();
             llvm::GlobalVariable* g = new llvm::GlobalVariable(t, true, llvm::GlobalValue::ExternalLinkage, NULL, mangled, gIR->module);
             assert(g);
             /*if (!tid->ir.irGlobal)
@@ -353,7 +354,7 @@
     ClassDeclaration* base = Type::typeinfotypedef;
     DtoResolveClass(base);
 
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
     this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
@@ -367,7 +368,7 @@
     ClassDeclaration* base = Type::typeinfotypedef;
     DtoForceConstInitDsymbol(base);
 
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
     Logger::cout() << "got stype: " << *stype << '\n';
 
     // vtbl
@@ -375,14 +376,14 @@
     sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
-    sinits.push_back(getNullPtr(getPtrToType(llvm::Type::Int8Ty)));
+    sinits.push_back(getNullPtr(getPtrToType(LLType::Int8Ty)));
 
     assert(tinfo->ty == Ttypedef);
     TypeTypedef *tc = (TypeTypedef *)tinfo;
     TypedefDeclaration *sd = tc->sym;
 
     // TypeInfo base
-    //const llvm::PointerType* basept = isaPointer(initZ->getOperand(1)->getType());
+    //const LLPointerType* basept = isaPointer(initZ->getOperand(1)->getType());
     //sinits.push_back(llvm::ConstantPointerNull::get(basept));
     Logger::println("generating base typeinfo");
     //sd->basetype = sd->basetype->merge();
@@ -403,7 +404,7 @@
     assert(sinits.back()->getType() == stype->getElementType(3));
 
     // void[] init
-    const llvm::PointerType* initpt = getPtrToType(llvm::Type::Int8Ty);
+    const LLPointerType* initpt = getPtrToType(LLType::Int8Ty);
     if (tinfo->isZeroInit() || !sd->init) // 0 initializer, or the same as the base type
     {
         sinits.push_back(DtoConstSlice(DtoConstSize_t(0), getNullPtr(initpt)));
@@ -439,7 +440,7 @@
     ClassDeclaration* base = Type::typeinfoenum;
     DtoResolveClass(base);
 
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
     this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
@@ -453,21 +454,21 @@
     ClassDeclaration* base = Type::typeinfoenum;
     DtoForceConstInitDsymbol(base);
 
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
 
     // vtbl
     std::vector<LLConstant*> sinits;
     sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
-    sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
+    sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty)));
 
     assert(tinfo->ty == Tenum);
     TypeEnum *tc = (TypeEnum *)tinfo;
     EnumDeclaration *sd = tc->sym;
 
     // TypeInfo base
-    //const llvm::PointerType* basept = isaPointer(initZ->getOperand(1)->getType());
+    //const LLPointerType* basept = isaPointer(initZ->getOperand(1)->getType());
     //sinits.push_back(llvm::ConstantPointerNull::get(basept));
     Logger::println("generating base typeinfo");
     //sd->basetype = sd->basetype->merge();
@@ -487,7 +488,7 @@
     assert(sinits.back()->getType() == stype->getElementType(3));
 
     // void[] init
-    const llvm::PointerType* initpt = getPtrToType(llvm::Type::Int8Ty);
+    const LLPointerType* initpt = getPtrToType(LLType::Int8Ty);
     if (tinfo->isZeroInit() || !sd->defaultval) // 0 initializer, or the same as the base type
     {
         sinits.push_back(DtoConstSlice(DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt)));
@@ -521,7 +522,7 @@
     ClassDeclaration* base = cd;
     DtoResolveClass(base);
 
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
     tid->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,tid->toChars(),gIR->module);
@@ -532,14 +533,14 @@
     ClassDeclaration* base = cd;
     DtoForceConstInitDsymbol(base);
 
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
 
     // vtbl
     std::vector<LLConstant*> sinits;
     sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
-    sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
+    sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty)));
 
     // TypeInfo base
     Logger::println("generating base typeinfo");
@@ -626,7 +627,7 @@
     DtoResolveClass(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
     this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
@@ -642,7 +643,7 @@
     DtoForceConstInitDsymbol(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
 
     // initializer vector
     std::vector<LLConstant*> sinits;
@@ -650,7 +651,7 @@
     sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
-    sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
+    sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty)));
 
     // value typeinfo
     assert(tinfo->ty == Tsarray);
@@ -689,7 +690,7 @@
     DtoResolveClass(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
     this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
@@ -705,7 +706,7 @@
     DtoForceConstInitDsymbol(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
 
     // initializer vector
     std::vector<LLConstant*> sinits;
@@ -713,7 +714,7 @@
     sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
-    sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
+    sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty)));
 
     // get type
     assert(tinfo->ty == Taarray);
@@ -822,7 +823,7 @@
     ClassDeclaration* base = Type::typeinfostruct;
     DtoResolveClass(base);
 
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
     this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
@@ -841,14 +842,14 @@
     ClassDeclaration* base = Type::typeinfostruct;
     DtoForceConstInitDsymbol(base);
 
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
 
     // vtbl
     std::vector<LLConstant*> sinits;
     sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
-    sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
+    sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty)));
 
     // char[] name
     char *name = sd->toPrettyChars();
@@ -857,7 +858,7 @@
     assert(sinits.back()->getType() == stype->getElementType(2));
 
     // void[] init
-    const llvm::PointerType* initpt = getPtrToType(llvm::Type::Int8Ty);
+    const LLPointerType* initpt = getPtrToType(LLType::Int8Ty);
 #if 0
     // the implementation of TypeInfo_Struct uses this to determine size. :/
     if (sd->zeroInit) // 0 initializer, or the same as the base type
@@ -918,7 +919,7 @@
 #endif
 
     //Logger::println("************** B");
-    const llvm::PointerType* ptty = isaPointer(stype->getElementType(4));
+    const LLPointerType* ptty = isaPointer(stype->getElementType(4));
     assert(ptty);
 
     s = search_function(sd, Id::tohash);
@@ -1025,7 +1026,7 @@
     DtoResolveClass(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
     this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
@@ -1042,7 +1043,7 @@
     DtoForceConstInitDsymbol(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
 
     // initializer vector
     std::vector<LLConstant*> sinits;
@@ -1050,7 +1051,7 @@
     sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
-    sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
+    sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty)));
 
     // get classinfo
     assert(tinfo->ty == Tclass);
@@ -1082,7 +1083,7 @@
     DtoResolveClass(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
     this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
@@ -1099,7 +1100,7 @@
     DtoForceConstInitDsymbol(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
 
     // initializer vector
     std::vector<LLConstant*> sinits;
@@ -1107,7 +1108,7 @@
     sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
-    sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
+    sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty)));
 
     // get classinfo
     assert(tinfo->ty == Tclass);
@@ -1138,7 +1139,7 @@
     DtoResolveClass(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
     this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
@@ -1155,7 +1156,7 @@
     DtoForceConstInitDsymbol(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
+    const LLStructType* stype = isaStruct(base->type->ir.type->get());
 
     // initializer vector
     std::vector<LLConstant*> sinits;
@@ -1163,7 +1164,7 @@
     sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
-    sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
+    sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(LLType::Int8Ty)));
 
     // create elements array
     assert(tinfo->ty == Ttuple);
@@ -1187,7 +1188,7 @@
     }
 
     // build array type
-    const llvm::ArrayType* arrTy = llvm::ArrayType::get(tiTy, dim);
+    const LLArrayType* arrTy = LLArrayType::get(tiTy, dim);
     LLConstant* arrC = llvm::ConstantArray::get(arrTy, arrInits);
 
     // build the slice