Mercurial > projects > ldc
comparison gen/asmstmt.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 | 661384d6a936 |
children | 03d7c4aac654 |
comparison
equal
deleted
inserted
replaced
919:c76f74d09fb1 | 920:545f54041d91 |
---|---|
13 #include "dsymbol.h" | 13 #include "dsymbol.h" |
14 | 14 |
15 #include <cassert> | 15 #include <cassert> |
16 #include <deque> | 16 #include <deque> |
17 #include <iostream> | 17 #include <iostream> |
18 #include <sstream> | |
19 #include <cstring> | 18 #include <cstring> |
20 | 19 |
21 //#include "d-lang.h" | 20 //#include "d-lang.h" |
22 //#include "d-codegen.h" | 21 //#include "d-codegen.h" |
23 | 22 |
154 error("inline asm is not allowed when the -noasm switch is used"); | 153 error("inline asm is not allowed when the -noasm switch is used"); |
155 err = true; | 154 err = true; |
156 } | 155 } |
157 if (err) | 156 if (err) |
158 fatal(); | 157 fatal(); |
158 | |
159 //puts(toChars()); | |
159 | 160 |
160 sc->func->inlineAsm = 1; | 161 sc->func->inlineAsm = 1; |
161 sc->func->inlineStatus = ILSno; // %% not sure | 162 sc->func->inlineStatus = ILSno; // %% not sure |
162 // %% need to set DECL_UNINLINABLE too? | 163 // %% need to set DECL_UNINLINABLE too? |
163 sc->func->hasReturnExp = 1; // %% DMD does this, apparently... | 164 sc->func->hasReturnExp = 1; // %% DMD does this, apparently... |
697 enclosinghandler = sc->tfOfTry; | 698 enclosinghandler = sc->tfOfTry; |
698 tf = sc->tf; | 699 tf = sc->tf; |
699 | 700 |
700 return CompoundStatement::semantic(sc); | 701 return CompoundStatement::semantic(sc); |
701 } | 702 } |
703 | |
704 ////////////////////////////////////////////////////////////////////////////// | |
705 | |
706 void AsmStatement::toNakedIR(IRState *p) | |
707 { | |
708 Logger::println("AsmStatement::toNakedIR(): %s", loc.toChars()); | |
709 LOG_SCOPE; | |
710 | |
711 // is there code? | |
712 if (!asmcode) | |
713 return; | |
714 AsmCode * code = (AsmCode *) asmcode; | |
715 | |
716 // build asm stmt | |
717 std::ostringstream& asmstr = p->nakedAsm; | |
718 asmstr << "\t"; | |
719 asmstr.write(code->insnTemplate, code->insnTemplateLen); | |
720 asmstr << std::endl; | |
721 } | |
722 | |
723 void AsmBlockStatement::toNakedIR(IRState *p) | |
724 { | |
725 Logger::println("AsmBlockStatement::toNakedIR(): %s", loc.toChars()); | |
726 LOG_SCOPE; | |
727 | |
728 // do asm statements | |
729 for (unsigned i=0; i<statements->dim; i++) | |
730 { | |
731 Statement* s = (Statement*)statements->data[i]; | |
732 if (s) s->toNakedIR(p); | |
733 } | |
734 } |