[LLVMdev] how to use lllvm interpreter api ?
ChiaLun
h3355626 at msn.com
Thu Nov 15 20:17:30 PST 2012
Hi everyone,
I build the interpreter with the following codes
* llvm::Module* mod = new llvm::Module("",llvm::getGlobalContext());
EngineBuilder builder(mod);
builder.setEngineKind(EngineKind::Interpreter);
builder.setOptLevel(CodeGenOpt::Default);
EE = builder.create();*
then I make 2 functions, their ir look like :
@1 = private unnamed_addr constant [11 x i8] c"1234567hi\0A\00"
*define void @setValue(i32* %v) {
store i32 3, i32* %v, align 4
ret void
}
define i32 @getValue() {
%1 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([11 x i8]*
@1, i32 0, i32 0))
ret i32 3
}*
Assumed the first function is named f1, the second is f2
I call the function with codes
*vector<GenericValue> arg;
GenericValue rv;
rv = EE->runFunction(f2,arg);
cout<<rv.IntVal.toString(10,1)<<endl;</b>
the result look like what I want
it prints 1234567hi, then cout print 3
Here's what I am confused, how to pass the argument to function f1.
Currently, I do
* int p = 5;
GenericValue gg((void*)(&p));
arg.push_back(gg);
EE->runFunction(f1,arg);
cout<<p<<endl;</b>
the output is 0
Does anyone know how to pass the argument ?
Chia Lun
--
View this message in context: http://llvm.1065342.n5.nabble.com/how-to-use-lllvm-interpreter-api-tp51345.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.
More information about the llvm-dev
mailing list