Mercurial > projects > ldc
changeset 300:7b1040c76dd2 trunk
[svn r321] Fix bug in argument remapping functions.
author | ChristianK |
---|---|
date | Tue, 24 Jun 2008 22:27:55 +0200 |
parents | df8a7b8d5929 |
children | f42a1090e895 |
files | gen/asmstmt.cpp |
diffstat | 1 files changed, 17 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/asmstmt.cpp Tue Jun 24 21:38:23 2008 +0200 +++ b/gen/asmstmt.cpp Tue Jun 24 22:27:55 2008 +0200 @@ -463,8 +463,11 @@ char buf[10]; for (unsigned i = 0; i < nargs; i++) { needle = prefix + digits[i] + suffix; - sprintf(buf, "%u", idx++); - insnt.replace(insnt.find(needle), needle.size(), buf); + size_t pos = insnt.find(needle); + if(pos != std::string::npos) { + sprintf(buf, "%u", idx++); + insnt.replace(pos, needle.size(), buf); + } } } @@ -485,8 +488,11 @@ char buf[10]; for (unsigned i = 0; i < nargs; i++) { needle = prefix + digits[i] + suffix; - sprintf(buf, "%u", idx++); - insnt.replace(insnt.find(needle), needle.size(), buf); + size_t pos = insnt.find(needle); + if(pos != std::string::npos) { + sprintf(buf, "%u", idx++); + insnt.replace(pos, needle.size(), buf); + } } } @@ -515,7 +521,11 @@ // this additional asm code sets the __llvm_jump_target variable // to a unique value that will identify the jump target in // a post-asm switch - //FIXME: Need to init __llvm_jump_target + + // create storage for and initialize the temporary + llvm::AllocaInst* jump_target = new llvm::AllocaInst(llvm::IntegerType::get(32), "__llvm_jump_target", p->topallocapoint()); + gIR->ir->CreateStore(llvm::ConstantInt::get(llvm::IntegerType::get(32), 0), jump_target); + //FIXME: Store the value -> label mapping somewhere, so it can be referenced later std::string asmGotoEnd = "jmp __llvm_asm_end ; "; std::string outGotoSetter = asmGotoEnd; @@ -582,7 +592,7 @@ { out_c += a->out_c; } - remap_outargs(a->code, onn, asmIdx); + remap_outargs(a->code, onn+a->in.size(), asmIdx); } for (size_t i=0; i<n; ++i) { @@ -598,7 +608,7 @@ { in_c += a->in_c; } - remap_inargs(a->code, inn, asmIdx); + remap_inargs(a->code, inn+a->out.size(), asmIdx); if (!code.empty()) code += " ; "; code += a->code;