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:
Wladimir J. van der Laan 2012-09-12 20:00:25 +02:00
commit 6e6bd1ea71
3 changed files with 46 additions and 1 deletions

View file

@ -1457,6 +1457,15 @@ class MetaData(Value):
ptr = _core.LLVMMetaDataGet(module.ptr, vs)
return MetaData(ptr)
@staticmethod
def get_named_operands(module, name):
lst = _core.LLVMGetNamedMetadataOperands(module.ptr, name)
return [MetaData(ptr) for ptr in lst]
@staticmethod
def add_named_operand(module, name, operand):
_core.LLVMAddNamedMetadataOperand(module.ptr, name, operand.ptr)
#===----------------------------------------------------------------------===
# Instruction
#===----------------------------------------------------------------------===