llvm.org GIT mirror llvm / fa27ff2
Kill Target specific ModuleMatchQuality stuff. - This was overkill and inconsistently implemented. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77114 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 11 years ago
16 changed file(s) with 13 addition(s) and 286 deletion(s). Raw diff Collapse all Expand all
4242 class Target {
4343 private:
4444 typedef unsigned (*TripleMatchQualityFnTy)(const std::string &TT);
45 typedef unsigned (*ModuleMatchQualityFnTy)(const Module &M);
46 typedef unsigned (*JITMatchQualityFnTy)();
4745
4846 typedef TargetMachine *(*TargetMachineCtorTy)(const Target &,
4947 const Module &,
6260 /// TripleMatchQualityFn - The target function for rating the match quality
6361 /// of a triple.
6462 TripleMatchQualityFnTy TripleMatchQualityFn;
65
66 /// ModuleMatchQualityFn - The target function for rating the match quality
67 /// of a module.
68 ModuleMatchQualityFnTy ModuleMatchQualityFn;
6963
7064 /// Name - The target name.
7165 const char *Name;
221215 /// string.
222216 /// @param TQualityFn - The triple match quality computation function for
223217 /// this target.
224 /// @param MQualityFn - The module match quality computation function for
225 /// this target.
226218 /// @param HasJIT - Whether the target supports JIT code
227219 /// generation.
228220 static void RegisterTarget(Target &T,
229221 const char *Name,
230222 const char *ShortDesc,
231223 Target::TripleMatchQualityFnTy TQualityFn,
232 Target::ModuleMatchQualityFnTy MQualityFn,
233224 bool HasJIT = false);
234225
235226 /// RegisterTargetMachine - Register a TargetMachine implementation for the
293284 /// struct FooInfo {
294285 /// static const bool HasJIT = ...;
295286 ///
296 /// static unsigned getJITMatchQuality() { ... }
297287 /// static unsigned getTripleMatchQuality(const std::string &) { ... }
298 /// static unsigned getModuleMatchQuality(const Module &) { ... }
299288 /// };
300289 /// }
301290 ///
307296 RegisterTarget(Target &T, const char *Name, const char *Desc) {
308297 TargetRegistry::RegisterTarget(T, Name, Desc,
309298 &TargetInfoImpl::getTripleMatchQuality,
310 &TargetInfoImpl::getModuleMatchQuality,
311299 TargetInfoImpl::HasJIT);
312300 }
313301 };
7373 const char *Name,
7474 const char *ShortDesc,
7575 Target::TripleMatchQualityFnTy TQualityFn,
76 Target::ModuleMatchQualityFnTy MQualityFn,
7776 bool HasJIT) {
78 assert(Name && ShortDesc && TQualityFn && MQualityFn &&
77 assert(Name && ShortDesc && TQualityFn &&
7978 "Missing required target information!");
8079
8180 // Check if this target has already been initialized, we allow this as a
9089 T.Name = Name;
9190 T.ShortDesc = ShortDesc;
9291 T.TripleMatchQualityFn = TQualityFn;
93 T.ModuleMatchQualityFn = MQualityFn;
9492 T.HasJIT = HasJIT;
9593 }
9694
2222 return 0;
2323 }
2424
25 static unsigned ARM_ModuleMatchQuality(const Module &M) {
26 // Check for a triple match.
27 if (unsigned Q = ARM_TripleMatchQuality(M.getTargetTriple()))
28 return Q;
29
30 // Otherwise if the target triple is non-empty, we don't match.
31 if (!M.getTargetTriple().empty()) return 0;
32
33 if (M.getEndianness() == Module::LittleEndian &&
34 M.getPointerSize() == Module::Pointer32)
35 return 10; // Weak match
36 else if (M.getEndianness() != Module::AnyEndianness ||
37 M.getPointerSize() != Module::AnyPointerSize)
38 return 0; // Match for some other target
39
40 return 0;
41 }
42
4325 Target llvm::TheThumbTarget;
4426
4527 static unsigned Thumb_TripleMatchQuality(const std::string &TT) {
5133 return 0;
5234 }
5335
54 static unsigned Thumb_ModuleMatchQuality(const Module &M) {
55 // Check for a triple match.
56 if (unsigned Q = Thumb_TripleMatchQuality(M.getTargetTriple()))
57 return Q;
58
59 // Otherwise if the target triple is non-empty, we don't match.
60 if (!M.getTargetTriple().empty()) return 0;
61
62 if (M.getEndianness() == Module::LittleEndian &&
63 M.getPointerSize() == Module::Pointer32)
64 return 10; // Weak match
65 else if (M.getEndianness() != Module::AnyEndianness ||
66 M.getPointerSize() != Module::AnyPointerSize)
67 return 0; // Match for some other target
68
69 return 0;
70 }
71
7236 extern "C" void LLVMInitializeARMTargetInfo() {
7337 TargetRegistry::RegisterTarget(TheARMTarget, "arm",
7438 "ARM",
7539 &ARM_TripleMatchQuality,
76 &ARM_ModuleMatchQuality,
7740 /*HasJIT=*/true);
7841
7942 TargetRegistry::RegisterTarget(TheThumbTarget, "thumb",
8043 "Thumb",
8144 &Thumb_TripleMatchQuality,
82 &Thumb_ModuleMatchQuality,
8345 /*HasJIT=*/true);
8446 }
2222 return 0;
2323 }
2424
25 static unsigned Alpha_ModuleMatchQuality(const Module &M) {
26 // Check for a triple match.
27 if (unsigned Q = Alpha_TripleMatchQuality(M.getTargetTriple()))
28 return Q;
29
30 // Otherwise if the target triple is non-empty, we don't match.
31 if (!M.getTargetTriple().empty()) return 0;
32
33 if (M.getEndianness() == Module::LittleEndian &&
34 M.getPointerSize() == Module::Pointer64)
35 return 10; // Weak match
36 else if (M.getEndianness() != Module::AnyEndianness ||
37 M.getPointerSize() != Module::AnyPointerSize)
38 return 0; // Match for some other target
39
40 return 0;
41 }
42
4325 extern "C" void LLVMInitializeAlphaTargetInfo() {
4426 TargetRegistry::RegisterTarget(TheAlphaTarget, "alpha",
4527 "Alpha [experimental]",
4628 &Alpha_TripleMatchQuality,
47 &Alpha_ModuleMatchQuality,
4829 /*HasJIT=*/true);
4930 }
1919 return 0;
2020 }
2121
22 static unsigned CBackend_ModuleMatchQuality(const Module &M) {
23 // This class always works, but must be requested explicitly on
24 // llc command line.
25 return 0;
26 }
27
2822 extern "C" void LLVMInitializeCBackendTargetInfo() {
2923 TargetRegistry::RegisterTarget(TheCBackendTarget, "c",
3024 "C backend",
31 &CBackend_TripleMatchQuality,
32 &CBackend_ModuleMatchQuality);
25 &CBackend_TripleMatchQuality);
3326 }
2424 return 0;
2525 }
2626
27 static unsigned CellSPU_ModuleMatchQuality(const Module &M) {
28 // Check for a triple match.
29 if (unsigned Q = CellSPU_TripleMatchQuality(M.getTargetTriple()))
30 return Q;
31
32 // Otherwise if the target triple is non-empty, we don't match.
33 if (!M.getTargetTriple().empty()) return 0;
34
35 return 0;
36 }
37
3827 extern "C" void LLVMInitializeCellSPUTargetInfo() {
3928 TargetRegistry::RegisterTarget(TheCellSPUTarget, "cellspu",
4029 "STI CBEA Cell SPU [experimental]",
41 &CellSPU_TripleMatchQuality,
42 &CellSPU_ModuleMatchQuality);
30 &CellSPU_TripleMatchQuality);
4331 }
1818 return 1;
1919 }
2020
21 static unsigned CppBackend_ModuleMatchQuality(const Module &M) {
22 // This class always works, but shouldn't be the default in most cases.
23 return 1;
24 }
25
2621 extern "C" void LLVMInitializeCppBackendTargetInfo() {
2722 TargetRegistry::RegisterTarget(TheCppBackendTarget, "cpp",
2823 "C++ backend",
29 &CppBackend_TripleMatchQuality,
30 &CppBackend_ModuleMatchQuality);
24 &CppBackend_TripleMatchQuality);
3125 }
1818 return 1;
1919 }
2020
21 static unsigned MSIL_ModuleMatchQuality(const Module &M) {
22 // This class always works, but shouldn't be the default in most cases.
23 return 1;
24 }
25
2621 extern "C" void LLVMInitializeMSILTargetInfo() {
2722 TargetRegistry::RegisterTarget(TheMSILTarget, "msil",
2823 "MSIL backend",
29 &MSIL_TripleMatchQuality,
30 &MSIL_ModuleMatchQuality);
24 &MSIL_TripleMatchQuality);
3125 }
2222 return 0;
2323 }
2424
25 static unsigned MSP430_ModuleMatchQuality(const Module &M) {
26 // Check for a triple match.
27 if (unsigned Q = MSP430_TripleMatchQuality(M.getTargetTriple()))
28 return Q;
29
30 // Otherwise if the target triple is non-empty, we don't match.
31 if (!M.getTargetTriple().empty()) return 0;
32
33 return 0;
34 }
35
3625 extern "C" void LLVMInitializeMSP430TargetInfo() {
3726 TargetRegistry::RegisterTarget(TheMSP430Target, "msp430",
3827 "MSP430 [experimental]",
39 &MSP430_TripleMatchQuality,
40 &MSP430_ModuleMatchQuality);
28 &MSP430_TripleMatchQuality);
4129 }
2525 return 0;
2626 }
2727
28 static unsigned Mips_ModuleMatchQuality(const Module &M) {
29 // Check for a triple match.
30 if (unsigned Q = Mips_TripleMatchQuality(M.getTargetTriple()))
31 return Q;
32
33 // Otherwise if the target triple is non-empty, we don't match.
34 if (!M.getTargetTriple().empty()) return 0;
35
36 return 0;
37 }
38
3928 Target llvm::TheMipselTarget;
4029
4130 static unsigned Mipsel_TripleMatchQuality(const std::string &TT) {
5342 return 0;
5443 }
5544
56 static unsigned Mipsel_ModuleMatchQuality(const Module &M) {
57 // Check for a triple match.
58 if (unsigned Q = Mipsel_TripleMatchQuality(M.getTargetTriple()))
59 return Q;
60
61 // Otherwise if the target triple is non-empty, we don't match.
62 if (!M.getTargetTriple().empty()) return 0;
63
64 return 0;
65 }
66
6745 extern "C" void LLVMInitializeMipsTargetInfo() {
6846 TargetRegistry::RegisterTarget(TheMipsTarget, "mips",
6947 "Mips",
70 &Mips_TripleMatchQuality,
71 &Mips_ModuleMatchQuality);
48 &Mips_TripleMatchQuality);
7249
7350 TargetRegistry::RegisterTarget(TheMipselTarget, "mipsel",
7451 "Mipsel",
75 &Mipsel_TripleMatchQuality,
76 &Mipsel_ModuleMatchQuality);
52 &Mipsel_TripleMatchQuality);
7753 }
1717 return 0;
1818 }
1919
20 static unsigned PIC16_ModuleMatchQuality(const Module &M) {
21 return 0;
22 }
23
2420 Target llvm::TheCooperTarget;
2521
2622 static unsigned Cooper_TripleMatchQuality(const std::string &TT) {
2723 return 0;
2824 }
2925
30 static unsigned Cooper_ModuleMatchQuality(const Module &M) {
31 return 0;
32 }
33
3426 extern "C" void LLVMInitializePIC16TargetInfo() {
3527 TargetRegistry::RegisterTarget(ThePIC16Target, "pic16",
3628 "PIC16 14-bit [experimental]",
37 &PIC16_TripleMatchQuality,
38 &PIC16_ModuleMatchQuality);
29 &PIC16_TripleMatchQuality);
3930
4031 TargetRegistry::RegisterTarget(TheCooperTarget, "cooper",
4132 "PIC16 Cooper [experimental]",
42 &Cooper_TripleMatchQuality,
43 &Cooper_ModuleMatchQuality);
33 &Cooper_TripleMatchQuality);
4434 }
2121 return 0;
2222 }
2323
24 static unsigned PPC32_ModuleMatchQuality(const Module &M) {
25 // Check for a triple match.
26 if (unsigned Q = PPC32_TripleMatchQuality(M.getTargetTriple()))
27 return Q;
28
29 // Otherwise if the target triple is non-empty, we don't match.
30 if (!M.getTargetTriple().empty()) return 0;
31
32 if (M.getEndianness() == Module::BigEndian &&
33 M.getPointerSize() == Module::Pointer64)
34 return 10; // Weak match
35 else if (M.getEndianness() != Module::AnyEndianness ||
36 M.getPointerSize() != Module::AnyPointerSize)
37 return 0; // Match for some other target
38
39 return 0;
40 }
41
4224 Target llvm::ThePPC64Target;
4325
4426 static unsigned PPC64_TripleMatchQuality(const std::string &TT) {
4931 return 0;
5032 }
5133
52 static unsigned PPC64_ModuleMatchQuality(const Module &M) {
53 // Check for a triple match.
54 if (unsigned Q = PPC64_TripleMatchQuality(M.getTargetTriple()))
55 return Q;
56
57 // Otherwise if the target triple is non-empty, we don't match.
58 if (!M.getTargetTriple().empty()) return 0;
59
60 if (M.getEndianness() == Module::BigEndian &&
61 M.getPointerSize() == Module::Pointer64)
62 return 10; // Weak match
63 else if (M.getEndianness() != Module::AnyEndianness ||
64 M.getPointerSize() != Module::AnyPointerSize)
65 return 0; // Match for some other target
66
67 return 0;
68 }
69
7034 extern "C" void LLVMInitializePowerPCTargetInfo() {
7135 TargetRegistry::RegisterTarget(ThePPC32Target, "ppc32",
7236 "PowerPC 32",
7337 &PPC32_TripleMatchQuality,
74 &PPC32_ModuleMatchQuality,
7538 /*HasJIT=*/true);
7639
7740 TargetRegistry::RegisterTarget(ThePPC64Target, "ppc64",
7841 "PowerPC 64",
7942 &PPC64_TripleMatchQuality,
80 &PPC64_ModuleMatchQuality,
8143 /*HasJIT=*/true);
8244 }
2020 return 0;
2121 }
2222
23 static unsigned Sparc_ModuleMatchQuality(const Module &M) {
24 // Check for a triple match.
25 if (unsigned Q = Sparc_TripleMatchQuality(M.getTargetTriple()))
26 return Q;
27
28 // Otherwise if the target triple is non-empty, we don't match.
29 if (!M.getTargetTriple().empty()) return 0;
30
31 // FIXME: This is bad, the target matching algorithm shouldn't depend on the
32 // host.
33 if (M.getEndianness() == Module::BigEndian &&
34 M.getPointerSize() == Module::Pointer32)
35 #ifdef __sparc__
36 return 20; // BE/32 ==> Prefer sparc on sparc
37 #else
38 return 5; // BE/32 ==> Prefer ppc elsewhere
39 #endif
40 else if (M.getEndianness() != Module::AnyEndianness ||
41 M.getPointerSize() != Module::AnyPointerSize)
42 return 0; // Match for some other target
43
44 #if defined(__sparc__)
45 return 10;
46 #else
47 return 0;
48 #endif
49 }
50
5123 extern "C" void LLVMInitializeSparcTargetInfo() {
5224 TargetRegistry::RegisterTarget(TheSparcTarget, "sparc",
5325 "Sparc",
54 &Sparc_TripleMatchQuality,
55 &Sparc_ModuleMatchQuality);
26 &Sparc_TripleMatchQuality);
5627 }
2222 return 0;
2323 }
2424
25 static unsigned SystemZ_ModuleMatchQuality(const Module &M) {
26 // Check for a triple match.
27 if (unsigned Q = SystemZ_TripleMatchQuality(M.getTargetTriple()))
28 return Q;
29
30 // Otherwise we don't match.
31 return 0;
32 }
33
3425 extern "C" void LLVMInitializeSystemZTargetInfo() {
3526 TargetRegistry::RegisterTarget(TheSystemZTarget, "systemz",
3627 "SystemZ",
37 &SystemZ_TripleMatchQuality,
38 &SystemZ_ModuleMatchQuality);
28 &SystemZ_TripleMatchQuality);
3929 }
2222 return 0;
2323 }
2424
25 static unsigned X86_32_ModuleMatchQuality(const Module &M) {
26 // Check for a triple match.
27 if (unsigned Q = X86_32_TripleMatchQuality(M.getTargetTriple()))
28 return Q;
29
30 // If the target triple is something non-X86, we don't match.
31 if (!M.getTargetTriple().empty()) return 0;
32
33 if (M.getEndianness() == Module::LittleEndian &&
34 M.getPointerSize() == Module::Pointer32)
35 return 10; // Weak match
36 else if (M.getEndianness() != Module::AnyEndianness ||
37 M.getPointerSize() != Module::AnyPointerSize)
38 return 0; // Match for some other target
39
40 return 0;
41 }
42
4325 Target llvm::TheX86_64Target;
4426
4527 static unsigned X86_64_TripleMatchQuality(const std::string &TT) {
5133 return 0;
5234 }
5335
54 static unsigned X86_64_ModuleMatchQuality(const Module &M) {
55 // Check for a triple match.
56 if (unsigned Q = X86_64_TripleMatchQuality(M.getTargetTriple()))
57 return Q;
58
59 // If the target triple is something non-X86-64, we don't match.
60 if (!M.getTargetTriple().empty()) return 0;
61
62 if (M.getEndianness() == Module::LittleEndian &&
63 M.getPointerSize() == Module::Pointer64)
64 return 10; // Weak match
65 else if (M.getEndianness() != Module::AnyEndianness ||
66 M.getPointerSize() != Module::AnyPointerSize)
67 return 0; // Match for some other target
68
69 return 0;
70 }
71
7236 extern "C" void LLVMInitializeX86TargetInfo() {
7337 TargetRegistry::RegisterTarget(TheX86_32Target, "x86",
7438 "32-bit X86: Pentium-Pro and above",
7539 &X86_32_TripleMatchQuality,
76 &X86_32_ModuleMatchQuality,
7740 /*HasJIT=*/true);
7841
7942 TargetRegistry::RegisterTarget(TheX86_64Target, "x86-64",
8043 "64-bit X86: EM64T and AMD64",
8144 &X86_64_TripleMatchQuality,
82 &X86_64_ModuleMatchQuality,
8345 /*HasJIT=*/true);
8446 }
2020 return 0;
2121 }
2222
23 static unsigned XCore_ModuleMatchQuality(const Module &M) {
24 // Check for a triple match.
25 if (unsigned Q = XCore_TripleMatchQuality(M.getTargetTriple()))
26 return Q;
27
28 // Otherwise we don't match.
29 return 0;
30 }
31
3223 extern "C" void LLVMInitializeXCoreTargetInfo() {
3324 TargetRegistry::RegisterTarget(TheXCoreTarget, "xcore",
3425 "XCore",
35 &XCore_TripleMatchQuality,
36 &XCore_ModuleMatchQuality);
26 &XCore_TripleMatchQuality);
3727 }