[LLVMdev] Advice - llvm as binary to binary translator ?

Erik Buck erik.buck at sbcglobal.net
Sun Jun 22 20:08:43 PDT 2008

I went ahead and tried to translate my legacy machine language into  
IR.  Legacy branch instructions have me stumped.  The branch  
instructions are already resolved to destination addresses in the  
legacy machine code.  For example, there is an instruction that  
performs an unconditional branch to the address stored in legacy  
register B1.

I can represent register B1 as a local variable:
%B1 = alloca i32  ; storage for emulated register B1
I can generate IR corresponding to legacy machine code that calculates  
the value to store in %B1.  I can generate the IR to store in %B1.
store i32 %indirectAddr, i32* %B1
Now, how do I generate an IR "br" instruction to the calculated  
address in %B1 ?  I don't have a suitable destination label in my IR.   
I can't create a block for the destination address if the address is  
calculated by the legacy code (can I?)

Am I off to the wrong approach ?  Are there any suggestions ? 

More information about the llvm-dev mailing list