Renamed IrStruct to IrAggr, as it is also used for classes.

The class-specific parts should probably be factored out.
This commit is contained in:
David Nadlinger
2013-06-12 11:40:30 +02:00
parent 28f39cbdad
commit f2f3c751b3
13 changed files with 52 additions and 52 deletions

View File

@@ -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 <algorithm>
//////////////////////////////////////////////////////////////////////////////
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<llvm::Constant*>& constants, size_t diff)
// Matches the way the type is built in IrTypeStruct
// maybe look at unifying the interface.
std::vector<llvm::Constant*> IrStruct::createStructDefaultInitializer()
std::vector<llvm::Constant*> IrAggr::createStructDefaultInitializer()
{
IF_LOG Logger::println("Building default initializer for %s", aggrdecl->toPrettyChars());
LOG_SCOPE;
@@ -218,7 +218,7 @@ std::vector<llvm::Constant*> 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;

View File

@@ -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 <map>
@@ -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,

View File

@@ -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<llvm::Constant*>& constants,
ClassDeclaration* base,
size_t& offset,
@@ -330,7 +330,7 @@ void IrStruct::addBaseClassInits(
//////////////////////////////////////////////////////////////////////////////
std::vector<llvm::Constant*> IrStruct::createClassDefaultInitializer()
std::vector<llvm::Constant*> IrAggr::createClassDefaultInitializer()
{
ClassDeclaration* cd = aggrdecl->isClassDeclaration();
assert(cd && "invalid class aggregate");
@@ -366,7 +366,7 @@ std::vector<llvm::Constant*> 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");

View File

@@ -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;

View File

@@ -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: