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"
37
// Declare all of the available disassembler initialization functions.
38
#define LLVM_DISASSEMBLER(TargetName) void LLVMInitialize##TargetName##Disassembler();
39
#include "llvm/Config/Disassemblers.def"
43
/// InitializeAllTargetInfos - The main program should call this function if
44
/// it wants access to all available targets that LLVM is configured to
45
/// support, to make them available via the TargetRegistry.
47
/// It is legal for a client to make multiple calls to this function.
48
inline void InitializeAllTargetInfos() {
49
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
50
#include "llvm/Config/Targets.def"
53
/// InitializeAllTargets - The main program should call this function if it
54
/// wants access to all available target machines that LLVM is configured to
55
/// support, to make them available via the TargetRegistry.
57
/// It is legal for a client to make multiple calls to this function.
58
inline void InitializeAllTargets() {
59
// FIXME: Remove this, clients should do it.
60
InitializeAllTargetInfos();
62
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
63
#include "llvm/Config/Targets.def"
66
/// InitializeAllAsmPrinters - The main program should call this function if
67
/// it wants all asm printers that LLVM is configured to support, to make them
68
/// available via the TargetRegistry.
70
/// It is legal for a client to make multiple calls to this function.
71
inline void InitializeAllAsmPrinters() {
72
#define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
73
#include "llvm/Config/AsmPrinters.def"
76
/// InitializeAllAsmParsers - The main program should call this function if it
77
/// wants all asm parsers that LLVM is configured to support, to make them
78
/// available via the TargetRegistry.
80
/// It is legal for a client to make multiple calls to this function.
81
inline void InitializeAllAsmParsers() {
82
#define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
83
#include "llvm/Config/AsmParsers.def"
86
/// InitializeAllDisassemblers - The main program should call this function if
87
/// it wants all disassemblers that LLVM is configured to support, to make
88
/// them available via the TargetRegistry.
90
/// It is legal for a client to make multiple calls to this function.
91
inline void InitializeAllDisassemblers() {
92
#define LLVM_DISASSEMBLER(TargetName) LLVMInitialize##TargetName##Disassembler();
93
#include "llvm/Config/Disassemblers.def"
96
/// InitializeNativeTarget - The main program should call this function to
97
/// initialize the native target corresponding to the host. This is useful
98
/// for JIT applications to ensure that the target gets linked in correctly.
100
/// It is legal for a client to make multiple calls to this function.
101
inline bool InitializeNativeTarget() {
102
// If we have a native target, initialize it to ensure it is linked in.
103
#ifdef LLVM_NATIVE_ARCH
104
#define DoInit2(TARG) \
105
LLVMInitialize ## TARG ## Info (); \
106
LLVMInitialize ## TARG ()
107
#define DoInit(T) DoInit2(T)
108
DoInit(LLVM_NATIVE_ARCH);