Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm-c/Target.h
Line
Count
Source (jump to first uncovered line)
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/Types.h"
23
#include "llvm/Config/llvm-config.h"
24
25
#ifdef __cplusplus
26
extern "C" {
27
#endif
28
29
/**
30
 * @defgroup LLVMCTarget Target information
31
 * @ingroup LLVMC
32
 *
33
 * @{
34
 */
35
36
enum LLVMByteOrdering { LLVMBigEndian, LLVMLittleEndian };
37
38
typedef struct LLVMOpaqueTargetData *LLVMTargetDataRef;
39
typedef struct LLVMOpaqueTargetLibraryInfotData *LLVMTargetLibraryInfoRef;
40
41
/* Declare all of the target-initialization functions that are available. */
42
#define LLVM_TARGET(TargetName) \
43
  void LLVMInitialize##TargetName##TargetInfo(void);
44
#include "llvm/Config/Targets.def"
45
#undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
46
47
#define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target(void);
48
#include "llvm/Config/Targets.def"
49
#undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
50
51
#define LLVM_TARGET(TargetName) \
52
  void LLVMInitialize##TargetName##TargetMC(void);
53
#include "llvm/Config/Targets.def"
54
#undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
55
56
/* Declare all of the available assembly printer initialization functions. */
57
#define LLVM_ASM_PRINTER(TargetName) \
58
  void LLVMInitialize##TargetName##AsmPrinter(void);
59
#include "llvm/Config/AsmPrinters.def"
60
#undef LLVM_ASM_PRINTER  /* Explicit undef to make SWIG happier */
61
62
/* Declare all of the available assembly parser initialization functions. */
63
#define LLVM_ASM_PARSER(TargetName) \
64
  void LLVMInitialize##TargetName##AsmParser(void);
65
#include "llvm/Config/AsmParsers.def"
66
#undef LLVM_ASM_PARSER  /* Explicit undef to make SWIG happier */
67
68
/* Declare all of the available disassembler initialization functions. */
69
#define LLVM_DISASSEMBLER(TargetName) \
70
  void LLVMInitialize##TargetName##Disassembler(void);
71
#include "llvm/Config/Disassemblers.def"
72
#undef LLVM_DISASSEMBLER  /* Explicit undef to make SWIG happier */
73
74
/** LLVMInitializeAllTargetInfos - The main program should call this function if
75
    it wants access to all available targets that LLVM is configured to
76
    support. */
77
0
static inline void LLVMInitializeAllTargetInfos(void) {
78
0
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo();
79
0
#include "llvm/Config/Targets.def"
80
0
#undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
81
0
}
82
83
/** LLVMInitializeAllTargets - The main program should call this function if it
84
    wants to link in all available targets that LLVM is configured to
85
    support. */
86
0
static inline void LLVMInitializeAllTargets(void) {
87
0
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target();
88
0
#include "llvm/Config/Targets.def"
89
0
#undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
90
0
}
91
92
/** LLVMInitializeAllTargetMCs - The main program should call this function if
93
    it wants access to all available target MC that LLVM is configured to
94
    support. */
95
0
static inline void LLVMInitializeAllTargetMCs(void) {
96
0
#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC();
97
0
#include "llvm/Config/Targets.def"
98
0
#undef LLVM_TARGET  /* Explicit undef to make SWIG happier */
99
0
}
100
101
/** LLVMInitializeAllAsmPrinters - The main program should call this function if
102
    it wants all asm printers that LLVM is configured to support, to make them
103
    available via the TargetRegistry. */
104
0
static inline void LLVMInitializeAllAsmPrinters(void) {
105
0
#define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter();
106
0
#include "llvm/Config/AsmPrinters.def"
107
0
#undef LLVM_ASM_PRINTER  /* Explicit undef to make SWIG happier */
108
0
}
109
110
/** LLVMInitializeAllAsmParsers - The main program should call this function if
111
    it wants all asm parsers that LLVM is configured to support, to make them
112
    available via the TargetRegistry. */
113
0
static inline void LLVMInitializeAllAsmParsers(void) {
114
0
#define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser();
115
0
#include "llvm/Config/AsmParsers.def"
116
0
#undef LLVM_ASM_PARSER  /* Explicit undef to make SWIG happier */
117
0
}
118
119
/** LLVMInitializeAllDisassemblers - The main program should call this function
120
    if it wants all disassemblers that LLVM is configured to support, to make
121
    them available via the TargetRegistry. */
122
0
static inline void LLVMInitializeAllDisassemblers(void) {
123
0
#define LLVM_DISASSEMBLER(TargetName) \
124
0
  LLVMInitialize##TargetName##Disassembler();
125
0
#include "llvm/Config/Disassemblers.def"
126
0
#undef LLVM_DISASSEMBLER  /* Explicit undef to make SWIG happier */
127
0
}
128
129
/** LLVMInitializeNativeTarget - The main program should call this function to
130
    initialize the native target corresponding to the host.  This is useful
131
    for JIT applications to ensure that the target gets linked in correctly. */
132
0
static inline LLVMBool LLVMInitializeNativeTarget(void) {
133
0
  /* If we have a native target, initialize it to ensure it is linked in. */
134
0
#ifdef LLVM_NATIVE_TARGET
135
0
  LLVM_NATIVE_TARGETINFO();
136
0
  LLVM_NATIVE_TARGET();
137
0
  LLVM_NATIVE_TARGETMC();
138
0
  return 0;
139
0
#else
140
0
  return 1;
141
0
#endif
142
0
}
143
144
/** LLVMInitializeNativeTargetAsmParser - The main program should call this
145
    function to initialize the parser for the native target corresponding to the
146
    host. */
147
0
static inline LLVMBool LLVMInitializeNativeAsmParser(void) {
148
0
#ifdef LLVM_NATIVE_ASMPARSER
149
0
  LLVM_NATIVE_ASMPARSER();
150
0
  return 0;
151
0
#else
152
0
  return 1;
153
0
#endif
154
0
}
155
156
/** LLVMInitializeNativeTargetAsmPrinter - The main program should call this
157
    function to initialize the printer for the native target corresponding to
158
    the host. */
159
0
static inline LLVMBool LLVMInitializeNativeAsmPrinter(void) {
160
0
#ifdef LLVM_NATIVE_ASMPRINTER
161
0
  LLVM_NATIVE_ASMPRINTER();
162
0
  return 0;
163
0
#else
164
0
  return 1;
165
0
#endif
166
0
}
167
168
/** LLVMInitializeNativeTargetDisassembler - The main program should call this
169
    function to initialize the disassembler for the native target corresponding
170
    to the host. */
171
0
static inline LLVMBool LLVMInitializeNativeDisassembler(void) {
172
0
#ifdef LLVM_NATIVE_DISASSEMBLER
173
0
  LLVM_NATIVE_DISASSEMBLER();
174
0
  return 0;
175
0
#else
176
0
  return 1;
177
0
#endif
178
0
}
179
180
/*===-- Target Data -------------------------------------------------------===*/
181
182
/**
183
 * Obtain the data layout for a module.
184
 *
185
 * @see Module::getDataLayout()
186
 */
187
LLVMTargetDataRef LLVMGetModuleDataLayout(LLVMModuleRef M);
188
189
/**
190
 * Set the data layout for a module.
191
 *
192
 * @see Module::setDataLayout()
193
 */
194
void LLVMSetModuleDataLayout(LLVMModuleRef M, LLVMTargetDataRef DL);
195
196
/** Creates target data from a target layout string.
197
    See the constructor llvm::DataLayout::DataLayout. */
198
LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep);
199
200
/** Deallocates a TargetData.
201
    See the destructor llvm::DataLayout::~DataLayout. */
