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/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 available assembly printer initialization functions.
30 #define LLVM_ASM_PRINTER(TargetName) void LLVMInitialize##TargetName##AsmPrinter();
31 #include "llvm/Config/AsmPrinters.def"
33 // Declare all of the available assembly parser initialization functions.
34 #define LLVM_ASM_PARSER(TargetName) void LLVMInitialize##TargetName##AsmParser();
35 #include "llvm/Config/AsmParsers.def"
39 /// InitializeAllTargetInfos - The main program should call this function if
40 /// it wants access to all available targets that LLVM is configured to
41 /// support, to make them available via the TargetRegistry.
43 /// It is legal for a client to make multiple calls to this function.
44 inline void InitializeAllTargetInfos() {
45 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
46 #include "llvm/Config/Targets.def"
49 /// InitializeAllTargets - The main program should call this function if it
50 /// wants access to all available target machines that LLVM is configured to
51 /// support, to make them available via the TargetRegistry.
53 /// It is legal for a client to make multiple calls to this function.
54 inline void InitializeAllTargets() {
55 // FIXME: Remove this, clients should do it.
56 InitializeAllTargetInfos();
58 #define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
59 #include "llvm/Config/Targets.def"
62 /// InitializeAllAsmPrinters - The main program should call this function if
63 /// it wants all asm printers that LLVM is configured to support, to make them
64 /// available via the TargetRegistry.
66 /// It is legal for a client to make multiple calls to this function.
67 inline void InitializeAllAsmPrinters() {
68 #define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
69 #include "llvm/Config/AsmPrinters.def"
72 /// InitializeAllAsmParsers - The main program should call this function if it
73 /// wants all asm parsers that LLVM is configured to support, to make them
74 /// available via the TargetRegistry.
76 /// It is legal for a client to make multiple calls to this function.
77 inline void InitializeAllAsmParsers() {
78 #define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
79 #include "llvm/Config/AsmParsers.def"
82 /// InitializeNativeTarget - The main program should call this function to
83 /// initialize the native target corresponding to the host. This is useful
84 /// for JIT applications to ensure that the target gets linked in correctly.
86 /// It is legal for a client to make multiple calls to this function.
87 inline bool InitializeNativeTarget() {
88 // If we have a native target, initialize it to ensure it is linked in.
89 #ifdef LLVM_NATIVE_ARCH
90 #define DoInit2(TARG) \
91 LLVMInitialize ## TARG ## Info (); \
92 LLVMInitialize ## TARG ()
93 #define DoInit(T) DoInit2(T)
94 DoInit(LLVM_NATIVE_ARCH);