Mercurial > projects > ldc
diff gen/llvmhelpers.cpp @ 1148:3d1b16dabd25
Eliminated the need for resolve, declare, const-init and define lists to drive code generation.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Fri, 27 Mar 2009 21:50:32 +0100 |
parents | dbe4af57b240 |
children | 3cf0066e6faf |
line wrap: on
line diff
--- a/gen/llvmhelpers.cpp Fri Mar 27 17:54:27 2009 +0100 +++ b/gen/llvmhelpers.cpp Fri Mar 27 21:50:32 2009 +0100 @@ -866,6 +866,8 @@ void DtoDeclareDsymbol(Dsymbol* dsym) { + DtoResolveDsymbol(dsym); + if (StructDeclaration* sd = dsym->isStructDeclaration()) { DtoDeclareStruct(sd); } @@ -888,6 +890,8 @@ void DtoConstInitDsymbol(Dsymbol* dsym) { + DtoDeclareDsymbol(dsym); + if (StructDeclaration* sd = dsym->isStructDeclaration()) { DtoConstInitStruct(sd); } @@ -910,6 +914,8 @@ void DtoDefineDsymbol(Dsymbol* dsym) { + DtoConstInitDsymbol(dsym); + if (StructDeclaration* sd = dsym->isStructDeclaration()) { DtoDefineStruct(sd); } @@ -917,7 +923,7 @@ DtoDefineClass(cd); } else if (FuncDeclaration* fd = dsym->isFuncDeclaration()) { - DtoDefineFunction(fd); + Type::sir->addFunctionBody(fd->ir.irFunc); } else if (TypeInfoDeclaration* fd = dsym->isTypeInfoDeclaration()) { DtoDefineTypeInfo(fd); @@ -932,6 +938,8 @@ void DtoConstInitGlobal(VarDeclaration* vd) { + vd->codegen(Type::sir); + if (vd->ir.initialized) return; vd->ir.initialized = gIR->dmodule; @@ -977,42 +985,6 @@ } } -////////////////////////////////////////////////////////////////////////////////////////// - -void DtoForceDeclareDsymbol(Dsymbol* dsym) -{ - if (dsym->ir.declared) return; - Logger::println("DtoForceDeclareDsymbol(%s)", dsym->toPrettyChars()); - LOG_SCOPE; - DtoResolveDsymbol(dsym); - DtoDeclareDsymbol(dsym); -} - -////////////////////////////////////////////////////////////////////////////////////////// - -void DtoForceConstInitDsymbol(Dsymbol* dsym) -{ - if (dsym->ir.initialized) return; - Logger::println("DtoForceConstInitDsymbol(%s)", dsym->toPrettyChars()); - LOG_SCOPE; - DtoResolveDsymbol(dsym); - DtoDeclareDsymbol(dsym); - DtoConstInitDsymbol(dsym); -} - -////////////////////////////////////////////////////////////////////////////////////////// - -void DtoForceDefineDsymbol(Dsymbol* dsym) -{ - if (dsym->ir.defined) return; - Logger::println("DtoForceDefineDsymbol(%s)", dsym->toPrettyChars()); - LOG_SCOPE; - DtoResolveDsymbol(dsym); - DtoDeclareDsymbol(dsym); - DtoConstInitDsymbol(dsym); - DtoDefineDsymbol(dsym); -} - /****************************************************************************************/ /*//////////////////////////////////////////////////////////////////////////////////////// // DECLARATION EXP HELPER @@ -1106,13 +1078,13 @@ else if (StructDeclaration* s = declaration->isStructDeclaration()) { Logger::println("StructDeclaration"); - DtoForceConstInitDsymbol(s); + s->codegen(Type::sir); } // function declaration else if (FuncDeclaration* f = declaration->isFuncDeclaration()) { Logger::println("FuncDeclaration"); - DtoForceDeclareDsymbol(f); + f->codegen(Type::sir); } // alias declaration else if (AliasDeclaration* a = declaration->isAliasDeclaration()) @@ -1130,7 +1102,7 @@ else if (ClassDeclaration* e = declaration->isClassDeclaration()) { Logger::println("ClassDeclaration"); - DtoForceConstInitDsymbol(e); + e->codegen(Type::sir); } // typedef else if (TypedefDeclaration* tdef = declaration->isTypedefDeclaration()) @@ -1392,8 +1364,9 @@ type->getTypeInfo(NULL); TypeInfoDeclaration* tidecl = type->vtinfo; assert(tidecl); - DtoForceDeclareDsymbol(tidecl); + tidecl->codegen(Type::sir); assert(tidecl->ir.irGlobal != NULL); + assert(tidecl->ir.irGlobal->value != NULL); LLConstant* c = isaConstant(tidecl->ir.irGlobal->value); assert(c != NULL); if (base)