202
void LLVMDisposeTargetData(LLVMTargetDataRef TD);
203
204
/** Adds target library information to a pass manager. This does not take
205
    ownership of the target library info.
206
    See the method llvm::PassManagerBase::add. */
207
void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef TLI,
208
                              LLVMPassManagerRef PM);
209
210
/** Converts target data to a target layout string. The string must be disposed
211
    with LLVMDisposeMessage.
212
    See the constructor llvm::DataLayout::DataLayout. */
213
char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef TD);
214
215
/** Returns the byte order of a target, either LLVMBigEndian or
216
    LLVMLittleEndian.
217
    See the method llvm::DataLayout::isLittleEndian. */
218
enum LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef TD);
219
220
/** Returns the pointer size in bytes for a target.
221
    See the method llvm::DataLayout::getPointerSize. */
222
unsigned LLVMPointerSize(LLVMTargetDataRef TD);
223
224
/** Returns the pointer size in bytes for a target for a specified
225
    address space.
226
    See the method llvm::DataLayout::getPointerSize. */
227
unsigned LLVMPointerSizeForAS(LLVMTargetDataRef TD, unsigned AS);
228
229
/** Returns the integer type that is the same size as a pointer on a target.
230
    See the method llvm::DataLayout::getIntPtrType. */
