Added instruction operands (Seth Warn)
git-svn-id: http://llvm-py.googlecode.com/svn/trunk@66 8d1e9007-1d4e-0410-b67e-1979fd6579aa
This commit is contained in:
parent
1b4b807884
commit
2eeb7630a1
6 changed files with 93 additions and 2 deletions
|
|
@ -531,9 +531,11 @@ _wrap_obj2obj(LLVMInstIsArithmeticShift, LLVMValueRef, int)
|
|||
_wrap_obj2obj(LLVMInstIsAssociative, LLVMValueRef, int)
|
||||
_wrap_obj2obj(LLVMInstIsCommutative, LLVMValueRef, int)
|
||||
_wrap_obj2obj(LLVMInstIsTrapping, LLVMValueRef, int)
|
||||
_wrap_obj2obj(LLVMInstIsVolatile, LLVMValueRef, int)
|
||||
_wrap_obj2obj(LLVMInstGetOpcode, LLVMValueRef, int)
|
||||
_wrap_obj2str(LLVMInstGetOpcodeName, LLVMValueRef)
|
||||
_wrap_obj2obj(LLVMInstIsVolatile, LLVMValueRef, int)
|
||||
_wrap_obj2obj(LLVMInstGetNumOperands, LLVMValueRef, int)
|
||||
_wrap_objint2obj(LLVMInstGetOperand, LLVMValueRef, LLVMValueRef)
|
||||
|
||||
/*===-- Call Sites (Call or Invoke) --------------------------------------===*/
|
||||
|
||||
|
|
@ -1250,9 +1252,11 @@ static PyMethodDef core_methods[] = {
|
|||
_method( LLVMInstIsAssociative )
|
||||
_method( LLVMInstIsCommutative )
|
||||
_method( LLVMInstIsTrapping )
|
||||
_method( LLVMInstIsVolatile )
|
||||
_method( LLVMInstGetOpcode )
|
||||
_method( LLVMInstGetOpcodeName )
|
||||
_method( LLVMInstIsVolatile )
|
||||
_method( LLVMInstGetNumOperands )
|
||||
_method( LLVMInstGetOperand )
|
||||
|
||||
/* Call Sites (Call or Invoke) */
|
||||
_method( LLVMSetInstructionCallConv )
|
||||
|
|
|
|||
16
llvm/core.py
16
llvm/core.py
|
|
@ -1772,6 +1772,10 @@ class GlobalValue(Constant):
|
|||
|
||||
def __init__(self, ptr):
|
||||
Constant.__init__(self, ptr)
|
||||
# Hang on to the module, don't let it die before we do.
|
||||
# It is nice to have just a map of functions without
|
||||
# retaining a ref to the owning module.
|
||||
self._module_obj = self.module
|
||||
|
||||
def _get_linkage(self): return _core.LLVMGetLinkage(self.ptr)
|
||||
def _set_linkage(self, value): _core.LLVMSetLinkage(self.ptr, value)
|
||||
|
|
@ -2001,6 +2005,18 @@ class Instruction(Value):
|
|||
def opcode_name(self):
|
||||
return _core.LLVMInstGetOpcodeName(self.ptr)
|
||||
|
||||
@property
|
||||
def operand_count(self):
|
||||
return _core.LLVMInstGetNumOperands(self.ptr)
|
||||
|
||||
@property
|
||||
def operands(self):
|
||||
"""Yields operands of this instruction."""
|
||||
return [self._get_operand(i) for i in range(self.operand_count)]
|
||||
|
||||
def _get_operand(self, i):
|
||||
return _make_value(_core.LLVMInstGetOperand(self.ptr, i))
|
||||
|
||||
|
||||
class CallOrInvokeInstruction(Instruction):
|
||||
|
||||
|
|
|
|||
|
|
@ -237,6 +237,21 @@ unsigned LLVMInstGetOpcode(LLVMValueRef inst)
|
|||
return instp->getOpcode();
|
||||
}
|
||||
|
||||
unsigned LLVMInstGetNumOperands(LLVMValueRef inst)
|
||||
{
|
||||
llvm::Instruction *instp = llvm::unwrap<llvm::Instruction>(inst);
|
||||
assert(instp);
|
||||
return instp->getNumOperands();
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMInstGetOperand(LLVMValueRef inst, unsigned idx)
|
||||
{
|
||||
llvm::Instruction *instp = llvm::unwrap<llvm::Instruction>(inst);
|
||||
assert(instp);
|
||||
llvm::Value *operand = instp->getOperand(idx);
|
||||
return llvm::wrap(operand);
|
||||
}
|
||||
|
||||
/* llvm::unwrap a set of `n' wrapped objects starting at `values',
|
||||
* into a vector of pointers to llvm::unwrapped objects `out'. */
|
||||
template <typename W, typename UW>
|
||||
|
|
|
|||
|
|
@ -121,6 +121,12 @@ const char *LLVMInstGetOpcodeName(LLVMValueRef inst);
|
|||
/* Wraps llvm::Instruction::getOpcode(). */
|
||||
unsigned LLVMInstGetOpcode(LLVMValueRef inst);
|
||||
|
||||
/* Wraps llvm:Instruction::getNumOperands(). */
|
||||
unsigned LLVMInstGetNumOperands(LLVMValueRef inst);
|
||||
|
||||
/* Wraps llvm:Instruction::getOperand(). */
|
||||
LLVMValueRef LLVMInstGetOperand(LLVMValueRef inst, unsigned idx);
|
||||
|
||||
/* Wraps llvm::ParseAssemblyString(). Returns a module reference or NULL (with
|
||||
* `out' pointing to an error message). Dispose error message after use, via
|
||||
* LLVMDisposeMessage(). */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue