llvm.org GIT mirror llvm / 0c795d6
Add new helpers for registering targets. - Less boilerplate == good. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77052 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 11 years ago
40 changed file(s) with 194 addition(s) and 350 deletion(s). Raw diff Collapse all Expand all
+0
-55
include/llvm/Target/TargetMachineRegistry.h less more
None //===-- Target/TargetMachineRegistry.h - Target Registration ----*- C++ -*-===//
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 // This file exposes two classes: the TargetMachineRegistry class, which allows
10 // tools to inspect all of registered targets, and the RegisterTarget class,
11 // which TargetMachine implementations should use to register themselves with
12 // the system.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_TARGET_TARGETMACHINEREGISTRY_H
17 #define LLVM_TARGET_TARGETMACHINEREGISTRY_H
18
19 #include "llvm/Module.h"
20 #include "llvm/Target/TargetRegistry.h"
21
22 namespace llvm {
23 class Module;
24 class Target;
25 class TargetMachine;
26
27 //===--------------------------------------------------------------------===//
28 /// RegisterTarget - This class is used to make targets automatically register
29 /// themselves with the tools they are linked with. Targets should define an
30 /// single global Target instance and register it using the TargetRegistry
31 /// interfaces. Targets must also include a static instance of this class.
32 ///
33 /// The type 'TargetMachineImpl' should provide a constructor with two
34 /// parameters:
35 /// - const Module& M: the module that is being compiled:
36 /// - const std::string& FS: target-specific string describing target
37 /// flavour.
38
39 template
40 struct RegisterTarget {
41 RegisterTarget(Target &T, const char *Name, const char *ShortDesc) {
42 TargetRegistry::RegisterTargetMachine(T, &Allocator);
43 }
44
45 private:
46 static TargetMachine *Allocator(const Target &T, const Module &M,
47 const std::string &FS) {
48 return new TargetMachineImpl(T, M, FS);
49 }
50 };
51
52 }
53
54 #endif
1818 #ifndef LLVM_TARGET_TARGETREGISTRY_H
1919 #define LLVM_TARGET_TARGETREGISTRY_H
2020
21 // FIXME: We shouldn't need this header, but we need it until there is a
22 // different interface to get the TargetAsmInfo.
23 #include "llvm/Target/TargetMachine.h"
2124 #include
2225 #include
2326
277280 /// @}
278281 };
279282
283
284 //===--------------------------------------------------------------------===//
285
286 /// RegisterTarget - Helper template for registering a target, for use in the
287 /// target's initialization function. Usage:
288 ///
289 ///
290 /// Target TheFooTarget; // The global target instance.
291 ///
292 /// namespace {
293 /// struct FooInfo {
294 /// static unsigned getJITMatchQuality() { ... }
295 /// static unsigned getTripleMatchQuality(const std::string &) { ... }
296 /// static unsigned getModuleMatchQuality(const Module &) { ... }
297 /// };
298 /// }
299 ///
300 /// extern "C" void LLVMInitializeFooTargetInfo() {
301 /// RegisterTarget X(TheFooTarget, "foo", "Foo description");
302 /// }
303 template
304 struct RegisterTarget {
305 RegisterTarget(Target &T, const char *Name, const char *Desc) {
306 TargetRegistry::RegisterTarget(T, Name, Desc,
307 &TargetInfoImpl::getTripleMatchQuality,
308 &TargetInfoImpl::getModuleMatchQuality,
309 &TargetInfoImpl::getJITMatchQuality);
310 }
311 };
312
313 /// RegisterTargetMachine - Helper template for registering a target machine
314 /// implementation, for use in the target machine initialization
315 /// function. Usage:
316 ///
317 /// extern "C" void LLVMInitializeFooTarget() {
318 /// extern Target TheFooTarget;
319 /// RegisterTargetMachine X(TheFooTarget);
320 /// }
321 template
322 struct RegisterTargetMachine {
323 RegisterTargetMachine(Target &T) {
324 TargetRegistry::RegisterTargetMachine(T, &Allocator);
325 }
326
327 private:
328 static TargetMachine *Allocator(const Target &T, const Module &M,
329 const std::string &FS) {
330 return new TargetMachineImpl(T, M, FS);
331 }
332 };
333
334 /// RegisterAsmPrinter - Helper template for registering a target specific
335 /// assembly printer, for use in the target machine initialization
336 /// function. Usage:
337 ///
338 /// extern "C" void LLVMInitializeFooAsmPrinter() {
339 /// extern Target TheFooTarget;
340 /// RegisterAsmPrinter X(TheFooTarget);
341 /// }
342 template
343 struct RegisterAsmPrinter {
344 RegisterAsmPrinter(Target &T) {
345 TargetRegistry::RegisterAsmPrinter(T, &Allocator);
346 }
347
348 private:
349 static FunctionPass *Allocator(formatted_raw_ostream &OS,
350 TargetMachine &TM,
351 bool Verbose) {
352 return new AsmPrinterImpl(OS, TM, TM.getTargetAsmInfo(), Verbose);
353 }
354 };
355
356 /// RegisterAsmParser - Helper template for registering a target specific asm
357 /// parser, for use in the target machine initialization function. Usage:
358 ///
359 /// extern "C" void LLVMInitializeFooAsmPrinter() {
360 /// extern Target TheFooTarget;
361 /// RegisterAsmPrinter X(TheFooTarget);
362 /// }
363 template
364 struct RegisterAsmParser {
365 RegisterAsmParser(Target &T) {
366 TargetRegistry::RegisterAsmParser(T, &Allocator);
367 }
368
369 private:
370 static TargetAsmParser *Allocator(const Target &T) {
371 return new AsmParserImpl(T);
372 }
373 };
374
280375 }
281376
282377 #endif
9292 }
9393
9494 FunctionPass *createARMISelDag(ARMBaseTargetMachine &TM);
95 FunctionPass *createARMCodePrinterPass(formatted_raw_ostream &O,
96 TargetMachine &TM,
97 bool Verbose);
9895 FunctionPass *createARMCodeEmitterPass(ARMBaseTargetMachine &TM,
9996 MachineCodeEmitter &MCE);
10097
1818 #include "llvm/CodeGen/Passes.h"
1919 #include "llvm/Support/CommandLine.h"
2020 #include "llvm/Support/FormattedStream.h"
21 #include "llvm/Target/TargetMachineRegistry.h"
2221 #include "llvm/Target/TargetOptions.h"
22 #include "llvm/Target/TargetRegistry.h"
2323 using namespace llvm;
2424
2525 static cl::opt DisableLdStOpti("disable-arm-loadstore-opti", cl::Hidden,
2727 static cl::opt DisableIfConversion("disable-arm-if-conversion",cl::Hidden,
2828 cl::desc("Disable if-conversion pass"));
2929
30 // Register the target.
31 static RegisterTarget X(llvm::TheARMTarget, "arm", "ARM");
32
33 static RegisterTarget Y(llvm::TheThumbTarget, "thumb",
34 "Thumb");
35
36 // Force static initialization.
37 extern "C" void LLVMInitializeARMTarget() { }
30 extern "C" void LLVMInitializeARMTarget() {
31 // Register the target.
32 RegisterTargetMachine X(TheARMTarget);
33 RegisterTargetMachine Y(TheThumbTarget);
34 }
3835
3936 /// TargetMachine ctor - Create an ARM architecture model.
4037 ///
13031303 return AsmPrinter::doFinalization(M);
13041304 }
13051305
1306 /// createARMCodePrinterPass - Returns a pass that prints the ARM
1307 /// assembly code for a MachineFunction to the given output stream,
1308 /// using the given target machine description. This should work
1309 /// regardless of whether the function is in SSA form.
1310 ///
1311 FunctionPass *llvm::createARMCodePrinterPass(formatted_raw_ostream &o,
1312 TargetMachine &tm,
1313 bool verbose) {
1314 return new ARMAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
1315 }
1316
13171306 // Force static initialization.
13181307 extern "C" void LLVMInitializeARMAsmPrinter() {
1319 TargetRegistry::RegisterAsmPrinter(TheARMTarget, createARMCodePrinterPass);
1320 TargetRegistry::RegisterAsmPrinter(TheThumbTarget, createARMCodePrinterPass);
1321 }
1308 RegisterAsmPrinter X(TheARMTarget);
1309 RegisterAsmPrinter Y(TheThumbTarget);
1310 }
2525 class formatted_raw_ostream;
2626
2727 FunctionPass *createAlphaISelDag(AlphaTargetMachine &TM);
28 FunctionPass *createAlphaCodePrinterPass(formatted_raw_ostream &OS,
29 TargetMachine &TM,
30 bool Verbose);
3128 FunctionPass *createAlphaPatternInstructionSelector(TargetMachine &TM);
3229 FunctionPass *createAlphaCodeEmitterPass(AlphaTargetMachine &TM,
3330 MachineCodeEmitter &MCE);
1515 #include "AlphaTargetMachine.h"
1616 #include "llvm/Module.h"
1717 #include "llvm/PassManager.h"
18 #include "llvm/Target/TargetMachineRegistry.h"
1918 #include "llvm/Support/FormattedStream.h"
19 #include "llvm/Target/TargetRegistry.h"
2020
2121 using namespace llvm;
2222
23 // Register the targets
24 static RegisterTarget X(TheAlphaTarget, "alpha",
25 "Alpha [experimental]");
26
27 // Force static initialization.
28 extern "C" void LLVMInitializeAlphaTarget() { }
23 extern "C" void LLVMInitializeAlphaTarget() {
24 // Register the target.
25 RegisterTargetMachine X(TheAlphaTarget);
26 }
2927
3028 const TargetAsmInfo *AlphaTargetMachine::createTargetAsmInfo() const {
3129 return new AlphaTargetAsmInfo(*this);
6262 };
6363 } // end of anonymous namespace
6464
65 /// createAlphaCodePrinterPass - Returns a pass that prints the Alpha
66 /// assembly code for a MachineFunction to the given output stream,
67 /// using the given target machine description. This should work
68 /// regardless of whether the function is in SSA form.
69 ///
70 FunctionPass *llvm::createAlphaCodePrinterPass(formatted_raw_ostream &o,
71 TargetMachine &tm,
72 bool verbose) {
73 return new AlphaAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
74 }
75
7665 #include "AlphaGenAsmWriter.inc"
7766
7867 void AlphaAsmPrinter::printOperand(const MachineInstr *MI, int opNum)
287276
288277 // Force static initialization.
289278 extern "C" void LLVMInitializeAlphaAsmPrinter() {
290 TargetRegistry::RegisterAsmPrinter(TheAlphaTarget,
291 createAlphaCodePrinterPass);
292 }
279 RegisterAsmPrinter X(TheAlphaTarget);
280 }
3131 #include "llvm/Transforms/Scalar.h"
3232 #include "llvm/Target/TargetAsmInfo.h"
3333 #include "llvm/Target/TargetData.h"
34 #include "llvm/Target/TargetMachineRegistry.h"
3534 #include "llvm/Target/TargetRegistry.h"
3635 #include "llvm/Support/CallSite.h"
3736 #include "llvm/Support/CFG.h"
4948 #include
5049 using namespace llvm;
5150
52 // Register the target.
53 static RegisterTarget X(TheCBackendTarget, "c", "C backend");
54
55 // Force static initialization.
56 extern "C" void LLVMInitializeCBackendTarget() { }
51 extern "C" void LLVMInitializeCBackendTarget() {
52 // Register the target.
53 RegisterTargetMachine X(TheCBackendTarget);
54 }
5755
5856 namespace {
5957 /// CBackendNameAllUsedStructsAndMergeFunctions - This pass inserts names for
583583 O << '\n';
584584 }
585585
586 /// createSPUCodePrinterPass - Returns a pass that prints the Cell SPU
587 /// assembly code for a MachineFunction to the given output stream, in a format
588 /// that the Linux SPU assembler can deal with.
589 ///
590 FunctionPass *llvm::createSPUAsmPrinterPass(formatted_raw_ostream &o,
591 TargetMachine &tm,
592 bool verbose) {
593 return new LinuxAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
594 }
595
596586 // Force static initialization.
597587 extern "C" void LLVMInitializeCellSPUAsmPrinter() {
598 TargetRegistry::RegisterAsmPrinter(TheCellSPUTarget, createSPUAsmPrinterPass);
599 }
588 RegisterAsmPrinter X(TheCellSPUTarget);
589 }
2323 class formatted_raw_ostream;
2424
2525 FunctionPass *createSPUISelDag(SPUTargetMachine &TM);
26 FunctionPass *createSPUAsmPrinterPass(formatted_raw_ostream &o,
27 TargetMachine &tm,
28 bool verbose);
2926
3027 /*--== Utility functions/predicates/etc used all over the place: --==*/
3128 //! Predicate test for a signed 10-bit value
1616 #include "SPUTargetMachine.h"
1717 #include "llvm/Module.h"
1818 #include "llvm/PassManager.h"
19 #include "llvm/Target/TargetMachineRegistry.h"
2019 #include "llvm/CodeGen/RegAllocRegistry.h"
2120 #include "llvm/CodeGen/SchedulerRegistry.h"
21 #include "llvm/Target/TargetRegistry.h"
2222
2323 using namespace llvm;
2424
25 namespace {
26 // Register the targets
27 RegisterTarget
28 CELLSPU(TheCellSPUTarget, "cellspu", "STI CBEA Cell SPU [experimental]");
25 extern "C" void LLVMInitializeCellSPUTarget() {
26 // Register the target.
27 RegisterTargetMachine X(TheCellSPUTarget);
2928 }
30
31 // Force static initialization.
32 extern "C" void LLVMInitializeCellSPUTarget() { }
3329
3430 const std::pair *
3531 SPUFrameInfo::getCalleeSaveSpillSlots(unsigned &NumEntries) const {
2222 #include "llvm/Pass.h"
2323 #include "llvm/PassManager.h"
2424 #include "llvm/TypeSymbolTable.h"
25 #include "llvm/Target/TargetMachineRegistry.h"
2625 #include "llvm/ADT/StringExtras.h"
2726 #include "llvm/ADT/STLExtras.h"
2827 #include "llvm/ADT/SmallPtrSet.h"
3029 #include "llvm/Support/ErrorHandling.h"
3130 #include "llvm/Support/FormattedStream.h"
3231 #include "llvm/Support/Streams.h"
32 #include "llvm/Target/TargetRegistry.h"
3333 #include "llvm/Config/config.h"
3434 #include
3535 #include
7171 cl::desc("Specify the name of the thing to generate"),
7272 cl::init("!bad!"));
7373
74 // Register the target.
75 static RegisterTarget X(TheCppBackendTarget, "cpp", "C++ backend");
76
77 // Force static initialization.
78 extern "C" void LLVMInitializeCppBackendTarget() { }
74 extern "C" void LLVMInitializeCppBackendTarget() {
75 // Register the target.
76 RegisterTargetMachine X(TheCppBackendTarget);
77 }
7978
8079 namespace {
8180 typedef std::vector TypeList;
2121 #include "llvm/Support/ErrorHandling.h"
2222 #include "llvm/Support/InstVisitor.h"
2323 #include "llvm/Support/MathExtras.h"
24 #include "llvm/Target/TargetRegistry.h"
2425 #include "llvm/Transforms/Scalar.h"
2526 #include "llvm/ADT/StringExtras.h"
2627 #include "llvm/CodeGen/Passes.h"
4748 };
4849 }
4950
50 static RegisterTarget X(TheMSILTarget, "msil", "MSIL backend");
51
52 // Force static initialization.
53 extern "C" void LLVMInitializeMSILTarget() { }
51 extern "C" void LLVMInitializeMSILTarget() {
52 // Register the target.
53 RegisterTargetMachine X(TheMSILTarget);
54 }
5455
5556 bool MSILModule::runOnModule(Module &M) {
5657 ModulePtr = &M;
2525 #include "llvm/Support/GetElementPtrTypeIterator.h"
2626 #include "llvm/Target/TargetData.h"
2727 #include "llvm/Target/TargetMachine.h"
28 #include "llvm/Target/TargetMachineRegistry.h"
2928 #include "llvm/Support/Mangler.h"
3029 #include
3130 using namespace llvm;
2323
2424 FunctionPass *createMSP430ISelDag(MSP430TargetMachine &TM,
2525 CodeGenOpt::Level OptLevel);
26 FunctionPass *createMSP430CodePrinterPass(formatted_raw_ostream &o,
27 TargetMachine &tm,
28 bool verbose);
2926
3027 extern Target TheMSP430Target;
3128
None //===-- MSP430AsmPrinter.cpp - MSP430 LLVM assembly writer ------------------===//
0 //===-- MSP430AsmPrinter.cpp - MSP430 LLVM assembly writer ----------------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
2626 #include "llvm/CodeGen/MachineInstr.h"
2727 #include "llvm/Target/TargetAsmInfo.h"
2828 #include "llvm/Target/TargetData.h"
29 #include "llvm/Target/TargetRegistry.h"
2930 #include "llvm/ADT/Statistic.h"
3031 #include "llvm/Support/Compiler.h"
3132 #include "llvm/Support/FormattedStream.h"
7071 } // end of anonymous namespace
7172
7273 #include "MSP430GenAsmWriter.inc"
73
74 /// createMSP430CodePrinterPass - Returns a pass that prints the MSP430
75 /// assembly code for a MachineFunction to the given output stream,
76 /// using the given target machine description. This should work
77 /// regardless of whether the function is in SSA form.
78 ///
79 FunctionPass *llvm::createMSP430CodePrinterPass(formatted_raw_ostream &o,
80 TargetMachine &tm,
81 bool verbose) {
82 return new MSP430AsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
83 }
8474
8575
8676 void MSP430AsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
254244 break;
255245 }
256246 }
247
248 extern "C" void LLVMInitializeMSP430Target() {
249 // Register the target.
250 RegisterTargetMachine X(TheMSP430Target);
251 RegisterAsmPrinter Y(TheMSP430Target);
252 }
1717 #include "llvm/PassManager.h"
1818 #include "llvm/CodeGen/Passes.h"
1919 #include "llvm/Target/TargetAsmInfo.h"
20 #include "llvm/Target/TargetMachineRegistry.h"
21
2220 using namespace llvm;
23
24 // Register the targets
25 static RegisterTarget
26 X(TheMSP430Target, "msp430", "MSP430 [experimental]");
27
28 // Force static initialization.
29 extern "C" void LLVMInitializeMSP430Target() {
30 TargetRegistry::RegisterAsmPrinter(TheMSP430Target,
31 &createMSP430CodePrinterPass);
32 }
3321
3422 MSP430TargetMachine::MSP430TargetMachine(const Target &T,
3523 const Module &M,
8585 } // end of anonymous namespace
8686
8787 #include "MipsGenAsmWriter.inc"
88
89 /// createMipsCodePrinterPass - Returns a pass that prints the MIPS
90 /// assembly code for a MachineFunction to the given output stream,
91 /// using the given target machine description. This should work
92 /// regardless of whether the function is in SSA form.
93 FunctionPass *llvm::createMipsCodePrinterPass(formatted_raw_ostream &o,
94 TargetMachine &tm,
95 bool verbose) {
96 return new MipsAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
97 }
9888
9989 //===----------------------------------------------------------------------===//
10090 //
559549
560550 // Force static initialization.
561551 extern "C" void LLVMInitializeMipsAsmPrinter() {
562 TargetRegistry::RegisterAsmPrinter(TheMipsTarget, createMipsCodePrinterPass);
563
564 TargetRegistry::RegisterAsmPrinter(TheMipselTarget,
565 createMipsCodePrinterPass);
566 }
552 RegisterAsmPrinter X(TheMipsTarget);
553 RegisterAsmPrinter Y(TheMipselTarget);
554 }
2424
2525 FunctionPass *createMipsISelDag(MipsTargetMachine &TM);
2626 FunctionPass *createMipsDelaySlotFillerPass(MipsTargetMachine &TM);
27 FunctionPass *createMipsCodePrinterPass(formatted_raw_ostream &OS,
28 TargetMachine &TM,
29 bool Verbose);
3027
3128 extern Target TheMipsTarget;
3229 extern Target TheMipselTarget;
1515 #include "MipsTargetMachine.h"
1616 #include "llvm/Module.h"
1717 #include "llvm/PassManager.h"
18 #include "llvm/Target/TargetMachineRegistry.h"
18 #include "llvm/Target/TargetRegistry.h"
1919 using namespace llvm;
2020
21 // Register the target.
22 static RegisterTarget X(TheMipsTarget, "mips", "Mips");
23
24 static RegisterTarget Y(TheMipselTarget, "mipsel",
25 "Mipsel");
26
27 // Force static initialization.
28 extern "C" void LLVMInitializeMipsTarget() { }
21 extern "C" void LLVMInitializeMipsTarget() {
22 // Register the target.
23 RegisterTargetMachine X(TheMipsTarget);
24 RegisterTargetMachine Y(TheMipselTarget);
25 }
2926
3027 const TargetAsmInfo *MipsTargetMachine::
3128 createTargetAsmInfo() const
342342
343343
344344 FunctionPass *createPIC16ISelDag(PIC16TargetMachine &TM);
345 FunctionPass *createPIC16CodePrinterPass(formatted_raw_ostream &OS,
346 TargetMachine &TM,
347 bool Verbose);
348 // Banksel optimzer pass.
345 // Banksel optimizer pass.
349346 FunctionPass *createPIC16MemSelOptimizerPass();
350347
351348 extern Target ThePIC16Target;
2323 #include "llvm/Support/ErrorHandling.h"
2424 #include "llvm/CodeGen/DwarfWriter.h"
2525 #include "llvm/CodeGen/MachineModuleInfo.h"
26 #include "llvm/Target/TargetRegistry.h"
2627
2728 using namespace llvm;
2829
104105 DbgInfo.EndFunction(MF);
105106
106107 return false; // we didn't modify anything.
107 }
108
109 /// createPIC16CodePrinterPass - Returns a pass that prints the PIC16
110 /// assembly code for a MachineFunction to the given output stream,
111 /// using the given target machine description. This should work
112 /// regardless of whether the function is in SSA form.
113 ///
114 FunctionPass *llvm::createPIC16CodePrinterPass(formatted_raw_ostream &o,
115 TargetMachine &tm,
116 bool verbose) {
117 return new PIC16AsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
118108 }
119109
120110
434424 }
435425 }
436426
427
428 extern "C" void LLVMInitializePIC16Target() {
429 // Register the targets
430 RegisterTargetMachine A(ThePIC16Target);
431 RegisterTargetMachine B(TheCooperTarget);
432 RegisterAsmPrinter C(ThePIC16Target);
433 RegisterAsmPrinter D(TheCooperTarget);
434 }
1717 #include "llvm/PassManager.h"
1818 #include "llvm/CodeGen/Passes.h"
1919 #include "llvm/Target/TargetAsmInfo.h"
20 #include "llvm/Target/TargetMachineRegistry.h"
2120
2221 using namespace llvm;
23
24 // Register the targets
25 static RegisterTarget
26 X(ThePIC16Target, "pic16", "PIC16 14-bit [experimental].");
27
28 static RegisterTarget
29 Y(TheCooperTarget, "cooper", "PIC16 Cooper [experimental].");
30
31 // Force static initialization.
32 extern "C" void LLVMInitializePIC16Target() {
33 TargetRegistry::RegisterAsmPrinter(ThePIC16Target,
34 &createPIC16CodePrinterPass);
35 TargetRegistry::RegisterAsmPrinter(TheCooperTarget,
36 &createPIC16CodePrinterPass);
37 }
3822
3923 // PIC16TargetMachine - Traditional PIC16 Machine.
4024 PIC16TargetMachine::PIC16TargetMachine(const Target &T, const Module &M,
10741074 /// for a MachineFunction to the given output stream, in a format that the
10751075 /// Darwin assembler can deal with.
10761076 ///
1077 FunctionPass *llvm::createPPCAsmPrinterPass(formatted_raw_ostream &o,
1077 static FunctionPass *createPPCAsmPrinterPass(formatted_raw_ostream &o,
10781078 TargetMachine &tm,
10791079 bool verbose) {
10801080 const PPCSubtarget *Subtarget = &tm.getSubtarget();
2828
2929 FunctionPass *createPPCBranchSelectionPass();
3030 FunctionPass *createPPCISelDag(PPCTargetMachine &TM);
31 FunctionPass *createPPCAsmPrinterPass(formatted_raw_ostream &OS,
32 TargetMachine &TM,
33 bool Verbose);
3431 FunctionPass *createPPCCodeEmitterPass(PPCTargetMachine &TM,
3532 MachineCodeEmitter &MCE);
3633 FunctionPass *createPPCJITCodeEmitterPass(PPCTargetMachine &TM,
1515 #include "PPCTargetMachine.h"
1616 #include "llvm/Module.h"
1717 #include "llvm/PassManager.h"
18 #include "llvm/Target/TargetMachineRegistry.h"
1918 #include "llvm/Target/TargetOptions.h"
19 #include "llvm/Target/TargetRegistry.h"
2020 #include "llvm/Support/FormattedStream.h"
2121 using namespace llvm;
2222
23 // Register the targets
24 static RegisterTarget
25 X(ThePPC32Target, "ppc32", "PowerPC 32");
26
27 static RegisterTarget
28 Y(ThePPC64Target, "ppc64", "PowerPC 64");
29
30 // Force static initialization.
31 extern "C" void LLVMInitializePowerPCTarget() { }
23 extern "C" void LLVMInitializePowerPCTarget() {
24 // Register the targets
25 RegisterTargetMachine A(ThePPC32Target);
26 RegisterTargetMachine B(ThePPC64Target);
27 }
3228
3329 const TargetAsmInfo *PPCTargetMachine::createTargetAsmInfo() const {
3430 if (Subtarget.isDarwin())
7575
7676 #include "SparcGenAsmWriter.inc"
7777
78 /// createSparcCodePrinterPass - Returns a pass that prints the SPARC
79 /// assembly code for a MachineFunction to the given output stream,
80 /// using the given target machine description. This should work
81 /// regardless of whether the function is in SSA form.
82 ///
83 FunctionPass *llvm::createSparcCodePrinterPass(formatted_raw_ostream &o,
84 TargetMachine &tm,
85 bool verbose) {
86 return new SparcAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
87 }
88
8978
9079 /// runOnMachineFunction - This uses the printInstruction()
9180 /// method to print assembly for each instruction.
335324
336325 // Force static initialization.
337326 extern "C" void LLVMInitializeSparcAsmPrinter() {
338 TargetRegistry::RegisterAsmPrinter(TheSparcTarget,
339 createSparcCodePrinterPass);
340 }
327 RegisterAsmPrinter X(TheSparcTarget);
328 }
2424 class formatted_raw_ostream;
2525
2626 FunctionPass *createSparcISelDag(SparcTargetMachine &TM);
27 FunctionPass *createSparcCodePrinterPass(formatted_raw_ostream &OS,
28 TargetMachine &TM,
29 bool Verbose);
3027 FunctionPass *createSparcDelaySlotFillerPass(TargetMachine &TM);
3128 FunctionPass *createSparcFPMoverPass(TargetMachine &TM);
3229
1414 #include "Sparc.h"
1515 #include "llvm/Module.h"
1616 #include "llvm/PassManager.h"
17 #include "llvm/Target/TargetMachineRegistry.h"
17 #include "llvm/Target/TargetRegistry.h"
1818 using namespace llvm;
1919
20 // Register the target.
21 static RegisterTarget X(TheSparcTarget, "sparc", "SPARC");
22
23 // Force static initialization.
24 extern "C" void LLVMInitializeSparcTarget() { }
20 extern "C" void LLVMInitializeSparcTarget() {
21 // Register the target.
22 RegisterTargetMachine X(TheSparcTarget);
23 }
2524
2625 const TargetAsmInfo *SparcTargetMachine::createTargetAsmInfo() const {
2726 // FIXME: Handle Solaris subtarget someday :)
7777
7878 #include "SystemZGenAsmWriter.inc"
7979
80 /// createSystemZCodePrinterPass - Returns a pass that prints the SystemZ
81 /// assembly code for a MachineFunction to the given output stream,
82 /// using the given target machine description. This should work
83 /// regardless of whether the function is in SSA form.
84 ///
85 FunctionPass *llvm::createSystemZCodePrinterPass(formatted_raw_ostream &o,
86 TargetMachine &tm,
87 bool verbose) {
88 return new SystemZAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
89 }
90
9180 void SystemZAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
9281 unsigned FnAlign = MF.getAlignment();
9382 const Function *F = MF.getFunction();
402391
403392 // Force static initialization.
404393 extern "C" void LLVMInitializeSystemZAsmPrinter() {
405 TargetRegistry::RegisterAsmPrinter(TheSystemZTarget,
406 createSystemZCodePrinterPass);
407 }
394 RegisterAsmPrinter X(TheSystemZTarget);
395 }
4545
4646 FunctionPass *createSystemZISelDag(SystemZTargetMachine &TM,
4747 CodeGenOpt::Level OptLevel);
48 FunctionPass *createSystemZCodePrinterPass(formatted_raw_ostream &o,
49 TargetMachine &tm,
50 bool verbose);
5148
5249 extern Target TheSystemZTarget;
5350
None //===-- SystemZTargetMachine.cpp - Define TargetMachine for SystemZ -----------===//
0 //===-- SystemZTargetMachine.cpp - Define TargetMachine for SystemZ -------===//
11 //
22 // The LLVM Compiler Infrastructure
33 //
1414 #include "SystemZ.h"
1515 #include "llvm/Module.h"
1616 #include "llvm/PassManager.h"
17 #include "llvm/Target/TargetMachineRegistry.h"
17 #include "llvm/Target/TargetRegistry.h"
1818 using namespace llvm;
1919
20 namespace {
20 extern "C" void LLVMInitializeSystemZTarget() {
2121 // Register the target.
22 RegisterTarget X(TheSystemZTarget,
23 "systemz",
24 "SystemZ [experimental]");
25 }
26
27 // Force static initialization.
28 extern "C" void LLVMInitializeSystemZTarget() {
29
22 RegisterTargetMachine X(TheSystemZTarget);
3023 }
3124
3225 const TargetAsmInfo *SystemZTargetMachine::createTargetAsmInfo() const {
5555 return MatchInstruction(Name, Operands, Inst);
5656 }
5757
58 namespace {
59 TargetAsmParser *createAsmParser(const Target &T) {
60 return new X86ATTAsmParser(T);
61 }
62 }
63
6458 // Force static initialization.
6559 extern "C" void LLVMInitializeX86AsmParser() {
66 TargetRegistry::RegisterAsmParser(TheX86_32Target, &createAsmParser);
67 TargetRegistry::RegisterAsmParser(TheX86_64Target, &createAsmParser);
60 RegisterAsmParser X(TheX86_32Target);
61 RegisterAsmParser Y(TheX86_64Target);
6862 }
2424 /// for a MachineFunction to the given output stream, using the given target
2525 /// machine description.
2626 ///
27 FunctionPass *llvm::createX86CodePrinterPass(formatted_raw_ostream &o,
28 TargetMachine &tm,
29 bool verbose) {
27 static FunctionPass *createX86CodePrinterPass(formatted_raw_ostream &o,
28 TargetMachine &tm,
29 bool verbose) {
3030 const X86Subtarget *Subtarget = &tm.getSubtarget();
3131
3232 if (Subtarget->isFlavorIntel())
4141 ///
4242 FunctionPass *createX87FPRegKillInserterPass();
4343
44 /// createX86CodePrinterPass - Returns a pass that prints the X86
45 /// assembly code for a MachineFunction to the given output stream,
46 /// using the given target machine description.
47 ///
48 FunctionPass *createX86CodePrinterPass(formatted_raw_ostream &o,
49 TargetMachine &tm,
50 bool Verbose);
51
5244 /// createX86CodeEmitterPass - Return a pass that emits the collected X86 code
5345 /// to the specified MCE object.
5446
1919 #include "llvm/CodeGen/Passes.h"
2020 #include "llvm/Support/FormattedStream.h"
2121 #include "llvm/Target/TargetOptions.h"
22 #include "llvm/Target/TargetMachineRegistry.h"
22 #include "llvm/Target/TargetRegistry.h"
2323 using namespace llvm;
2424
25 // Register the target.
26 static RegisterTarget
27 X(TheX86_32Target, "x86", "32-bit X86: Pentium-Pro and above");
28
29 static RegisterTarget
30 Y(TheX86_64Target, "x86-64", "64-bit X86: EM64T and AMD64");
31
32 // Force static initialization.
3325 extern "C" void LLVMInitializeX86Target() {
34
26 // Register the target.
27 RegisterTargetMachine X(TheX86_32Target);
28 RegisterTargetMachine Y(TheX86_64Target);
3529 }
3630
3731 const TargetAsmInfo *X86TargetMachine::createTargetAsmInfo() const {
2323 class formatted_raw_ostream;
2424
2525 FunctionPass *createXCoreISelDag(XCoreTargetMachine &TM);
26 FunctionPass *createXCoreCodePrinterPass(formatted_raw_ostream &OS,
27 TargetMachine &TM,
28 bool Verbose);
2926
3027 extern Target TheXCoreTarget;
3128
2727 #include "llvm/CodeGen/MachineInstr.h"
2828 #include "llvm/Target/TargetAsmInfo.h"
2929 #include "llvm/Target/TargetData.h"
30 #include "llvm/Target/TargetRegistry.h"
3031 #include "llvm/Support/Mangler.h"
3132 #include "llvm/ADT/Statistic.h"
3233 #include "llvm/ADT/StringExtras.h"
8990 } // end of anonymous namespace
9091
9192 #include "XCoreGenAsmWriter.inc"
92
93 /// createXCoreCodePrinterPass - Returns a pass that prints the XCore
94 /// assembly code for a MachineFunction to the given output stream,
95 /// using the given target machine description. This should work
96 /// regardless of whether the function is in SSA form.
97 ///
98 FunctionPass *llvm::createXCoreCodePrinterPass(formatted_raw_ostream &o,
99 TargetMachine &tm,
100 bool verbose) {
101 return new XCoreAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
102 }
10393
10494 void XCoreAsmPrinter::
10595 emitGlobalDirective(const std::string &name)
386376 }
387377
388378
379
380 // Force static initialization.
381 extern "C" void LLVMInitializeXCoreTarget() {
382 RegisterTargetMachine X(TheXCoreTarget);
383 RegisterAsmPrinter Y(TheXCoreTarget);
384 }
1414 #include "XCore.h"
1515 #include "llvm/Module.h"
1616 #include "llvm/PassManager.h"
17 #include "llvm/Target/TargetMachineRegistry.h"
1817 using namespace llvm;
19
20 namespace {
21 // Register the target.
22 RegisterTarget X(TheXCoreTarget, "xcore", "XCore");
23 }
24
25 // Force static initialization.
26 extern "C" void LLVMInitializeXCoreTarget() {
27 TargetRegistry::RegisterAsmPrinter(TheXCoreTarget,
28 &createXCoreCodePrinterPass);
29 }
3018
3119 const TargetAsmInfo *XCoreTargetMachine::createTargetAsmInfo() const {
3220 return new XCoreTargetAsmInfo(*this);