From 65c4558cac6d769325b051a50ceb8744d83da3fe Mon Sep 17 00:00:00 2001 From: anthony cantor Date: Tue, 3 Sep 2013 00:10:41 -0600 Subject: [PATCH] added opcode property to llvm.mc.Instr --- llvm/mc/__init__.py | 7 ++++++- test/example-disassemble.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/llvm/mc/__init__.py b/llvm/mc/__init__.py index f165d5d..b177827 100644 --- a/llvm/mc/__init__.py +++ b/llvm/mc/__init__.py @@ -91,7 +91,7 @@ class Instr(object): @property def instr_desc(self): - return self.tm.instr_info.get(self.mcinst.getOpcode()) + return self.tm.instr_info.get(self.opcode) @property def flags(self): @@ -101,6 +101,11 @@ class Instr(object): def ts_flags(self): return self.instr_desc.TSFlags + @property + def opcode(self): + return self.mcinst.getOpcode() + + class BadInstr(Instr): pass diff --git a/test/example-disassemble.py b/test/example-disassemble.py index 862036f..bb9d47b 100644 --- a/test/example-disassemble.py +++ b/test/example-disassemble.py @@ -21,7 +21,7 @@ if llvm.version >= (3, 4): else: print("\t0x%x ops = %s" % (addr, ops)) - print("\t\tflags = 0x%x, tsflags = 0x%x" % (inst.flags, inst.ts_flags)) + print("\t\topcode = 0x%x, flags = 0x%x, tsflags = 0x%x" % (inst.opcode, inst.flags, inst.ts_flags)) for line in str(inst).split("\n"): print("\t\t%-24s %s" % ("".join(map(lambda b: "%02x" % b, data))+":", line.strip()))