added functionality to llvm.mc.Instr to print itself

uses binding of printInst on MCInstPrinter for printing
instruction.

also fixed a bug in llvm.mc.Disassembler.decode: idx should
start at zero, and we should pass code.getBase() + idx to
getInstruction. idx must start at zero because the while loop
compares it against code.getExtent() which returns only the
length of bs.
This commit is contained in:
anthony cantor 2013-08-18 16:39:26 -06:00 • committed by Siu Kwan Lam
commit 8dbfc377ad
4 changed files with 50 additions and 18 deletions

View file

@ -225,6 +225,19 @@ class TargetMachine(llvm.Wrapper):
return self._dasm
@property
def inst_printer(self):
if not getattr(self, '_mip', False):
self._mip = self.target.createMCInstPrinter(
self.asm_info.getAssemblerDialect(),
self.asm_info,
self.instr_info,
self.reg_info,
self.subtarget_info
)
return self._mip
def is_little_endian(self):
return self.asm_info.isLittleEndian()