Added instruction properties (is_XXX, opcode, opcode_name)
git-svn-id: http://llvm-py.googlecode.com/svn/trunk@42 8d1e9007-1d4e-0410-b67e-1979fd6579aa
This commit is contained in:
parent
b873cb8bea
commit
aee33c6612
5 changed files with 108 additions and 5 deletions
21
llvm/_core.c
21
llvm/_core.c
|
|
@ -462,6 +462,17 @@ _wrap_obj2obj(LLVMGetInstructionParent, LLVMValueRef, LLVMBasicBlockRef)
|
||||||
_wrap_obj2obj(LLVMGetFirstInstruction, LLVMBasicBlockRef, LLVMValueRef)
|
_wrap_obj2obj(LLVMGetFirstInstruction, LLVMBasicBlockRef, LLVMValueRef)
|
||||||
_wrap_obj2obj(LLVMGetNextInstruction, LLVMValueRef, LLVMValueRef)
|
_wrap_obj2obj(LLVMGetNextInstruction, LLVMValueRef, LLVMValueRef)
|
||||||
_wrap_obj2obj(LLVMInstIsTerminator, LLVMValueRef, int)
|
_wrap_obj2obj(LLVMInstIsTerminator, LLVMValueRef, int)
|
||||||
|
_wrap_obj2obj(LLVMInstIsBinaryOp, LLVMValueRef, int)
|
||||||
|
_wrap_obj2obj(LLVMInstIsShift, LLVMValueRef, int)
|
||||||
|
_wrap_obj2obj(LLVMInstIsCast, LLVMValueRef, int)
|
||||||
|
_wrap_obj2obj(LLVMInstIsLogicalShift, LLVMValueRef, int)
|
||||||
|
_wrap_obj2obj(LLVMInstIsArithmeticShift, LLVMValueRef, int)
|
||||||
|
_wrap_obj2obj(LLVMInstIsAssociative, LLVMValueRef, int)
|
||||||
|
_wrap_obj2obj(LLVMInstIsCommutative, LLVMValueRef, int)
|
||||||
|
_wrap_obj2obj(LLVMInstIsTrapping, LLVMValueRef, int)
|
||||||
|
_wrap_obj2obj(LLVMInstGetOpcode, LLVMValueRef, int)
|
||||||
|
_wrap_obj2str(LLVMInstGetOpcodeName, LLVMValueRef)
|
||||||
|
|
||||||
|
|
||||||
/*===-- Call Sites (Call or Invoke) --------------------------------------===*/
|
/*===-- Call Sites (Call or Invoke) --------------------------------------===*/
|
||||||
|
|
||||||
|
|
@ -1131,6 +1142,16 @@ static PyMethodDef core_methods[] = {
|
||||||
_method( LLVMGetFirstInstruction )
|
_method( LLVMGetFirstInstruction )
|
||||||
_method( LLVMGetNextInstruction )
|
_method( LLVMGetNextInstruction )
|
||||||
_method( LLVMInstIsTerminator )
|
_method( LLVMInstIsTerminator )
|
||||||
|
_method( LLVMInstIsBinaryOp )
|
||||||
|
_method( LLVMInstIsShift )
|
||||||
|
_method( LLVMInstIsCast )
|
||||||
|
_method( LLVMInstIsLogicalShift )
|
||||||
|
_method( LLVMInstIsArithmeticShift )
|
||||||
|
_method( LLVMInstIsAssociative )
|
||||||
|
_method( LLVMInstIsCommutative )
|
||||||
|
_method( LLVMInstIsTrapping )
|
||||||
|
_method( LLVMInstGetOpcode )
|
||||||
|
_method( LLVMInstGetOpcodeName )
|
||||||
|
|
||||||
/* Call Sites (Call or Invoke) */
|
/* Call Sites (Call or Invoke) */
|
||||||
_method( LLVMSetInstructionCallConv )
|
_method( LLVMSetInstructionCallConv )
|
||||||
|
|
|
||||||
42
llvm/core.py
42
llvm/core.py
|
|
@ -1686,7 +1686,47 @@ class Instruction(Value):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_terminator(self):
|
def is_terminator(self):
|
||||||
return _core.LLVMInstIsTerminator(self.ptr)
|
return _core.LLVMInstIsTerminator(self.ptr) != 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_binary_op(self):
|
||||||
|
return _core.LLVMInstIsBinaryOp(self.ptr) != 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_shift(self):
|
||||||
|
return _core.LLVMInstIsShift(self.ptr) != 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_cast(self):
|
||||||
|
return _core.LLVMInstIsCast(self.ptr) != 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_logical_shift(self):
|
||||||
|
return _core.LLVMInstIsLogicalShift(self.ptr) != 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_arithmetic_shift(self):
|
||||||
|
return _core.LLVMInstIsArithmeticShift(self.ptr) != 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_associative(self):
|
||||||
|
return _core.LLVMInstIsAssociative(self.ptr) != 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_commutative(self):
|
||||||
|
return _core.LLVMInstIsCommutative(self.ptr) != 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_trapping(self):
|
||||||
|
return _core.LLVMInstIsTrapping(self.ptr) != 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def opcode(self):
|
||||||
|
return _core.LLVMInstGetOpcode(self.ptr)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def opcode_name(self):
|
||||||
|
return _core.LLVMInstGetOpcodeName(self.ptr)
|
||||||
|
|
||||||
|
|
||||||
class CallOrInvokeInstruction(Instruction):
|
class CallOrInvokeInstruction(Instruction):
|
||||||
|
|
|
||||||
|
|
@ -84,8 +84,29 @@ LLVMValueRef LLVMBuildVFCmp(LLVMBuilderRef B, LLVMRealPredicate Op,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned LLVMInstIsTerminator(LLVMValueRef I) {
|
#define inst_checkfn(ourfn, llvmfn) \
|
||||||
return unwrap<Instruction>(I)->isTerminator() ? 1 : 0;
|
unsigned ourfn (LLVMValueRef I) { \
|
||||||
|
return unwrap<Instruction>(I)-> llvmfn () ? 1 : 0; \
|
||||||
|
}
|
||||||
|
|
||||||
|
inst_checkfn(LLVMInstIsTerminator, isTerminator)
|
||||||
|
inst_checkfn(LLVMInstIsBinaryOp, isBinaryOp)
|
||||||
|
inst_checkfn(LLVMInstIsShift, isShift)
|
||||||
|
inst_checkfn(LLVMInstIsCast, isCast)
|
||||||
|
inst_checkfn(LLVMInstIsLogicalShift,isLogicalShift)
|
||||||
|
inst_checkfn(LLVMInstIsArithmeticShift,isArithmeticShift)
|
||||||
|
inst_checkfn(LLVMInstIsAssociative, isAssociative)
|
||||||
|
inst_checkfn(LLVMInstIsCommutative, isCommutative)
|
||||||
|
inst_checkfn(LLVMInstIsTrapping, isTrapping)
|
||||||
|
|
||||||
|
const char *LLVMInstGetOpcodeName(LLVMValueRef I)
|
||||||
|
{
|
||||||
|
return unwrap<Instruction>(I)->getOpcodeName();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned LLVMInstGetOpcode(LLVMValueRef I)
|
||||||
|
{
|
||||||
|
return unwrap<Instruction>(I)->getOpcode();
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMValueRef LLVMBuildRetMultiple(LLVMBuilderRef B, LLVMValueRef *Values,
|
LLVMValueRef LLVMBuildRetMultiple(LLVMBuilderRef B, LLVMValueRef *Values,
|
||||||
|
|
|
||||||
11
llvm/extra.h
11
llvm/extra.h
|
|
@ -54,6 +54,17 @@ LLVMValueRef LLVMGetIntrinsic(LLVMModuleRef B, int ID,
|
||||||
/* instruction */
|
/* instruction */
|
||||||
|
|
||||||
unsigned LLVMInstIsTerminator(LLVMValueRef I);
|
unsigned LLVMInstIsTerminator(LLVMValueRef I);
|
||||||
|
unsigned LLVMInstIsBinaryOp(LLVMValueRef I);
|
||||||
|
unsigned LLVMInstIsShift(LLVMValueRef I);
|
||||||
|
unsigned LLVMInstIsCast(LLVMValueRef I);
|
||||||
|
unsigned LLVMInstIsLogicalShift(LLVMValueRef I);
|
||||||
|
unsigned LLVMInstIsArithmeticShift(LLVMValueRef I);
|
||||||
|
unsigned LLVMInstIsAssociative(LLVMValueRef I);
|
||||||
|
unsigned LLVMInstIsCommutative(LLVMValueRef I);
|
||||||
|
unsigned LLVMInstIsTrapping(LLVMValueRef I);
|
||||||
|
|
||||||
|
const char *LLVMInstGetOpcodeName(LLVMValueRef I);
|
||||||
|
unsigned LLVMInstGetOpcode(LLVMValueRef I);
|
||||||
|
|
||||||
/* reading llvm "assembly" */
|
/* reading llvm "assembly" */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -411,6 +411,16 @@ def do_builder():
|
||||||
i = b.phi(Type.int())
|
i = b.phi(Type.int())
|
||||||
i.add_incoming(v, blk)
|
i.add_incoming(v, blk)
|
||||||
t = i.is_terminator == False
|
t = i.is_terminator == False
|
||||||
|
t = i.is_binary_op == False
|
||||||
|
t = i.is_shift == False
|
||||||
|
t = i.is_cast == False
|
||||||
|
t = i.is_logical_shift == False
|
||||||
|
t = i.is_arithmetic_shift == False
|
||||||
|
t = i.is_associative == False
|
||||||
|
t = i.is_commutative == False
|
||||||
|
t = i.is_trapping == False
|
||||||
|
t = i.opcode
|
||||||
|
t = i.opcode_name
|
||||||
|
|
||||||
|
|
||||||
def do_moduleprovider():
|
def do_moduleprovider():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue