llvm.org GIT mirror llvm / 48ac8e9
Move TargetRegistry.cpp from lib/Support to lib/Target where it belongs. The header file was already properly located. The previous need for it in Support had to do with the version string printing which was fixed in r135757. Also update build dependencies where libraries that needed the functionality of the Target library (in the form of the TargetRegistry) were picking it up via Support. This is pretty pervasive, essentially every TargetInfo library (ARMInfo, etc) uses TargetRegistry, making it depend on Target. All of these were previously just sneaking by. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135760 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 8 years ago
5 changed file(s) with 139 addition(s) and 139 deletion(s). Raw diff Collapse all Expand all
22 set(MSVC_LIB_DEPS_LLVMARMCodeGen LLVMARMAsmPrinter LLVMARMDesc LLVMARMInfo LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget)
33 set(MSVC_LIB_DEPS_LLVMARMDesc LLVMARMInfo LLVMMC LLVMSupport)
44 set(MSVC_LIB_DEPS_LLVMARMDisassembler LLVMARMDesc LLVMARMInfo LLVMMC LLVMSupport)
5 set(MSVC_LIB_DEPS_LLVMARMInfo LLVMMC LLVMSupport)
5 set(MSVC_LIB_DEPS_LLVMARMInfo LLVMMC LLVMSupport LLVMTarget)
66 set(MSVC_LIB_DEPS_LLVMAlphaCodeGen LLVMAlphaDesc LLVMAlphaInfo LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget)
77 set(MSVC_LIB_DEPS_LLVMAlphaDesc LLVMAlphaInfo LLVMMC)
8 set(MSVC_LIB_DEPS_LLVMAlphaInfo LLVMMC LLVMSupport)
8 set(MSVC_LIB_DEPS_LLVMAlphaInfo LLVMMC LLVMSupport LLVMTarget)
99 set(MSVC_LIB_DEPS_LLVMAnalysis LLVMCore LLVMSupport LLVMTarget)
1010 set(MSVC_LIB_DEPS_LLVMArchive LLVMBitReader LLVMCore LLVMSupport)
1111 set(MSVC_LIB_DEPS_LLVMAsmParser LLVMCore LLVMSupport)
1414 set(MSVC_LIB_DEPS_LLVMBitWriter LLVMCore LLVMSupport)
1515 set(MSVC_LIB_DEPS_LLVMBlackfinCodeGen LLVMAsmPrinter LLVMBlackfinDesc LLVMBlackfinInfo LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget)
1616 set(MSVC_LIB_DEPS_LLVMBlackfinDesc LLVMBlackfinInfo LLVMMC)
17 set(MSVC_LIB_DEPS_LLVMBlackfinInfo LLVMMC LLVMSupport)
17 set(MSVC_LIB_DEPS_LLVMBlackfinInfo LLVMMC LLVMSupport LLVMTarget)
1818 set(MSVC_LIB_DEPS_LLVMCBackend LLVMAnalysis LLVMCBackendInfo LLVMCodeGen LLVMCore LLVMMC LLVMScalarOpts LLVMSupport LLVMTarget LLVMTransformUtils)
19 set(MSVC_LIB_DEPS_LLVMCBackendInfo LLVMMC LLVMSupport)
19 set(MSVC_LIB_DEPS_LLVMCBackendInfo LLVMMC LLVMSupport LLVMTarget)
2020 set(MSVC_LIB_DEPS_LLVMCellSPUCodeGen LLVMAsmPrinter LLVMCellSPUDesc LLVMCellSPUInfo LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget)
2121 set(MSVC_LIB_DEPS_LLVMCellSPUDesc LLVMCellSPUInfo LLVMMC)
22 set(MSVC_LIB_DEPS_LLVMCellSPUInfo LLVMMC LLVMSupport)
22 set(MSVC_LIB_DEPS_LLVMCellSPUInfo LLVMMC LLVMSupport LLVMTarget)
2323 set(MSVC_LIB_DEPS_LLVMCodeGen LLVMAnalysis LLVMCore LLVMMC LLVMScalarOpts LLVMSupport LLVMTarget LLVMTransformUtils)
2424 set(MSVC_LIB_DEPS_LLVMCore LLVMSupport)
2525 set(MSVC_LIB_DEPS_LLVMCppBackend LLVMCore LLVMCppBackendInfo LLVMSupport LLVMTarget)
26 set(MSVC_LIB_DEPS_LLVMCppBackendInfo LLVMMC LLVMSupport)
26 set(MSVC_LIB_DEPS_LLVMCppBackendInfo LLVMMC LLVMTarget)
2727 set(MSVC_LIB_DEPS_LLVMExecutionEngine LLVMCore LLVMMC LLVMSupport LLVMTarget)
2828 set(MSVC_LIB_DEPS_LLVMInstCombine LLVMAnalysis LLVMCore LLVMSupport LLVMTarget LLVMTransformUtils)
2929 set(MSVC_LIB_DEPS_LLVMInstrumentation LLVMAnalysis LLVMCore LLVMSupport LLVMTransformUtils)
3535 set(MSVC_LIB_DEPS_LLVMMBlazeCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMBlazeAsmPrinter LLVMMBlazeDesc LLVMMBlazeInfo LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget)
3636 set(MSVC_LIB_DEPS_LLVMMBlazeDesc LLVMMBlazeInfo LLVMMC LLVMSupport)
3737 set(MSVC_LIB_DEPS_LLVMMBlazeDisassembler LLVMMBlazeCodeGen LLVMMBlazeDesc LLVMMBlazeInfo LLVMMC)
38 set(MSVC_LIB_DEPS_LLVMMBlazeInfo LLVMMC LLVMSupport)
38 set(MSVC_LIB_DEPS_LLVMMBlazeInfo LLVMMC LLVMSupport LLVMTarget)
3939 set(MSVC_LIB_DEPS_LLVMMC LLVMSupport)
40 set(MSVC_LIB_DEPS_LLVMMCDisassembler LLVMARMAsmParser LLVMARMCodeGen LLVMARMDesc LLVMARMDisassembler LLVMARMInfo LLVMAlphaCodeGen LLVMAlphaDesc LLVMAlphaInfo LLVMBlackfinCodeGen LLVMBlackfinDesc LLVMBlackfinInfo LLVMCBackend LLVMCBackendInfo LLVMCellSPUCodeGen LLVMCellSPUDesc LLVMCellSPUInfo LLVMCppBackend LLVMCppBackendInfo LLVMMBlazeAsmParser LLVMMBlazeCodeGen LLVMMBlazeDesc LLVMMBlazeDisassembler LLVMMBlazeInfo LLVMMC LLVMMCParser LLVMMSP430CodeGen LLVMMSP430Desc LLVMMSP430Info LLVMMipsCodeGen LLVMMipsDesc LLVMMipsInfo LLVMPTXCodeGen LLVMPTXDesc LLVMPTXInfo LLVMPowerPCCodeGen LLVMPowerPCDesc LLVMPowerPCInfo LLVMSparcCodeGen LLVMSparcDesc LLVMSparcInfo LLVMSupport LLVMSystemZCodeGen LLVMSystemZDesc LLVMSystemZInfo LLVMX86AsmParser LLVMX86CodeGen LLVMX86Desc LLVMX86Disassembler LLVMX86Info LLVMXCoreCodeGen LLVMXCoreDesc LLVMXCoreInfo)
40 set(MSVC_LIB_DEPS_LLVMMCDisassembler LLVMARMAsmParser LLVMARMCodeGen LLVMARMDesc LLVMARMDisassembler LLVMARMInfo LLVMAlphaCodeGen LLVMAlphaDesc LLVMAlphaInfo LLVMBlackfinCodeGen LLVMBlackfinDesc LLVMBlackfinInfo LLVMCBackend LLVMCBackendInfo LLVMCellSPUCodeGen LLVMCellSPUDesc LLVMCellSPUInfo LLVMCppBackend LLVMCppBackendInfo LLVMMBlazeAsmParser LLVMMBlazeCodeGen LLVMMBlazeDesc LLVMMBlazeDisassembler LLVMMBlazeInfo LLVMMC LLVMMCParser LLVMMSP430CodeGen LLVMMSP430Desc LLVMMSP430Info LLVMMipsCodeGen LLVMMipsDesc LLVMMipsInfo LLVMPTXCodeGen LLVMPTXDesc LLVMPTXInfo LLVMPowerPCCodeGen LLVMPowerPCDesc LLVMPowerPCInfo LLVMSparcCodeGen LLVMSparcDesc LLVMSparcInfo LLVMSupport LLVMSystemZCodeGen LLVMSystemZDesc LLVMSystemZInfo LLVMTarget LLVMX86AsmParser LLVMX86CodeGen LLVMX86Desc LLVMX86Disassembler LLVMX86Info LLVMXCoreCodeGen LLVMXCoreDesc LLVMXCoreInfo)
4141 set(MSVC_LIB_DEPS_LLVMMCJIT LLVMCore LLVMExecutionEngine LLVMRuntimeDyld LLVMSupport LLVMTarget)
4242 set(MSVC_LIB_DEPS_LLVMMCParser LLVMMC LLVMSupport)
4343 set(MSVC_LIB_DEPS_LLVMMSP430AsmPrinter LLVMMC LLVMSupport)
4444 set(MSVC_LIB_DEPS_LLVMMSP430CodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMMSP430AsmPrinter LLVMMSP430Desc LLVMMSP430Info LLVMSelectionDAG LLVMSupport LLVMTarget)
4545 set(MSVC_LIB_DEPS_LLVMMSP430Desc LLVMMC LLVMMSP430Info)
46 set(MSVC_LIB_DEPS_LLVMMSP430Info LLVMMC LLVMSupport)
46 set(MSVC_LIB_DEPS_LLVMMSP430Info LLVMMC LLVMSupport LLVMTarget)
4747 set(MSVC_LIB_DEPS_LLVMMipsAsmPrinter LLVMMC LLVMSupport)
4848 set(MSVC_LIB_DEPS_LLVMMipsCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMMipsAsmPrinter LLVMMipsDesc LLVMMipsInfo LLVMSelectionDAG LLVMSupport LLVMTarget)
4949 set(MSVC_LIB_DEPS_LLVMMipsDesc LLVMMC LLVMMipsInfo LLVMSupport)
50 set(MSVC_LIB_DEPS_LLVMMipsInfo LLVMMC LLVMSupport)
50 set(MSVC_LIB_DEPS_LLVMMipsInfo LLVMMC LLVMSupport LLVMTarget)
5151 set(MSVC_LIB_DEPS_LLVMObject LLVMSupport)
5252 set(MSVC_LIB_DEPS_LLVMPTXCodeGen LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMPTXDesc LLVMPTXInfo LLVMSelectionDAG LLVMSupport LLVMTarget)
5353 set(MSVC_LIB_DEPS_LLVMPTXDesc LLVMMC LLVMPTXInfo LLVMSupport)
54 set(MSVC_LIB_DEPS_LLVMPTXInfo LLVMMC LLVMSupport)
54 set(MSVC_LIB_DEPS_LLVMPTXInfo LLVMMC LLVMSupport LLVMTarget)
5555 set(MSVC_LIB_DEPS_LLVMPowerPCAsmPrinter LLVMMC LLVMSupport)
5656 set(MSVC_LIB_DEPS_LLVMPowerPCCodeGen LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMPowerPCAsmPrinter LLVMPowerPCDesc LLVMPowerPCInfo LLVMSelectionDAG LLVMSupport LLVMTarget)
5757 set(MSVC_LIB_DEPS_LLVMPowerPCDesc LLVMMC LLVMPowerPCInfo LLVMSupport)
58 set(MSVC_LIB_DEPS_LLVMPowerPCInfo LLVMMC LLVMSupport)
58 set(MSVC_LIB_DEPS_LLVMPowerPCInfo LLVMMC LLVMSupport LLVMTarget)
5959 set(MSVC_LIB_DEPS_LLVMRuntimeDyld LLVMObject LLVMSupport)
6060 set(MSVC_LIB_DEPS_LLVMScalarOpts LLVMAnalysis LLVMCore LLVMInstCombine LLVMSupport LLVMTarget LLVMTransformUtils)
6161 set(MSVC_LIB_DEPS_LLVMSelectionDAG LLVMAnalysis LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMTarget LLVMTransformUtils)
6262 set(MSVC_LIB_DEPS_LLVMSparcCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSparcDesc LLVMSparcInfo LLVMSupport LLVMTarget)
6363 set(MSVC_LIB_DEPS_LLVMSparcDesc LLVMMC LLVMSparcInfo LLVMSupport)
64 set(MSVC_LIB_DEPS_LLVMSparcInfo LLVMMC LLVMSupport)
64 set(MSVC_LIB_DEPS_LLVMSparcInfo LLVMMC LLVMSupport LLVMTarget)
6565 set(MSVC_LIB_DEPS_LLVMSupport )
6666 set(MSVC_LIB_DEPS_LLVMSystemZCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMSystemZDesc LLVMSystemZInfo LLVMTarget)
6767 set(MSVC_LIB_DEPS_LLVMSystemZDesc LLVMMC LLVMSystemZInfo)
68 set(MSVC_LIB_DEPS_LLVMSystemZInfo LLVMMC LLVMSupport)
68 set(MSVC_LIB_DEPS_LLVMSystemZInfo LLVMMC LLVMSupport LLVMTarget)
6969 set(MSVC_LIB_DEPS_LLVMTarget LLVMCore LLVMMC LLVMSupport)
7070 set(MSVC_LIB_DEPS_LLVMTransformUtils LLVMAnalysis LLVMCore LLVMSupport LLVMTarget LLVMipa)
7171 set(MSVC_LIB_DEPS_LLVMX86AsmParser LLVMMC LLVMMCParser LLVMSupport LLVMTarget LLVMX86Info)
7373 set(MSVC_LIB_DEPS_LLVMX86CodeGen LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget LLVMX86AsmPrinter LLVMX86Desc LLVMX86Info LLVMX86Utils)
7474 set(MSVC_LIB_DEPS_LLVMX86Desc LLVMMC LLVMSupport LLVMX86Info)
7575 set(MSVC_LIB_DEPS_LLVMX86Disassembler LLVMMC LLVMSupport LLVMX86Info)
76 set(MSVC_LIB_DEPS_LLVMX86Info LLVMMC LLVMSupport)
76 set(MSVC_LIB_DEPS_LLVMX86Info LLVMMC LLVMSupport LLVMTarget)
7777 set(MSVC_LIB_DEPS_LLVMX86Utils LLVMCore LLVMSupport)
7878 set(MSVC_LIB_DEPS_LLVMXCoreCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget LLVMXCoreDesc LLVMXCoreInfo)
7979 set(MSVC_LIB_DEPS_LLVMXCoreDesc LLVMMC LLVMXCoreInfo)
80 set(MSVC_LIB_DEPS_LLVMXCoreInfo LLVMMC LLVMSupport)
80 set(MSVC_LIB_DEPS_LLVMXCoreInfo LLVMMC LLVMSupport LLVMTarget)
8181 set(MSVC_LIB_DEPS_LLVMipa LLVMAnalysis LLVMCore LLVMSupport)
8282 set(MSVC_LIB_DEPS_LLVMipo LLVMAnalysis LLVMCore LLVMScalarOpts LLVMSupport LLVMTarget LLVMTransformUtils LLVMipa)
4141 StringPool.cpp
4242 StringRef.cpp
4343 SystemUtils.cpp
44 TargetRegistry.cpp
4544 Timer.cpp
4645 ToolOutputFile.cpp
4746 Triple.cpp
+0
-122
lib/Support/TargetRegistry.cpp less more
None //===--- TargetRegistry.cpp - Target registration -------------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/ADT/STLExtras.h"
10 #include "llvm/ADT/StringRef.h"
11 #include "llvm/Target/TargetRegistry.h"
12 #include "llvm/Support/Host.h"
13 #include "llvm/Support/raw_ostream.h"
14 #include
15 #include
16 using namespace llvm;
17
18 // Clients are responsible for avoid race conditions in registration.
19 static Target *FirstTarget = 0;
20
21 TargetRegistry::iterator TargetRegistry::begin() {
22 return iterator(FirstTarget);
23 }
24
25 const Target *TargetRegistry::lookupTarget(const std::string &TT,
26 std::string &Error) {
27 // Provide special warning when no targets are initialized.
28 if (begin() == end()) {
29 Error = "Unable to find target for this triple (no targets are registered)";
30 return 0;
31 }
32 const Target *Best = 0, *EquallyBest = 0;
33 unsigned BestQuality = 0;
34 for (iterator it = begin(), ie = end(); it != ie; ++it) {
35 if (unsigned Qual = it->TripleMatchQualityFn(TT)) {
36 if (!Best || Qual > BestQuality) {
37 Best = &*it;
38 EquallyBest = 0;
39 BestQuality = Qual;
40 } else if (Qual == BestQuality)
41 EquallyBest = &*it;
42 }
43 }
44
45 if (!Best) {
46 Error = "No available targets are compatible with this triple, "
47 "see -version for the available targets.";
48 return 0;
49 }
50
51 // Otherwise, take the best target, but make sure we don't have two equally
52 // good best targets.
53 if (EquallyBest) {
54 Error = std::string("Cannot choose between targets \"") +
55 Best->Name + "\" and \"" + EquallyBest->Name + "\"";
56 return 0;
57 }
58
59 return Best;
60 }
61
62 void TargetRegistry::RegisterTarget(Target &T,
63 const char *Name,
64 const char *ShortDesc,
65 Target::TripleMatchQualityFnTy TQualityFn,
66 bool HasJIT) {
67 assert(Name && ShortDesc && TQualityFn &&
68 "Missing required target information!");
69
70 // Check if this target has already been initialized, we allow this as a
71 // convenience to some clients.
72 if (T.Name)
73 return;
74
75 // Add to the list of targets.
76 T.Next = FirstTarget;
77 FirstTarget = &T;
78
79 T.Name = Name;
80 T.ShortDesc = ShortDesc;
81 T.TripleMatchQualityFn = TQualityFn;
82 T.HasJIT = HasJIT;
83 }
84
85 const Target *TargetRegistry::getClosestTargetForJIT(std::string &Error) {
86 const Target *TheTarget = lookupTarget(sys::getHostTriple(), Error);
87
88 if (TheTarget && !TheTarget->hasJIT()) {
89 Error = "No JIT compatible target available for this host";
90 return 0;
91 }
92
93 return TheTarget;
94 }
95
96 static int TargetArraySortFn(const void *LHS, const void *RHS) {
97 typedef std::pair pair_ty;
98 return ((const pair_ty*)LHS)->first.compare(((const pair_ty*)RHS)->first);
99 }
100
101 void TargetRegistry::printRegisteredTargetsForVersion() {
102 std::vector > Targets;
103 size_t Width = 0;
104 for (TargetRegistry::iterator I = TargetRegistry::begin(),
105 E = TargetRegistry::end();
106 I != E; ++I) {
107 Targets.push_back(std::make_pair(I->getName(), &*I));
108 Width = std::max(Width, Targets.back().first.size());
109 }
110 array_pod_sort(Targets.begin(), Targets.end(), TargetArraySortFn);
111
112 raw_ostream &OS = outs();
113 OS << " Registered Targets:\n";
114 for (unsigned i = 0, e = Targets.size(); i != e; ++i) {
115 OS << " " << Targets[i].first;
116 OS.indent(Width - Targets[i].first.size()) << " - "
117 << Targets[i].second->getShortDescription() << '\n';
118 }
119 if (Targets.empty())
120 OS << " (none)\n";
121 }
1010 TargetLoweringObjectFile.cpp
1111 TargetMachine.cpp
1212 TargetRegisterInfo.cpp
13 TargetRegistry.cpp
1314 TargetSubtargetInfo.cpp
1415 )
1516
0 //===--- TargetRegistry.cpp - Target registration -------------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/ADT/STLExtras.h"
10 #include "llvm/ADT/StringRef.h"
11 #include "llvm/Target/TargetRegistry.h"
12 #include "llvm/Support/Host.h"
13 #include "llvm/Support/raw_ostream.h"
14 #include
15 #include
16 using namespace llvm;
17
18 // Clients are responsible for avoid race conditions in registration.
19 static Target *FirstTarget = 0;
20
21 TargetRegistry::iterator TargetRegistry::begin() {
22 return iterator(FirstTarget);
23 }
24
25 const Target *TargetRegistry::lookupTarget(const std::string &TT,
26 std::string &Error) {
27 // Provide special warning when no targets are initialized.
28 if (begin() == end()) {
29 Error = "Unable to find target for this triple (no targets are registered)";
30 return 0;
31 }
32 const Target *Best = 0, *EquallyBest = 0;
33 unsigned BestQuality = 0;
34 for (iterator it = begin(), ie = end(); it != ie; ++it) {
35 if (unsigned Qual = it->TripleMatchQualityFn(TT)) {
36 if (!Best || Qual > BestQuality) {
37 Best = &*it;
38 EquallyBest = 0;
39 BestQuality = Qual;
40 } else if (Qual == BestQuality)
41 EquallyBest = &*it;
42 }
43 }
44
45 if (!Best) {
46 Error = "No available targets are compatible with this triple, "
47 "see -version for the available targets.";
48 return 0;
49 }
50
51 // Otherwise, take the best target, but make sure we don't have two equally
52 // good best targets.
53 if (EquallyBest) {
54 Error = std::string("Cannot choose between targets \"") +
55 Best->Name + "\" and \"" + EquallyBest->Name + "\"";
56 return 0;
57 }
58
59 return Best;
60 }
61
62 void TargetRegistry::RegisterTarget(Target &T,
63 const char *Name,
64 const char *ShortDesc,
65 Target::TripleMatchQualityFnTy TQualityFn,
66 bool HasJIT) {
67 assert(Name && ShortDesc && TQualityFn &&
68 "Missing required target information!");
69
70 // Check if this target has already been initialized, we allow this as a
71 // convenience to some clients.
72 if (T.Name)
73 return;
74
75 // Add to the list of targets.
76 T.Next = FirstTarget;
77 FirstTarget = &T;
78
79 T.Name = Name;
80 T.ShortDesc = ShortDesc;
81 T.TripleMatchQualityFn = TQualityFn;
82 T.HasJIT = HasJIT;
83 }
84
85 const Target *TargetRegistry::getClosestTargetForJIT(std::string &Error) {
86 const Target *TheTarget = lookupTarget(sys::getHostTriple(), Error);
87
88 if (TheTarget && !TheTarget->hasJIT()) {
89 Error = "No JIT compatible target available for this host";
90 return 0;
91 }
92
93 return TheTarget;
94 }
95
96 static int TargetArraySortFn(const void *LHS, const void *RHS) {
97 typedef std::pair pair_ty;
98 return ((const pair_ty*)LHS)->first.compare(((const pair_ty*)RHS)->first);
99 }
100
101 void TargetRegistry::printRegisteredTargetsForVersion() {
102 std::vector > Targets;
103 size_t Width = 0;
104 for (TargetRegistry::iterator I = TargetRegistry::begin(),
105 E = TargetRegistry::end();
106 I != E; ++I) {
107 Targets.push_back(std::make_pair(I->getName(), &*I));
108 Width = std::max(Width, Targets.back().first.size());
109 }
110 array_pod_sort(Targets.begin(), Targets.end(), TargetArraySortFn);
111
112 raw_ostream &OS = outs();
113 OS << " Registered Targets:\n";
114 for (unsigned i = 0, e = Targets.size(); i != e; ++i) {
115 OS << " " << Targets[i].first;
116 OS.indent(Width - Targets[i].first.size()) << " - "
117 << Targets[i].second->getShortDescription() << '\n';
118 }
119 if (Targets.empty())
120 OS << " (none)\n";
121 }