llvm.org GIT mirror llvm / 4246790
Register Target's TargetMachine and AsmPrinter in the new registry. - This abuses TargetMachineRegistry's constructor for now, this will get cleaned up in time. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75762 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 11 years ago
37 changed file(s) with 134 addition(s) and 59 deletion(s). Raw diff Collapse all Expand all
1818
1919 #include "llvm/Module.h"
2020 #include "llvm/Support/Registry.h"
21 #include "llvm/Target/TargetRegistry.h"
2122
2223 namespace llvm {
2324 class Module;
7576
7677 template
7778 struct RegisterTarget {
78 RegisterTarget(const char *Name, const char *ShortDesc)
79 RegisterTarget(Target &T, const char *Name, const char *ShortDesc)
7980 : Entry(Name, ShortDesc, &Allocator,
8081 &TargetMachineImpl::getModuleMatchQuality,
8182 &TargetMachineImpl::getJITMatchQuality),
82 Node(Entry)
83 {}
83 Node(Entry) {
84 TargetRegistry::RegisterTargetMachine(T, &Allocator);
85 }
8486
8587 private:
8688 TargetMachineRegistry::entry Entry;
9393
9494 FunctionPass *createARMISelDag(ARMBaseTargetMachine &TM);
9595 FunctionPass *createARMCodePrinterPass(formatted_raw_ostream &O,
96 ARMBaseTargetMachine &TM,
96 TargetMachine &TM,
9797 bool Verbose);
9898 FunctionPass *createARMCodeEmitterPass(ARMBaseTargetMachine &TM,
9999 MachineCodeEmitter &MCE);
3535 int ARMTargetMachineModule = 0;
3636
3737 // Register the target.
38 static RegisterTarget X("arm", "ARM");
39 static RegisterTarget Y("thumb", "Thumb");
38 extern Target TheARMTarget;
39 static RegisterTarget X(TheARMTarget, "arm", "ARM");
40
41 extern Target TheThumbTarget;
42 static RegisterTarget Y(TheThumbTarget, "thumb", "Thumb");
4043
4144 // Force static initialization.
4245 extern "C" void LLVMInitializeARMTarget() { }
4141 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
4242 // set this functions to ctor pointer at startup time if they are linked in.
4343 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
44 ARMBaseTargetMachine &tm,
44 TargetMachine &tm,
4545 bool verbose);
4646 static AsmPrinterCtorFn AsmPrinterCtor;
4747
3030 #include "llvm/Target/TargetData.h"
3131 #include "llvm/Target/TargetMachine.h"
3232 #include "llvm/Target/TargetOptions.h"
33 #include "llvm/Target/TargetRegistry.h"
3334 #include "llvm/ADT/Statistic.h"
3435 #include "llvm/ADT/StringExtras.h"
3536 #include "llvm/ADT/StringSet.h"
12861287 /// regardless of whether the function is in SSA form.
12871288 ///
12881289 FunctionPass *llvm::createARMCodePrinterPass(formatted_raw_ostream &o,
1289 ARMBaseTargetMachine &tm,
1290 TargetMachine &tm,
12901291 bool verbose) {
12911292 return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
12921293 }
13001301 }
13011302
13021303 // Force static initialization.
1303 extern "C" void LLVMInitializeARMAsmPrinter() { }
1304 extern "C" void LLVMInitializeARMAsmPrinter() {
1305 extern Target TheARMTarget, TheThumbTarget;
1306 TargetRegistry::RegisterAsmPrinter(TheARMTarget, createARMCodePrinterPass);
1307 TargetRegistry::RegisterAsmPrinter(TheThumbTarget, createARMCodePrinterPass);
1308 }
2121 using namespace llvm;
2222
2323 // Register the targets
24 static RegisterTarget X("alpha", "Alpha [experimental]");
24 extern Target TheAlphaTarget;
25 static RegisterTarget X(TheAlphaTarget, "alpha",
26 "Alpha [experimental]");
2527
2628 // No assembler printer by default
2729 AlphaTargetMachine::AsmPrinterCtorFn AlphaTargetMachine::AsmPrinterCtor = 0;
2323 #include "llvm/CodeGen/DwarfWriter.h"
2424 #include "llvm/Target/TargetAsmInfo.h"
2525 #include "llvm/Target/TargetMachine.h"
26 #include "llvm/Target/TargetRegistry.h"
2627 #include "llvm/Support/Compiler.h"
2728 #include "llvm/Support/ErrorHandling.h"
2829 #include "llvm/Support/Mangler.h"
291292 return false;
292293 }
293294
294 // Force static initialization.
295 extern "C" void LLVMInitializeAlphaAsmPrinter() { }
296
297295 namespace {
298296 static struct Register {
299297 Register() {
301299 }
302300 } Registrator;
303301 }
302
303 // Force static initialization.
304 extern "C" void LLVMInitializeAlphaAsmPrinter() {
305 extern Target TheAlphaTarget;
306 TargetRegistry::RegisterAsmPrinter(TheAlphaTarget,
307 createAlphaCodePrinterPass);
308 }
5757 int CBackendTargetMachineModule = 0;
5858
5959 // Register the target.
60 static RegisterTarget X("c", "C backend");
60 extern Target TheCBackendTarget;
61 static RegisterTarget X(TheCBackendTarget, "c", "C backend");
6162
6263 // Force static initialization.
6364 extern "C" void LLVMInitializeCBackendTarget() { }
3636 #include "llvm/Target/TargetRegisterInfo.h"
3737 #include "llvm/Target/TargetInstrInfo.h"
3838 #include "llvm/Target/TargetOptions.h"
39 #include "llvm/Target/TargetRegistry.h"
3940 #include "llvm/ADT/Statistic.h"
4041 #include "llvm/ADT/StringExtras.h"
4142 #include
288289 class VISIBILITY_HIDDEN LinuxAsmPrinter : public SPUAsmPrinter {
289290 DwarfWriter *DW;
290291 public:
291 explicit LinuxAsmPrinter(formatted_raw_ostream &O, SPUTargetMachine &TM,
292 explicit LinuxAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
292293 const TargetAsmInfo *T, bool V)
293294 : SPUAsmPrinter(O, TM, T, V), DW(0) {}
294295
598599 /// that the Linux SPU assembler can deal with.
599600 ///
600601 FunctionPass *llvm::createSPUAsmPrinterPass(formatted_raw_ostream &o,
601 SPUTargetMachine &tm,
602 TargetMachine &tm,
602603 bool verbose) {
603604 return new LinuxAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
604605 }
605
606 // Force static initialization.
607 extern "C" void LLVMInitializeCellSPUAsmPrinter() { }
608606
609607 namespace {
610608 static struct Register {
613611 }
614612 } Registrator;
615613 }
614
615 // Force static initialization.
616 extern "C" void LLVMInitializeCellSPUAsmPrinter() {
617 extern Target TheCellSPUTarget;
618 TargetRegistry::RegisterAsmPrinter(TheCellSPUTarget, createSPUAsmPrinterPass);
619 }
2424
2525 FunctionPass *createSPUISelDag(SPUTargetMachine &TM);
2626 FunctionPass *createSPUAsmPrinterPass(formatted_raw_ostream &o,
27 SPUTargetMachine &tm,
27 TargetMachine &tm,
2828 bool verbose);
2929
3030 /*--== Utility functions/predicates/etc used all over the place: --==*/
2222
2323 using namespace llvm;
2424
25 extern Target TheCellSPUTarget;
2526 namespace {
2627 // Register the targets
2728 RegisterTarget
28 CELLSPU("cellspu", "STI CBEA Cell SPU [experimental]");
29 CELLSPU(TheCellSPUTarget, "cellspu", "STI CBEA Cell SPU [experimental]");
2930 }
3031
3132 // No assembler printer by default
4141 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
4242 // set this functions to ctor pointer at startup time if they are linked in.
4343 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
44 SPUTargetMachine &tm,
44 TargetMachine &tm,
4545 bool verbose);
4646 static AsmPrinterCtorFn AsmPrinterCtor;
4747
8080 int CppBackendTargetMachineModule = 0;
8181
8282 // Register the target.
83 static RegisterTarget X("cpp", "C++ backend");
83 extern Target TheCppBackendTarget;
84 static RegisterTarget X(TheCppBackendTarget, "cpp", "C++ backend");
8485
8586 // Force static initialization.
8687 extern "C" void LLVMInitializeCppBackendTarget() { }
2525 #include "llvm/CodeGen/DwarfWriter.h"
2626 #include "llvm/CodeGen/MachineFunctionPass.h"
2727 #include "llvm/Target/TargetAsmInfo.h"
28 #include "llvm/Target/TargetRegistry.h"
2829 #include "llvm/Support/ErrorHandling.h"
2930 #include "llvm/Support/FormattedStream.h"
3031 #include "llvm/Support/Mangler.h"
368369 /// the given target machine description.
369370 ///
370371 FunctionPass *llvm::createIA64CodePrinterPass(formatted_raw_ostream &o,
371 IA64TargetMachine &tm,
372 TargetMachine &tm,
372373 bool verbose) {
373374 return new IA64AsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
374375 }
383384
384385
385386 // Force static initialization.
386 extern "C" void LLVMInitializeIA64AsmPrinter() { }
387 extern "C" void LLVMInitializeIA64AsmPrinter() {
388 extern Target TheIA64Target;
389 TargetRegistry::RegisterAsmPrinter(TheIA64Target, createIA64CodePrinterPass);
390 }
3737 /// regardless of whether the function is in SSA form.
3838 ///
3939 FunctionPass *createIA64CodePrinterPass(formatted_raw_ostream &o,
40 IA64TargetMachine &tm,
40 TargetMachine &tm,
4141 bool verbose);
4242
4343 } // End llvm namespace
1919 using namespace llvm;
2020
2121 // Register the target
22 static RegisterTarget X("ia64",
22 extern Target TheIA64Target;
23 static RegisterTarget X(TheIA64Target, "ia64",
2324 "IA-64 (Itanium) [experimental]");
2425
2526 // No assembler printer by default
3636 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
3737 // set this functions to ctor pointer at startup time if they are linked in.
3838 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
39 IA64TargetMachine &tm,
39 TargetMachine &tm,
4040 bool verbose);
4141 static AsmPrinterCtorFn AsmPrinterCtor;
4242
5454 extern "C" int MSILTargetMachineModule;
5555 int MSILTargetMachineModule = 0;
5656
57 static RegisterTarget X("msil", "MSIL backend");
57 extern Target TheMSILTarget;
58 static RegisterTarget X(TheMSILTarget, "msil", "MSIL backend");
5859
5960 // Force static initialization.
6061 extern "C" void LLVMInitializeMSILTarget() { }
3131
3232
3333 // Register the targets
34 extern Target TheMSP430Target;
3435 static RegisterTarget
35 X("msp430", "MSP430 [experimental]");
36 X(TheMSP430Target, "msp430", "MSP430 [experimental]");
3637
3738 // Force static initialization.
3839 extern "C" void LLVMInitializeMSP430Target() { }
3232 #include "llvm/Target/TargetData.h"
3333 #include "llvm/Target/TargetMachine.h"
3434 #include "llvm/Target/TargetOptions.h"
35 #include "llvm/Target/TargetRegistry.h"
3536 #include "llvm/Support/ErrorHandling.h"
3637 #include "llvm/Support/Mangler.h"
3738 #include "llvm/ADT/Statistic.h"
5051 class VISIBILITY_HIDDEN MipsAsmPrinter : public AsmPrinter {
5152 const MipsSubtarget *Subtarget;
5253 public:
53 explicit MipsAsmPrinter(formatted_raw_ostream &O, MipsTargetMachine &TM,
54 explicit MipsAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
5455 const TargetAsmInfo *T, bool V)
5556 : AsmPrinter(O, TM, T, V) {
5657 Subtarget = &TM.getSubtarget();
9192 /// using the given target machine description. This should work
9293 /// regardless of whether the function is in SSA form.
9394 FunctionPass *llvm::createMipsCodePrinterPass(formatted_raw_ostream &o,
94 MipsTargetMachine &tm,
95 TargetMachine &tm,
9596 bool verbose) {
9697 return new MipsAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
9798 }
583584 }
584585
585586 // Force static initialization.
586 extern "C" void LLVMInitializeMipsAsmPrinter() { }
587 extern "C" void LLVMInitializeMipsAsmPrinter() {
588 extern Target TheMipsTarget;
589 TargetRegistry::RegisterAsmPrinter(TheMipsTarget, createMipsCodePrinterPass);
590
591 extern Target TheMipselTarget;
592 TargetRegistry::RegisterAsmPrinter(TheMipselTarget,
593 createMipsCodePrinterPass);
594 }
2525 FunctionPass *createMipsISelDag(MipsTargetMachine &TM);
2626 FunctionPass *createMipsDelaySlotFillerPass(MipsTargetMachine &TM);
2727 FunctionPass *createMipsCodePrinterPass(formatted_raw_ostream &OS,
28 MipsTargetMachine &TM,
28 TargetMachine &TM,
2929 bool Verbose);
3030 } // end namespace llvm;
3131
2727 int MipsTargetMachineModule = 0;
2828
2929 // Register the target.
30 static RegisterTarget X("mips", "Mips");
31 static RegisterTarget Y("mipsel", "Mipsel");
30 extern Target TheMipsTarget;
31 static RegisterTarget X(TheMipsTarget, "mips", "Mips");
32
33 extern Target TheMipselTarget;
34 static RegisterTarget Y(TheMipselTarget, "mipsel",
35 "Mipsel");
3236
3337 MipsTargetMachine::AsmPrinterCtorFn MipsTargetMachine::AsmPrinterCtor = 0;
3438
3737 // asmprinter set this functions to ctor pointer at startup time if they are
3838 // linked in.
3939 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
40 MipsTargetMachine &tm,
40 TargetMachine &tm,
4141 bool verbose);
4242 static AsmPrinterCtorFn AsmPrinterCtor;
4343
3131
3232
3333 // Register the targets
34 extern Target ThePIC16Target;
3435 static RegisterTarget
35 X("pic16", "PIC16 14-bit [experimental].");
36 X(ThePIC16Target, "pic16", "PIC16 14-bit [experimental].");
37
38 extern Target TheCooperTarget;
3639 static RegisterTarget
37 Y("cooper", "PIC16 Cooper [experimental].");
40 Y(TheCooperTarget, "cooper", "PIC16 Cooper [experimental].");
3841
3942 // Force static initialization.
4043 extern "C" void LLVMInitializePIC16Target() { }
4242 #include "llvm/Target/TargetRegisterInfo.h"
4343 #include "llvm/Target/TargetInstrInfo.h"
4444 #include "llvm/Target/TargetOptions.h"
45 #include "llvm/Target/TargetRegistry.h"
4546 #include "llvm/ADT/Statistic.h"
4647 #include "llvm/ADT/StringExtras.h"
4748 #include "llvm/ADT/StringSet.h"
316317 /// PPCLinuxAsmPrinter - PowerPC assembly printer, customized for Linux
317318 class VISIBILITY_HIDDEN PPCLinuxAsmPrinter : public PPCAsmPrinter {
318319 public:
319 explicit PPCLinuxAsmPrinter(formatted_raw_ostream &O, PPCTargetMachine &TM,
320 explicit PPCLinuxAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
320321 const TargetAsmInfo *T, bool V)
321322 : PPCAsmPrinter(O, TM, T, V){}
322323
342343 class VISIBILITY_HIDDEN PPCDarwinAsmPrinter : public PPCAsmPrinter {
343344 formatted_raw_ostream &OS;
344345 public:
345 explicit PPCDarwinAsmPrinter(formatted_raw_ostream &O, PPCTargetMachine &TM,
346 explicit PPCDarwinAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
346347 const TargetAsmInfo *T, bool V)
347348 : PPCAsmPrinter(O, TM, T, V), OS(O) {}
348349
10791080 /// Darwin assembler can deal with.
10801081 ///
10811082 FunctionPass *llvm::createPPCAsmPrinterPass(formatted_raw_ostream &o,
1082 PPCTargetMachine &tm,
1083 TargetMachine &tm,
10831084 bool verbose) {
10841085 const PPCSubtarget *Subtarget = &tm.getSubtarget();
10851086
11021103 int PowerPCAsmPrinterForceLink = 0;
11031104
11041105 // Force static initialization.
1105 extern "C" void LLVMInitializePowerPCAsmPrinter() { }
1106 extern "C" void LLVMInitializePowerPCAsmPrinter() {
1107 extern Target ThePPC32Target;
1108 TargetRegistry::RegisterAsmPrinter(ThePPC32Target, createPPCAsmPrinterPass);
1109
1110 extern Target ThePPC64Target;
1111 TargetRegistry::RegisterAsmPrinter(ThePPC64Target, createPPCAsmPrinterPass);
1112 }
2929 FunctionPass *createPPCBranchSelectionPass();
3030 FunctionPass *createPPCISelDag(PPCTargetMachine &TM);
3131 FunctionPass *createPPCAsmPrinterPass(formatted_raw_ostream &OS,
32 PPCTargetMachine &TM,
32 TargetMachine &TM,
3333 bool Verbose);
3434 FunctionPass *createPPCCodeEmitterPass(PPCTargetMachine &TM,
3535 MachineCodeEmitter &MCE);
2929 int PowerPCTargetMachineModule = 0;
3030
3131 // Register the targets
32 extern Target ThePPC32Target;
3233 static RegisterTarget
33 X("ppc32", "PowerPC 32");
34 X(ThePPC32Target, "ppc32", "PowerPC 32");
35
36 extern Target ThePPC64Target;
3437 static RegisterTarget
35 Y("ppc64", "PowerPC 64");
38 Y(ThePPC64Target, "ppc64", "PowerPC 64");
3639
3740 // Force static initialization.
3841 extern "C" void LLVMInitializePowerPCTarget() { }
4444 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
4545 // set this functions to ctor pointer at startup time if they are linked in.
4646 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
47 PPCTargetMachine &tm,
47 TargetMachine &m,
4848 bool verbose);
4949 static AsmPrinterCtorFn AsmPrinterCtor;
5050
2525 #include "llvm/CodeGen/MachineConstantPool.h"
2626 #include "llvm/CodeGen/MachineInstr.h"
2727 #include "llvm/Target/TargetAsmInfo.h"
28 #include "llvm/Target/TargetRegistry.h"
2829 #include "llvm/Support/ErrorHandling.h"
2930 #include "llvm/Support/FormattedStream.h"
3031 #include "llvm/Support/Mangler.h"
358359 }
359360
360361 // Force static initialization.
361 extern "C" void LLVMInitializeSparcAsmPrinter() { }
362 extern "C" void LLVMInitializeSparcAsmPrinter() {
363 extern Target TheSparcTarget;
364 TargetRegistry::RegisterAsmPrinter(TheSparcTarget,
365 createSparcCodePrinterPass);
366 }
1818 using namespace llvm;
1919
2020 // Register the target.
21 static RegisterTarget X("sparc", "SPARC");
21 extern Target TheSparcTarget;
22 static RegisterTarget X(TheSparcTarget, "sparc", "SPARC");
2223
2324 // No assembler printer by default
2425 SparcTargetMachine::AsmPrinterCtorFn SparcTargetMachine::AsmPrinterCtor = 0;
3636 MCContext *Context;
3737 MCStreamer *Streamer;
3838 public:
39 explicit X86ATTAsmPrinter(formatted_raw_ostream &O, X86TargetMachine &TM,
39 explicit X86ATTAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
4040 const TargetAsmInfo *T, bool V)
4141 : AsmPrinter(O, TM, T, V) {
4242 Subtarget = &TM.getSubtarget();
1616 #include "X86ATTAsmPrinter.h"
1717 #include "X86IntelAsmPrinter.h"
1818 #include "X86Subtarget.h"
19 #include "llvm/Target/TargetRegistry.h"
1920 using namespace llvm;
2021
2122 /// createX86CodePrinterPass - Returns a pass that prints the X86 assembly code
2324 /// machine description.
2425 ///
2526 FunctionPass *llvm::createX86CodePrinterPass(formatted_raw_ostream &o,
26 X86TargetMachine &tm,
27 TargetMachine &tm,
2728 bool verbose) {
2829 const X86Subtarget *Subtarget = &tm.getSubtarget();
2930
4445 int X86AsmPrinterForceLink = 0;
4546
4647 // Force static initialization.
47 extern "C" void LLVMInitializeX86AsmPrinter() { }
48 extern "C" void LLVMInitializeX86AsmPrinter() {
49 extern Target TheX86_32Target;
50 TargetRegistry::RegisterAsmPrinter(TheX86_32Target, createX86CodePrinterPass);
51
52 extern Target TheX86_64Target;
53 TargetRegistry::RegisterAsmPrinter(TheX86_64Target, createX86CodePrinterPass);
54 }
2424 namespace llvm {
2525
2626 struct VISIBILITY_HIDDEN X86IntelAsmPrinter : public AsmPrinter {
27 explicit X86IntelAsmPrinter(formatted_raw_ostream &O, X86TargetMachine &TM,
27 explicit X86IntelAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
2828 const TargetAsmInfo *T, bool V)
2929 : AsmPrinter(O, TM, T, V) {}
3030
4646 /// using the given target machine description.
4747 ///
4848 FunctionPass *createX86CodePrinterPass(formatted_raw_ostream &o,
49 X86TargetMachine &tm,
49 TargetMachine &tm,
5050 bool Verbose);
5151
5252 /// createX86CodeEmitterPass - Return a pass that emits the collected X86 code
3030 int X86TargetMachineModule = 0;
3131
3232 // Register the target.
33 extern Target TheX86_32Target;
3334 static RegisterTarget
34 X("x86", "32-bit X86: Pentium-Pro and above");
35 X(TheX86_32Target, "x86", "32-bit X86: Pentium-Pro and above");
36
37 extern Target TheX86_64Target;
3538 static RegisterTarget
36 Y("x86-64", "64-bit X86: EM64T and AMD64");
39 Y(TheX86_64Target, "x86-64", "64-bit X86: EM64T and AMD64");
3740
3841 // Force static initialization.
39 extern "C" void LLVMInitializeX86Target() { }
42 extern "C" void LLVMInitializeX86Target() {
43
44 }
4045
4146 // No assembler printer by default
4247 X86TargetMachine::AsmPrinterCtorFn X86TargetMachine::AsmPrinterCtor = 0;
4343 // To avoid having target depend on the asmprinter stuff libraries, asmprinter
4444 // set this functions to ctor pointer at startup time if they are linked in.
4545 typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o,
46 X86TargetMachine &tm,
46 TargetMachine &tm,
4747 bool verbose);
4848 static AsmPrinterCtorFn AsmPrinterCtor;
4949
2525 extern "C" int XCoreTargetMachineModule;
2626 int XCoreTargetMachineModule = 0;
2727
28 extern Target TheXCoreTarget;
2829 namespace {
2930 // Register the target.
30 RegisterTarget X("xcore", "XCore");
31 RegisterTarget X(TheXCoreTarget, "xcore", "XCore");
3132 }
3233
3334 // Force static initialization.