Mercurial > projects > ldc
comparison gen/toobj.cpp @ 920:545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Fixed align N; in asm blocks.
Fixed inreg parameter passing on x86 for ref/out params.
Removed support for lazy initialization of function local static variables, I have no idea why I ever implemented this, it's not in the D spec, and DMD doesn't support it :P
Some of the global variable related changes might cause minor regressions, but they should be easily fixable.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 03 Feb 2009 08:54:57 +0100 |
parents | c76f74d09fb1 |
children | d3a6f1a96731 |
comparison
equal
deleted
inserted
replaced
919:c76f74d09fb1 | 920:545f54041d91 |
---|---|
912 | 912 |
913 this->ir.irGlobal = new IrGlobal(this); | 913 this->ir.irGlobal = new IrGlobal(this); |
914 | 914 |
915 Logger::println("parent: %s (%s)", parent->toChars(), parent->kind()); | 915 Logger::println("parent: %s (%s)", parent->toChars(), parent->kind()); |
916 | 916 |
917 // handle static local variables | |
918 bool static_local = false; | |
919 #if DMDV2 | 917 #if DMDV2 |
920 // not sure why this is only needed for d2 | 918 // not sure why this is only needed for d2 |
921 bool _isconst = isConst() && init; | 919 bool _isconst = isConst() && init; |
922 #else | 920 #else |
923 bool _isconst = isConst(); | 921 bool _isconst = isConst(); |
924 #endif | 922 #endif |
925 Dsymbol* par = toParent2(); | 923 |
926 if (par && par->isFuncDeclaration()) | |
927 { | |
928 static_local = true; | |
929 if (init && init->isExpInitializer()) { | |
930 _isconst = false; | |
931 } | |
932 } | |
933 | 924 |
934 Logger::println("Creating global variable"); | 925 Logger::println("Creating global variable"); |
935 | 926 |
936 const LLType* _type = this->ir.irGlobal->type.get(); | 927 const LLType* _type = this->ir.irGlobal->type.get(); |
937 llvm::GlobalValue::LinkageTypes _linkage = DtoLinkage(this); | 928 llvm::GlobalValue::LinkageTypes _linkage = DtoLinkage(this); |
941 this->ir.irGlobal->value = gvar; | 932 this->ir.irGlobal->value = gvar; |
942 | 933 |
943 if (Logger::enabled()) | 934 if (Logger::enabled()) |
944 Logger::cout() << *gvar << '\n'; | 935 Logger::cout() << *gvar << '\n'; |
945 | 936 |
946 if (static_local) | 937 // if this global is used from a nested function, this is necessary or |
947 DtoConstInitGlobal(this); | 938 // optimization could potentially remove the global (if it's the only use) |
948 else | 939 if (nakedUse) |
949 gIR->constInitList.push_back(this); | 940 gIR->usedArray.push_back(DtoBitCast(gvar, getVoidPtrType())); |
941 | |
942 gIR->constInitList.push_back(this); | |
950 } | 943 } |
951 else | 944 else |
952 { | 945 { |
953 // might already have its irField, as classes derive each other without getting copies of the VarDeclaration | 946 // might already have its irField, as classes derive each other without getting copies of the VarDeclaration |
954 if (!ir.irField) | 947 if (!ir.irField) |