diff --git a/gen/classes.cpp b/gen/classes.cpp index d915c1cd..efb8ac49 100644 --- a/gen/classes.cpp +++ b/gen/classes.cpp @@ -25,7 +25,7 @@ #include "gen/structs.h" #include "gen/tollvm.h" #include "gen/utils.h" -#include "ir/irstruct.h" +#include "ir/iraggr.h" #include "ir/irtypeclass.h" ////////////////////////////////////////////////////////////////////////////////////////// @@ -55,10 +55,10 @@ void DtoResolveClass(ClassDeclaration* cd) // make sure type exists DtoType(cd->type); - // create IrStruct + // create IrAggr assert(cd->ir.irStruct == NULL); - IrStruct* irstruct = new IrStruct(cd); - cd->ir.irStruct = irstruct; + IrAggr* irAggr = new IrAggr(cd); + cd->ir.irStruct = irAggr; // make sure all fields really get their ir field ArrayIter it(cd->fields); @@ -75,30 +75,30 @@ void DtoResolveClass(ClassDeclaration* cd) bool needs_def = mustDefineSymbol(cd); // emit the ClassZ symbol - LLGlobalVariable* ClassZ = irstruct->getClassInfoSymbol(); + LLGlobalVariable* ClassZ = irAggr->getClassInfoSymbol(); // emit the interfaceInfosZ symbol if necessary if (cd->vtblInterfaces && cd->vtblInterfaces->dim > 0) - irstruct->getInterfaceArraySymbol(); // initializer is applied when it's built + irAggr->getInterfaceArraySymbol(); // initializer is applied when it's built // interface only emit typeinfo and classinfo if (cd->isInterfaceDeclaration()) { - irstruct->initializeInterface(); + irAggr->initializeInterface(); } else { // emit the initZ symbol - LLGlobalVariable* initZ = irstruct->getInitSymbol(); + LLGlobalVariable* initZ = irAggr->getInitSymbol(); // emit the vtblZ symbol - LLGlobalVariable* vtblZ = irstruct->getVtblSymbol(); + LLGlobalVariable* vtblZ = irAggr->getVtblSymbol(); // perform definition if (needs_def) { // set symbol initializers - initZ->setInitializer(irstruct->getDefaultInit()); - vtblZ->setInitializer(irstruct->getVtblInit()); + initZ->setInitializer(irAggr->getDefaultInit()); + vtblZ->setInitializer(irAggr->getVtblInit()); } } @@ -121,7 +121,7 @@ void DtoResolveClass(ClassDeclaration* cd) DtoTypeInfoOf(cd->type); // define classinfo - ClassZ->setInitializer(irstruct->getClassInfoInit()); + ClassZ->setInitializer(irAggr->getClassInfoInit()); } } @@ -689,7 +689,7 @@ LLConstant* DtoDefineClassInfo(ClassDeclaration* cd) assert(cd->type->ty == Tclass); TypeClass* cdty = static_cast(cd->type); - IrStruct* ir = cd->ir.irStruct; + IrAggr* ir = cd->ir.irStruct; assert(ir); ClassDeclaration* cinfo = ClassDeclaration::classinfo; diff --git a/gen/irstate.cpp b/gen/irstate.cpp index 442f1292..e260b763 100644 --- a/gen/irstate.cpp +++ b/gen/irstate.cpp @@ -105,7 +105,7 @@ llvm::Instruction* IRState::topallocapoint() return functions.back()->allocapoint; } -IrStruct* IRState::topstruct() +IrAggr* IRState::topstruct() { assert(!structs.empty() && "Struct vector is empty!"); return structs.back(); diff --git a/gen/irstate.h b/gen/irstate.h index 80f263ba..3d57918e 100644 --- a/gen/irstate.h +++ b/gen/irstate.h @@ -18,7 +18,7 @@ #include "aggregate.h" #include "root.h" #include "ir/irfunction.h" -#include "ir/irstruct.h" +#include "ir/iraggr.h" #include "ir/irvar.h" #include #include @@ -146,9 +146,9 @@ struct IRState llvm::Instruction* topallocapoint(); // structs - typedef std::vector StructVector; + typedef std::vector StructVector; StructVector structs; - IrStruct* topstruct(); + IrAggr* topstruct(); // D main function bool emitMain; diff --git a/gen/rttibuilder.cpp b/gen/rttibuilder.cpp index 0c8ccde5..bc182b5f 100644 --- a/gen/rttibuilder.cpp +++ b/gen/rttibuilder.cpp @@ -16,7 +16,7 @@ #include "gen/llvm.h" #include "gen/llvmhelpers.h" #include "gen/tollvm.h" -#include "ir/irstruct.h" +#include "ir/iraggr.h" RTTIBuilder::RTTIBuilder(AggregateDeclaration* base_class) { diff --git a/gen/rttibuilder.h b/gen/rttibuilder.h index a539bb45..ebacc098 100644 --- a/gen/rttibuilder.h +++ b/gen/rttibuilder.h @@ -27,7 +27,7 @@ struct ClassDeclaration; struct Dsymbol; struct FuncDeclaration; struct IrGlobal; -struct IrStruct; +struct IrAggr; struct Type; struct TypeClass; namespace llvm { class StructType; } @@ -36,7 +36,7 @@ struct RTTIBuilder { AggregateDeclaration* base; TypeClass* basetype; - IrStruct* baseir; + IrAggr* baseir; // 10 is enough for any D1 TypeInfo // 14 is enough for any D1 ClassInfo diff --git a/gen/structs.cpp b/gen/structs.cpp index 353010a1..519fc343 100644 --- a/gen/structs.cpp +++ b/gen/structs.cpp @@ -21,7 +21,7 @@ #include "gen/structs.h" #include "gen/tollvm.h" #include "gen/utils.h" -#include "ir/irstruct.h" +#include "ir/iraggr.h" #include "ir/irtypestruct.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/ManagedStatic.h" @@ -45,8 +45,8 @@ void DtoResolveStruct(StructDeclaration* sd) if (sd->sizeok != 1) return; - // create the IrStruct - IrStruct* irstruct = new IrStruct(sd); + // create the IrAggr + IrAggr* irstruct = new IrAggr(sd); sd->ir.irStruct = irstruct; // Set up our field metadata. diff --git a/gen/todebug.cpp b/gen/todebug.cpp index 325e4dc5..9e99bc53 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -280,7 +280,7 @@ static llvm::DIType dwarfCompositeType(Type* type) if (sd->sizeok == 0) return llvm::DICompositeType(NULL); - IrStruct* ir = sd->ir.irStruct; + IrAggr* ir = sd->ir.irStruct; assert(ir); if (static_cast(ir->diCompositeType) != 0) return ir->diCompositeType; diff --git a/gen/typinf.cpp b/gen/typinf.cpp index d2eaa759..9e69d951 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -607,7 +607,7 @@ void TypeInfoStructDeclaration::llvmDefine() } sd->codegen(Type::sir); - IrStruct* irstruct = sd->ir.irStruct; + IrAggr* irstruct = sd->ir.irStruct; RTTIBuilder b(Type::typeinfostruct); diff --git a/ir/irstruct.cpp b/ir/iraggr.cpp similarity index 96% rename from ir/irstruct.cpp rename to ir/iraggr.cpp index c8f0f15a..f4e0417f 100644 --- a/ir/irstruct.cpp +++ b/ir/iraggr.cpp @@ -1,4 +1,4 @@ -//===-- irstruct.cpp ------------------------------------------------------===// +//===-- iraggr.cpp --------------------------------------------------------===// // // LDC – the LLVM D compiler // @@ -17,13 +17,13 @@ #include "gen/logger.h" #include "gen/tollvm.h" #include "gen/utils.h" -#include "ir/irstruct.h" +#include "ir/iraggr.h" #include "ir/irtypeclass.h" #include ////////////////////////////////////////////////////////////////////////////// -IrStruct::IrStruct(AggregateDeclaration* aggr) +IrAggr::IrAggr(AggregateDeclaration* aggr) : diCompositeType(NULL), init_type(LLStructType::create(gIR->context(), std::string(aggr->toPrettyChars()) + "_init")) { @@ -50,7 +50,7 @@ IrStruct::IrStruct(AggregateDeclaration* aggr) ////////////////////////////////////////////////////////////////////////////// -LLGlobalVariable * IrStruct::getInitSymbol() +LLGlobalVariable * IrAggr::getInitSymbol() { if (init) return init; @@ -76,7 +76,7 @@ LLGlobalVariable * IrStruct::getInitSymbol() ////////////////////////////////////////////////////////////////////////////// -llvm::Constant * IrStruct::getDefaultInit() +llvm::Constant * IrAggr::getDefaultInit() { if (constInit) return constInit; @@ -158,7 +158,7 @@ size_t add_zeros(std::vector& constants, size_t diff) // Matches the way the type is built in IrTypeStruct // maybe look at unifying the interface. -std::vector IrStruct::createStructDefaultInitializer() +std::vector IrAggr::createStructDefaultInitializer() { IF_LOG Logger::println("Building default initializer for %s", aggrdecl->toPrettyChars()); LOG_SCOPE; @@ -218,7 +218,7 @@ std::vector IrStruct::createStructDefaultInitializer() ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -LLConstant * IrStruct::createStructInitializer(StructInitializer * si) +LLConstant * IrAggr::createStructInitializer(StructInitializer * si) { IF_LOG Logger::println("Building StructInitializer of type %s", si->ad->toPrettyChars()); LOG_SCOPE; diff --git a/ir/irstruct.h b/ir/iraggr.h similarity index 96% rename from ir/irstruct.h rename to ir/iraggr.h index 7159149d..93e6557c 100644 --- a/ir/irstruct.h +++ b/ir/iraggr.h @@ -1,4 +1,4 @@ -//===-- ir/irstruct.h - Codegen state for D aggregates ----------*- C++ -*-===// +//===-- ir/iraggr.h - Codegen state for D aggregates ------------*- C++ -*-===// // // LDC – the LLVM D compiler // @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LDC_IR_IRSTRUCT_H -#define LDC_IR_IRSTRUCT_H +#ifndef LDC_IR_IRAGGR_H +#define LDC_IR_IRAGGR_H #include "ir/ir.h" #include @@ -26,10 +26,10 @@ struct StructInitializer; // represents a struct or class // it is used during codegen to hold all the vital info we need -struct IrStruct +struct IrAggr { /// Constructor. - IrStruct(AggregateDeclaration* agg); + IrAggr(AggregateDeclaration* agg); ////////////////////////////////////////////////////////////////////////// // public fields, diff --git a/ir/irclass.cpp b/ir/irclass.cpp index b5e43b02..3634ab8e 100644 --- a/ir/irclass.cpp +++ b/ir/irclass.cpp @@ -29,7 +29,7 @@ #include "gen/metadata.h" #include "gen/runtime.h" -#include "ir/irstruct.h" +#include "ir/iraggr.h" #include "ir/irtypeclass.h" ////////////////////////////////////////////////////////////////////////////// @@ -41,7 +41,7 @@ extern LLConstant* DtoDefineClassInfo(ClassDeclaration* cd); ////////////////////////////////////////////////////////////////////////////// -LLGlobalVariable * IrStruct::getVtblSymbol() +LLGlobalVariable * IrAggr::getVtblSymbol() { if (vtbl) return vtbl; @@ -63,7 +63,7 @@ LLGlobalVariable * IrStruct::getVtblSymbol() ////////////////////////////////////////////////////////////////////////////// -LLGlobalVariable * IrStruct::getClassInfoSymbol() +LLGlobalVariable * IrAggr::getClassInfoSymbol() { if (classInfo) return classInfo; @@ -114,7 +114,7 @@ LLGlobalVariable * IrStruct::getClassInfoSymbol() ////////////////////////////////////////////////////////////////////////////// -LLGlobalVariable * IrStruct::getInterfaceArraySymbol() +LLGlobalVariable * IrAggr::getInterfaceArraySymbol() { if (classInterfacesArray) return classInterfacesArray; @@ -145,7 +145,7 @@ LLGlobalVariable * IrStruct::getInterfaceArraySymbol() ////////////////////////////////////////////////////////////////////////////// -LLConstant * IrStruct::getVtblInit() +LLConstant * IrAggr::getVtblInit() { if (constVtbl) return constVtbl; @@ -253,7 +253,7 @@ LLConstant * IrStruct::getVtblInit() ////////////////////////////////////////////////////////////////////////////// -LLConstant * IrStruct::getClassInfoInit() +LLConstant * IrAggr::getClassInfoInit() { if (constClassInfo) return constClassInfo; @@ -263,7 +263,7 @@ LLConstant * IrStruct::getClassInfoInit() ////////////////////////////////////////////////////////////////////////////// -void IrStruct::addBaseClassInits( +void IrAggr::addBaseClassInits( std::vector& constants, ClassDeclaration* base, size_t& offset, @@ -330,7 +330,7 @@ void IrStruct::addBaseClassInits( ////////////////////////////////////////////////////////////////////////////// -std::vector IrStruct::createClassDefaultInitializer() +std::vector IrAggr::createClassDefaultInitializer() { ClassDeclaration* cd = aggrdecl->isClassDeclaration(); assert(cd && "invalid class aggregate"); @@ -366,7 +366,7 @@ std::vector IrStruct::createClassDefaultInitializer() ////////////////////////////////////////////////////////////////////////////// -llvm::GlobalVariable * IrStruct::getInterfaceVtbl(BaseClass * b, bool new_instance, size_t interfaces_index) +llvm::GlobalVariable * IrAggr::getInterfaceVtbl(BaseClass * b, bool new_instance, size_t interfaces_index) { ClassGlobalMap::iterator it = interfaceVtblMap.find(b->base); if (it != interfaceVtblMap.end()) @@ -454,7 +454,7 @@ llvm::GlobalVariable * IrStruct::getInterfaceVtbl(BaseClass * b, bool new_instan ////////////////////////////////////////////////////////////////////////////// -LLConstant * IrStruct::getClassInfoInterfaces() +LLConstant * IrAggr::getClassInfoInterfaces() { IF_LOG Logger::println("Building ClassInfo.interfaces"); LOG_SCOPE; @@ -496,7 +496,7 @@ LLConstant * IrStruct::getClassInfoInterfaces() IF_LOG Logger::println("Adding interface %s", it->base->toPrettyChars()); - IrStruct* irinter = it->base->ir.irStruct; + IrAggr* irinter = it->base->ir.irStruct; assert(irinter && "interface has null IrStruct"); IrTypeClass* itc = stripModifiers(irinter->type)->irtype->isClass(); assert(itc && "null interface IrTypeClass"); @@ -559,7 +559,7 @@ LLConstant * IrStruct::getClassInfoInterfaces() ////////////////////////////////////////////////////////////////////////////// -void IrStruct::initializeInterface() +void IrAggr::initializeInterface() { InterfaceDeclaration* base = aggrdecl->isInterfaceDeclaration(); assert(base && "not interface"); diff --git a/ir/irdsymbol.h b/ir/irdsymbol.h index ca9a0124..932ffdef 100644 --- a/ir/irdsymbol.h +++ b/ir/irdsymbol.h @@ -18,7 +18,7 @@ struct IrModule; struct IrFunction; -struct IrStruct; +struct IrAggr; struct IrGlobal; struct IrLocal; struct IrParameter; @@ -52,7 +52,7 @@ struct IrDsymbol IrModule* irModule; - IrStruct* irStruct; + IrAggr* irStruct; IrFunction* irFunc; diff --git a/ir/irtype.h b/ir/irtype.h index 7b0e477a..9fdd203f 100644 --- a/ir/irtype.h +++ b/ir/irtype.h @@ -56,7 +56,7 @@ class IrTypeVector; /// easily check for uniqueness violations in the face of forward references. /// TODO: Implement the described changes (now that the forward reference /// handling logic seems to work correctly) and get rid of the "no-op" DtoType -/// calls in IrStruct, ... that only exist for their side effect. +/// calls in IrAggr, ... that only exist for their side effect. class IrType { public: