added methods to Instr which describe possible branch/terminator properties

This commit is contained in:
anthony cantor 2013-09-03 01:21:06 -06:00 • committed by Siu Kwan Lam
commit 3e77a55de3
3 changed files with 45 additions and 0 deletions

View file

@ -9,6 +9,16 @@ if llvm.version >= (3, 4):
llvm.target.initialize_all()
def print_instructions(dasm, bs):
branch_properties = [
'is_branch',
'is_cond_branch',
'is_uncond_branch',
'is_indirect_branch',
'is_call',
'is_return',
'is_terminator'
]
print("print instructions")
for (addr, data, inst) in dasm.decode(bs, 0x4000):
@ -25,6 +35,9 @@ if llvm.version >= (3, 4):
for line in str(inst).split("\n"):
print("\t\t%-24s %s" % ("".join(map(lambda b: "%02x" % b, data))+":", line.strip()))
for bp in branch_properties:
print("\t\t%-22s%r" % (bp+":", getattr(inst, bp)() ))
x86 = TargetMachine.x86()
print("x86: LE=%s" % x86.is_little_endian())