comparison 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
comparison
equal deleted inserted replaced
953:5fa3e0ea06e9 954:e048e36bc155
205 } 205 }
206 else if (rt->ty == Tarray || rt->ty == Tdelegate) 206 else if (rt->ty == Tarray || rt->ty == Tdelegate)
207 { 207 {
208 as->out_c = "={ax},={dx},"; 208 as->out_c = "={ax},={dx},";
209 asmblock->retn = 2; 209 asmblock->retn = 2;
210 #if 0
211 // this is to show how to allocate a temporary for the return value
212 // in case the appropriate multi register constraint isn't supported.
213 // this way abi return from inline asm can still be emulated.
214
215 // generate asm
216 as->out_c = "=*m,=*m,";
217 LLValue* tmp = DtoAlloca(llretTy, ".tmp_asm_ret");
218 as->out.push_back( tmp );
219 as->out.push_back( DtoGEPi(tmp, 0,1) );
220 as->code = "movd %eax, $<<out0>>" "\n\t" "mov %edx, $<<out1>>";
221
222 // fix asmblock
223 asmblock->retn = 0;
224 asmblock->retemu = true;
225 asmblock->asmBlock->abiret = tmp;
226
227 // add "ret" stmt
228 asmblock->s.push_back(as);
229
230 // done, we don't want anything pushed in the front of the block
231 return;
232 #endif
210 } 233 }
211 else 234 else
212 { 235 {
213 error(loc, "unimplemented return type '%s' for implicit abi return", rt->toChars()); 236 error(loc, "unimplemented return type '%s' for implicit abi return", rt->toChars());
214 fatal(); 237 fatal();