add bindings for instruction description methods to MCInstrDesc
use these new bindings instead of MCInstrAnalysis bindings in llvm.mc.Instr because MCInstrAnalaysis is just a thin layer encapsulating MCInstrInfo that seems largely pointless.
This commit is contained in:
parent
0f3d5a8127
commit
083586464b
3 changed files with 29 additions and 12 deletions
|
|
@ -106,25 +106,28 @@ class Instr(object):
|
|||
return self.mcinst.getOpcode()
|
||||
|
||||
def is_branch(self):
|
||||
return self.tm.instr_analysis.isBranch(self.mcinst)
|
||||
return self.instr_desc.isBranch()
|
||||
|
||||
def is_cond_branch(self):
|
||||
return self.tm.instr_analysis.isConditionalBranch(self.mcinst)
|
||||
return self.instr_desc.isConditionalBranch()
|
||||
|
||||
def is_uncond_branch(self):
|
||||
return self.tm.instr_analysis.isUnconditionalBranch(self.mcinst)
|
||||
return self.instr_desc.isUnconditionalBranch()
|
||||
|
||||
def is_indirect_branch(self):
|
||||
return self.tm.instr_analysis.isIndirectBranch(self.mcinst)
|
||||
return self.instr_desc.isIndirectBranch()
|
||||
|
||||
def is_call(self):
|
||||
return self.tm.instr_analysis.isCall(self.mcinst)
|
||||
return self.instr_desc.isCall()
|
||||
|
||||
def is_return(self):
|
||||
return self.tm.instr_analysis.isReturn(self.mcinst)
|
||||
return self.instr_desc.isReturn()
|
||||
|
||||
def is_terminator(self):
|
||||
return self.tm.instr_analysis.isTerminator(self.mcinst)
|
||||
return self.instr_desc.isTerminator()
|
||||
|
||||
def is_barrier(self):
|
||||
return self.instr_desc.isBarrier()
|
||||
|
||||
class BadInstr(Instr):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -22,11 +22,24 @@ TargetRegisterInfo = llvm.Class(MCRegisterInfo)
|
|||
|
||||
@MCInstrDesc
|
||||
class MCInstrDesc:
|
||||
_include_ = "llvm/MC/MCInstrDesc.h"
|
||||
_include_ = "llvm/MC/MCInstrDesc.h"
|
||||
|
||||
TSFlags = Attr(getter=cast(Uint64, int), setter=cast(int, Uint64))
|
||||
getFlags = Method(cast(Unsigned, int))
|
||||
getOpcode = Method(cast(Unsigned, int))
|
||||
|
||||
def _ret_bool():
|
||||
return Method(cast(Bool, bool))
|
||||
|
||||
isReturn = _ret_bool()
|
||||
isCall = _ret_bool()
|
||||
isBarrier = _ret_bool()
|
||||
isBranch = _ret_bool()
|
||||
isTerminator = _ret_bool()
|
||||
isIndirectBranch = _ret_bool()
|
||||
isConditionalBranch = _ret_bool()
|
||||
isUnconditionalBranch = _ret_bool()
|
||||
|
||||
TSFlags = Attr(getter=cast(Uint64, int), setter=cast(int, Uint64))
|
||||
getFlags = Method(cast(Unsigned, int))
|
||||
getOpcode = Method(cast(Unsigned, int))
|
||||
|
||||
@MCSubtargetInfo
|
||||
class MCSubtargetInfo:
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ if llvm.version >= (3, 4):
|
|||
'is_indirect_branch',
|
||||
'is_call',
|
||||
'is_return',
|
||||
'is_terminator'
|
||||
'is_terminator',
|
||||
'is_barrier'
|
||||
]
|
||||
|
||||
print("print instructions")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue