1 //===- TargetSelect.h - Target Selection & Registration ---------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_TARGET_TARGETSELECT_H
17 #define LLVM_TARGET_TARGETSELECT_H
19 #include "llvm/Config/llvm-config.h"
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"
26 #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target();
27 #include "llvm/Config/Targets.def"
29 #define LLVM_TARGET(TargetName) \
30 void LLVMInitialize##TargetName##MCAsmInfo();
31 #include "llvm/Config/Targets.def"
33 #define LLVM_TARGET(TargetName) \
34 void LLVMInitialize##TargetName##MCCodeGenInfo();
35 #include "llvm/Config/Targets.def"
37 #define LLVM_TARGET(TargetName) \
38 void LLVMInitialize##TargetName##MCInstrInfo();
39 #include "llvm/Config/Targets.def"
41 #define LLVM_TARGET(TargetName) \
42 void LLVMInitialize##TargetName##MCRegisterInfo();
43 #include "llvm/Config/Targets.def"
45 #define LLVM_TARGET(TargetName) \
46 void LLVMInitialize##TargetName##MCSubtargetInfo();
47 #include "llvm/Config/Targets.def"
49 // Declare all of the available assembly printer initialization functions.
50 #define LLVM_ASM_PRINTER(TargetName) void LLVMInitialize##TargetName##AsmPrinter();
51 #include "llvm/Config/AsmPrinters.def"
53 // Declare all of the available assembly parser initialization functions.
54 #define LLVM_ASM_PARSER(TargetName) void LLVMInitialize##TargetName##AsmParser();
55 #include "llvm/Config/AsmParsers.def"
57 // Declare all of the available disassembler initialization functions.
58 #define LLVM_DISASSEMBLER(TargetName) \
59 void LLVMInitialize##TargetName##Disassembler();
60 #include "llvm/Config/Disassemblers.def"
64 /// InitializeAllTargetInfos - The main program should call this function if
65 /// it wants access to all available targets that LLVM is configured to
66 /// support, to make them available via the TargetRegistry.
68 /// It is legal for a client to make multiple calls to this function.
69 inline void InitializeAllTargetInfos() {
70 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
71 #include "llvm/Config/Targets.def"
74 /// InitializeAllTargets - The main program should call this function if it
75 /// wants access to all available target machines that LLVM is configured to
76 /// support, to make them available via the TargetRegistry.
78 /// It is legal for a client to make multiple calls to this function.
79 inline void InitializeAllTargets() {
80 // FIXME: Remove this, clients should do it.
81 InitializeAllTargetInfos();
83 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
84 #include "llvm/Config/Targets.def"
87 /// InitializeAllMCAsmInfos - The main program should call this function
88 /// if it wants access to all available assembly infos for targets that
89 /// LLVM is configured to support, to make them available via the
92 /// It is legal for a client to make multiple calls to this function.
93 inline void InitializeAllMCAsmInfos() {
94 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##MCAsmInfo();
95 #include "llvm/Config/Targets.def"
98 /// InitializeAllMCCodeGenInfos - The main program should call this function
99 /// if it wants access to all targets machines that LLVM is configured to
100 /// support, to make them available via the TargetRegistry.
102 /// It is legal for a client to make multiple calls to this function.
103 inline void InitializeAllMCCodeGenInfos() {
104 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##MCCodeGenInfo();
105 #include "llvm/Config/Targets.def"
108 /// InitializeAllMCInstrInfos - The main program should call this function
109 /// if it wants access to all available instruction infos for targets that
110 /// LLVM is configured to support, to make them available via the
113 /// It is legal for a client to make multiple calls to this function.
114 inline void InitializeAllMCInstrInfos() {
115 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##MCInstrInfo();
116 #include "llvm/Config/Targets.def"
119 /// InitializeAllMCRegisterInfos - The main program should call this function
120 /// if it wants access to all available register infos for targets that
121 /// LLVM is configured to support, to make them available via the
124 /// It is legal for a client to make multiple calls to this function.
125 inline void InitializeAllMCRegisterInfos() {
126 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##MCRegisterInfo();
127 #include "llvm/Config/Targets.def"
130 /// InitializeAllMCSubtargetInfos - The main program should call this function
131 /// if it wants access to all available subtarget infos for targets that LLVM
132 /// is configured to support, to make them available via the TargetRegistry.
134 /// It is legal for a client to make multiple calls to this function.
135 inline void InitializeAllMCSubtargetInfos() {
136 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##MCSubtargetInfo();
137 #include "llvm/Config/Targets.def"
140 /// InitializeAllAsmPrinters - The main program should call this function if
141 /// it wants all asm printers that LLVM is configured to support, to make them
142 /// available via the TargetRegistry.
144 /// It is legal for a client to make multiple calls to this function.
145 inline void InitializeAllAsmPrinters() {
146 #define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
147 #include "llvm/Config/AsmPrinters.def"
150 /// InitializeAllAsmParsers - The main program should call this function if it
151 /// wants all asm parsers that LLVM is configured to support, to make them
152 /// available via the TargetRegistry.
154 /// It is legal for a client to make multiple calls to this function.
155 inline void InitializeAllAsmParsers() {
156 #define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
157 #include "llvm/Config/AsmParsers.def"
160 /// InitializeAllDisassemblers - The main program should call this function if
161 /// it wants all disassemblers that LLVM is configured to support, to make
162 /// them available via the TargetRegistry.
164 /// It is legal for a client to make multiple calls to this function.
165 inline void InitializeAllDisassemblers() {
166 #define LLVM_DISASSEMBLER(TargetName) LLVMInitialize##TargetName##Disassembler();
167 #include "llvm/Config/Disassemblers.def"
170 /// InitializeNativeTarget - The main program should call this function to
171 /// initialize the native target corresponding to the host. This is useful
172 /// for JIT applications to ensure that the target gets linked in correctly.
174 /// It is legal for a client to make multiple calls to this function.
175 inline bool InitializeNativeTarget() {
176 // If we have a native target, initialize it to ensure it is linked in.
177 #ifdef LLVM_NATIVE_TARGET
178 LLVM_NATIVE_TARGETINFO();
179 LLVM_NATIVE_TARGET();
180 LLVM_NATIVE_MCASMINFO();
181 LLVM_NATIVE_MCCODEGENINFO();
188 /// InitializeNativeTargetAsmPrinter - The main program should call
189 /// this function to initialize the native target asm printer.
190 inline bool InitializeNativeTargetAsmPrinter() {
191 // If we have a native target, initialize the corresponding asm printer.
192 #ifdef LLVM_NATIVE_ASMPRINTER
193 LLVM_NATIVE_ASMPRINTER();
200 /// InitializeNativeTargetAsmParser - The main program should call
201 /// this function to initialize the native target asm parser.
202 inline bool InitializeNativeTargetAsmParser() {
203 // If we have a native target, initialize the corresponding asm parser.
204 #ifdef LLVM_NATIVE_ASMPARSER
205 LLVM_NATIVE_ASMPARSER();