clang 23.0.0git
TargetInfo.h
Go to the documentation of this file.
1//===---- TargetInfo.h - Encapsulate target details -------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// These classes wrap the information about a call or function
10// definition used to handle ABI compliancy.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
15#define LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
16
17#include "CGBuilder.h"
18#include "CGValue.h"
19#include "CodeGenModule.h"
20#include "clang/AST/Type.h"
21#include "clang/Basic/LLVM.h"
24#include "llvm/ADT/SmallString.h"
25#include "llvm/ADT/StringRef.h"
26
27namespace llvm {
28class Constant;
29class GlobalValue;
30class Type;
31class Value;
32}
33
34namespace clang {
35class CXXRecordDecl;
36class Decl;
37
38namespace CodeGen {
39class ABIInfo;
40class CallArgList;
41class CodeGenFunction;
43class CGBlockInfo;
45class SwiftABIInfo;
46
47/// TargetCodeGenInfo - This class organizes various target-specific
48/// codegeneration issues, like target-specific attributes, builtins and so
49/// on.
51 std::unique_ptr<ABIInfo> Info;
52
53protected:
54 // Target hooks supporting Swift calling conventions. The target must
55 // initialize this field if it claims to support these calling conventions
56 // by returning true from TargetInfo::checkCallingConvention for them.
57 std::unique_ptr<SwiftABIInfo> SwiftInfo;
58
59 // Returns ABI info helper for the target. This is for use by derived classes.
60 template <typename T> const T &getABIInfo() const {
61 return static_cast<const T &>(*Info);
62 }
63
64public:
65 TargetCodeGenInfo(std::unique_ptr<ABIInfo> Info);
67
68 /// getABIInfo() - Returns ABI info helper for the target.
69 const ABIInfo &getABIInfo() const { return *Info; }
70
71 /// Returns Swift ABI info helper for the target.
73 assert(SwiftInfo && "Swift ABI info has not been initialized");
74 return *SwiftInfo;
75 }
76
77 /// supportsLibCall - Query to whether or not target supports all
78 /// lib calls.
79 virtual bool supportsLibCall() const { return true; }
80
81 /// setTargetAttributes - Provides a convenient hook to handle extra
82 /// target-specific attributes for the given global.
83 virtual void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
84 CodeGen::CodeGenModule &M) const {}
85
86 /// emitTargetMetadata - Provides a convenient hook to handle extra
87 /// target-specific metadata for the given globals.
88 virtual void emitTargetMetadata(
90 const llvm::MapVector<GlobalDecl, StringRef> &MangledDeclNames) const {}
91
92 /// Provides a convenient hook to handle extra target-specific globals.
93 virtual void emitTargetGlobals(CodeGen::CodeGenModule &CGM) const {}
94
95 /// Any further codegen related checks that need to be done on a function
96 /// signature in a target specific manner.
98 const FunctionDecl *Decl) const {}
99
100 /// Any further codegen related checks that need to be done on a function call
101 /// in a target specific manner.
103 const FunctionDecl *Caller,
104 const FunctionDecl *Callee,
105 const CallArgList &Args,
106 QualType ReturnType) const {}
107
108 /// Returns true if inlining the function call would produce incorrect code
109 /// for the current target and should be ignored (even with the always_inline
110 /// or flatten attributes).
111 ///
112 /// Note: This probably should be handled in LLVM. However, the LLVM
113 /// `alwaysinline` attribute currently means the inliner will ignore
114 /// mismatched attributes (which sometimes can generate invalid code). So,
115 /// this hook allows targets to avoid adding the LLVM `alwaysinline` attribute
116 /// based on C/C++ attributes or other target-specific reasons.
117 ///
118 /// See previous discussion here:
119 /// https://discourse.llvm.org/t/rfc-avoid-inlining-alwaysinline-functions-when-they-cannot-be-inlined/79528
120 virtual bool
122 const FunctionDecl *Callee) const {
123 return false;
124 }
125
126 /// Determines the size of struct _Unwind_Exception on this platform,
127 /// in 8-bit units. The Itanium ABI defines this as:
128 /// struct _Unwind_Exception {
129 /// uint64 exception_class;
130 /// _Unwind_Exception_Cleanup_Fn exception_cleanup;
131 /// uint64 private_1;
132 /// uint64 private_2;
133 /// };
134 virtual unsigned getSizeOfUnwindException() const;
135
136 /// Controls whether __builtin_extend_pointer should sign-extend
137 /// pointers to uint64_t or zero-extend them (the default). Has
138 /// no effect for targets:
139 /// - that have 64-bit pointers, or
140 /// - that cannot address through registers larger than pointers, or
141 /// - that implicitly ignore/truncate the top bits when addressing
142 /// through such registers.
143 virtual bool extendPointerWithSExt() const { return false; }
144
145 /// Determines the DWARF register number for the stack pointer, for
146 /// exception-handling purposes. Implements __builtin_dwarf_sp_column.
147 ///
148 /// Returns -1 if the operation is unsupported by this target.
150 return -1;
151 }
152
153 /// Initializes the given DWARF EH register-size table, a char*.
154 /// Implements __builtin_init_dwarf_reg_size_table.
155 ///
156 /// Returns true if the operation is unsupported by this target.
158 llvm::Value *Address) const {
159 return true;
160 }
161
162 /// Performs the code-generation required to convert a return
163 /// address as stored by the system into the actual address of the
164 /// next instruction that will be executed.
165 ///
166 /// Used by __builtin_extract_return_addr().
168 llvm::Value *Address) const {
169 return Address;
170 }
171
172 /// Performs the code-generation required to convert the address
173 /// of an instruction into a return address suitable for storage
174 /// by the system in a return slot.
175 ///
176 /// Used by __builtin_frob_return_addr().
178 llvm::Value *Address) const {
179 return Address;
180 }
181
182 /// Performs a target specific test of a floating point value for things
183 /// like IsNaN, Infinity, ... Nullptr is returned if no implementation
184 /// exists.
185 virtual llvm::Value *
186 testFPKind(llvm::Value *V, unsigned BuiltinID, CGBuilderTy &Builder,
187 CodeGenModule &CGM) const {
188 assert(V->getType()->isFloatingPointTy() && "V should have an FP type.");
189 return nullptr;
190 }
191
192 /// Corrects the low-level LLVM type for a given constraint and "usual"
193 /// type.
194 ///
195 /// \returns A pointer to a new LLVM type, possibly the same as the original
196 /// on success; 0 on failure.
198 StringRef Constraint,
199 llvm::Type *Ty) const {
200 return Ty;
201 }
202
203 /// Target hook to decide whether an inline asm operand can be passed
204 /// by value.
206 llvm::Type *Ty) const {
207 return false;
208 }
209
210 /// Adds constraints and types for result registers.
213 std::string &Constraints, std::vector<llvm::Type *> &ResultRegTypes,
214 std::vector<llvm::Type *> &ResultTruncRegTypes,
215 std::vector<CodeGen::LValue> &ResultRegDests, std::string &AsmString,
216 unsigned NumOutputs) const {}
217
218 /// doesReturnSlotInterfereWithArgs - Return true if the target uses an
219 /// argument slot for an 'sret' type.
220 virtual bool doesReturnSlotInterfereWithArgs() const { return true; }
221
222 /// Retrieve the address of a function to call immediately before
223 /// calling objc_retainAutoreleasedReturnValue. The
224 /// implementation of objc_autoreleaseReturnValue sniffs the
225 /// instruction stream following its return address to decide
226 /// whether it's a call to objc_retainAutoreleasedReturnValue.
227 /// This can be prohibitively expensive, depending on the
228 /// relocation model, and so on some targets it instead sniffs for
229 /// a particular instruction sequence. This functions returns
230 /// that instruction sequence in inline assembly, which will be
231 /// empty if none is required.
233 return "";
234 }
235
236 /// Determine whether a call to objc_retainAutoreleasedReturnValue or
237 /// objc_unsafeClaimAutoreleasedReturnValue should be marked as 'notail'.
238 virtual bool markARCOptimizedReturnCallsAsNoTail() const { return false; }
239
240 /// Return a constant used by UBSan as a signature to identify functions
241 /// possessing type information, or 0 if the platform is unsupported.
242 /// This magic number is invalid instruction encoding in many targets.
243 virtual llvm::Constant *
245 return llvm::ConstantInt::get(CGM.Int32Ty, 0xc105cafe);
246 }
247
248 /// Determine whether a call to an unprototyped functions under
249 /// the given calling convention should use the variadic
250 /// convention or the non-variadic convention.
251 ///
252 /// There's a good reason to make a platform's variadic calling
253 /// convention be different from its non-variadic calling
254 /// convention: the non-variadic arguments can be passed in
255 /// registers (better for performance), and the variadic arguments
256 /// can be passed on the stack (also better for performance). If
257 /// this is done, however, unprototyped functions *must* use the
258 /// non-variadic convention, because C99 states that a call
259 /// through an unprototyped function type must succeed if the
260 /// function was defined with a non-variadic prototype with
261 /// compatible parameters. Therefore, splitting the conventions
262 /// makes it impossible to call a variadic function through an
263 /// unprototyped type. Since function prototypes came out in the
264 /// late 1970s, this is probably an acceptable trade-off.
265 /// Nonetheless, not all platforms are willing to make it, and in
266 /// particularly x86-64 bends over backwards to make the
267 /// conventions compatible.
268 ///
269 /// The default is false. This is correct whenever:
270 /// - the conventions are exactly the same, because it does not
271 /// matter and the resulting IR will be somewhat prettier in
272 /// certain cases; or
273 /// - the conventions are substantively different in how they pass
274 /// arguments, because in this case using the variadic convention
275 /// will lead to C99 violations.
276 ///
277 /// However, some platforms make the conventions identical except
278 /// for passing additional out-of-band information to a variadic
279 /// function: for example, x86-64 passes the number of SSE
280 /// arguments in %al. On these platforms, it is desirable to
281 /// call unprototyped functions using the variadic convention so
282 /// that unprototyped calls to varargs functions still succeed.
283 ///
284 /// Relatedly, platforms which pass the fixed arguments to this:
285 /// A foo(B, C, D);
286 /// differently than they would pass them to this:
287 /// A foo(B, C, D, ...);
288 /// may need to adjust the debugger-support code in Sema to do the
289 /// right thing when calling a function with no know signature.
290 virtual bool isNoProtoCallVariadic(const CodeGen::CallArgList &args,
291 const FunctionNoProtoType *fnType) const;
292
293 /// Gets the linker options necessary to link a dependent library on this
294 /// platform.
295 virtual void getDependentLibraryOption(llvm::StringRef Lib,
296 llvm::SmallString<24> &Opt) const;
297
298 /// Gets the linker options necessary to detect object file mismatches on
299 /// this platform.
300 virtual void getDetectMismatchOption(llvm::StringRef Name,
301 llvm::StringRef Value,
302 llvm::SmallString<32> &Opt) const {}
303
304 /// Get LLVM calling convention for device kernels.
305 virtual unsigned getDeviceKernelCallingConv() const;
306
307 /// Get target specific null pointer.
308 /// \param T is the LLVM type of the null pointer.
309 /// \param QT is the clang QualType of the null pointer.
310 /// \return ConstantPointerNull with the given type \p T.
311 /// Each target can override it to return its own desired constant value.
312 virtual llvm::Constant *getNullPointer(const CodeGen::CodeGenModule &CGM,
313 llvm::PointerType *T, QualType QT) const;
314
315 /// Get target favored AST address space of a global variable for languages
316 /// other than OpenCL and CUDA.
317 /// If \p D is nullptr, returns the default target favored address space
318 /// for global variable.
320 const VarDecl *D) const;
321
322 /// Get the AST address space for alloca.
324
325 /// Get the address space for an indirect (sret) return of the given type.
326 /// The default falls back to the alloca AS.
327 virtual LangAS getSRetAddrSpace(const CXXRecordDecl *RD) const {
329 }
330
331 /// Get address space of pointer parameter for __cxa_atexit.
333 return LangAS::Default;
334 }
335
336 /// Get the syncscope used in LLVM IR as a string
337 virtual StringRef getLLVMSyncScopeStr(const LangOptions &LangOpts,
339 llvm::AtomicOrdering Ordering) const;
340
341 /// Get the syncscope used in LLVM IR as a SyncScope ID.
342 llvm::SyncScope::ID getLLVMSyncScopeID(const LangOptions &LangOpts,
344 llvm::AtomicOrdering Ordering,
345 llvm::LLVMContext &Ctx) const;
346
347 /// Allow the target to apply other metadata to an atomic instruction
349 llvm::Instruction &AtomicInst,
350 const AtomicExpr *Expr = nullptr) const {
351 }
352
353 /// Interface class for filling custom fields of a block literal for OpenCL.
355 public:
356 typedef std::pair<llvm::Value *, StringRef> ValueTy;
359 /// Get the custom field types for OpenCL blocks.
361 /// Get the custom field values for OpenCL blocks.
364 virtual bool areAllCustomFieldValuesConstant(const CGBlockInfo &Info) = 0;
365 /// Get the custom field values for OpenCL blocks if all values are LLVM
366 /// constants.
369 };
371 return nullptr;
372 }
373
374 /// Create an OpenCL kernel for an enqueued block. The kernel function is
375 /// a wrapper for the block invoke function with target-specific calling
376 /// convention and ABI as an OpenCL kernel. The wrapper function accepts
377 /// block context and block arguments in target-specific way and calls
378 /// the original block invoke function.
379 virtual llvm::Value *
381 llvm::Function *BlockInvokeFunc,
382 llvm::Type *BlockTy) const;
383
384 /// \return true if the target supports alias from the unmangled name to the
385 /// mangled name of functions declared within an extern "C" region and marked
386 /// as 'used', and having internal linkage.
387 virtual bool shouldEmitStaticExternCAliases() const { return true; }
388
389 /// \return true if annonymous zero-sized bitfields should be emitted to
390 /// correctly distinguish between struct types whose memory layout is the
391 /// same, but whose layout may differ when used as argument passed by value
392 virtual bool shouldEmitDWARFBitFieldSeparators() const { return false; }
393
394 virtual void setCUDAKernelCallingConvention(const FunctionType *&FT) const {}
395 virtual void setOCLKernelStubCallingConvention(const FunctionType *&FT) const;
396 /// Return the device-side type for the CUDA device builtin surface type.
397 virtual llvm::Type *getCUDADeviceBuiltinSurfaceDeviceType() const {
398 // By default, no change from the original one.
399 return nullptr;
400 }
401 /// Return the device-side type for the CUDA device builtin texture type.
402 virtual llvm::Type *getCUDADeviceBuiltinTextureDeviceType() const {
403 // By default, no change from the original one.
404 return nullptr;
405 }
406
407 /// Return the WebAssembly externref reference type.
408 virtual llvm::Type *getWasmExternrefReferenceType() const { return nullptr; }
409
410 /// Return the WebAssembly funcref reference type.
411 virtual llvm::Type *getWasmFuncrefReferenceType() const { return nullptr; }
412
413 /// Emit the device-side copy of the builtin surface type.
415 LValue Dst,
416 LValue Src) const {
417 // DO NOTHING by default.
418 return false;
419 }
420 /// Emit the device-side copy of the builtin texture type.
422 LValue Dst,
423 LValue Src) const {
424 // DO NOTHING by default.
425 return false;
426 }
427
428 /// Return an LLVM type that corresponds to an OpenCL type.
429 virtual llvm::Type *getOpenCLType(CodeGenModule &CGM, const Type *T) const {
430 return nullptr;
431 }
432
433 /// Return an LLVM type that corresponds to a HLSL type
434 virtual llvm::Type *getHLSLType(CodeGenModule &CGM, const Type *T,
435 const CGHLSLOffsetInfo &OffsetInfo) const {
436 return nullptr;
437 }
438
439 /// Return an LLVM type that corresponds to padding in HLSL types
440 virtual llvm::Type *getHLSLPadding(CodeGenModule &CGM,
441 CharUnits NumBytes) const {
442 return nullptr;
443 }
444
445 /// Return true if this is an HLSL padding type.
446 virtual bool isHLSLPadding(llvm::Type *Ty) const { return false; }
447
448 // Set the Branch Protection Attributes of the Function accordingly to the
449 // BPI. Remove attributes that contradict with current BPI.
450 static void
452 llvm::Function &F);
453
454 // Add the Branch Protection Attributes of the FuncAttrs.
455 static void
457 llvm::AttrBuilder &FuncAttrs);
458
459 // Set the ptrauth-* attributes of the Function accordingly to the Opts.
460 // Remove attributes that contradict with current Opts.
461 static void setPointerAuthFnAttributes(const PointerAuthOptions &Opts,
462 llvm::Function &F);
463
464 // Add the ptrauth-* Attributes to the FuncAttrs.
465 static void initPointerAuthFnAttributes(const PointerAuthOptions &Opts,
466 llvm::AttrBuilder &FuncAttrs);
467
468protected:
469 static std::string qualifyWindowsLibrary(StringRef Lib);
470
471 void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
472 CodeGen::CodeGenModule &CGM) const;
473};
474
475std::unique_ptr<TargetCodeGenInfo>
476createDefaultTargetCodeGenInfo(CodeGenModule &CGM);
477
484
485std::unique_ptr<TargetCodeGenInfo>
486createAArch64TargetCodeGenInfo(CodeGenModule &CGM, AArch64ABIKind Kind);
487
488std::unique_ptr<TargetCodeGenInfo>
490
491std::unique_ptr<TargetCodeGenInfo>
492createAMDGPUTargetCodeGenInfo(CodeGenModule &CGM);
493
494std::unique_ptr<TargetCodeGenInfo>
495createARCTargetCodeGenInfo(CodeGenModule &CGM);
496
497enum class ARMABIKind {
498 APCS = 0,
499 AAPCS = 1,
502};
503
504std::unique_ptr<TargetCodeGenInfo>
505createARMTargetCodeGenInfo(CodeGenModule &CGM, ARMABIKind Kind);
506
507std::unique_ptr<TargetCodeGenInfo>
508createWindowsARMTargetCodeGenInfo(CodeGenModule &CGM, ARMABIKind K);
509
510std::unique_ptr<TargetCodeGenInfo>
511createAVRTargetCodeGenInfo(CodeGenModule &CGM, unsigned NPR, unsigned NRR);
512
513std::unique_ptr<TargetCodeGenInfo>
514createBPFTargetCodeGenInfo(CodeGenModule &CGM);
515
516std::unique_ptr<TargetCodeGenInfo>
517createCSKYTargetCodeGenInfo(CodeGenModule &CGM, unsigned FLen);
518
519std::unique_ptr<TargetCodeGenInfo>
520createHexagonTargetCodeGenInfo(CodeGenModule &CGM);
521
522std::unique_ptr<TargetCodeGenInfo>
523createLanaiTargetCodeGenInfo(CodeGenModule &CGM);
524
525std::unique_ptr<TargetCodeGenInfo>
526createLoongArchTargetCodeGenInfo(CodeGenModule &CGM, unsigned GRLen,
527 unsigned FLen);
528
529std::unique_ptr<TargetCodeGenInfo>
530createM68kTargetCodeGenInfo(CodeGenModule &CGM);
531
532std::unique_ptr<TargetCodeGenInfo>
533createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
534
535std::unique_ptr<TargetCodeGenInfo>
536createWindowsMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
537
538std::unique_ptr<TargetCodeGenInfo>
539createMSP430TargetCodeGenInfo(CodeGenModule &CGM);
540
541std::unique_ptr<TargetCodeGenInfo>
542createNVPTXTargetCodeGenInfo(CodeGenModule &CGM);
543
545 ELFv1 = 0,
547};
548
549std::unique_ptr<TargetCodeGenInfo>
550createAIXTargetCodeGenInfo(CodeGenModule &CGM, bool Is64Bit);
551
552std::unique_ptr<TargetCodeGenInfo>
553createPPC32TargetCodeGenInfo(CodeGenModule &CGM, bool SoftFloatABI);
554
555std::unique_ptr<TargetCodeGenInfo>
556createPPC64TargetCodeGenInfo(CodeGenModule &CGM);
557
558std::unique_ptr<TargetCodeGenInfo>
560 bool SoftFloatABI);
561
562std::unique_ptr<TargetCodeGenInfo>
563createRISCVTargetCodeGenInfo(CodeGenModule &CGM, unsigned XLen, unsigned FLen,
564 bool EABI);
565
566std::unique_ptr<TargetCodeGenInfo>
567createCommonSPIRTargetCodeGenInfo(CodeGenModule &CGM);
568
569std::unique_ptr<TargetCodeGenInfo>
570createSPIRVTargetCodeGenInfo(CodeGenModule &CGM);
571
572std::unique_ptr<TargetCodeGenInfo>
573createSparcV8TargetCodeGenInfo(CodeGenModule &CGM);
574
575std::unique_ptr<TargetCodeGenInfo>
576createSparcV9TargetCodeGenInfo(CodeGenModule &CGM);
577
578std::unique_ptr<TargetCodeGenInfo>
579createSystemZTargetCodeGenInfo(CodeGenModule &CGM, bool HasVector,
580 bool SoftFloatABI);
581
582std::unique_ptr<TargetCodeGenInfo>
583createTCETargetCodeGenInfo(CodeGenModule &CGM);
584
585std::unique_ptr<TargetCodeGenInfo>
586createVETargetCodeGenInfo(CodeGenModule &CGM);
587
588std::unique_ptr<TargetCodeGenInfo>
589createDirectXTargetCodeGenInfo(CodeGenModule &CGM);
590
592 MVP = 0,
594};
595
596std::unique_ptr<TargetCodeGenInfo>
597createWebAssemblyTargetCodeGenInfo(CodeGenModule &CGM, WebAssemblyABIKind K);
598
599/// The AVX ABI level for X86 targets.
605
606std::unique_ptr<TargetCodeGenInfo> createX86_32TargetCodeGenInfo(
607 CodeGenModule &CGM, bool DarwinVectorABI, bool Win32StructABI,
608 unsigned NumRegisterParameters, bool SoftFloatABI);
609
610std::unique_ptr<TargetCodeGenInfo>
611createWinX86_32TargetCodeGenInfo(CodeGenModule &CGM, bool DarwinVectorABI,
612 bool Win32StructABI,
613 unsigned NumRegisterParameters);
614
615std::unique_ptr<TargetCodeGenInfo>
616createX86_64TargetCodeGenInfo(CodeGenModule &CGM, X86AVXABILevel AVXLevel);
617
618std::unique_ptr<TargetCodeGenInfo>
619createWinX86_64TargetCodeGenInfo(CodeGenModule &CGM, X86AVXABILevel AVXLevel);
620
621std::unique_ptr<TargetCodeGenInfo>
622createXCoreTargetCodeGenInfo(CodeGenModule &CGM);
623
624} // namespace CodeGen
625} // namespace clang
626
627#endif // LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
#define V(N, I)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Provides definitions for the atomic synchronization scopes.
C Language Family Type Representation.
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
Definition Expr.h:6929
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
CharUnits - This is an opaque type for sizes expressed in character units.
Definition CharUnits.h:38
ABIInfo - Target specific hooks for defining how a type should be passed or returned from functions.
Definition ABIInfo.h:48
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
Definition Address.h:128
CGBlockInfo - Information to generate a block literal.
Definition CGBlocks.h:157
CallArgList - Type for representing both the value and type of arguments in a call.
Definition CGCall.h:274
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
This class organizes the cross-function state that is used while generating LLVM code.
LValue - This represents an lvalue references.
Definition CGValue.h:183
Target specific hooks for defining how a type should be passed or returned from functions with one of...
Definition ABIInfo.h:149
Interface class for filling custom fields of a block literal for OpenCL.
Definition TargetInfo.h:354
virtual llvm::SmallVector< llvm::Type *, 1 > getCustomFieldTypes()=0
Get the custom field types for OpenCL blocks.
virtual llvm::SmallVector< llvm::Constant *, 1 > getCustomFieldValues(CodeGenModule &CGM, const CGBlockInfo &Info)=0
Get the custom field values for OpenCL blocks if all values are LLVM constants.
virtual bool areAllCustomFieldValuesConstant(const CGBlockInfo &Info)=0
virtual llvm::SmallVector< ValueTy, 1 > getCustomFieldValues(CodeGenFunction &CGF, const CGBlockInfo &Info)=0
Get the custom field values for OpenCL blocks.
std::pair< llvm::Value *, StringRef > ValueTy
Definition TargetInfo.h:356
virtual void addReturnRegisterOutputs(CodeGen::CodeGenFunction &CGF, CodeGen::LValue ReturnValue, std::string &Constraints, std::vector< llvm::Type * > &ResultRegTypes, std::vector< llvm::Type * > &ResultTruncRegTypes, std::vector< CodeGen::LValue > &ResultRegDests, std::string &AsmString, unsigned NumOutputs) const
Adds constraints and types for result registers.
Definition TargetInfo.h:211
virtual bool emitCUDADeviceBuiltinSurfaceDeviceCopy(CodeGenFunction &CGF, LValue Dst, LValue Src) const
Emit the device-side copy of the builtin surface type.
Definition TargetInfo.h:414
virtual llvm::Type * getWasmFuncrefReferenceType() const
Return the WebAssembly funcref reference type.
Definition TargetInfo.h:411
virtual unsigned getDeviceKernelCallingConv() const
Get LLVM calling convention for device kernels.
virtual bool supportsLibCall() const
supportsLibCall - Query to whether or not target supports all lib calls.
Definition TargetInfo.h:79
virtual unsigned getSizeOfUnwindException() const
Determines the size of struct _Unwind_Exception on this platform, in 8-bit units.
virtual llvm::Type * getWasmExternrefReferenceType() const
Return the WebAssembly externref reference type.
Definition TargetInfo.h:408
virtual llvm::Type * getOpenCLType(CodeGenModule &CGM, const Type *T) const
Return an LLVM type that corresponds to an OpenCL type.
Definition TargetInfo.h:429
virtual bool emitCUDADeviceBuiltinTextureDeviceCopy(CodeGenFunction &CGF, LValue Dst, LValue Src) const
Emit the device-side copy of the builtin texture type.
Definition TargetInfo.h:421
virtual bool doesReturnSlotInterfereWithArgs() const
doesReturnSlotInterfereWithArgs - Return true if the target uses an argument slot for an 'sret' type.
Definition TargetInfo.h:220
virtual bool wouldInliningViolateFunctionCallABI(const FunctionDecl *Caller, const FunctionDecl *Callee) const
Returns true if inlining the function call would produce incorrect code for the current target and sh...
Definition TargetInfo.h:121
std::unique_ptr< SwiftABIInfo > SwiftInfo
Definition TargetInfo.h:57
virtual void setCUDAKernelCallingConvention(const FunctionType *&FT) const
Definition TargetInfo.h:394
virtual void setOCLKernelStubCallingConvention(const FunctionType *&FT) const
virtual llvm::Type * getCUDADeviceBuiltinSurfaceDeviceType() const
Return the device-side type for the CUDA device builtin surface type.
Definition TargetInfo.h:397
virtual llvm::Type * adjustInlineAsmType(CodeGen::CodeGenFunction &CGF, StringRef Constraint, llvm::Type *Ty) const
Corrects the low-level LLVM type for a given constraint and "usual" type.
Definition TargetInfo.h:197
virtual void getDependentLibraryOption(llvm::StringRef Lib, llvm::SmallString< 24 > &Opt) const
Gets the linker options necessary to link a dependent library on this platform.
virtual StringRef getARCRetainAutoreleasedReturnValueMarker() const
Retrieve the address of a function to call immediately before calling objc_retainAutoreleasedReturnVa...
Definition TargetInfo.h:232
virtual StringRef getLLVMSyncScopeStr(const LangOptions &LangOpts, SyncScope Scope, llvm::AtomicOrdering Ordering) const
Get the syncscope used in LLVM IR as a string.
const SwiftABIInfo & getSwiftABIInfo() const
Returns Swift ABI info helper for the target.
Definition TargetInfo.h:72
virtual bool isHLSLPadding(llvm::Type *Ty) const
Return true if this is an HLSL padding type.
Definition TargetInfo.h:446
virtual llvm::Value * encodeReturnAddress(CodeGen::CodeGenFunction &CGF, llvm::Value *Address) const
Performs the code-generation required to convert the address of an instruction into a return address ...
Definition TargetInfo.h:177
llvm::SyncScope::ID getLLVMSyncScopeID(const LangOptions &LangOpts, SyncScope Scope, llvm::AtomicOrdering Ordering, llvm::LLVMContext &Ctx) const
Get the syncscope used in LLVM IR as a SyncScope ID.
static void setBranchProtectionFnAttributes(const TargetInfo::BranchProtectionInfo &BPI, llvm::Function &F)
virtual void checkFunctionCallABI(CodeGenModule &CGM, SourceLocation CallLoc, const FunctionDecl *Caller, const FunctionDecl *Callee, const CallArgList &Args, QualType ReturnType) const
Any further codegen related checks that need to be done on a function call in a target specific manne...
Definition TargetInfo.h:102
virtual llvm::Value * decodeReturnAddress(CodeGen::CodeGenFunction &CGF, llvm::Value *Address) const
Performs the code-generation required to convert a return address as stored by the system into the ac...
Definition TargetInfo.h:167
virtual bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF, llvm::Value *Address) const
Initializes the given DWARF EH register-size table, a char*.
Definition TargetInfo.h:157
static void initPointerAuthFnAttributes(const PointerAuthOptions &Opts, llvm::AttrBuilder &FuncAttrs)
static void setPointerAuthFnAttributes(const PointerAuthOptions &Opts, llvm::Function &F)
virtual LangAS getGlobalVarAddressSpace(CodeGenModule &CGM, const VarDecl *D) const
Get target favored AST address space of a global variable for languages other than OpenCL and CUDA.
virtual LangAS getSRetAddrSpace(const CXXRecordDecl *RD) const
Get the address space for an indirect (sret) return of the given type.
Definition TargetInfo.h:327
virtual void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M) const
setTargetAttributes - Provides a convenient hook to handle extra target-specific attributes for the g...
Definition TargetInfo.h:83
virtual llvm::Type * getCUDADeviceBuiltinTextureDeviceType() const
Return the device-side type for the CUDA device builtin texture type.
Definition TargetInfo.h:402
virtual void checkFunctionABI(CodeGenModule &CGM, const FunctionDecl *Decl) const
Any further codegen related checks that need to be done on a function signature in a target specific ...
Definition TargetInfo.h:97
virtual bool isScalarizableAsmOperand(CodeGen::CodeGenFunction &CGF, llvm::Type *Ty) const
Target hook to decide whether an inline asm operand can be passed by value.
Definition TargetInfo.h:205
static std::string qualifyWindowsLibrary(StringRef Lib)
Definition X86.cpp:1624
void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const
const ABIInfo & getABIInfo() const
getABIInfo() - Returns ABI info helper for the target.
Definition TargetInfo.h:69
virtual bool shouldEmitDWARFBitFieldSeparators() const
Definition TargetInfo.h:392
virtual LangAS getAddrSpaceOfCxaAtexitPtrParam() const
Get address space of pointer parameter for __cxa_atexit.
Definition TargetInfo.h:332
virtual bool extendPointerWithSExt() const
Controls whether __builtin_extend_pointer should sign-extend pointers to uint64_t or zero-extend them...
Definition TargetInfo.h:143
virtual llvm::Constant * getNullPointer(const CodeGen::CodeGenModule &CGM, llvm::PointerType *T, QualType QT) const
Get target specific null pointer.
static void initBranchProtectionFnAttributes(const TargetInfo::BranchProtectionInfo &BPI, llvm::AttrBuilder &FuncAttrs)
virtual llvm::Type * getHLSLPadding(CodeGenModule &CGM, CharUnits NumBytes) const
Return an LLVM type that corresponds to padding in HLSL types.
Definition TargetInfo.h:440
virtual llvm::Type * getHLSLType(CodeGenModule &CGM, const Type *T, const CGHLSLOffsetInfo &OffsetInfo) const
Return an LLVM type that corresponds to a HLSL type.
Definition TargetInfo.h:434
virtual TargetOpenCLBlockHelper * getTargetOpenCLBlockHelper() const
Definition TargetInfo.h:370
virtual LangAS getASTAllocaAddressSpace() const
Get the AST address space for alloca.
Definition TargetInfo.h:323
virtual int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const
Determines the DWARF register number for the stack pointer, for exception-handling purposes.
Definition TargetInfo.h:149
virtual void emitTargetMetadata(CodeGen::CodeGenModule &CGM, const llvm::MapVector< GlobalDecl, StringRef > &MangledDeclNames) const
emitTargetMetadata - Provides a convenient hook to handle extra target-specific metadata for the give...
Definition TargetInfo.h:88
TargetCodeGenInfo(std::unique_ptr< ABIInfo > Info)
virtual void setTargetAtomicMetadata(CodeGenFunction &CGF, llvm::Instruction &AtomicInst, const AtomicExpr *Expr=nullptr) const
Allow the target to apply other metadata to an atomic instruction.
Definition TargetInfo.h:348
virtual llvm::Value * createEnqueuedBlockKernel(CodeGenFunction &CGF, llvm::Function *BlockInvokeFunc, llvm::Type *BlockTy) const
Create an OpenCL kernel for an enqueued block.
virtual llvm::Value * testFPKind(llvm::Value *V, unsigned BuiltinID, CGBuilderTy &Builder, CodeGenModule &CGM) const
Performs a target specific test of a floating point value for things like IsNaN, Infinity,...
Definition TargetInfo.h:186
virtual bool markARCOptimizedReturnCallsAsNoTail() const
Determine whether a call to objc_retainAutoreleasedReturnValue or objc_unsafeClaimAutoreleasedReturnV...
Definition TargetInfo.h:238
virtual void emitTargetGlobals(CodeGen::CodeGenModule &CGM) const
Provides a convenient hook to handle extra target-specific globals.
Definition TargetInfo.h:93
virtual void getDetectMismatchOption(llvm::StringRef Name, llvm::StringRef Value, llvm::SmallString< 32 > &Opt) const
Gets the linker options necessary to detect object file mismatches on this platform.
Definition TargetInfo.h:300
virtual llvm::Constant * getUBSanFunctionSignature(CodeGen::CodeGenModule &CGM) const
Return a constant used by UBSan as a signature to identify functions possessing type information,...
Definition TargetInfo.h:244
virtual bool shouldEmitStaticExternCAliases() const
Definition TargetInfo.h:387
virtual bool isNoProtoCallVariadic(const CodeGen::CallArgList &args, const FunctionNoProtoType *fnType) const
Determine whether a call to an unprototyped functions under the given calling convention should use t...
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
This represents one expression.
Definition Expr.h:112
Represents a function declaration or definition.
Definition Decl.h:2018
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition TypeBase.h:4940
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition TypeBase.h:4558
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
A (possibly-)qualified type.
Definition TypeBase.h:937
Scope - A scope is a transient data structure that is used while parsing the program.
Definition Scope.h:41
Encodes a location in the source.
Represents a variable declaration or definition.
Definition Decl.h:924
Defines the clang::TargetInfo interface.
std::unique_ptr< TargetCodeGenInfo > createARMTargetCodeGenInfo(CodeGenModule &CGM, ARMABIKind Kind)
Definition ARM.cpp:846
std::unique_ptr< TargetCodeGenInfo > createM68kTargetCodeGenInfo(CodeGenModule &CGM)
Definition M68k.cpp:53
@ Type
The l-value was considered opaque, so the alignment was determined from a type.
Definition CGValue.h:155
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
Definition CGValue.h:146
std::unique_ptr< TargetCodeGenInfo > createBPFTargetCodeGenInfo(CodeGenModule &CGM)
Definition BPF.cpp:102
std::unique_ptr< TargetCodeGenInfo > createMSP430TargetCodeGenInfo(CodeGenModule &CGM)
Definition MSP430.cpp:96
std::unique_ptr< TargetCodeGenInfo > createX86_64TargetCodeGenInfo(CodeGenModule &CGM, X86AVXABILevel AVXLevel)
Definition X86.cpp:3567
std::unique_ptr< TargetCodeGenInfo > createWebAssemblyTargetCodeGenInfo(CodeGenModule &CGM, WebAssemblyABIKind K)
std::unique_ptr< TargetCodeGenInfo > createPPC64_SVR4_TargetCodeGenInfo(CodeGenModule &CGM, PPC64_SVR4_ABIKind Kind, bool SoftFloatABI)
Definition PPC.cpp:1086
std::unique_ptr< TargetCodeGenInfo > createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32)
Definition Mips.cpp:455
std::unique_ptr< TargetCodeGenInfo > createHexagonTargetCodeGenInfo(CodeGenModule &CGM)
Definition Hexagon.cpp:420
std::unique_ptr< TargetCodeGenInfo > createNVPTXTargetCodeGenInfo(CodeGenModule &CGM)
Definition NVPTX.cpp:394
std::unique_ptr< TargetCodeGenInfo > createSystemZTargetCodeGenInfo(CodeGenModule &CGM, bool HasVector, bool SoftFloatABI)
Definition SystemZ.cpp:548
std::unique_ptr< TargetCodeGenInfo > createWinX86_32TargetCodeGenInfo(CodeGenModule &CGM, bool DarwinVectorABI, bool Win32StructABI, unsigned NumRegisterParameters)
Definition X86.cpp:3556
std::unique_ptr< TargetCodeGenInfo > createAIXTargetCodeGenInfo(CodeGenModule &CGM, bool Is64Bit)
Definition PPC.cpp:1069
std::unique_ptr< TargetCodeGenInfo > createAMDGPUTargetCodeGenInfo(CodeGenModule &CGM)
Definition AMDGPU.cpp:854
X86AVXABILevel
The AVX ABI level for X86 targets.
Definition TargetInfo.h:600
std::unique_ptr< TargetCodeGenInfo > createTCETargetCodeGenInfo(CodeGenModule &CGM)
Definition TCE.cpp:77
std::unique_ptr< TargetCodeGenInfo > createWindowsARMTargetCodeGenInfo(CodeGenModule &CGM, ARMABIKind K)
Definition ARM.cpp:851
std::unique_ptr< TargetCodeGenInfo > createAVRTargetCodeGenInfo(CodeGenModule &CGM, unsigned NPR, unsigned NRR)
Definition AVR.cpp:151
std::unique_ptr< TargetCodeGenInfo > createDirectXTargetCodeGenInfo(CodeGenModule &CGM)
Definition DirectX.cpp:138
std::unique_ptr< TargetCodeGenInfo > createARCTargetCodeGenInfo(CodeGenModule &CGM)
Definition ARC.cpp:159
std::unique_ptr< TargetCodeGenInfo > createDefaultTargetCodeGenInfo(CodeGenModule &CGM)
std::unique_ptr< TargetCodeGenInfo > createAArch64TargetCodeGenInfo(CodeGenModule &CGM, AArch64ABIKind Kind)
Definition AArch64.cpp:1372
std::unique_ptr< TargetCodeGenInfo > createSPIRVTargetCodeGenInfo(CodeGenModule &CGM)
Definition SPIR.cpp:953
std::unique_ptr< TargetCodeGenInfo > createWindowsMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32)
Definition Mips.cpp:460
std::unique_ptr< TargetCodeGenInfo > createSparcV8TargetCodeGenInfo(CodeGenModule &CGM)
Definition Sparc.cpp:415
std::unique_ptr< TargetCodeGenInfo > createVETargetCodeGenInfo(CodeGenModule &CGM)
Definition VE.cpp:69
std::unique_ptr< TargetCodeGenInfo > createCommonSPIRTargetCodeGenInfo(CodeGenModule &CGM)
Definition SPIR.cpp:948
std::unique_ptr< TargetCodeGenInfo > createRISCVTargetCodeGenInfo(CodeGenModule &CGM, unsigned XLen, unsigned FLen, bool EABI)
Definition RISCV.cpp:1033
std::unique_ptr< TargetCodeGenInfo > createWindowsAArch64TargetCodeGenInfo(CodeGenModule &CGM, AArch64ABIKind K)
Definition AArch64.cpp:1378
std::unique_ptr< TargetCodeGenInfo > createSparcV9TargetCodeGenInfo(CodeGenModule &CGM)
Definition Sparc.cpp:420
std::unique_ptr< TargetCodeGenInfo > createX86_32TargetCodeGenInfo(CodeGenModule &CGM, bool DarwinVectorABI, bool Win32StructABI, unsigned NumRegisterParameters, bool SoftFloatABI)
Definition X86.cpp:3546
std::unique_ptr< TargetCodeGenInfo > createLanaiTargetCodeGenInfo(CodeGenModule &CGM)
Definition Lanai.cpp:156
std::unique_ptr< TargetCodeGenInfo > createPPC32TargetCodeGenInfo(CodeGenModule &CGM, bool SoftFloatABI)
Definition PPC.cpp:1074
std::unique_ptr< TargetCodeGenInfo > createLoongArchTargetCodeGenInfo(CodeGenModule &CGM, unsigned GRLen, unsigned FLen)
std::unique_ptr< TargetCodeGenInfo > createPPC64TargetCodeGenInfo(CodeGenModule &CGM)
Definition PPC.cpp:1082
std::unique_ptr< TargetCodeGenInfo > createWinX86_64TargetCodeGenInfo(CodeGenModule &CGM, X86AVXABILevel AVXLevel)
Definition X86.cpp:3573
std::unique_ptr< TargetCodeGenInfo > createXCoreTargetCodeGenInfo(CodeGenModule &CGM)
Definition XCore.cpp:658
std::unique_ptr< TargetCodeGenInfo > createCSKYTargetCodeGenInfo(CodeGenModule &CGM, unsigned FLen)
Definition CSKY.cpp:173
The JSON file list parser is used to communicate input to InstallAPI.
LangAS
Defines the address space values used by the address space qualifier of QualType.
SyncScope
Defines sync scope values used internally by clang.
Definition SyncScope.h:42
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30