Mercurial > projects > ldc
changeset 301:f42a1090e895 trunk
[svn r322] More asm-to-outside jumping work. Unfinished.
author | ChristianK |
---|---|
date | Tue, 24 Jun 2008 22:48:33 +0200 |
parents | 7b1040c76dd2 |
children | bef811104734 |
files | gen/asmstmt.cpp |
diffstat | 1 files changed, 17 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/asmstmt.cpp Tue Jun 24 22:27:55 2008 +0200 +++ b/gen/asmstmt.cpp Tue Jun 24 22:48:33 2008 +0200 @@ -526,9 +526,13 @@ 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 + IRAsmStmt* outSetterStmt = new IRAsmStmt; std::string asmGotoEnd = "jmp __llvm_asm_end ; "; - std::string outGotoSetter = asmGotoEnd; + outSetterStmt->code = asmGotoEnd; + outSetterStmt->out_c = "=*m,"; + outSetterStmt->out.push_back(jump_target); + + int n_goto = 1; size_t n = asmblock->s.size(); for(size_t i=0; i<n; ++i) @@ -551,19 +555,21 @@ // provide an in-asm target for the branch and set value Logger::println("statement '%s' references outer label '%s': creating forwarder", a->code.c_str(), a->isBranchToLabel->string); - outGotoSetter += a->isBranchToLabel->string; - outGotoSetter += ": ; "; - outGotoSetter += "nop ; "; //FIXME: Change this to set __llvm_jump_target to a unique value - outGotoSetter += asmGotoEnd; + outSetterStmt->code += a->isBranchToLabel->string; + outSetterStmt->code += ": ; "; + outSetterStmt->code += "movl $<<in1>>, $<<out0>> ; "; + //FIXME: Store the value -> label mapping somewhere, so it can be referenced later + outSetterStmt->in.push_back(llvm::ConstantInt::get(llvm::IntegerType::get(32), n_goto++)); + outSetterStmt->in_c += "i,"; + outSetterStmt->code += asmGotoEnd; } - if(outGotoSetter != asmGotoEnd) + if(outSetterStmt->code != asmGotoEnd) { - outGotoSetter += "__llvm_asm_end: ; "; - IRAsmStmt* outSetterStmt = new IRAsmStmt; - outSetterStmt->code = outGotoSetter; - //FIXME: set other stuff + outSetterStmt->code += "__llvm_asm_end: ; "; asmblock->s.push_back(outSetterStmt); } + else + delete outSetterStmt; // build asm block