CompareInstruction class (Seth Warn)

git-svn-id: http://llvm-py.googlecode.com/svn/trunk@76 8d1e9007-1d4e-0410-b67e-1979fd6579aa
This commit is contained in:
mdevan.foobar 2009-03-25 12:14:28 +00:00
commit f3989aa240
4 changed files with 26 additions and 0 deletions

View file

@ -579,6 +579,10 @@ _wrap_obj2obj(LLVMCountIncoming, LLVMValueRef, int)
_wrap_objint2obj(LLVMGetIncomingValue, LLVMValueRef, LLVMValueRef)
_wrap_objint2obj(LLVMGetIncomingBlock, LLVMValueRef, LLVMBasicBlockRef)
/*===-- Compare Instructions ---------------------------------------------===*/
_wrap_obj2obj(LLVMCmpInstGetPredicate, LLVMValueRef, int)
/*===-- Instruction builders ----------------------------------------------===*/
_wrap_none2obj(LLVMCreateBuilder, LLVMBuilderRef)
@ -1373,6 +1377,9 @@ static PyMethodDef core_methods[] = {
_method( LLVMGetIncomingValue )
_method( LLVMGetIncomingBlock )
/* Comparison Instructions */
_method( LLVMCmpInstGetPredicate )
/* Instruction builders */
_method( LLVMCreateBuilder )
_method( LLVMPositionBuilderBefore )

View file

@ -1420,6 +1420,13 @@ class SwitchInstruction(Instruction):
_core.LLVMAddCase(self.ptr, const.ptr, bblk.ptr)
class CompareInstruction(Instruction):
@property
def predicate(self):
return _core.LLVMCmpInstGetPredicate(self.ptr)
#===----------------------------------------------------------------------===
# Basic block
#===----------------------------------------------------------------------===
@ -1469,6 +1476,8 @@ __class_for_valueid = {
VALUE_INSTRUCTION + OPCODE_CALL : CallOrInvokeInstruction,
VALUE_INSTRUCTION + OPCODE_INVOKE : CallOrInvokeInstruction,
VALUE_INSTRUCTION + OPCODE_SWITCH : SwitchInstruction,
VALUE_INSTRUCTION + OPCODE_ICMP : CompareInstruction,
VALUE_INSTRUCTION + OPCODE_FCMP : CompareInstruction
}
def _make_value(ptr):

View file

@ -240,6 +240,13 @@ unsigned LLVMInstGetOpcode(LLVMValueRef inst)
return instp->getOpcode();
}
unsigned LLVMCmpInstGetPredicate(LLVMValueRef cmpinst)
{
llvm::CmpInst *instp = llvm::unwrap<llvm::CmpInst>(cmpinst);
assert(instp);
return instp->getPredicate();
}
/* 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>

View file

@ -139,6 +139,9 @@ const char *LLVMInstGetOpcodeName(LLVMValueRef inst);
/* Wraps llvm::Instruction::getOpcode(). */
unsigned LLVMInstGetOpcode(LLVMValueRef inst);
/* Wraps llvm::CmpInst::getPredicate(). */
unsigned LLVMCmpInstGetPredicate(LLVMValueRef cmpinst);
/* Wraps llvm::ParseAssemblyString(). Returns a module reference or NULL (with
* `out' pointing to an error message). Dispose error message after use, via
* LLVMDisposeMessage(). */