Mercurial > projects > ldc
comparison gen/asmstmt.cpp @ 971:985104c0f1db
Fix the problems exposed by the callingconv1.d test case.
The first was that unless otherwise specified, inputs are assumed to be in
registers even if they specify a "matching output" that's in memory.
While testing that fix, I also ran into a bug causing the generated "matching
output" for any input was always the first one instead of the correct one.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Tue, 17 Feb 2009 00:08:20 +0100 |
parents | fe2d9bb7078d |
children | 6a32d2e18175 |
comparison
equal
deleted
inserted
replaced
970:fb31a4afa2df | 971:985104c0f1db |
---|---|
383 int n = 0; | 383 int n = 0; |
384 typedef std::deque<std::string>::iterator it; | 384 typedef std::deque<std::string>::iterator it; |
385 for(it i = output_constraints.begin(), e = output_constraints.end(); i != e; ++i, ++n) { | 385 for(it i = output_constraints.begin(), e = output_constraints.end(); i != e; ++i, ++n) { |
386 // rewrite update constraint to in and out constraints | 386 // rewrite update constraint to in and out constraints |
387 if((*i)[0] == '+') { | 387 if((*i)[0] == '+') { |
388 (*i)[0] = '='; | 388 assert(*i == mrw_cns && "What else are we updating except memory?"); |
389 std::string input_constraint; | 389 /* LLVM doesn't support updating operands, so split into an input |
390 std::stringstream ss; | 390 * and an output operand. |
391 ss << n; | 391 */ |
392 ss >> input_constraint; | 392 |
393 //FIXME: I think multiple inout constraints will mess up the order! | 393 // Change update operand to pure output operand. |
394 input_constraints.push_front(input_constraint); | 394 *i = mw_cns; |
395 | |
396 // Add input operand with same value, with original as "matching output". | |
397 std::ostringstream ss; | |
398 ss << m_cns << (n + asmblock->outputcount); | |
399 input_constraints.push_front(ss.str()); | |
395 input_values.push_front(output_values[n]); | 400 input_values.push_front(output_values[n]); |
396 } | 401 } |
397 llvmOutConstraints += *i; | 402 llvmOutConstraints += *i; |
398 llvmOutConstraints += ","; | 403 llvmOutConstraints += ","; |
399 } | 404 } |
405 asmblock->outputcount += n; | |
406 | |
400 for(it i = input_constraints.begin(), e = input_constraints.end(); i != e; ++i) { | 407 for(it i = input_constraints.begin(), e = input_constraints.end(); i != e; ++i) { |
401 llvmInConstraints += *i; | 408 llvmInConstraints += *i; |
402 llvmInConstraints += ","; | 409 llvmInConstraints += ","; |
403 } | 410 } |
404 | 411 |