]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/llvm/include/llvm/Target/TargetSelect.h
Copy head to stable/9 as part of 9.0-RELEASE release cycle.
[FreeBSD/stable/9.git] / contrib / llvm / include / llvm / Target / TargetSelect.h
1 //===- TargetSelect.h - Target Selection & Registration ---------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file provides utilities to make sure that certain classes of targets are
11 // linked into the main application executable, and initialize them as
12 // appropriate.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_TARGET_TARGETSELECT_H
17 #define LLVM_TARGET_TARGETSELECT_H
18
19 #include "llvm/Config/llvm-config.h"
20
21 extern "C" {
22   // Declare all of the target-initialization functions that are available.
23 #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##TargetInfo();
24 #include "llvm/Config/Targets.def"
25
26 #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target();
27 #include "llvm/Config/Targets.def"
28   
29 #define LLVM_TARGET(TargetName) \
30   void LLVMInitialize##TargetName##MCAsmInfo();
31 #include "llvm/Config/Targets.def"
32
33 #define LLVM_TARGET(TargetName) \
34   void LLVMInitialize##TargetName##MCInstrInfo();
35 #include "llvm/Config/Targets.def"
36
37 #define LLVM_TARGET(TargetName) \
38   void LLVMInitialize##TargetName##MCSubtargetInfo();
39 #include "llvm/Config/Targets.def"
40
41   // Declare all of the available assembly printer initialization functions.
42 #define LLVM_ASM_PRINTER(TargetName) void LLVMInitialize##TargetName##AsmPrinter();
43 #include "llvm/Config/AsmPrinters.def"
44
45   // Declare all of the available assembly parser initialization functions.
46 #define LLVM_ASM_PARSER(TargetName) void LLVMInitialize##TargetName##AsmParser();
47 #include "llvm/Config/AsmParsers.def"
48
49   // Declare all of the available disassembler initialization functions.
50 #define LLVM_DISASSEMBLER(TargetName) \
51   void LLVMInitialize##TargetName##Disassembler();
52 #include "llvm/Config/Disassemblers.def"
53 }
54
55 namespace llvm {
56   /// InitializeAllTargetInfos - The main program should call this function if
57   /// it wants access to all available targets that LLVM is configured to
58   /// support, to make them available via the TargetRegistry.
59   ///
60   /// It is legal for a client to make multiple calls to this function.
61   inline void InitializeAllTargetInfos() {
62 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
63 #include "llvm/Config/Targets.def"
64   }
65   
66   /// InitializeAllTargets - The main program should call this function if it
67   /// wants access to all available target machines that LLVM is configured to
68   /// support, to make them available via the TargetRegistry.
69   ///
70   /// It is legal for a client to make multiple calls to this function.
71   inline void InitializeAllTargets() {
72     // FIXME: Remove this, clients should do it.
73     InitializeAllTargetInfos();
74
75 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
76 #include "llvm/Config/Targets.def"
77   }
78   
79   /// InitializeAllMCAsmInfos - The main program should call this function
80   /// if it wants access to all available assembly infos for targets that
81   /// LLVM is configured to support, to make them available via the
82   /// TargetRegistry.
83   ///
84   /// It is legal for a client to make multiple calls to this function.
85   inline void InitializeAllMCAsmInfos() {
86 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##MCAsmInfo();
87 #include "llvm/Config/Targets.def"
88   }
89   
90   /// InitializeAllMCInstrInfos - The main program should call this function
91   /// if it wants access to all available instruction infos for targets that
92   /// LLVM is configured to support, to make them available via the
93   /// TargetRegistry.
94   ///
95   /// It is legal for a client to make multiple calls to this function.
96   inline void InitializeAllMCInstrInfos() {
97 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##MCInstrInfo();
98 #include "llvm/Config/Targets.def"
99   }
100   
101   /// InitializeAllMCSubtargetInfos - The main program should call this function
102   /// if it wants access to all available subtarget infos for targets that LLVM
103   /// is configured to support, to make them available via the TargetRegistry.
104   ///
105   /// It is legal for a client to make multiple calls to this function.
106   inline void InitializeAllMCSubtargetInfos() {
107 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##MCSubtargetInfo();
108 #include "llvm/Config/Targets.def"
109   }
110   
111   /// InitializeAllAsmPrinters - The main program should call this function if
112   /// it wants all asm printers that LLVM is configured to support, to make them
113   /// available via the TargetRegistry.
114   ///
115   /// It is legal for a client to make multiple calls to this function.
116   inline void InitializeAllAsmPrinters() {
117 #define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
118 #include "llvm/Config/AsmPrinters.def"
119   }
120   
121   /// InitializeAllAsmParsers - The main program should call this function if it
122   /// wants all asm parsers that LLVM is configured to support, to make them
123   /// available via the TargetRegistry.
124   ///
125   /// It is legal for a client to make multiple calls to this function.
126   inline void InitializeAllAsmParsers() {
127 #define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
128 #include "llvm/Config/AsmParsers.def"
129   }
130   
131   /// InitializeAllDisassemblers - The main program should call this function if
132   /// it wants all disassemblers that LLVM is configured to support, to make
133   /// them available via the TargetRegistry.
134   ///
135   /// It is legal for a client to make multiple calls to this function.
136   inline void InitializeAllDisassemblers() {
137 #define LLVM_DISASSEMBLER(TargetName) LLVMInitialize##TargetName##Disassembler();
138 #include "llvm/Config/Disassemblers.def"
139   }
140   
141   /// InitializeNativeTarget - The main program should call this function to
142   /// initialize the native target corresponding to the host.  This is useful 
143   /// for JIT applications to ensure that the target gets linked in correctly.
144   ///
145   /// It is legal for a client to make multiple calls to this function.
146   inline bool InitializeNativeTarget() {
147   // If we have a native target, initialize it to ensure it is linked in.
148 #ifdef LLVM_NATIVE_TARGET
149     LLVM_NATIVE_TARGETINFO();
150     LLVM_NATIVE_TARGET();
151     LLVM_NATIVE_MCASMINFO();
152     return false;
153 #else
154     return true;
155 #endif
156   }  
157
158   /// InitializeNativeTargetAsmPrinter - The main program should call
159   /// this function to initialize the native target asm printer.
160   inline bool InitializeNativeTargetAsmPrinter() {
161   // If we have a native target, initialize the corresponding asm printer.
162 #ifdef LLVM_NATIVE_ASMPRINTER
163     LLVM_NATIVE_ASMPRINTER();
164     return false;
165 #else
166     return true;
167 #endif
168   }  
169
170   /// InitializeNativeTargetAsmParser - The main program should call
171   /// this function to initialize the native target asm parser.
172   inline bool InitializeNativeTargetAsmParser() {
173   // If we have a native target, initialize the corresponding asm parser.
174 #ifdef LLVM_NATIVE_ASMPARSER
175     LLVM_NATIVE_ASMPARSER();
176     return false;
177 #else
178     return true;
179 #endif
180   }  
181
182 }
183
184 #endif