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_SUPPORT_TARGETSELECT_H
17 #define LLVM_SUPPORT_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 // Declare all of the target-MC-initialization functions that are available.
30 #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##TargetMC();
31 #include "llvm/Config/Targets.def"
33 // Declare all of the available assembly printer initialization functions.
34 #define LLVM_ASM_PRINTER(TargetName) void LLVMInitialize##TargetName##AsmPrinter();
35 #include "llvm/Config/AsmPrinters.def"
37 // Declare all of the available assembly parser initialization functions.
38 #define LLVM_ASM_PARSER(TargetName) void LLVMInitialize##TargetName##AsmParser();
39 #include "llvm/Config/AsmParsers.def"
41 // Declare all of the available disassembler initialization functions.
42 #define LLVM_DISASSEMBLER(TargetName) \
43 void LLVMInitialize##TargetName##Disassembler();
44 #include "llvm/Config/Disassemblers.def"
48 /// InitializeAllTargetInfos - The main program should call this function if
49 /// it wants access to all available targets that LLVM is configured to
50 /// support, to make them available via the TargetRegistry.
52 /// It is legal for a client to make multiple calls to this function.
53 inline void InitializeAllTargetInfos() {
54 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
55 #include "llvm/Config/Targets.def"
58 /// InitializeAllTargets - The main program should call this function if it
59 /// wants access to all available target machines that LLVM is configured to
60 /// support, to make them available via the TargetRegistry.
62 /// It is legal for a client to make multiple calls to this function.
63 inline void InitializeAllTargets() {
64 // FIXME: Remove this, clients should do it.
65 InitializeAllTargetInfos();
67 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
68 #include "llvm/Config/Targets.def"
71 /// InitializeAllTargetMCs - The main program should call this function if it
72 /// wants access to all available target MC that LLVM is configured to
73 /// support, to make them available via the TargetRegistry.
75 /// It is legal for a client to make multiple calls to this function.
76 inline void InitializeAllTargetMCs() {
77 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC();
78 #include "llvm/Config/Targets.def"
81 /// InitializeAllAsmPrinters - The main program should call this function if
82 /// it wants all asm printers that LLVM is configured to support, to make them
83 /// available via the TargetRegistry.
85 /// It is legal for a client to make multiple calls to this function.
86 inline void InitializeAllAsmPrinters() {
87 #define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
88 #include "llvm/Config/AsmPrinters.def"
91 /// InitializeAllAsmParsers - The main program should call this function if it
92 /// wants all asm parsers that LLVM is configured to support, to make them
93 /// available via the TargetRegistry.
95 /// It is legal for a client to make multiple calls to this function.
96 inline void InitializeAllAsmParsers() {
97 #define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
98 #include "llvm/Config/AsmParsers.def"
101 /// InitializeAllDisassemblers - The main program should call this function if
102 /// it wants all disassemblers that LLVM is configured to support, to make
103 /// them available via the TargetRegistry.
105 /// It is legal for a client to make multiple calls to this function.
106 inline void InitializeAllDisassemblers() {
107 #define LLVM_DISASSEMBLER(TargetName) LLVMInitialize##TargetName##Disassembler();
108 #include "llvm/Config/Disassemblers.def"
111 /// InitializeNativeTarget - The main program should call this function to
112 /// initialize the native target corresponding to the host. This is useful
113 /// for JIT applications to ensure that the target gets linked in correctly.
115 /// It is legal for a client to make multiple calls to this function.
116 inline bool InitializeNativeTarget() {
117 // If we have a native target, initialize it to ensure it is linked in.
118 #ifdef LLVM_NATIVE_TARGET
119 LLVM_NATIVE_TARGETINFO();
120 LLVM_NATIVE_TARGET();
121 LLVM_NATIVE_TARGETMC();
128 /// InitializeNativeTargetAsmPrinter - The main program should call
129 /// this function to initialize the native target asm printer.
130 inline bool InitializeNativeTargetAsmPrinter() {
131 // If we have a native target, initialize the corresponding asm printer.
132 #ifdef LLVM_NATIVE_ASMPRINTER
133 LLVM_NATIVE_ASMPRINTER();
140 /// InitializeNativeTargetAsmParser - The main program should call
141 /// this function to initialize the native target asm parser.
142 inline bool InitializeNativeTargetAsmParser() {
143 // If we have a native target, initialize the corresponding asm parser.
144 #ifdef LLVM_NATIVE_ASMPARSER
145 LLVM_NATIVE_ASMPARSER();
152 /// InitializeNativeTargetDisassembler - The main program should call
153 /// this function to initialize the native target disassembler.
154 inline bool InitializeNativeTargetDisassembler() {
155 // If we have a native target, initialize the corresponding disassembler.
156 #ifdef LLVM_NATIVE_DISASSEMBLER
157 LLVM_NATIVE_DISASSEMBLER();