Get raw function pointers, inline functions (Corrado Zoccolo)

git-svn-id: http://llvm-py.googlecode.com/svn/trunk@75 8d1e9007-1d4e-0410-b67e-1979fd6579aa
This commit is contained in:
mdevan.foobar 2009-03-25 12:09:37 +00:00
commit fa30225181
6 changed files with 111 additions and 0 deletions

View file

@ -56,15 +56,18 @@
#include "llvm/Assembly/Parser.h"
#include "llvm/System/DynamicLibrary.h"
#include "llvm/PassManager.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"
#include "llvm/Transforms/Instrumentation.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Linker.h"
// LLVM-C includes
#include "llvm-c/Core.h"
#include "llvm-c/ExecutionEngine.h"
// our includes
#include "extra.h"
@ -463,6 +466,27 @@ unsigned LLVMLoadLibraryPermanently(const char* filename, char **errmsg)
return 1;
}
void *LLVMGetPointerToFunction(LLVMExecutionEngineRef ee, LLVMValueRef fn)
{
llvm::ExecutionEngine *eep = llvm::unwrap(ee);
assert(eep);
llvm::Function *fnp = llvm::unwrap<llvm::Function>(fn);
assert(fnp);
return eep->getPointerToFunction(fnp);
}
int LLVMInlineFunction(LLVMValueRef call)
{
llvm::Value *callp = llvm::unwrap(call);
assert(callp);
llvm::CallSite cs = llvm::CallSite::get(callp);
return llvm::InlineFunction(cs);
}
/* Passes. A few passes (listed below) are used directly from LLVM-C,
* rest are defined here.