1 //===- TargetSelect.h - Target Selection & Registration ---------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file provides utilities to make sure that certain classes of targets are
10 // linked into the main application executable, and initialize them as
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_SUPPORT_TARGETSELECT_H
16 #define LLVM_SUPPORT_TARGETSELECT_H
18 #include "llvm/Config/llvm-config.h"
21 // Declare all of the target-initialization functions that are available.
22 #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##TargetInfo();
23 #include "llvm/Config/Targets.def"
25 #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target();
26 #include "llvm/Config/Targets.def"
28 // Declare all of the target-MC-initialization functions that are available.
29 #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##TargetMC();
30 #include "llvm/Config/Targets.def"
32 // Declare all of the available assembly printer initialization functions.
33 #define LLVM_ASM_PRINTER(TargetName) void LLVMInitialize##TargetName##AsmPrinter();
34 #include "llvm/Config/AsmPrinters.def"
36 // Declare all of the available assembly parser initialization functions.
37 #define LLVM_ASM_PARSER(TargetName) void LLVMInitialize##TargetName##AsmParser();
38 #include "llvm/Config/AsmParsers.def"
40 // Declare all of the available disassembler initialization functions.
41 #define LLVM_DISASSEMBLER(TargetName) \
42 void LLVMInitialize##TargetName##Disassembler();
43 #include "llvm/Config/Disassemblers.def"
47 /// InitializeAllTargetInfos - The main program should call this function if
48 /// it wants access to all available targets that LLVM is configured to
49 /// support, to make them available via the TargetRegistry.
51 /// It is legal for a client to make multiple calls to this function.
52 inline void InitializeAllTargetInfos() {
53 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
54 #include "llvm/Config/Targets.def"
57 /// InitializeAllTargets - The main program should call this function if it
58 /// wants access to all available target machines that LLVM is configured to
59 /// support, to make them available via the TargetRegistry.
61 /// It is legal for a client to make multiple calls to this function.
62 inline void InitializeAllTargets() {
63 // FIXME: Remove this, clients should do it.
64 InitializeAllTargetInfos();
66 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
67 #include "llvm/Config/Targets.def"
70 /// InitializeAllTargetMCs - The main program should call this function if it
71 /// wants access to all available target MC that LLVM is configured to
72 /// support, to make them available via the TargetRegistry.
74 /// It is legal for a client to make multiple calls to this function.
75 inline void InitializeAllTargetMCs() {
76 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC();
77 #include "llvm/Config/Targets.def"
80 /// InitializeAllAsmPrinters - The main program should call this function if
81 /// it wants all asm printers that LLVM is configured to support, to make them
82 /// available via the TargetRegistry.
84 /// It is legal for a client to make multiple calls to this function.
85 inline void InitializeAllAsmPrinters() {
86 #define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
87 #include "llvm/Config/AsmPrinters.def"
90 /// InitializeAllAsmParsers - The main program should call this function if it
91 /// wants all asm parsers that LLVM is configured to support, to make them
92 /// available via the TargetRegistry.
94 /// It is legal for a client to make multiple calls to this function.
95 inline void InitializeAllAsmParsers() {
96 #define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
97 #include "llvm/Config/AsmParsers.def"
100 /// InitializeAllDisassemblers - The main program should call this function if
101 /// it wants all disassemblers that LLVM is configured to support, to make
102 /// them available via the TargetRegistry.
104 /// It is legal for a client to make multiple calls to this function.
105 inline void InitializeAllDisassemblers() {
106 #define LLVM_DISASSEMBLER(TargetName) LLVMInitialize##TargetName##Disassembler();
107 #include "llvm/Config/Disassemblers.def"
110 /// InitializeNativeTarget - The main program should call this function to
111 /// initialize the native target corresponding to the host. This is useful
112 /// for JIT applications to ensure that the target gets linked in correctly.
114 /// It is legal for a client to make multiple calls to this function.
115 inline bool InitializeNativeTarget() {
116 // If we have a native target, initialize it to ensure it is linked in.
117 #ifdef LLVM_NATIVE_TARGET
118 LLVM_NATIVE_TARGETINFO();
119 LLVM_NATIVE_TARGET();
120 LLVM_NATIVE_TARGETMC();
127 /// InitializeNativeTargetAsmPrinter - The main program should call
128 /// this function to initialize the native target asm printer.
129 inline bool InitializeNativeTargetAsmPrinter() {
130 // If we have a native target, initialize the corresponding asm printer.
131 #ifdef LLVM_NATIVE_ASMPRINTER
132 LLVM_NATIVE_ASMPRINTER();
139 /// InitializeNativeTargetAsmParser - The main program should call
140 /// this function to initialize the native target asm parser.
141 inline bool InitializeNativeTargetAsmParser() {
142 // If we have a native target, initialize the corresponding asm parser.
143 #ifdef LLVM_NATIVE_ASMPARSER
144 LLVM_NATIVE_ASMPARSER();
151 /// InitializeNativeTargetDisassembler - The main program should call
152 /// this function to initialize the native target disassembler.
153 inline bool InitializeNativeTargetDisassembler() {
154 // If we have a native target, initialize the corresponding disassembler.
155 #ifdef LLVM_NATIVE_DISASSEMBLER
156 LLVM_NATIVE_DISASSEMBLER();