Mercurial > projects > ldc
diff gen/asmstmt.cpp @ 979:523bf4f166bc
Fix some assembler issues:
The assembler was miscompiling "add" (specifically, the "add reg/mem, imm"
variations).
The change that caused this seems to have been made because without it, some
"add"s didn't compile at all.
This patch reverts the previous change, and makes sure assembler operands are
remapped correctly even though the input operands auto-generated due to
updating operations aren't explicitly used.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Wed, 18 Feb 2009 21:46:14 +0100 |
parents | 6a32d2e18175 |
children | ae710cba0884 |
line wrap: on
line diff
--- a/gen/asmstmt.cpp Wed Feb 18 03:38:12 2009 +0100 +++ b/gen/asmstmt.cpp Wed Feb 18 21:46:14 2009 +0100 @@ -396,8 +396,9 @@ // Add input operand with same value, with original as "matching output". std::ostringstream ss; ss << '*' << (n + asmblock->outputcount); - input_constraints.push_front(ss.str()); - input_values.push_front(output_values[n]); + // Must be at the back; unused operands before used ones screw up numbering. + input_constraints.push_back(ss.str()); + input_values.push_back(output_values[n]); } llvmOutConstraints += *i; llvmOutConstraints += ","; @@ -440,7 +441,7 @@ } // rewrite argument indices to the block scope indices -static void remap_outargs(std::string& insnt, size_t nargs, size_t& idx) +static void remap_outargs(std::string& insnt, size_t nargs, size_t idx) { static const std::string digits[10] = { @@ -465,7 +466,7 @@ } // rewrite argument indices to the block scope indices -static void remap_inargs(std::string& insnt, size_t nargs, size_t& idx) +static void remap_inargs(std::string& insnt, size_t nargs, size_t idx) { static const std::string digits[10] = { @@ -644,6 +645,7 @@ out_c += a->out_c; } remap_outargs(a->code, onn+a->in.size(), asmIdx); + asmIdx += onn; } Logger::println("do inputs"); @@ -662,6 +664,7 @@ in_c += a->in_c; } remap_inargs(a->code, inn+a->out.size(), asmIdx); + asmIdx += inn; if (!code.empty()) code += "\n\t"; code += a->code; @@ -707,8 +710,12 @@ if (Logger::enabled()) { Logger::cout() << "Arguments:" << '\n'; Logger::indent(); - for (std::vector<LLValue*>::iterator b = args.begin(), i = b, e = args.end(); i != e; ++i) - Logger::cout() << '$' << (i - b) << " ==> " << **i; + for (std::vector<LLValue*>::iterator b = args.begin(), i = b, e = args.end(); i != e; ++i) { + std::ostream& cout = Logger::cout(); + cout << '$' << (i - b) << " ==> " << **i; + if (llvm::isa<LLConstant>(*i)) + cout << '\n'; + } Logger::undent(); }