Mercurial > projects > ldc
changeset 969:fe2d9bb7078d
Add some extra debug output that's useful in diagnosing inline assembler bugs.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Mon, 16 Feb 2009 23:56:56 +0100 |
parents | a9feaed801d7 |
children | fb31a4afa2df |
files | gen/asmstmt.cpp |
diffstat | 1 files changed, 42 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/asmstmt.cpp Mon Feb 16 19:31:10 2009 +0100 +++ b/gen/asmstmt.cpp Mon Feb 16 23:56:56 2009 +0100 @@ -346,7 +346,34 @@ ++p; } - Logger::println("final asm: %.*s", code->insnTemplateLen, code->insnTemplate); + if (Logger::enabled()) { + Logger::println("final asm: %.*s", code->insnTemplateLen, code->insnTemplate); + std::ostringstream ss; + + ss << "GCC-style output constraints: {"; + typedef std::deque<std::string>::iterator It; + for (It i = output_constraints.begin(), e = output_constraints.end(); i != e; ++i) { + ss << " " << *i; + } + ss << " }"; + Logger::println("%s", ss.str().c_str()); + + ss.str(""); + ss << "GCC-style input constraints: {"; + for (It i = input_constraints.begin(), e = input_constraints.end(); i != e; ++i) { + ss << " " << *i; + } + ss << " }"; + Logger::println("%s", ss.str().c_str()); + + ss.str(""); + ss << "GCC-style clobbers: {"; + for (It i = clobbers.begin(), e = clobbers.end(); i != e; ++i) { + ss << " " << *i; + } + ss << " }"; + Logger::println("%s", ss.str().c_str()); + } std::string insnt(code->insnTemplate, code->insnTemplateLen); @@ -665,14 +692,27 @@ llvm::FunctionType* fty = llvm::FunctionType::get(retty, types, false); if (Logger::enabled()) Logger::cout() << "function type = " << *fty << '\n'; - llvm::InlineAsm* ia = llvm::InlineAsm::get(fty, code, out_c, true); std::vector<LLValue*> args; args.insert(args.end(), outargs.begin(), outargs.end()); args.insert(args.end(), inargs.begin(), inargs.end()); + + 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; + Logger::undent(); + } + + llvm::InlineAsm* ia = llvm::InlineAsm::get(fty, code, out_c, true); + llvm::CallInst* call = p->ir->CreateCall(ia, args.begin(), args.end(), retty == LLType::VoidTy ? "" : "asm"); + if (Logger::enabled()) + Logger::cout() << "Complete asm statement: " << *call << '\n'; + // capture abi return value if (useabiret) {