LLVM 24.0.0git
Target.h
Go to the documentation of this file.
1/*===-- llvm-c/Target.h - Target Lib C Iface --------------------*- C++ -*-===*/
2/* */
3/* Part of the LLVM Project, under the Apache License v2.0 with LLVM */
4/* Exceptions. */
5/* See https://llvm.org/LICENSE.txt for license information. */
6/* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */
7/* */
8/*===----------------------------------------------------------------------===*/
9/* */
10/* This header declares the C interface to libLLVMTarget.a, which */
11/* implements target information. */
12/* */
13/* Many exotic languages can interoperate with C code but have a harder time */
14/* with C++ due to name mangling. So in addition to C, this interface enables */
15/* tools written in such languages. */
16/* */
17/*===----------------------------------------------------------------------===*/
18
19#ifndef LLVM_C_TARGET_H
20#define LLVM_C_TARGET_H
21
22#include "llvm-c/Deprecated.h"
23#include "llvm-c/ExternC.h"
24#include "llvm-c/Types.h"
25#include "llvm-c/Visibility.h"
26#include "llvm/Config/llvm-config.h"
27
29
30/**
31 * @defgroup LLVMCTarget Target information
32 * @ingroup LLVMC
33 *
34 * @{
35 */
36
37typedef struct LLVMOpaqueTargetLibraryInfotData *LLVMTargetLibraryInfoRef;
38
39/** Adds target library information to a pass manager. This does not take
40 ownership of the target library info.
41 See the method llvm::PassManagerBase::add. */
44
45/* Declare all of the target-initialization functions that are available. */
46#define LLVM_TARGET(TargetName) \
47 LLVM_C_ABI void LLVMInitialize##TargetName##TargetInfo(void);
48#include "llvm/Config/Targets.def"
49#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
50
51#define LLVM_TARGET(TargetName) \
52 LLVM_C_ABI void LLVMInitialize##TargetName##Target(void);
53#include "llvm/Config/Targets.def"
54#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
55
56#define LLVM_TARGET(TargetName) \
57 LLVM_C_ABI void LLVMInitialize##TargetName##TargetMC(void);
58#include "llvm/Config/Targets.def"
59#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
60
61/* Declare all of the available assembly printer initialization functions. */
62#define LLVM_ASM_PRINTER(TargetName) \
63 LLVM_C_ABI void LLVMInitialize##TargetName##AsmPrinter(void);
64#include "llvm/Config/AsmPrinters.def"
65#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */
66
67/* Declare all of the available assembly parser initialization functions. */
68#define LLVM_ASM_PARSER(TargetName) \
69 LLVM_C_ABI void LLVMInitialize##TargetName##AsmParser(void);
70#include "llvm/Config/AsmParsers.def"
71#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */
72
73/* Declare all of the available disassembler initialization functions. */
74#define LLVM_DISASSEMBLER(TargetName) \
75 LLVM_C_ABI void LLVMInitialize##TargetName##Disassembler(void);
76#include "llvm/Config/Disassemblers.def"
77#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */
78
79/** LLVMInitializeAllTargetInfos - The main program should call this function if
80 it wants access to all available targets that LLVM is configured to
81 support. */
82static inline void LLVMInitializeAllTargetInfos(void) {
83#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
84#include "llvm/Config/Targets.def"
85#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
86}
87
88/** LLVMInitializeAllTargets - The main program should call this function if it
89 wants to link in all available targets that LLVM is configured to
90 support. */
91static inline void LLVMInitializeAllTargets(void) {
92#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
93#include "llvm/Config/Targets.def"
94#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
95}
96
97/** LLVMInitializeAllTargetMCs - The main program should call this function if
98 it wants access to all available target MC that LLVM is configured to
99 support. */
100static inline void LLVMInitializeAllTargetMCs(void) {
101#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC();
102#include "llvm/Config/Targets.def"
103#undef LLVM_TARGET /* Explicit undef to make SWIG happier */
104}
105
106/** LLVMInitializeAllAsmPrinters - The main program should call this function if
107 it wants all asm printers that LLVM is configured to support, to make them
108 available via the TargetRegistry. */
109static inline void LLVMInitializeAllAsmPrinters(void) {
110#define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
111#include "llvm/Config/AsmPrinters.def"
112#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */
113}
114
115/** LLVMInitializeAllAsmParsers - The main program should call this function if
116 it wants all asm parsers that LLVM is configured to support, to make them
117 available via the TargetRegistry. */
118static inline void LLVMInitializeAllAsmParsers(void) {
119#define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
120#include "llvm/Config/AsmParsers.def"
121#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */
122}
123
124/** LLVMInitializeAllDisassemblers - The main program should call this function
125 if it wants all disassemblers that LLVM is configured to support, to make
126 them available via the TargetRegistry. */
127static inline void LLVMInitializeAllDisassemblers(void) {
128#define LLVM_DISASSEMBLER(TargetName) \
129 LLVMInitialize##TargetName##Disassembler();
130#include "llvm/Config/Disassemblers.def"
131#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */
132}
133
134/** LLVMInitializeNativeTarget - The main program should call this function to
135 initialize the native target corresponding to the host. This is useful
136 for JIT applications to ensure that the target gets linked in correctly. */
138 /* If we have a native target, initialize it to ensure it is linked in. */
139#ifdef LLVM_NATIVE_TARGET
140 LLVM_NATIVE_TARGETINFO();
141 LLVM_NATIVE_TARGET();
142 LLVM_NATIVE_TARGETMC();
143 return 0;
144#else
145 return 1;
146#endif
147}
148
149/** LLVMInitializeNativeTargetAsmParser - The main program should call this
150 function to initialize the parser for the native target corresponding to the
151 host. */
153#ifdef LLVM_NATIVE_ASMPARSER
154 LLVM_NATIVE_ASMPARSER();
155 return 0;
156#else
157 return 1;
158#endif
159}
160
161/** LLVMInitializeNativeTargetAsmPrinter - The main program should call this
162 function to initialize the printer for the native target corresponding to
163 the host. */
165#ifdef LLVM_NATIVE_ASMPRINTER
166 LLVM_NATIVE_ASMPRINTER();
167 return 0;
168#else
169 return 1;
170#endif
171}
172
173/** LLVMInitializeNativeTargetDisassembler - The main program should call this
174 function to initialize the disassembler for the native target corresponding
175 to the host. */
177#ifdef LLVM_NATIVE_DISASSEMBLER
178 LLVM_NATIVE_DISASSEMBLER();
179 return 0;
180#else
181 return 1;
182#endif
183}
184
185/**
186 * @}
187 */
188
190
191#endif
#define LLVM_C_EXTERN_C_BEGIN
Definition ExternC.h:35
#define LLVM_C_EXTERN_C_END
Definition ExternC.h:36
#define LLVM_C_ABI
LLVM_C_ABI is the export/visibility macro used to mark symbols declared in llvm-c as exported when bu...
Definition Visibility.h:40
int LLVMBool
Definition Types.h:28
struct LLVMOpaquePassManager * LLVMPassManagerRef
Definition Types.h:127
static LLVMBool LLVMInitializeNativeAsmParser(void)
LLVMInitializeNativeTargetAsmParser - The main program should call this function to initialize the pa...
Definition Target.h:152
LLVM_C_ABI void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef TLI, LLVMPassManagerRef PM)
Adds target library information to a pass manager.
Definition Target.cpp:36
static void LLVMInitializeAllTargetInfos(void)
LLVMInitializeAllTargetInfos - The main program should call this function if it wants access to all a...
Definition Target.h:82
static LLVMBool LLVMInitializeNativeAsmPrinter(void)
LLVMInitializeNativeTargetAsmPrinter - The main program should call this function to initialize the p...
Definition Target.h:164
static LLVMBool LLVMInitializeNativeDisassembler(void)
LLVMInitializeNativeTargetDisassembler - The main program should call this function to initialize the...
Definition Target.h:176
static void LLVMInitializeAllTargetMCs(void)
LLVMInitializeAllTargetMCs - The main program should call this function if it wants access to all ava...
Definition Target.h:100
struct LLVMOpaqueTargetLibraryInfotData * LLVMTargetLibraryInfoRef
Definition Target.h:37
static void LLVMInitializeAllAsmParsers(void)
LLVMInitializeAllAsmParsers - The main program should call this function if it wants all asm parsers ...
Definition Target.h:118
static LLVMBool LLVMInitializeNativeTarget(void)
LLVMInitializeNativeTarget - The main program should call this function to initialize the native targ...
Definition Target.h:137
static void LLVMInitializeAllTargets(void)
LLVMInitializeAllTargets - The main program should call this function if it wants to link in all avai...
Definition Target.h:91
static void LLVMInitializeAllAsmPrinters(void)
LLVMInitializeAllAsmPrinters - The main program should call this function if it wants all asm printer...
Definition Target.h:109
static void LLVMInitializeAllDisassemblers(void)
LLVMInitializeAllDisassemblers - The main program should call this function if it wants all disassemb...
Definition Target.h:127