Mercurial > projects > ldc
comparison gen/asmstmt.cpp @ 234:9760f54af0b7 trunk
[svn r250] Fixed the warning about dropping arguments to _Dmain when optimizing.
Did a few cleanups in inline asm code.
author | lindquist |
---|---|
date | Sun, 08 Jun 2008 08:03:19 +0200 |
parents | 76ee1bbe487e |
children | a168a2c3ea48 |
comparison
equal
deleted
inserted
replaced
233:76ee1bbe487e | 234:9760f54af0b7 |
---|---|
155 | 155 |
156 // may need to make this target-specific | 156 // may need to make this target-specific |
157 static void d_format_priv_asm_label(char * buf, unsigned n) | 157 static void d_format_priv_asm_label(char * buf, unsigned n) |
158 { | 158 { |
159 //ASM_GENERATE_INTERNAL_LABEL(buf, "LDASM", n);//inserts a '*' for use with assemble_name | 159 //ASM_GENERATE_INTERNAL_LABEL(buf, "LDASM", n);//inserts a '*' for use with assemble_name |
160 assert(0); | |
160 sprintf(buf, ".LDASM%u", n); | 161 sprintf(buf, ".LDASM%u", n); |
161 } | 162 } |
162 | 163 |
163 void | 164 void |
164 d_expand_priv_asm_label(IRState * irs, unsigned n) | 165 d_expand_priv_asm_label(IRState * irs, unsigned n) |
268 arg_val = arg->expr->toElem(irs)->getRVal(); | 269 arg_val = arg->expr->toElem(irs)->getRVal(); |
269 do_integer: | 270 do_integer: |
270 cns = i_cns; | 271 cns = i_cns; |
271 break; | 272 break; |
272 case Arg_Pointer: | 273 case Arg_Pointer: |
273 // FIXME | 274 assert(arg->expr->op == TOKvar); |
274 std::cout << "asm fixme Arg_Pointer" << std::endl; | 275 arg_val = arg->expr->toElem(irs)->getRVal(); |
275 if (arg->expr->op == TOKdsymbol) | 276 cns = p_cns; |
276 { | |
277 assert(0); | |
278 DsymbolExp* dse = (DsymbolExp*)arg->expr; | |
279 LabelDsymbol* lbl = dse->s->isLabel(); | |
280 assert(lbl); | |
281 arg_val = lbl->statement->llvmBB; | |
282 if (!arg_val) | |
283 { | |
284 arg_val = lbl->statement->llvmBB = llvm::BasicBlock::Create("label", irs->topfunc()); | |
285 } | |
286 cns = l_cns; | |
287 } | |
288 else | |
289 { | |
290 arg_val = arg->expr->toElem(irs)->getRVal(); | |
291 cns = p_cns; | |
292 } | |
293 /*if (arg->expr->op == TOKvar) | |
294 arg_val = arg->expr->toElem(irs); | |
295 else if (arg->expr->op == TOKdsymbol) | |
296 arg_val = arg->expr->toElem(irs); | |
297 else | |
298 assert(0);*/ | |
299 | 277 |
300 break; | 278 break; |
301 case Arg_Memory: | 279 case Arg_Memory: |
302 // FIXME | |
303 std::cout << "asm fixme Arg_Memory" << std::endl; | |
304 arg_val = arg->expr->toElem(irs)->getRVal(); | 280 arg_val = arg->expr->toElem(irs)->getRVal(); |
305 // if (arg->expr->op == TOKvar) | |
306 // arg_val = arg->expr->toElem(irs); | |
307 // else | |
308 // arg_val = arg->expr->toElem(irs); | |
309 | 281 |
310 switch (arg->mode) { | 282 switch (arg->mode) { |
311 case Mode_Input: cns = m_cns; break; | 283 case Mode_Input: cns = m_cns; break; |
312 case Mode_Output: cns = mw_cns; is_input = false; break; | 284 case Mode_Output: cns = mw_cns; is_input = false; break; |
313 case Mode_Update: cns = mrw_cns; is_input = false; break; | 285 case Mode_Update: cns = mrw_cns; is_input = false; break; |
469 "0","1","2","3","4", | 441 "0","1","2","3","4", |
470 "5","6","7","8","9" | 442 "5","6","7","8","9" |
471 }; | 443 }; |
472 assert(nargs <= 10); | 444 assert(nargs <= 10); |
473 | 445 |
474 static const std::string prefix("<<<out"); | 446 static const std::string prefix("<<out"); |
475 static const std::string suffix(">>>"); | 447 static const std::string suffix(">>"); |
476 std::string argnum; | 448 std::string argnum; |
477 std::string needle; | 449 std::string needle; |
478 char buf[10]; | 450 char buf[10]; |
479 for (unsigned i = 0; i < nargs; i++) { | 451 for (unsigned i = 0; i < nargs; i++) { |
480 needle = prefix + digits[i] + suffix; | 452 needle = prefix + digits[i] + suffix; |
491 "0","1","2","3","4", | 463 "0","1","2","3","4", |
492 "5","6","7","8","9" | 464 "5","6","7","8","9" |
493 }; | 465 }; |
494 assert(nargs <= 10); | 466 assert(nargs <= 10); |
495 | 467 |
496 static const std::string prefix("<<<in"); | 468 static const std::string prefix("<<in"); |
497 static const std::string suffix(">>>"); | 469 static const std::string suffix(">>"); |
498 std::string argnum; | 470 std::string argnum; |
499 std::string needle; | 471 std::string needle; |
500 char buf[10]; | 472 char buf[10]; |
501 for (unsigned i = 0; i < nargs; i++) { | 473 for (unsigned i = 0; i < nargs; i++) { |
502 needle = prefix + digits[i] + suffix; | 474 needle = prefix + digits[i] + suffix; |