added example-instruction-info.py
demonstrates getting flag information for an opcode
This commit is contained in:
parent
7234b0d200
commit
0ed471d336
1 changed files with 37 additions and 0 deletions
37
test/example-instruction-info.py
Normal file
37
test/example-instruction-info.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import llvm.target
|
||||
from llvmpy import api, extra
|
||||
|
||||
|
||||
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()
|
||||
if not tm:
|
||||
print("error: failed to lookup target x86 \n")
|
||||
return 1
|
||||
|
||||
print("created target machine\n")
|
||||
|
||||
MII = tm.instr_info
|
||||
if not MII:
|
||||
print("error: no instruction info for target " + triple + "\n")
|
||||
return 1
|
||||
|
||||
print("created instr info\n")
|
||||
MID = MII.get(919) #int3
|
||||
print("INT3(%d): flags=0x%x, tsflags=0x%x\n" % (MID.getOpcode(), MID.getFlags(), MID.TSFlags))
|
||||
|
||||
return 0
|
||||
|
||||
exit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue