Mercurial > projects > ldc
diff gen/tollvm.cpp @ 323:0d52412d5b1a trunk
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
Changed the way moduleinfo is registered to use the same approach as DMD, this eliminates the need for correct linking order and should make the way for using a natively compiled runtime library. This should speed up linking tremendously and should now be possible.
Fixed the llvm.used array to only be emitted if really necessary.
author | lindquist |
---|---|
date | Wed, 09 Jul 2008 23:43:51 +0200 |
parents | 1a2777460bd5 |
children | 7086a84ab3d6 |
line wrap: on
line diff
--- a/gen/tollvm.cpp Wed Jul 09 17:02:55 2008 +0200 +++ b/gen/tollvm.cpp Wed Jul 09 23:43:51 2008 +0200 @@ -6,6 +6,7 @@ #include "aggregate.h" #include "declaration.h" #include "init.h" +#include "module.h" #include "gen/tollvm.h" #include "gen/irstate.h" @@ -724,3 +725,30 @@ gIR->module->addTypeName("D_CRITICAL_SECTION", pmutex); return pmutex; } + +////////////////////////////////////////////////////////////////////////////////////////// + +const LLStructType* DtoModuleReferenceType() +{ + if (gIR->moduleRefType) + return gIR->moduleRefType; + + // this is a recursive type so start out with the opaque + LLOpaqueType* opaque = LLOpaqueType::get(); + + // add members + std::vector<const LLType*> types; + types.push_back(getPtrToType(opaque)); + types.push_back(DtoType(Module::moduleinfo->type)); + + // resolve type + const LLStructType* st = LLStructType::get(types); + LLPATypeHolder pa(st); + opaque->refineAbstractTypeTo(pa.get()); + st = isaStruct(pa.get()); + + // done + gIR->moduleRefType = st; + gIR->module->addTypeName("ModuleReference", st); + return st; +}