[LLVMdev] retrieve information from a macro inlined as x86_64 asm in LLVM IR

Jimborean Alexandra xinfinity_a at yahoo.com
Tue Jun 28 08:40:11 PDT 2011


Hi LLVM devs,

I work on a pass that creates multiple versions of a code region and switches 
between them. The decision about the version to be selected is taken by an 
external runtime system. I insert callbacks to this system in my code to pass 
the control of the execution.  All callbacks are written in inline assembly, in 
macros. 

The problem comes when I need to send some information from the runtime system, 
back to the code. 

I create one local variable : 

lim = new AllocaInst(.......); 

and I want the value of %lim to be set by the runtime system. For this, I want 
to create a macro that takes as parameter the address of this variable, such 
that the runtime system can put the value it computes in this address, at 
runtime. (Similar to sending a parameter by reference. )
If I send the address of the  Value* lim as a param to the macro, it puts the 
hardcoded address (as expected).  


std::stringstream out;
out.str(std::string()); out << &lim;


InlineAsm* IA = InlineAsm::get(asmFuncTy,   "camus_macro_decision" + out.str()   
, "=r", true);
CallInst* cmp = CallInst::Create(IA,  ...);

creates the call:   
camus_macro_decision   0x7fffdf3172f0

I tried also by creating a pointer to the Value* lim, without any success.

I know this is not the good approach, but can you suggest a solution to retrieve 
information from the macro?

Thank you,
Alexandra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110628/f19cbd46/attachment.html>


More information about the llvm-dev mailing list