clang 22.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 Decl;
36
37namespace CodeGen {
38class ABIInfo;
39class CallArgList;
40class CodeGenFunction;
41class CGBlockInfo;
42class SwiftABIInfo;
43
44/// TargetCodeGenInfo - This class organizes various target-specific
45/// codegeneration issues, like target-specific attributes, builtins and so
46/// on.
48 std::unique_ptr<ABIInfo> Info;
49
50protected:
51 // Target hooks supporting Swift calling conventions. The target must
52 // initialize this field if it claims to support these calling conventions
53 // by returning true from TargetInfo::checkCallingConvention for them.
54 std::unique_ptr<SwiftABIInfo> SwiftInfo;
55
56 // Returns ABI info helper for the target. This is for use by derived classes.
57 template <typename T> const T &getABIInfo() const {
58 return static_cast<const T &>(*Info);
59 }
60
61public:
62 TargetCodeGenInfo(std::unique_ptr<ABIInfo> Info);
64
65 /// getABIInfo() - Returns ABI info helper for the target.
66 const ABIInfo &getABIInfo() const { return *Info; }
67
68 /// Returns Swift ABI info helper for the target.
70 assert(SwiftInfo && "Swift ABI info has not been initialized");
71 return *SwiftInfo;
72 }
73
74 /// supportsLibCall - Query to whether or not target supports all
75 /// lib calls.
76 virtual bool supportsLibCall() const { return true; }
77
78 /// setTargetAttributes - Provides a convenient hook to handle extra
79 /// target-specific attributes for the given global.
80 virtual void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
81 CodeGen::CodeGenModule &M) const {}
82
83 /// emitTargetMetadata - Provides a convenient hook to handle extra
84 /// target-specific metadata for the given globals.
85 virtual void emitTargetMetadata(
87 const llvm::MapVector<GlobalDecl, StringRef> &MangledDeclNames) const {}
88
89 /// Provides a convenient hook to handle extra target-specific globals.
90 virtual void emitTargetGlobals(CodeGen::CodeGenModule &CGM) const {}
91
92 /// Any further codegen related checks that need to be done on a function
93 /// signature in a target specific manner.
95 const FunctionDecl *Decl) const {}
96
97 /// Any further codegen related checks that need to be done on a function call
98 /// in a target specific manner.
100 const FunctionDecl *Caller,
101 const FunctionDecl *Callee,
102 const CallArgList &Args,
103 QualType ReturnType) const {}
104
105 /// Returns true if inlining the function call would produce incorrect code
106 /// for the current target and should be ignored (even with the always_inline
107 /// or flatten attributes).
108 ///
109 /// Note: This probably should be handled in LLVM. However, the LLVM
110 /// `alwaysinline` attribute currently means the inliner will ignore
111 /// mismatched attributes (which sometimes can generate invalid code). So,
112 /// this hook allows targets to avoid adding the LLVM `alwaysinline` attribute
113 /// based on C/C++ attributes or other target-specific reasons.
114 ///
115 /// See previous discussion here:
116 /// https://discourse.llvm.org/t/rfc-avoid-inlining-alwaysinline-functions-when-they-cannot-be-inlined/79528
117 virtual bool
119 const FunctionDecl *Callee) const {
120 return false;
121 }
122
123 /// Determines the size of struct _Unwind_Exception on this platform,
124 /// in 8-bit units. The Itanium ABI defines this as:
125 /// struct _Unwind_Exception {
126 /// uint64 exception_class;
127 /// _Unwind_Exception_Cleanup_Fn exception_cleanup;
128 /// uint64 private_1;
129 /// uint64 private_2;
130 /// };
131 virtual unsigned getSizeOfUnwindException() const;
132
133 /// Controls whether __builtin_extend_pointer should sign-extend
134 /// pointers to uint64_t or zero-extend them (the default). Has
135 /// no effect for targets:
136 /// - that have 64-bit pointers, or
137 /// - that cannot address through registers larger than pointers, or
138 /// - that implicitly ignore/truncate the top bits when addressing
139 /// through such registers.
140 virtual bool extendPointerWithSExt() const { return false; }
141
142 /// Determines the DWARF register number for the stack pointer, for
143 /// exception-handling purposes. Implements __builtin_dwarf_sp_column.
144 ///
145 /// Returns -1 if the operation is unsupported by this target.
147 return -1;
148 }
149
150 /// Initializes the given DWARF EH register-size table, a char*.
151 /// Implements __builtin_init_dwarf_reg_size_table.
152 ///
153 /// Returns true if the operation is unsupported by this target.
155 llvm::Value *Address) const {
156 return true;
157 }
158
159 /// Performs the code-generation required to convert a return
160 /// address as stored by the system into the actual address of the
161 /// next instruction that will be executed.
162 ///
163 /// Used by __builtin_extract_return_addr().
165 llvm::Value *Address) const {
166 return Address;
167 }
168
169 /// Performs the code-generation required to convert the address
170 /// of an instruction into a return address suitable for storage
171 /// by the system in a return slot.
172 ///
173 /// Used by __builtin_frob_return_addr().
175 llvm::Value *Address) const {
176 return Address;
177 }
178
179 /// Performs a target specific test of a floating point value for things
180 /// like IsNaN, Infinity, ... Nullptr is returned if no implementation
181 /// exists.
182 virtual llvm::Value *
183 testFPKind(llvm::Value *V, unsigned BuiltinID, CGBuilderTy &Builder,
184 CodeGenModule &CGM) const {
185 assert(V->getType()->isFloatingPointTy() && "V should have an FP type.");
186 return nullptr;
187 }
188
189 /// Corrects the low-level LLVM type for a given constraint and "usual"
190 /// type.
191 ///
192 /// \returns A pointer to a new LLVM type, possibly the same as the original
193 /// on success; 0 on failure.
195 StringRef Constraint,
196 llvm::Type *Ty) const {
197 return Ty;
198 }
199
200 /// Target hook to decide whether an inline asm operand can be passed
201 /// by value.
203 llvm::Type *Ty) const {
204 return false;
205 }
206
207 /// Adds constraints and types for result registers.
210 std::string &Constraints, std::vector<llvm::Type *> &ResultRegTypes,
211 std::vector<llvm::Type *> &ResultTruncRegTypes,
212 std::vector<CodeGen::LValue> &ResultRegDests, std::string &AsmString,
213 unsigned NumOutputs) const {}
214
215 /// doesReturnSlotInterfereWithArgs - Return true if the target uses an
216 /// argument slot for an 'sret' type.
217 virtual bool doesReturnSlotInterfereWithArgs() const { return true; }
218
219 /// Retrieve the address of a function to call immediately before
220 /// calling objc_retainAutoreleasedReturnValue. The
221 /// implementation of objc_autoreleaseReturnValue sniffs the
222 /// instruction stream following its return address to decide
223 /// whether it's a call to objc_retainAutoreleasedReturnValue.
224 /// This can be prohibitively expensive, depending on the
225 /// relocation model, and so on some targets it instead sniffs for
226 /// a particular instruction sequence. This functions returns
227 /// that instruction sequence in inline assembly, which will be
228 /// empty if none is required.
230 return "";
231 }
232
233 /// Determine whether a call to objc_retainAutoreleasedReturnValue or
234 /// objc_unsafeClaimAutoreleasedReturnValue should be marked as 'notail'.
235 virtual bool markARCOptimizedReturnCallsAsNoTail() const { return false; }
236
237 /// Return a constant used by UBSan as a signature to identify functions
238 /// possessing type information, or 0 if the platform is unsupported.
239 /// This magic number is invalid instruction encoding in many targets.
240 virtual llvm::Constant *
242 return llvm::ConstantInt::get(CGM.Int32Ty, 0xc105cafe);
243 }
244
245 /// Determine whether a call to an unprototyped functions under
246 /// the given calling convention should use the variadic
247 /// convention or the non-variadic convention.
248 ///
249 /// There's a good reason to make a platform's variadic calling
250 /// convention be different from its non-variadic calling
251 /// convention: the non-variadic arguments can be passed in
252 /// registers (better for performance), and the variadic arguments
253 /// can be passed on the stack (also better for performance). If
254 /// this is done, however, unprototyped functions *must* use the
255 /// non-variadic convention, because C99 states that a call
256 /// through an unprototyped function type must succeed if the
257 /// function was defined with a non-variadic prototype with
258 /// compatible parameters. Therefore, splitting the conventions
259 /// makes it impossible to call a variadic function through an
260 /// unprototyped type. Since function prototypes came out in the
261 /// late 1970s, this is probably an acceptable trade-off.
262 /// Nonetheless, not all platforms are willing to make it, and in
263 /// particularly x86-64 bends over backwards to make the
264 /// conventions compatible.
265 ///
266 /// The default is false. This is correct whenever:
267 /// - the conventions are exactly the same, because it does not
268 /// matter and the resulting IR will be somewhat prettier in
269 /// certain cases; or
270 /// - the conventions are substantively different in how they pass
271 /// arguments, because in this case using the variadic convention
272 /// will lead to C99 violations.
273 ///
274 /// However, some platforms make the conventions identical except
275 /// for passing additional out-of-band information to a variadic
276 /// function: for example, x86-64 passes the number of SSE
277 /// arguments in %al. On these platforms, it is desirable to
278 /// call unprototyped functions using the variadic convention so
279 /// that unprototyped calls to varargs functions still succeed.
280 ///
281 /// Relatedly, platforms which pass the fixed arguments to this:
282 /// A foo(B, C, D);
283 /// differently than they would pass them to this:
284 /// A foo(B, C, D, ...);
285 /// may need to adjust the debugger-support code in Sema to do the
286 /// right thing when calling a function with no know signature.
287 virtual bool isNoProtoCallVariadic(const CodeGen::CallArgList &args,
288 const FunctionNoProtoType *fnType) const;
289
290 /// Gets the linker options necessary to link a dependent library on this
291 /// platform.
292 virtual void getDependentLibraryOption(llvm::StringRef Lib,
293 llvm::SmallString<24> &Opt) const;
294
295 /// Gets the linker options necessary to detect object file mismatches on
296 /// this platform.
297 virtual void getDetectMismatchOption(llvm::StringRef Name,
298 llvm::StringRef Value,
299 llvm::SmallString<32> &Opt) const {}
300
301 /// Get LLVM calling convention for device kernels.
302 virtual unsigned getDeviceKernelCallingConv() const;
303
304 /// Get target specific null pointer.
305 /// \param T is the LLVM type of the null pointer.
306 /// \param QT is the clang QualType of the null pointer.
307 /// \return ConstantPointerNull with the given type \p T.
308 /// Each target can override it to return its own desired constant value.
309 virtual llvm::Constant *getNullPointer(const CodeGen::CodeGenModule &CGM,
310 llvm::PointerType *T, QualType QT) const;
311
312 /// Get target favored AST address space of a global variable for languages
313 /// other than OpenCL and CUDA.
314 /// If \p D is nullptr, returns the default target favored address space
315 /// for global variable.
317 const VarDecl *D) const;
318
319 /// Get the AST address space for alloca.
321
323 LangAS SrcAddr, llvm::Type *DestTy,
324 bool IsNonNull = false) const;
325
326 /// Perform address space cast of an expression of pointer type.
327 /// \param V is the LLVM value to be casted to another address space.
328 /// \param SrcAddr is the language address space of \p V.
329 /// \param DestAddr is the targeted language address space.
330 /// \param DestTy is the destination LLVM pointer type.
331 /// \param IsNonNull is the flag indicating \p V is known to be non null.
332 virtual llvm::Value *performAddrSpaceCast(CodeGen::CodeGenFunction &CGF,
333 llvm::Value *V, LangAS SrcAddr,
334 llvm::Type *DestTy,
335 bool IsNonNull = false) const;
336
337 /// Perform address space cast of a constant expression of pointer type.
338 /// \param V is the LLVM constant to be casted to another address space.
339 /// \param SrcAddr is the language address space of \p V.
340 /// \param DestAddr is the targeted language address space.
341 /// \param DestTy is the destination LLVM pointer type.
342 virtual llvm::Constant *performAddrSpaceCast(CodeGenModule &CGM,
343 llvm::Constant *V,
344 LangAS SrcAddr,
345 llvm::Type *DestTy) const;
346
347 /// Get address space of pointer parameter for __cxa_atexit.
349 return LangAS::Default;
350 }
351
352 /// Get the syncscope used in LLVM IR.
353 virtual llvm::SyncScope::ID getLLVMSyncScopeID(const LangOptions &LangOpts,
355 llvm::AtomicOrdering Ordering,
356 llvm::LLVMContext &Ctx) const;
357
358 /// Allow the target to apply other metadata to an atomic instruction
360 llvm::Instruction &AtomicInst,
361 const AtomicExpr *Expr = nullptr) const {
362 }
363
364 /// Interface class for filling custom fields of a block literal for OpenCL.
366 public:
367 typedef std::pair<llvm::Value *, StringRef> ValueTy;
370 /// Get the custom field types for OpenCL blocks.
372 /// Get the custom field values for OpenCL blocks.
375 virtual bool areAllCustomFieldValuesConstant(const CGBlockInfo &Info) = 0;
376 /// Get the custom field values for OpenCL blocks if all values are LLVM
377 /// constants.
380 };
382 return nullptr;
383 }
384
385 /// Create an OpenCL kernel for an enqueued block. The kernel function is
386 /// a wrapper for the block invoke function with target-specific calling
387 /// convention and ABI as an OpenCL kernel. The wrapper function accepts
388 /// block context and block arguments in target-specific way and calls
389 /// the original block invoke function.
390 virtual llvm::Value *
392 llvm::Function *BlockInvokeFunc,
393 llvm::Type *BlockTy) const;
394
395 /// \return true if the target supports alias from the unmangled name to the
396 /// mangled name of functions declared within an extern "C" region and marked
397 /// as 'used', and having internal linkage.
398 virtual bool shouldEmitStaticExternCAliases() const { return true; }
399
400 /// \return true if annonymous zero-sized bitfields should be emitted to
401 /// correctly distinguish between struct types whose memory layout is the
402 /// same, but whose layout may differ when used as argument passed by value
403 virtual bool shouldEmitDWARFBitFieldSeparators() const { return false; }
404
405 virtual void setCUDAKernelCallingConvention(const FunctionType *&FT) const {}
406 virtual void setOCLKernelStubCallingConvention(const FunctionType *&FT) const;
407 /// Return the device-side type for the CUDA device builtin surface type.
408 virtual llvm::Type *getCUDADeviceBuiltinSurfaceDeviceType() const {
409 // By default, no change from the original one.
410 return nullptr;
411 }
412 /// Return the device-side type for the CUDA device builtin texture type.
413 virtual llvm::Type *getCUDADeviceBuiltinTextureDeviceType() const {
414 // By default, no change from the original one.
415 return nullptr;
416 }
417
418 /// Return the WebAssembly externref reference type.
419 virtual llvm::Type *getWasmExternrefReferenceType() const { return nullptr; }
420
421 /// Return the WebAssembly funcref reference type.
422 virtual llvm::Type *getWasmFuncrefReferenceType() const { return nullptr; }
423
424 /// Emit the device-side copy of the builtin surface type.
426 LValue Dst,
427 LValue Src) const {
428 // DO NOTHING by default.
429 return false;
430 }
431 /// Emit the device-side copy of the builtin texture type.
433 LValue Dst,
434 LValue Src) const {
435 // DO NOTHING by default.
436 return false;
437 }
438
439 /// Return an LLVM type that corresponds to an OpenCL type.
440 virtual llvm::Type *getOpenCLType(CodeGenModule &CGM, const Type *T) const {
441 return nullptr;
442 }
443
444 /// Return an LLVM type that corresponds to a HLSL type
445 virtual llvm::Type *
447 const SmallVector<int32_t> *Packoffsets = nullptr) const {
448 return nullptr;
449 }
450
451 // Set the Branch Protection Attributes of the Function accordingly to the
452 // BPI. Remove attributes that contradict with current BPI.
453 static void
455 llvm::Function &F);
456
457 // Add the Branch Protection Attributes of the FuncAttrs.
458 static void
460 llvm::AttrBuilder &FuncAttrs);
461
462 // Set the ptrauth-* attributes of the Function accordingly to the Opts.
463 // Remove attributes that contradict with current Opts.
464 static void setPointerAuthFnAttributes(const PointerAuthOptions &Opts,
465 llvm::Function &F);
466
467 // Add the ptrauth-* Attributes to the FuncAttrs.
468 static void initPointerAuthFnAttributes(const PointerAuthOptions &Opts,
469 llvm::AttrBuilder &FuncAttrs);
470
471protected:
472 static std::string qualifyWindowsLibrary(StringRef Lib);
473
474 void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
475 CodeGen::CodeGenModule &CGM) const;
476};
477
478std::unique_ptr<TargetCodeGenInfo>
479createDefaultTargetCodeGenInfo(CodeGenModule &CGM);
480
481enum class AArch64ABIKind {
482 AAPCS = 0,
483 DarwinPCS,
484 Win64,
485 AAPCSSoft,
486 PAuthTest,
487};
488
489std::unique_ptr<TargetCodeGenInfo>
491
492std::unique_ptr<TargetCodeGenInfo>
494
495std::unique_ptr<TargetCodeGenInfo>
496createAMDGPUTargetCodeGenInfo(CodeGenModule &CGM);
497
498std::unique_ptr<TargetCodeGenInfo>
499createARCTargetCodeGenInfo(CodeGenModule &CGM);
500
501enum class ARMABIKind {
502 APCS = 0,
503 AAPCS = 1,
504 AAPCS_VFP = 2,
505 AAPCS16_VFP = 3,
506};
507
508std::unique_ptr<TargetCodeGenInfo>
509createARMTargetCodeGenInfo(CodeGenModule &CGM, ARMABIKind Kind);
510
511std::unique_ptr<TargetCodeGenInfo>
512createWindowsARMTargetCodeGenInfo(CodeGenModule &CGM, ARMABIKind K);
513
514std::unique_ptr<TargetCodeGenInfo>
515createAVRTargetCodeGenInfo(CodeGenModule &CGM, unsigned NPR, unsigned NRR);
516
517std::unique_ptr<TargetCodeGenInfo>
518createBPFTargetCodeGenInfo(CodeGenModule &CGM);
519
520std::unique_ptr<TargetCodeGenInfo>
521createCSKYTargetCodeGenInfo(CodeGenModule &CGM, unsigned FLen);
522
523std::unique_ptr<TargetCodeGenInfo>
524createHexagonTargetCodeGenInfo(CodeGenModule &CGM);
525
526std::unique_ptr<TargetCodeGenInfo>
527createLanaiTargetCodeGenInfo(CodeGenModule &CGM);
528
529std::unique_ptr<TargetCodeGenInfo>
530createLoongArchTargetCodeGenInfo(CodeGenModule &CGM, unsigned GRLen,
531 unsigned FLen);
532
533std::unique_ptr<TargetCodeGenInfo>
534createM68kTargetCodeGenInfo(CodeGenModule &CGM);
535
536std::unique_ptr<TargetCodeGenInfo>
537createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
538
539std::unique_ptr<TargetCodeGenInfo>
540createWindowsMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
541
542std::unique_ptr<TargetCodeGenInfo>
543createMSP430TargetCodeGenInfo(CodeGenModule &CGM);
544
545std::unique_ptr<TargetCodeGenInfo>
546createNVPTXTargetCodeGenInfo(CodeGenModule &CGM);
547
549 ELFv1 = 0,
550 ELFv2,
551};
552
553std::unique_ptr<TargetCodeGenInfo>
554createAIXTargetCodeGenInfo(CodeGenModule &CGM, bool Is64Bit);
555
556std::unique_ptr<TargetCodeGenInfo>
557createPPC32TargetCodeGenInfo(CodeGenModule &CGM, bool SoftFloatABI);
558
559std::unique_ptr<TargetCodeGenInfo>
560createPPC64TargetCodeGenInfo(CodeGenModule &CGM);
561
562std::unique_ptr<TargetCodeGenInfo>
564 bool SoftFloatABI);
565
566std::unique_ptr<TargetCodeGenInfo>
567createRISCVTargetCodeGenInfo(CodeGenModule &CGM, unsigned XLen, unsigned FLen,
568 bool EABI);
569
570std::unique_ptr<TargetCodeGenInfo>
571createCommonSPIRTargetCodeGenInfo(CodeGenModule &CGM);
572
573std::unique_ptr<TargetCodeGenInfo>
574createSPIRVTargetCodeGenInfo(CodeGenModule &CGM);
575
576std::unique_ptr<TargetCodeGenInfo>
577createSparcV8TargetCodeGenInfo(CodeGenModule &CGM);
578
579std::unique_ptr<TargetCodeGenInfo>
580createSparcV9TargetCodeGenInfo(CodeGenModule &CGM);
581
582std::unique_ptr<TargetCodeGenInfo>
583createSystemZTargetCodeGenInfo(CodeGenModule &CGM, bool HasVector,
584 bool SoftFloatABI);
585
586std::unique_ptr<TargetCodeGenInfo>
587createTCETargetCodeGenInfo(CodeGenModule &CGM);
588
589std::unique_ptr<TargetCodeGenInfo>
590createVETargetCodeGenInfo(CodeGenModule &CGM);
591
592std::unique_ptr<TargetCodeGenInfo>
593createDirectXTargetCodeGenInfo(CodeGenModule &CGM);
594
596 MVP = 0,
597 ExperimentalMV = 1,
598};
599
600std::unique_ptr<TargetCodeGenInfo>
602
603/// The AVX ABI level for X86 targets.
604enum class X86AVXABILevel {
605 None,
606 AVX,
607 AVX512,
608};
609
610std::unique_ptr<TargetCodeGenInfo> createX86_32TargetCodeGenInfo(
611 CodeGenModule &CGM, bool DarwinVectorABI, bool Win32StructABI,
612 unsigned NumRegisterParameters, bool SoftFloatABI);
613
614std::unique_ptr<TargetCodeGenInfo>
615createWinX86_32TargetCodeGenInfo(CodeGenModule &CGM, bool DarwinVectorABI,
616 bool Win32StructABI,
617 unsigned NumRegisterParameters);
618
619std::unique_ptr<TargetCodeGenInfo>
620createX86_64TargetCodeGenInfo(CodeGenModule &CGM, X86AVXABILevel AVXLevel);
621
622std::unique_ptr<TargetCodeGenInfo>
623createWinX86_64TargetCodeGenInfo(CodeGenModule &CGM, X86AVXABILevel AVXLevel);
624
625std::unique_ptr<TargetCodeGenInfo>
626createXCoreTargetCodeGenInfo(CodeGenModule &CGM);
627
628} // namespace CodeGen
629} // namespace clang
630
631#endif // LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
#define V(N, I)
Definition: ASTContext.h:3597
MatchType Type
const Decl * D
enum clang::sema::@1840::IndirectLocalPathEntry::EntryKind Kind
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:6816
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:182
Target specific hooks for defining how a type should be passed or returned from functions with one of...
Definition: ABIInfo.h:145
Interface class for filling custom fields of a block literal for OpenCL.
Definition: TargetInfo.h:365
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:367
TargetCodeGenInfo - This class organizes various target-specific codegeneration issues,...
Definition: TargetInfo.h:47
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:208
virtual bool emitCUDADeviceBuiltinSurfaceDeviceCopy(CodeGenFunction &CGF, LValue Dst, LValue Src) const
Emit the device-side copy of the builtin surface type.
Definition: TargetInfo.h:425
virtual llvm::Type * getWasmFuncrefReferenceType() const
Return the WebAssembly funcref reference type.
Definition: TargetInfo.h:422
virtual unsigned getDeviceKernelCallingConv() const
Get LLVM calling convention for device kernels.
Definition: TargetInfo.cpp:113
virtual bool supportsLibCall() const
supportsLibCall - Query to whether or not target supports all lib calls.
Definition: TargetInfo.h:76
virtual unsigned getSizeOfUnwindException() const
Determines the size of struct _Unwind_Exception on this platform, in 8-bit units.
Definition: TargetInfo.cpp:84
virtual llvm::Type * getWasmExternrefReferenceType() const
Return the WebAssembly externref reference type.
Definition: TargetInfo.h:419
virtual llvm::Type * getOpenCLType(CodeGenModule &CGM, const Type *T) const
Return an LLVM type that corresponds to an OpenCL type.
Definition: TargetInfo.h:440
virtual bool emitCUDADeviceBuiltinTextureDeviceCopy(CodeGenFunction &CGF, LValue Dst, LValue Src) const
Emit the device-side copy of the builtin texture type.
Definition: TargetInfo.h:432
virtual bool doesReturnSlotInterfereWithArgs() const
doesReturnSlotInterfereWithArgs - Return true if the target uses an argument slot for an 'sret' type.
Definition: TargetInfo.h:217
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:118
std::unique_ptr< SwiftABIInfo > SwiftInfo
Definition: TargetInfo.h:54
virtual void setCUDAKernelCallingConvention(const FunctionType *&FT) const
Definition: TargetInfo.h:405
virtual void setOCLKernelStubCallingConvention(const FunctionType *&FT) const
Definition: TargetInfo.cpp:130
virtual llvm::Type * getCUDADeviceBuiltinSurfaceDeviceType() const
Return the device-side type for the CUDA device builtin surface type.
Definition: TargetInfo.h:408
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:194
virtual void getDependentLibraryOption(llvm::StringRef Lib, llvm::SmallString< 24 > &Opt) const
Gets the linker options necessary to link a dependent library on this platform.
Definition: TargetInfo.cpp:104
Address performAddrSpaceCast(CodeGen::CodeGenFunction &CGF, Address Addr, LangAS SrcAddr, llvm::Type *DestTy, bool IsNonNull=false) const
virtual StringRef getARCRetainAutoreleasedReturnValueMarker() const
Retrieve the address of a function to call immediately before calling objc_retainAutoreleasedReturnVa...
Definition: TargetInfo.h:229
const SwiftABIInfo & getSwiftABIInfo() const
Returns Swift ABI info helper for the target.
Definition: TargetInfo.h:69
virtual llvm::Type * getHLSLType(CodeGenModule &CGM, const Type *T, const SmallVector< int32_t > *Packoffsets=nullptr) const
Return an LLVM type that corresponds to a HLSL 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:174
virtual llvm::SyncScope::ID getLLVMSyncScopeID(const LangOptions &LangOpts, SyncScope Scope, llvm::AtomicOrdering Ordering, llvm::LLVMContext &Ctx) const
Get the syncscope used in LLVM IR.
Definition: TargetInfo.cpp:171
static void setBranchProtectionFnAttributes(const TargetInfo::BranchProtectionInfo &BPI, llvm::Function &F)
Definition: TargetInfo.cpp:226
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:99
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:164
virtual bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF, llvm::Value *Address) const
Initializes the given DWARF EH register-size table, a char*.
Definition: TargetInfo.h:154
const T & getABIInfo() const
Definition: TargetInfo.h:57
static void initPointerAuthFnAttributes(const PointerAuthOptions &Opts, llvm::AttrBuilder &FuncAttrs)
Definition: TargetInfo.cpp:286
static void setPointerAuthFnAttributes(const PointerAuthOptions &Opts, llvm::Function &F)
Definition: TargetInfo.cpp:271
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.
Definition: TargetInfo.cpp:141
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:80
virtual llvm::Type * getCUDADeviceBuiltinTextureDeviceType() const
Return the device-side type for the CUDA device builtin texture type.
Definition: TargetInfo.h:413
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:94
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:202
static std::string qualifyWindowsLibrary(StringRef Lib)
Definition: X86.cpp:1621
void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const
Definition: TargetInfo.cpp:178
const ABIInfo & getABIInfo() const
getABIInfo() - Returns ABI info helper for the target.
Definition: TargetInfo.h:66
virtual bool shouldEmitDWARFBitFieldSeparators() const
Definition: TargetInfo.h:403
virtual LangAS getAddrSpaceOfCxaAtexitPtrParam() const
Get address space of pointer parameter for __cxa_atexit.
Definition: TargetInfo.h:348
virtual bool extendPointerWithSExt() const
Controls whether __builtin_extend_pointer should sign-extend pointers to uint64_t or zero-extend them...
Definition: TargetInfo.h:140
virtual llvm::Constant * getNullPointer(const CodeGen::CodeGenModule &CGM, llvm::PointerType *T, QualType QT) const
Get target specific null pointer.
Definition: TargetInfo.cpp:136
static void initBranchProtectionFnAttributes(const TargetInfo::BranchProtectionInfo &BPI, llvm::AttrBuilder &FuncAttrs)
Definition: TargetInfo.cpp:255
virtual TargetOpenCLBlockHelper * getTargetOpenCLBlockHelper() const
Definition: TargetInfo.h:381
virtual LangAS getASTAllocaAddressSpace() const
Get the AST address space for alloca.
Definition: TargetInfo.h:320
virtual int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const
Determines the DWARF register number for the stack pointer, for exception-handling purposes.
Definition: TargetInfo.h:146
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:85
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:359
virtual llvm::Value * createEnqueuedBlockKernel(CodeGenFunction &CGF, llvm::Function *BlockInvokeFunc, llvm::Type *BlockTy) const
Create an OpenCL kernel for an enqueued block.
Definition: TargetInfo.cpp:194
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:183
virtual bool markARCOptimizedReturnCallsAsNoTail() const
Determine whether a call to objc_retainAutoreleasedReturnValue or objc_unsafeClaimAutoreleasedReturnV...
Definition: TargetInfo.h:235
virtual void emitTargetGlobals(CodeGen::CodeGenModule &CGM) const
Provides a convenient hook to handle extra target-specific globals.
Definition: TargetInfo.h:90
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:297
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:241
virtual bool shouldEmitStaticExternCAliases() const
Definition: TargetInfo.h:398
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...
Definition: TargetInfo.cpp:94
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:1999
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition: TypeBase.h:4860
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition: TypeBase.h:4478
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:434
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.
The base class of the type hierarchy.
Definition: TypeBase.h:1833
Represents a variable declaration or definition.
Definition: Decl.h:925
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
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:3532
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:1056
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:361
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:3521
std::unique_ptr< TargetCodeGenInfo > createAIXTargetCodeGenInfo(CodeGenModule &CGM, bool Is64Bit)
Definition: PPC.cpp:1039
std::unique_ptr< TargetCodeGenInfo > createAMDGPUTargetCodeGenInfo(CodeGenModule &CGM)
Definition: AMDGPU.cpp:758
X86AVXABILevel
The AVX ABI level for X86 targets.
Definition: TargetInfo.h:604
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:97
std::unique_ptr< TargetCodeGenInfo > createARCTargetCodeGenInfo(CodeGenModule &CGM)
Definition: ARC.cpp:160
std::unique_ptr< TargetCodeGenInfo > createDefaultTargetCodeGenInfo(CodeGenModule &CGM)
Definition: TargetInfo.cpp:309
std::unique_ptr< TargetCodeGenInfo > createAArch64TargetCodeGenInfo(CodeGenModule &CGM, AArch64ABIKind Kind)
Definition: AArch64.cpp:1345
std::unique_ptr< TargetCodeGenInfo > createSPIRVTargetCodeGenInfo(CodeGenModule &CGM)
Definition: SPIR.cpp:624
std::unique_ptr< TargetCodeGenInfo > createWindowsMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32)
Definition: Mips.cpp:460
std::unique_ptr< TargetCodeGenInfo > createSparcV8TargetCodeGenInfo(CodeGenModule &CGM)
Definition: Sparc.cpp:411
std::unique_ptr< TargetCodeGenInfo > createVETargetCodeGenInfo(CodeGenModule &CGM)
Definition: VE.cpp:69
std::unique_ptr< TargetCodeGenInfo > createCommonSPIRTargetCodeGenInfo(CodeGenModule &CGM)
Definition: SPIR.cpp:619
std::unique_ptr< TargetCodeGenInfo > createRISCVTargetCodeGenInfo(CodeGenModule &CGM, unsigned XLen, unsigned FLen, bool EABI)
Definition: RISCV.cpp:1026
std::unique_ptr< TargetCodeGenInfo > createWindowsAArch64TargetCodeGenInfo(CodeGenModule &CGM, AArch64ABIKind K)
Definition: AArch64.cpp:1351
std::unique_ptr< TargetCodeGenInfo > createSparcV9TargetCodeGenInfo(CodeGenModule &CGM)
Definition: Sparc.cpp:416
std::unique_ptr< TargetCodeGenInfo > createX86_32TargetCodeGenInfo(CodeGenModule &CGM, bool DarwinVectorABI, bool Win32StructABI, unsigned NumRegisterParameters, bool SoftFloatABI)
Definition: X86.cpp:3511
std::unique_ptr< TargetCodeGenInfo > createLanaiTargetCodeGenInfo(CodeGenModule &CGM)
Definition: Lanai.cpp:157
std::unique_ptr< TargetCodeGenInfo > createPPC32TargetCodeGenInfo(CodeGenModule &CGM, bool SoftFloatABI)
Definition: PPC.cpp:1044
std::unique_ptr< TargetCodeGenInfo > createLoongArchTargetCodeGenInfo(CodeGenModule &CGM, unsigned GRLen, unsigned FLen)
Definition: LoongArch.cpp:459
std::unique_ptr< TargetCodeGenInfo > createPPC64TargetCodeGenInfo(CodeGenModule &CGM)
Definition: PPC.cpp:1052
std::unique_ptr< TargetCodeGenInfo > createWinX86_64TargetCodeGenInfo(CodeGenModule &CGM, X86AVXABILevel AVXLevel)
Definition: X86.cpp:3538
std::unique_ptr< TargetCodeGenInfo > createXCoreTargetCodeGenInfo(CodeGenModule &CGM)
Definition: XCore.cpp:658
std::unique_ptr< TargetCodeGenInfo > createCSKYTargetCodeGenInfo(CodeGenModule &CGM, unsigned FLen)
Definition: CSKY.cpp:173
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
Definition: ModuleMapFile.h:36
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.
Definition: AddressSpaces.h:25
const FunctionProtoType * T
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