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
This commit is contained in:
anthony cantor 2013-08-11 17:27:23 -06:00 • committed by Siu Kwan Lam
commit 8f2c27ba41
4 changed files with 45 additions and 2 deletions

30
test/target_info.py Normal file
View file

@ -0,0 +1,30 @@
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("")