231
LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef TD);
232
233
/** Returns the integer type that is the same size as a pointer on a target.
234
    This version allows the address space to be specified.
235
    See the method llvm::DataLayout::getIntPtrType. */
236
LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef TD, unsigned AS);
237
238
/** Returns the integer type that is the same size as a pointer on a target.
239
    See the method llvm::DataLayout::getIntPtrType. */
240
LLVMTypeRef LLVMIntPtrTypeInContext(LLVMContextRef C, LLVMTargetDataRef TD);
241
242
/** Returns the integer type that is the same size as a pointer on a target.
243
    This version allows the address space to be specified.
244
    See the method llvm::DataLayout::getIntPtrType. */
245
LLVMTypeRef LLVMIntPtrTypeForASInContext(LLVMContextRef C, LLVMTargetDataRef TD,
246
                                         unsigned AS);
247
248
/** Computes the size of a type in bytes for a target.
249
    See the method llvm::DataLayout::getTypeSizeInBits. */
250
unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty);
251
252
/** Computes the storage size of a type in bytes for a target.
253
    See the method llvm::DataLayout::getTypeStoreSize. */
254
unsigned long long LLVMStoreSizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty);
255
256
/** Computes the ABI size of a type in bytes for a target.
257
    See the method llvm::DataLayout::getTypeAllocSize. */
258
unsigned long long LLVMABISizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty);
259
260
/** Computes the ABI alignment of a type in bytes for a target.
261
    See the method llvm::DataLayout::getTypeABISize. */
262
unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty);
263
264
/** Computes the call frame alignment of a type in bytes for a target.
265
    See the method llvm::DataLayout::getTypeABISize. */
266
unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty);
267
268
/** Computes the preferred alignment of a type in bytes for a target.
269
    See the method llvm::DataLayout::getTypeABISize. */
270
unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty);
271
272
/** Computes the preferred alignment of a global variable in bytes for a target.
273
    See the method llvm::DataLayout::getPreferredAlignment. */
274
unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef TD,
275
                                        LLVMValueRef GlobalVar);
276
277
/** Computes the structure element that contains the byte offset for a target.
278
    See the method llvm::StructLayout::getElementContainingOffset. */
279
unsigned LLVMElementAtOffset(LLVMTargetDataRef TD, LLVMTypeRef StructTy,
280
                             unsigned long long Offset);
281
282
/** Computes the byte offset of the indexed struct element for a target.
283
    See the method llvm::StructLayout::getElementContainingOffset. */
284
unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef TD,
285
                                       LLVMTypeRef StructTy, unsigned Element);
286
287
/**
288
 * @}
289
 */
290
291
#ifdef __cplusplus
292
}
293
#endif /* defined(__cplusplus) */
294
295
#endif