Access to MetaData operands
This is not available in the C API, so add functions to extra.cpp: - `LLVMMetaDataGetOperand` wraps MDNode::getOperand - `LLVMMetaDataGetNumOperands` wraps MDNode::getNumOperands
This commit is contained in:
parent
6e6bd1ea71
commit
7f69beb258
5 changed files with 40 additions and 1 deletions
12
llvm/core.py
12
llvm/core.py
|
|
@ -1466,6 +1466,18 @@ class MetaData(Value):
|
|||
def add_named_operand(module, name, operand):
|
||||
_core.LLVMAddNamedMetadataOperand(module.ptr, name, operand.ptr)
|
||||
|
||||
@property
|
||||
def operand_count(self):
|
||||
return _core.LLVMMetaDataGetNumOperands(self.ptr)
|
||||
|
||||
@property
|
||||
def operands(self):
|
||||
"""Yields operands of this metadata."""
|
||||
return [self._get_operand(i) for i in range(self.operand_count)]
|
||||
|
||||
def _get_operand(self, i):
|
||||
return _make_value(_core.LLVMMetaDataGetOperand(self.ptr, i))
|
||||
|
||||
#===----------------------------------------------------------------------===
|
||||
# Instruction
|
||||
#===----------------------------------------------------------------------===
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue