# HG changeset patch # User ChristianK # Date 1209641528 -7200 # Node ID 5c17f81fc1c1b1a8b1979f9dae46a1eac1221657 # Parent ccd07d9f2ce9b1e88e3ecf747cf972926b14f64f [svn r173] moved IR state previously stored in Type into IrType and a Type->IrType map; fixes #7 diff -r ccd07d9f2ce9 -r 5c17f81fc1c1 dmd/mtype.c --- a/dmd/mtype.c Thu May 01 13:05:53 2008 +0200 +++ b/dmd/mtype.c Thu May 01 13:32:08 2008 +0200 @@ -114,7 +114,6 @@ this->arrayof = NULL; this->vtinfo = NULL; this->ctype = NULL; - this->llvmType = NULL; } Type *Type::syntaxCopy() @@ -4413,7 +4412,6 @@ : Type(Tclass, NULL) { this->sym = sym; - llvmVtblType = 0; } char *TypeClass::toChars() diff -r ccd07d9f2ce9 -r 5c17f81fc1c1 dmd/mtype.h --- a/dmd/mtype.h Thu May 01 13:05:53 2008 +0200 +++ b/dmd/mtype.h Thu May 01 13:32:08 2008 +0200 @@ -21,16 +21,6 @@ #include "arraytypes.h" #include "expression.h" -// LLVMDC -namespace llvm -{ - class Value; - class Instruction; - class Type; - class PATypeHolder; - class GlobalVariable; -} - struct Scope; struct Identifier; struct Expression; @@ -253,8 +243,6 @@ virtual type *toCParamtype(); virtual Symbol *toSymbol(); - llvm::PATypeHolder* llvmType; - // For eliminating dynamic_cast virtual TypeBasic *isTypeBasic(); }; @@ -637,8 +625,6 @@ type *toCtype(); Symbol *toSymbol(); - - llvm::PATypeHolder* llvmVtblType; }; struct TypeTuple : Type diff -r ccd07d9f2ce9 -r 5c17f81fc1c1 gen/arrays.cpp --- a/gen/arrays.cpp Thu May 01 13:05:53 2008 +0200 +++ b/gen/arrays.cpp Thu May 01 13:32:08 2008 +0200 @@ -41,8 +41,8 @@ const llvm::ArrayType* DtoStaticArrayType(Type* t) { - if (t->llvmType) - return isaArray(t->llvmType->get()); + if (gIR->irType[t].type) + return isaArray(gIR->irType[t].type->get()); assert(t->ty == Tsarray); assert(t->next); @@ -53,8 +53,8 @@ assert(tsa->dim->type->isintegral()); const llvm::ArrayType* arrty = llvm::ArrayType::get(at,tsa->dim->toUInteger()); - assert(!tsa->llvmType); - tsa->llvmType = new llvm::PATypeHolder(arrty); + assert(!gIR->irType[tsa].type); + gIR->irType[tsa].type = new llvm::PATypeHolder(arrty); return arrty; } diff -r ccd07d9f2ce9 -r 5c17f81fc1c1 gen/classes.cpp --- a/gen/classes.cpp Thu May 01 13:05:53 2008 +0200 +++ b/gen/classes.cpp Thu May 01 13:32:08 2008 +0200 @@ -128,8 +128,8 @@ gIR->classes.push_back(cd); // add vtable - ts->llvmVtblType = new llvm::PATypeHolder(llvm::OpaqueType::get()); - const llvm::Type* vtabty = getPtrToType(ts->llvmVtblType->get()); + gIR->irType[ts].vtblType = new llvm::PATypeHolder(llvm::OpaqueType::get()); + const llvm::Type* vtabty = getPtrToType(gIR->irType[ts].vtblType->get()); std::vector fieldtypes; fieldtypes.push_back(vtabty); @@ -237,11 +237,11 @@ // set vtbl type TypeClass* itc = (TypeClass*)id->type; - const llvm::Type* ivtblTy = getPtrToType(itc->llvmVtblType->get()); + const llvm::Type* ivtblTy = getPtrToType(gIR->irType[itc].vtblType->get()); fieldtypes.push_back(ivtblTy); // fix the interface vtable type - iri->vtblTy = isaStruct(itc->llvmVtblType->get()); + iri->vtblTy = isaStruct(gIR->irType[itc].vtblType->get()); // set index iri->index = interIdx++; @@ -259,14 +259,14 @@ structtype = isaStruct(spa.get()); // make it official - if (!ts->llvmType) - ts->llvmType = new llvm::PATypeHolder(structtype); + if (!gIR->irType[ts].type) + gIR->irType[ts].type = new llvm::PATypeHolder(structtype); else - *ts->llvmType = structtype; - spa = *ts->llvmType; + *gIR->irType[ts].type = structtype; + spa = *gIR->irType[ts].type; // name the type - gIR->module->addTypeName(cd->mangle(), ts->llvmType->get()); + gIR->module->addTypeName(cd->mangle(), gIR->irType[ts].type->get()); // get interface info type const llvm::StructType* infoTy = DtoInterfaceInfoType(); @@ -285,7 +285,7 @@ DtoResolveFunction(fd); //assert(fd->type->ty == Tfunction); //TypeFunction* tf = (TypeFunction*)fd->type; - //const llvm::Type* fpty = getPtrToType(tf->llvmType->get()); + //const llvm::Type* fpty = getPtrToType(gIR->irType[tf].type->get()); const llvm::FunctionType* vfty = DtoBaseFunctionType(fd); const llvm::Type* vfpty = getPtrToType(vfty); sinits_ty.push_back(vfpty); @@ -297,11 +297,11 @@ cinfoty = infoTy; } else if (cd != ClassDeclaration::classinfo) { - cinfoty = ClassDeclaration::classinfo->type->llvmType->get(); + cinfoty = gIR->irType[ClassDeclaration::classinfo->type].type->get(); } else { // this is the ClassInfo class, the type is this type - cinfoty = ts->llvmType->get(); + cinfoty = gIR->irType[ts].type->get(); } const llvm::Type* cty = getPtrToType(cinfoty); sinits_ty.push_back(cty); @@ -318,7 +318,7 @@ gIR->module->addTypeName(styname, svtbl_ty); // refine for final vtable type - llvm::cast(ts->llvmVtblType->get())->refineAbstractTypeTo(svtbl_ty); + llvm::cast(gIR->irType[ts].vtblType->get())->refineAbstractTypeTo(svtbl_ty); gIR->classes.pop_back(); gIR->structs.pop_back(); @@ -360,7 +360,7 @@ varname.append(cd->mangle()); varname.append("6__vtblZ"); - const llvm::StructType* svtbl_ty = isaStruct(ts->llvmVtblType->get()); + const llvm::StructType* svtbl_ty = isaStruct(gIR->irType[ts].vtblType->get()); gIR->irDsymbol[cd].irStruct->vtbl = new llvm::GlobalVariable(svtbl_ty, true, _linkage, 0, varname, gIR->module); } @@ -408,7 +408,7 @@ initname.append(cd->mangle()); initname.append("6__initZ"); - llvm::GlobalVariable* initvar = new llvm::GlobalVariable(ts->llvmType->get(), true, _linkage, NULL, initname, gIR->module); + llvm::GlobalVariable* initvar = new llvm::GlobalVariable(gIR->irType[ts].type->get(), true, _linkage, NULL, initname, gIR->module); gIR->irDsymbol[cd].irStruct->init = initvar; } @@ -447,8 +447,8 @@ // get the struct (class) type assert(cd->type->ty == Tclass); TypeClass* ts = (TypeClass*)cd->type; - const llvm::StructType* structtype = isaStruct(ts->llvmType->get()); - const llvm::StructType* vtbltype = isaStruct(ts->llvmVtblType->get()); + const llvm::StructType* structtype = isaStruct(gIR->irType[ts].type->get()); + const llvm::StructType* vtbltype = isaStruct(gIR->irType[ts].vtblType->get()); // make sure each offset knows its default initializer for (IrStruct::OffsetMap::iterator i=irstruct->offsets.begin(); i!=irstruct->offsets.end(); ++i) @@ -468,7 +468,7 @@ fieldinits.push_back( llvm::ConstantPointerNull::get( getPtrToType( - ts->llvmVtblType->get() + gIR->irType[ts].vtblType->get() ) ) ); @@ -569,7 +569,7 @@ assert(0); } - const llvm::StructType* svtbl_ty = isaStruct(ts->llvmVtblType->get()); + const llvm::StructType* svtbl_ty = isaStruct(gIR->irType[ts].vtblType->get()); #if 0 for (size_t i=0; i< sinits.size(); ++i) @@ -593,7 +593,7 @@ assert(id->type->ty == Tclass); TypeClass* its = (TypeClass*)id->type; - const llvm::StructType* ivtbl_ty = isaStruct(its->llvmVtblType->get()); + const llvm::StructType* ivtbl_ty = isaStruct(gIR->irType[its].vtblType->get()); // generate interface info initializer std::vector infoInits; @@ -612,11 +612,11 @@ // offset // generate target independent offset with constGEP /*llvm::Value* cidx = DtoConstInt(iri->index); - Logger::cout() << "offset to interface in class type: " << *cd->type->llvmType->get() << '\n'; - size_t ioff = gTargetData->getIndexedOffset(cd->type->llvmType->get(), &cidx, 1); + Logger::cout() << "offset to interface in class type: " << *gIR->irType[cd->type].type->get() << '\n'; + size_t ioff = gTargetData->getIndexedOffset(gIR->irType[cd->type].type->get(), &cidx, 1); infoInits.push_back(DtoConstUint(ioff));*/ assert(iri->index >= 0); - size_t ioff = gTargetData->getStructLayout(isaStruct(cd->type->llvmType->get()))->getElementOffset(iri->index); + size_t ioff = gTargetData->getStructLayout(isaStruct(gIR->irType[cd->type].type->get()))->getElementOffset(iri->index); infoInits.push_back(DtoConstUint(ioff)); // create interface info initializer constant @@ -805,7 +805,7 @@ void DtoInitClass(TypeClass* tc, llvm::Value* dst) { size_t presz = 2*getABITypeSize(DtoSize_t()); - uint64_t n = getABITypeSize(tc->llvmType->get()) - presz; + uint64_t n = getABITypeSize(gIR->irType[tc].type->get()) - presz; // set vtable field seperately, this might give better optimization assert(gIR->irDsymbol[tc->sym].irStruct->vtbl); @@ -1199,7 +1199,7 @@ else gname.append("11__InterfaceZ"); - const llvm::Type* st = cinfo->type->llvmType->get(); + const llvm::Type* st = gIR->irType[cinfo->type].type->get(); gIR->irDsymbol[cd].irStruct->classInfo = new llvm::GlobalVariable(st, true, DtoLinkage(cd), NULL, gname, gIR->module); } @@ -1224,7 +1224,7 @@ DtoForceDeclareDsymbol(vd->type->vtinfo); llvm::Constant* c = isaConstant(gIR->irDsymbol[vd->type->vtinfo].getIrValue()); - const llvm::Type* tiTy = getPtrToType(Type::typeinfo->type->llvmType->get()); + const llvm::Type* tiTy = getPtrToType(gIR->irType[Type::typeinfo->type].type->get()); //Logger::cout() << "tiTy = " << *tiTy << '\n'; types.push_back(tiTy); @@ -1265,7 +1265,7 @@ // OffsetTypeInfo type std::vector elemtypes; elemtypes.push_back(DtoSize_t()); - const llvm::Type* tiTy = getPtrToType(Type::typeinfo->type->llvmType->get()); + const llvm::Type* tiTy = getPtrToType(gIR->irType[Type::typeinfo->type].type->get()); elemtypes.push_back(tiTy); const llvm::StructType* sTy = llvm::StructType::get(elemtypes); @@ -1290,7 +1290,7 @@ { // construct the function std::vector paramTypes; - paramTypes.push_back(getPtrToType(cd->type->llvmType->get())); + paramTypes.push_back(getPtrToType(gIR->irType[cd->type].type->get())); const llvm::FunctionType* fnTy = llvm::FunctionType::get(llvm::Type::VoidTy, paramTypes, false); diff -r ccd07d9f2ce9 -r 5c17f81fc1c1 gen/functions.cpp --- a/gen/functions.cpp Thu May 01 13:05:53 2008 +0200 +++ b/gen/functions.cpp Thu May 01 13:32:08 2008 +0200 @@ -23,8 +23,8 @@ TypeFunction* f = (TypeFunction*)type; assert(f != 0); - if (type->llvmType != NULL) { - return llvm::cast(type->llvmType->get()); + if (gIR->irType[type].type != NULL) { + return llvm::cast(gIR->irType[type].type->get()); } bool typesafeVararg = false; @@ -126,10 +126,10 @@ f->llvmRetInPtr = retinptr; f->llvmUsesThis = usesthis; - //if (!f->llvmType) - f->llvmType = new llvm::PATypeHolder(functype); + //if (!gIR->irType[f].type) + gIR->irType[f].type = new llvm::PATypeHolder(functype); //else - //assert(functype == f->llvmType->get()); + //assert(functype == gIR->irType[f].type->get()); return functype; } @@ -139,8 +139,8 @@ static const llvm::FunctionType* DtoVaFunctionType(FuncDeclaration* fdecl) { // type has already been resolved - if (fdecl->type->llvmType != 0) { - return llvm::cast(fdecl->type->llvmType->get()); + if (gIR->irType[fdecl->type].type != 0) { + return llvm::cast(gIR->irType[fdecl->type].type->get()); } TypeFunction* f = (TypeFunction*)fdecl->type; @@ -163,7 +163,7 @@ const llvm::FunctionType* fty = llvm::FunctionType::get(llvm::Type::VoidTy, args, false); - f->llvmType = new llvm::PATypeHolder(fty); + gIR->irType[f].type = new llvm::PATypeHolder(fty); return fty; } @@ -183,8 +183,8 @@ }*/ // type has already been resolved - if (fdecl->type->llvmType != 0) { - return llvm::cast(fdecl->type->llvmType->get()); + if (gIR->irType[fdecl->type].type != 0) { + return llvm::cast(gIR->irType[fdecl->type].type->get()); } const llvm::Type* thisty = NULL; @@ -367,7 +367,7 @@ func->setCallingConv(llvm::CallingConv::C); gIR->irDsymbol[fdecl].irFunc->func = func; - assert(llvm::isa(f->llvmType->get())); + assert(llvm::isa(gIR->irType[f].type->get())); // main if (fdecl->isMain()) { @@ -462,7 +462,7 @@ Type* t = DtoDType(fd->type); TypeFunction* f = (TypeFunction*)t; - assert(f->llvmType); + assert(gIR->irType[f].type); llvm::Function* func = gIR->irDsymbol[fd].irFunc->func; const llvm::FunctionType* functype = func->getFunctionType(); diff -r ccd07d9f2ce9 -r 5c17f81fc1c1 gen/irstate.h --- a/gen/irstate.h Thu May 01 13:05:53 2008 +0200 +++ b/gen/irstate.h Thu May 01 13:32:08 2008 +0200 @@ -12,6 +12,7 @@ #include "ir/irstruct.h" #include "ir/irvar.h" #include "ir/irsymbol.h" +#include "ir/irtype.h" // global ir state for current module struct IRState; @@ -79,6 +80,9 @@ // ir data associated with DMD Dsymbol nodes std::map irDsymbol; + // ir data associated with DMD Type instances + std::map irType; + // functions typedef std::vector FunctionVector; FunctionVector functions; diff -r ccd07d9f2ce9 -r 5c17f81fc1c1 gen/runtime.cpp --- a/gen/runtime.cpp Thu May 01 13:05:53 2008 +0200 +++ b/gen/runtime.cpp Thu May 01 13:32:08 2008 +0200 @@ -15,6 +15,7 @@ #include "gen/runtime.h" #include "gen/logger.h" #include "gen/tollvm.h" +#include "gen/irstate.h" static llvm::Module* M = NULL; static bool runtime_failed = false; @@ -188,9 +189,9 @@ const llvm::Type* stringTy = rt_array(byteTy); const llvm::Type* wstringTy = rt_array(shortTy); const llvm::Type* dstringTy = rt_array(intTy); - const llvm::Type* objectTy = rt_ptr(ClassDeclaration::object->type->llvmType->get()); - const llvm::Type* classInfoTy = rt_ptr(ClassDeclaration::classinfo->type->llvmType->get()); - const llvm::Type* typeInfoTy = rt_ptr(Type::typeinfo->type->llvmType->get()); + const llvm::Type* objectTy = rt_ptr(gIR->irType[ClassDeclaration::object->type].type->get()); + const llvm::Type* classInfoTy = rt_ptr(gIR->irType[ClassDeclaration::classinfo->type].type->get()); + const llvm::Type* typeInfoTy = rt_ptr(gIR->irType[Type::typeinfo->type].type->get()); const llvm::Type* aaTy = rt_ptr(llvm::OpaqueType::get()); ///////////////////////////////////////////////////////////////////////////////////// diff -r ccd07d9f2ce9 -r 5c17f81fc1c1 gen/structs.cpp --- a/gen/structs.cpp Thu May 01 13:05:53 2008 +0200 +++ b/gen/structs.cpp Thu May 01 13:32:08 2008 +0200 @@ -82,7 +82,7 @@ TypeStruct* ts = (TypeStruct*)si->ad->type; - const llvm::StructType* structtype = isaStruct(ts->llvmType->get()); + const llvm::StructType* structtype = isaStruct(gIR->irType[ts].type->get()); Logger::cout() << "llvm struct type: " << *structtype << '\n'; assert(si->value.dim == si->vars.dim); @@ -304,8 +304,8 @@ structtype = isaStruct(pa.get()); } - assert(ts->llvmType == 0); - ts->llvmType = new llvm::PATypeHolder(structtype); + assert(gIR->irType[ts].type == 0); + gIR->irType[ts].type = new llvm::PATypeHolder(structtype); if (sd->parent->isModule()) { gIR->module->addTypeName(sd->mangle(),structtype); @@ -333,7 +333,7 @@ initname.append("6__initZ"); llvm::GlobalValue::LinkageTypes _linkage = DtoExternalLinkage(sd); - llvm::GlobalVariable* initvar = new llvm::GlobalVariable(ts->llvmType->get(), true, _linkage, NULL, initname, gIR->module); + llvm::GlobalVariable* initvar = new llvm::GlobalVariable(gIR->irType[ts].type->get(), true, _linkage, NULL, initname, gIR->module); gIR->irDsymbol[sd].irStruct->init = initvar; gIR->constInitList.push_back(sd); @@ -363,7 +363,7 @@ gIR->irDsymbol[so->var].irField->constInit = finit; } - const llvm::StructType* structtype = isaStruct(sd->type->llvmType->get()); + const llvm::StructType* structtype = isaStruct(gIR->irType[sd->type].type->get()); // go through the field inits and build the default initializer std::vector fieldinits_ll; diff -r ccd07d9f2ce9 -r 5c17f81fc1c1 gen/tollvm.cpp --- a/gen/tollvm.cpp Thu May 01 13:05:53 2008 +0200 +++ b/gen/tollvm.cpp Thu May 01 13:32:08 2008 +0200 @@ -98,7 +98,7 @@ // aggregates case Tstruct: { - if (!t->llvmType || *t->llvmType == NULL) { + if (!gIR->irType[t].type || *gIR->irType[t].type == NULL) { // recursive or cyclic declaration if (!gIR->structs.empty()) { @@ -116,11 +116,11 @@ TypeStruct* ts = (TypeStruct*)t; assert(ts->sym); DtoResolveDsymbol(ts->sym); - return gIR->irDsymbol[ts->sym].irStruct->recty.get();//t->llvmType->get(); + return gIR->irDsymbol[ts->sym].irStruct->recty.get(); // gIR->irType[t].type->get(); } case Tclass: { - /*if (!t->llvmType || *t->llvmType == NULL) { + /*if (!gIR->irType[t].type || *gIR->irType[t].type == NULL) { // recursive or cyclic declaration if (!gIR->structs.empty()) { @@ -139,28 +139,28 @@ TypeClass* tc = (TypeClass*)t; assert(tc->sym); DtoResolveDsymbol(tc->sym); - return getPtrToType(gIR->irDsymbol[tc->sym].irStruct->recty.get());//t->llvmType->get()); + return getPtrToType(gIR->irDsymbol[tc->sym].irStruct->recty.get()); // gIR->irType[t].type->get()); } // functions case Tfunction: { - if (!t->llvmType || *t->llvmType == NULL) { + if (!gIR->irType[t].type || *gIR->irType[t].type == NULL) { return DtoFunctionType(t,NULL); } else { - return t->llvmType->get(); + return gIR->irType[t].type->get(); } } // delegates case Tdelegate: { - if (!t->llvmType || *t->llvmType == NULL) { + if (!gIR->irType[t].type || *gIR->irType[t].type == NULL) { return DtoDelegateType(t); } else { - return t->llvmType->get(); + return gIR->irType[t].type->get(); } } @@ -1797,7 +1797,7 @@ // ClassInfo classinfo ClassDeclaration* cd2 = ClassDeclaration::classinfo; DtoResolveClass(cd2); - types.push_back(getPtrToType(cd2->type->llvmType->get())); + types.push_back(getPtrToType(gIR->irType[cd2->type].type->get())); // void*[] vtbl std::vector vtbltypes; vtbltypes.push_back(DtoSize_t()); diff -r ccd07d9f2ce9 -r 5c17f81fc1c1 gen/toobj.cpp --- a/gen/toobj.cpp Thu May 01 13:05:53 2008 +0200 +++ b/gen/toobj.cpp Thu May 01 13:32:08 2008 +0200 @@ -98,17 +98,17 @@ } // start out by providing opaque for the built-in class types - if (!ClassDeclaration::object->type->llvmType) - ClassDeclaration::object->type->llvmType = new llvm::PATypeHolder(llvm::OpaqueType::get()); + if (!gIR->irType[ClassDeclaration::object->type].type) + gIR->irType[ClassDeclaration::object->type].type = new llvm::PATypeHolder(llvm::OpaqueType::get()); - if (!Type::typeinfo->type->llvmType) - Type::typeinfo->type->llvmType = new llvm::PATypeHolder(llvm::OpaqueType::get()); + if (!gIR->irType[Type::typeinfo->type].type) + gIR->irType[Type::typeinfo->type].type = new llvm::PATypeHolder(llvm::OpaqueType::get()); - if (!ClassDeclaration::classinfo->type->llvmType) - ClassDeclaration::classinfo->type->llvmType = new llvm::PATypeHolder(llvm::OpaqueType::get()); + if (!gIR->irType[ClassDeclaration::classinfo->type].type) + gIR->irType[ClassDeclaration::classinfo->type].type = new llvm::PATypeHolder(llvm::OpaqueType::get()); - /*if (!Type::typeinfoclass->type->llvmType) - Type::typeinfoclass->type->llvmType = new llvm::PATypeHolder(llvm::OpaqueType::get());*/ + /*if (!gIR->irType[Type::typeinfoclass->type].type) + gIR->irType[Type::typeinfoclass->type].type = new llvm::PATypeHolder(llvm::OpaqueType::get());*/ // process module members for (int k=0; k < members->dim; k++) { @@ -289,10 +289,10 @@ DtoForceConstInitDsymbol(moduleinfo); // moduleinfo llvm struct type - const llvm::StructType* moduleinfoTy = isaStruct(moduleinfo->type->llvmType->get()); + const llvm::StructType* moduleinfoTy = isaStruct(gIR->irType[moduleinfo->type].type->get()); // classinfo llvm struct type - const llvm::StructType* classinfoTy = isaStruct(ClassDeclaration::classinfo->type->llvmType->get()); + const llvm::StructType* classinfoTy = isaStruct(gIR->irType[ClassDeclaration::classinfo->type].type->get()); // initializer vector std::vector initVec; diff -r ccd07d9f2ce9 -r 5c17f81fc1c1 gen/typinf.cpp --- a/gen/typinf.cpp Thu May 01 13:05:53 2008 +0200 +++ b/gen/typinf.cpp Thu May 01 13:32:08 2008 +0200 @@ -353,7 +353,7 @@ ClassDeclaration* base = Type::typeinfotypedef; DtoResolveClass(base); - const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); // create the symbol gIR->irDsymbol[this].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); @@ -367,7 +367,7 @@ ClassDeclaration* base = Type::typeinfotypedef; DtoForceConstInitDsymbol(base); - const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); Logger::cout() << "got stype: " << *stype << '\n'; // vtbl @@ -439,7 +439,7 @@ ClassDeclaration* base = Type::typeinfoenum; DtoResolveClass(base); - const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); // create the symbol gIR->irDsymbol[this].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); @@ -453,7 +453,7 @@ ClassDeclaration* base = Type::typeinfoenum; DtoForceConstInitDsymbol(base); - const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); // vtbl std::vector sinits; @@ -521,7 +521,7 @@ ClassDeclaration* base = cd; DtoResolveClass(base); - const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); // create the symbol gIR->irDsymbol[tid].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,tid->toChars(),gIR->module); @@ -532,7 +532,7 @@ ClassDeclaration* base = cd; DtoForceConstInitDsymbol(base); - const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); // vtbl std::vector sinits; @@ -626,7 +626,7 @@ DtoResolveClass(base); // get type of typeinfo class - const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); // create the symbol gIR->irDsymbol[this].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); @@ -642,7 +642,7 @@ DtoForceConstInitDsymbol(base); // get type of typeinfo class - const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); // initializer vector std::vector sinits; @@ -689,7 +689,7 @@ DtoResolveClass(base); // get type of typeinfo class - const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); // create the symbol gIR->irDsymbol[this].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); @@ -705,7 +705,7 @@ DtoForceConstInitDsymbol(base); // get type of typeinfo class - const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); // initializer vector std::vector sinits; @@ -822,7 +822,7 @@ ClassDeclaration* base = Type::typeinfostruct; DtoResolveClass(base); - const llvm::StructType* stype = isaStruct(((TypeClass*)base->type)->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); // create the symbol gIR->irDsymbol[this].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); @@ -841,7 +841,7 @@ ClassDeclaration* base = Type::typeinfostruct; DtoForceConstInitDsymbol(base); - const llvm::StructType* stype = isaStruct(((TypeClass*)base->type)->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); // vtbl std::vector sinits; @@ -864,7 +864,7 @@ } else { - size_t cisize = getTypeStoreSize(tc->llvmType->get()); + size_t cisize = getTypeStoreSize(gIR->irType[tc].type->get()); llvm::Constant* cicast = llvm::ConstantExpr::getBitCast(gIR->irDsymbol[sd].irStruct->init, initpt); sinits.push_back(DtoConstSlice(DtoConstSize_t(cisize), cicast)); } @@ -1022,7 +1022,7 @@ DtoResolveClass(base); // get type of typeinfo class - const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); // create the symbol gIR->irDsymbol[this].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); @@ -1039,7 +1039,7 @@ DtoForceConstInitDsymbol(base); // get type of typeinfo class - const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); // initializer vector std::vector sinits; @@ -1078,7 +1078,7 @@ DtoResolveClass(base); // get type of typeinfo class - const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); // create the symbol gIR->irDsymbol[this].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); @@ -1095,7 +1095,7 @@ DtoForceConstInitDsymbol(base); // get type of typeinfo class - const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); // initializer vector std::vector sinits; @@ -1134,7 +1134,7 @@ DtoResolveClass(base); // get type of typeinfo class - const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); // create the symbol gIR->irDsymbol[this].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module); @@ -1151,7 +1151,7 @@ DtoForceConstInitDsymbol(base); // get type of typeinfo class - const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); + const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get()); // initializer vector std::vector sinits; @@ -1168,7 +1168,7 @@ size_t dim = tu->arguments->dim; std::vector arrInits; - const llvm::Type* tiTy = Type::typeinfo->type->llvmType->get(); + const llvm::Type* tiTy = gIR->irType[Type::typeinfo->type].type->get(); tiTy = getPtrToType(tiTy); for (size_t i = 0; i < dim; i++) diff -r ccd07d9f2ce9 -r 5c17f81fc1c1 ir/irstruct.cpp --- a/ir/irstruct.cpp Thu May 01 13:05:53 2008 +0200 +++ b/ir/irstruct.cpp Thu May 01 13:32:08 2008 +0200 @@ -2,6 +2,7 @@ #include "mtype.h" #include "aggregate.h" #include "ir/irstruct.h" +#include "gen/irstate.h" IrInterface::IrInterface(BaseClass* b, const llvm::StructType* vt) { @@ -26,7 +27,7 @@ ////////////////////////////////////////////////////////////////////////////// IrStruct::IrStruct(Type* t) - : recty((t->llvmType != NULL) ? *t->llvmType : llvm::OpaqueType::get()) + : recty((gIR && gIR->irType[t].type) ? *gIR->irType[t].type : llvm::OpaqueType::get()) { type = t; defined = false;