llvmpy/test/target_info.py
anthony cantor 8f2c27ba41 added TargetRegistry_targets_list
this allows all targets to be enumerated. this is generally useful,
but i specifically wanted to be able to see which targets report
having a disassembler. it is necessary to init the various
target components in order for them to report that they have one,
thus i added InitializeAllDisassemblers and InitializeAllAsmParsers
to TargetSelect.py
2013-09-18 11:52:20 -05:00

30 lines
1 KiB
Python

from llvmpy.api import llvm;
llvm.InitializeAllTargets()
llvm.InitializeAllTargetInfos()
llvm.InitializeAllTargetMCs()
llvm.InitializeAllAsmPrinters()
llvm.InitializeAllDisassemblers()
llvm.InitializeAllAsmParsers()
mthds = (
("description:", "getShortDescription"),
("has JIT:", "hasJIT" ),
("has target machine:", "hasTargetMachine" ),
("has asm backend:", "hasMCAsmBackend" ),
("has asm parser:", "hasMCAsmParser" ),
("has asm printer:", "hasAsmPrinter" ),
("has disassembler:", "hasMCDisassembler" ),
("has inst printer:", "hasMCInstPrinter" ),
("has code emitter:", "hasMCCodeEmitter" ),
("has object streamer:", "hasMCObjectStreamer"),
("has asm streamer:", "hasAsmStreamer" )
)
for target in llvm.TargetRegistry.targetsList():
print("target %s" % target.getName())
fmt = "%3s%-25s%r"
for (desc, mthd) in mthds:
print(fmt % ("", desc, getattr(target, mthd)()))
print("")