From 3c06f0d590fe52a14038ecd468dc726da0e9d05e Mon Sep 17 00:00:00 2001 From: anthony cantor Date: Tue, 27 Aug 2013 14:25:05 -0600 Subject: [PATCH] add flags, ts_flags properties for Instr class --- llvm/mc/__init__.py | 12 ++++++++++++ test/example-disassemble.py | 1 + test/example-instruction-info.py | 2 -- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/llvm/mc/__init__.py b/llvm/mc/__init__.py index 5143e86..0ec8211 100644 --- a/llvm/mc/__init__.py +++ b/llvm/mc/__init__.py @@ -87,6 +87,18 @@ class Instr(object): return l + @property + def instr_desc(self): + return self.tm.instr_info.get(self.mcinst.getOpcode()) + + @property + def flags(self): + return self.instr_desc.getFlags() + + @property + def ts_flags(self): + return self.instr_desc.TSFlags + class BadInstr(Instr): pass diff --git a/test/example-disassemble.py b/test/example-disassemble.py index c1c3098..0958842 100644 --- a/test/example-disassemble.py +++ b/test/example-disassemble.py @@ -20,6 +20,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)) for line in str(inst).split("\n"): print("\t%s" % (line)) diff --git a/test/example-instruction-info.py b/test/example-instruction-info.py index 214b1e8..6ff341b 100644 --- a/test/example-instruction-info.py +++ b/test/example-instruction-info.py @@ -6,14 +6,12 @@ def main(): triple = "i386--" print("init start") - ''' api.llvm.InitializeAllTargets() api.llvm.InitializeAllTargetInfos() api.llvm.InitializeAllTargetMCs() api.llvm.InitializeAllAsmParsers() api.llvm.InitializeAllAsmPrinters() api.llvm.InitializeAllDisassemblers() - ''' print("init done\n") tm = llvm.target.TargetMachine.x86()