diff --git a/dmd/mtype.c b/dmd/mtype.c index 69b125ba..86d9ad94 100644 --- a/dmd/mtype.c +++ b/dmd/mtype.c @@ -114,7 +114,6 @@ Type::Type(TY ty, Type *next) this->arrayof = NULL; this->vtinfo = NULL; this->ctype = NULL; - this->llvmType = NULL; } Type *Type::syntaxCopy() @@ -4413,7 +4412,6 @@ TypeClass::TypeClass(ClassDeclaration *sym) : Type(Tclass, NULL) { this->sym = sym; - llvmVtblType = 0; } char *TypeClass::toChars() diff --git a/dmd/mtype.h b/dmd/mtype.h index 7ba9aaf2..aaf9ba07 100644 --- a/dmd/mtype.h +++ b/dmd/mtype.h @@ -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 @@ struct Type : Object virtual type *toCParamtype(); virtual Symbol *toSymbol(); - llvm::PATypeHolder* llvmType; - // For eliminating dynamic_cast virtual TypeBasic *isTypeBasic(); }; @@ -637,8 +625,6 @@ struct TypeClass : Type type *toCtype(); Symbol *toSymbol(); - - llvm::PATypeHolder* llvmVtblType; }; struct TypeTuple : Type diff --git a/gen/arrays.cpp b/gen/arrays.cpp index c5cde0ae..f0541f4c 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -41,8 +41,8 @@ const llvm::StructType* DtoArrayType(Type* t) 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 @@ const llvm::ArrayType* DtoStaticArrayType(Type* t) 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 --git a/gen/classes.cpp b/gen/classes.cpp index 10c67d00..6817fb64 100644 --- a/gen/classes.cpp +++ b/gen/classes.cpp @@ -128,8 +128,8 @@ void DtoResolveClass(ClassDeclaration* cd) 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 @@ void DtoResolveClass(ClassDeclaration* cd) // 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 @@ void DtoResolveClass(ClassDeclaration* cd) 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 @@ void DtoResolveClass(ClassDeclaration* cd) 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 @@ void DtoResolveClass(ClassDeclaration* cd) 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 @@ void DtoResolveClass(ClassDeclaration* cd) 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 @@ void DtoDeclareClass(ClassDeclaration* cd) 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 @@ void DtoDeclareClass(ClassDeclaration* cd) 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 @@ void DtoConstInitClass(ClassDeclaration* cd) // 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 @@ void DtoConstInitClass(ClassDeclaration* cd) fieldinits.push_back( llvm::ConstantPointerNull::get( getPtrToType( - ts->llvmVtblType->get() + gIR->irType[ts].vtblType->get() ) ) ); @@ -569,7 +569,7 @@ void DtoConstInitClass(ClassDeclaration* cd) 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 @@ void DtoConstInitClass(ClassDeclaration* cd) 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 @@ void DtoConstInitClass(ClassDeclaration* cd) // 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 @@ DValue* DtoNewClass(TypeClass* tc, NewExp* newexp) 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 @@ void DtoDeclareClassInfo(ClassDeclaration* cd) 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 @@ static llvm::Constant* build_offti_entry(VarDeclaration* vd) 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 @@ static llvm::Constant* build_offti_array(ClassDeclaration* cd, llvm::Constant* i // 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 @@ static llvm::Constant* build_class_dtor(ClassDeclaration* cd) { // 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 --git a/gen/functions.cpp b/gen/functions.cpp index e5643b22..6112949c 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -23,8 +23,8 @@ const llvm::FunctionType* DtoFunctionType(Type* type, const llvm::Type* thistype 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 @@ const llvm::FunctionType* DtoFunctionType(Type* type, const llvm::Type* thistype 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 @@ const llvm::FunctionType* DtoFunctionType(Type* type, const llvm::Type* thistype 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 @@ static const llvm::FunctionType* DtoVaFunctionType(FuncDeclaration* fdecl) 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 @@ const llvm::FunctionType* DtoFunctionType(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()); } const llvm::Type* thisty = NULL; @@ -367,7 +367,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) 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 @@ void DtoDefineFunc(FuncDeclaration* fd) 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 --git a/gen/irstate.h b/gen/irstate.h index 30d2426d..b276ac72 100644 --- a/gen/irstate.h +++ b/gen/irstate.h @@ -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 @@ struct IRState // 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 --git a/gen/runtime.cpp b/gen/runtime.cpp index 1c54cea5..585c3974 100644 --- a/gen/runtime.cpp +++ b/gen/runtime.cpp @@ -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 @@ static void LLVM_D_BuildRuntimeModule() 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 --git a/gen/structs.cpp b/gen/structs.cpp index a56f1cee..b31336a1 100644 --- a/gen/structs.cpp +++ b/gen/structs.cpp @@ -82,7 +82,7 @@ llvm::Constant* DtoConstStructInitializer(StructInitializer* si) 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 @@ void DtoResolveStruct(StructDeclaration* sd) 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 @@ void DtoDeclareStruct(StructDeclaration* sd) 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 @@ void DtoConstInitStruct(StructDeclaration* sd) 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 --git a/gen/tollvm.cpp b/gen/tollvm.cpp index 379d393a..13ca4ac7 100644 --- a/gen/tollvm.cpp +++ b/gen/tollvm.cpp @@ -98,7 +98,7 @@ const llvm::Type* DtoType(Type* t) // 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 @@ const llvm::Type* DtoType(Type* t) 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 @@ const llvm::Type* DtoType(Type* t) 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 @@ const llvm::StructType* DtoInterfaceInfoType() // 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 --git a/gen/toobj.cpp b/gen/toobj.cpp index cf6e839a..13c7a7a9 100644 --- a/gen/toobj.cpp +++ b/gen/toobj.cpp @@ -98,17 +98,17 @@ void Module::genobjfile() } // 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 @@ void Module::genmoduleinfo() 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 --git a/gen/typinf.cpp b/gen/typinf.cpp index ca966afa..c777a03f 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -353,7 +353,7 @@ void TypeInfoTypedefDeclaration::llvmDeclare() 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 @@ void TypeInfoTypedefDeclaration::llvmDefine() 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 @@ void TypeInfoEnumDeclaration::llvmDeclare() 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 @@ void TypeInfoEnumDeclaration::llvmDefine() 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 @@ static llvm::Constant* LLVM_D_Declare_TypeInfoBase(TypeInfoDeclaration* tid, Cla 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 @@ static llvm::Constant* LLVM_D_Define_TypeInfoBase(Type* basetype, TypeInfoDeclar 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 @@ void TypeInfoStaticArrayDeclaration::llvmDeclare() 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 @@ void TypeInfoStaticArrayDeclaration::llvmDefine() 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 @@ void TypeInfoAssociativeArrayDeclaration::llvmDeclare() 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 @@ void TypeInfoAssociativeArrayDeclaration::llvmDefine() 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 @@ void TypeInfoStructDeclaration::llvmDeclare() 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 @@ void TypeInfoStructDeclaration::llvmDefine() 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 @@ void TypeInfoStructDeclaration::llvmDefine() } 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 @@ void TypeInfoClassDeclaration::llvmDeclare() 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 @@ void TypeInfoClassDeclaration::llvmDefine() 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 @@ void TypeInfoInterfaceDeclaration::llvmDeclare() 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 @@ void TypeInfoInterfaceDeclaration::llvmDefine() 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 @@ void TypeInfoTupleDeclaration::llvmDeclare() 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 @@ void TypeInfoTupleDeclaration::llvmDefine() 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 @@ void TypeInfoTupleDeclaration::llvmDefine() 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 --git a/ir/irstruct.cpp b/ir/irstruct.cpp index 2f91eae1..2a2bf7aa 100644 --- a/ir/irstruct.cpp +++ b/ir/irstruct.cpp @@ -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 @@ IrInterface::~IrInterface() ////////////////////////////////////////////////////////////////////////////// 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;