Add binding for Intrinsics.

Add support for functions that free the resource but is not a destructor.
This commit is contained in:
Siu Kwan Lam 2013-02-07 13:27:03 -06:00
commit 11cc78d780
8 changed files with 92 additions and 4 deletions

View file

@ -13,6 +13,7 @@
#include <llvm/Module.h>
#include <llvm/Analysis/Verifier.h>
#include <llvm/Constants.h>
#include <llvm/Intrinsics.h>
#include "auto_pyobject.h"
@ -694,3 +695,21 @@ PyObject* ConstantVector_get(PyObject* Elems)
return pycapsule_new(ary, "llvm::Value", "llvm::Constant");
}
static
PyObject* Intrinsic_getDeclaration(llvm::Module* Mod,
unsigned ID,
PyObject* Types=NULL)
{
using namespace llvm;
Function* Fn = NULL;
if (Types) {
std::vector<Type*> types;
bool ok = extract<Type>::from_py_sequence(types, Types, "llvm::Type");
if (!ok) return NULL;
Fn = Intrinsic::getDeclaration(Mod, (Intrinsic::ID)ID, types);
} else {
Fn = Intrinsic::getDeclaration(Mod, (Intrinsic::ID)ID);
}
return pycapsule_new(Fn, "llvm::Value", "llvm::Function");
}