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##MCInstrInfo();
35 #include "llvm/Config/Targets.def"
37 #define LLVM_TARGET(TargetName) \
38 void LLVMInitialize##TargetName##MCSubtargetInfo();
39 #include "llvm/Config/Targets.def"
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"
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"
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"
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.
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"
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.
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();
75 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
76 #include "llvm/Config/Targets.def"
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
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"
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
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"
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.
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"
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.
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"
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.
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"
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.
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"
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.
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();
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();
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();