diff gen/naked.cpp @ 954:e048e36bc155

Added support for using a temporary to implement emulated ABI return from inline asm, could be easier to use, but I think this will do. It's so extremely target dependent in any case that doing a completely generic approach seems hard.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sat, 14 Feb 2009 15:25:48 +0100
parents b2d27ddf8f45
children 7e669954db7d
line wrap: on
line diff
--- a/gen/naked.cpp	Fri Feb 13 22:20:30 2009 +0100
+++ b/gen/naked.cpp	Sat Feb 14 15:25:48 2009 +0100
@@ -207,6 +207,29 @@
         {
             as->out_c = "={ax},={dx},";
             asmblock->retn = 2;
+        #if 0
+            // this is to show how to allocate a temporary for the return value
+            // in case the appropriate multi register constraint isn't supported.
+            // this way abi return from inline asm can still be emulated.
+
+            // generate asm
+            as->out_c = "=*m,=*m,";
+            LLValue* tmp = DtoAlloca(llretTy, ".tmp_asm_ret");
+            as->out.push_back( tmp );
+            as->out.push_back( DtoGEPi(tmp, 0,1) );
+            as->code = "movd %eax, $<<out0>>" "\n\t" "mov %edx, $<<out1>>";
+
+            // fix asmblock
+            asmblock->retn = 0;
+            asmblock->retemu = true;
+            asmblock->asmBlock->abiret = tmp;
+
+            // add "ret" stmt
+            asmblock->s.push_back(as);
+
+            // done, we don't want anything pushed in the front of the block
+            return;
+        #endif
         }
         else
         {