Add support for module named metadata
This is mainly useful to get access to top-level debug information through 'llvm.dbg.cu'. Wraps LLVM C-API functions `LLVMGetNamedMetadataNumOperands`, `LLVMGetNamedMetadataOperands` and `LLVMAddNamedMetadataOperand`. Also add testcase.
This commit is contained in:
parent
5ee6bba66b
commit
6e6bd1ea71
3 changed files with 46 additions and 1 deletions
|
|
@ -607,6 +607,27 @@ _wrap_obj2none(LLVMDeleteBasicBlock, LLVMBasicBlockRef)
|
|||
/*===-- MetaData -----------------------------------------------------===*/
|
||||
|
||||
_wrap_objlist2obj(LLVMMetaDataGet, LLVMModuleRef, LLVMValueRef, LLVMValueRef)
|
||||
_wrap_objstrobj2none(LLVMAddNamedMetadataOperand, LLVMModuleRef, LLVMValueRef)
|
||||
|
||||
static PyObject *
|
||||
_wLLVMGetNamedMetadataOperands(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *obj_module;
|
||||
const char *name;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "Os", &obj_module, &name))
|
||||
return NULL;
|
||||
|
||||
LLVMModuleRef module = (LLVMModuleRef)PyCapsule_GetPointer(obj_module, NULL);
|
||||
unsigned num_operands = LLVMGetNamedMetadataNumOperands(module, name);
|
||||
LLVMValueRef *operands = (LLVMValueRef*)malloc(sizeof(LLVMValueRef)*num_operands);
|
||||
LLVMGetNamedMetadataOperands(module, name, operands);
|
||||
|
||||
PyObject *list = make_list_from_LLVMValueRef_array(operands, num_operands);
|
||||
free(operands);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/*===-- Instructions -----------------------------------------------------===*/
|
||||
|
||||
|
|
@ -1660,6 +1681,8 @@ static PyMethodDef core_methods[] = {
|
|||
|
||||
/* MetaData */
|
||||
_method( LLVMMetaDataGet )
|
||||
_method( LLVMGetNamedMetadataOperands )
|
||||
_method( LLVMAddNamedMetadataOperand )
|
||||
|
||||
/* Instructions */
|
||||
_method( LLVMGetInstructionParent )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue