[LLVMdev] How to call a pointer that points to a C function (original) (raw)
C K Tan cktanx at gmail.com
Mon Oct 27 00:46:58 PDT 2014
- Previous message: [LLVMdev] questions about memory dependence analysis
- Next message: [LLVMdev] How to call a pointer that points to a C function
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I have a pointer to a function that I need to invoke without going through llvm::Module::getOrInsertFunction. This example does not work:
static int add(int x, int y); llvm::Value *one, *two;
llvm::Constant* addfn = llvm::ConstantInt::get(JB->getIntPtrTy(DataLayout), (intptr_t)add); llvm::Type* args[] = { Int32Ty, Int32Ty }; llvm::FunctionType* ftype = llvm::FunctionType::get(Int32Ty, args); addfn = llvm::ConstantExpr::getPointerCast(addfn, ftype); CreateCall(addfn, one, two);
Is there a way? Or must I call getOrInsertFunction?
Before anyone asks why I am doing this, it is because I have maybe 200 functions with the same signature that I would like JIT a call to. I would like to avoid calling getOrInsertFunction 200 times. I know exactly the address of the functions.
Thanks.
- Previous message: [LLVMdev] questions about memory dependence analysis
- Next message: [LLVMdev] How to call a pointer that points to a C function
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]