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 address space for an indirect (sret) return of the given type.
323 /// The default falls back to the alloca AS.
324 virtual LangAS getSRetAddrSpace(const CXXRecordDecl *RD) const {
325 return LangAS::Default;
326 }
327
328 /// Get address space of pointer parameter for __cxa_atexit.
330 return LangAS::Default;
331 }
332
333 /// Get the syncscope used in LLVM IR as a string
334 virtual StringRef getLLVMSyncScopeStr(const LangOptions &LangOpts,
336 llvm::AtomicOrdering Ordering) const;
337
338 /// Get the syncscope used in LLVM IR as a SyncScope ID.
339 llvm::SyncScope::ID getLLVMSyncScopeID(const LangOptions &LangOpts,
341 llvm::AtomicOrdering Ordering,
342 llvm::LLVMContext &Ctx) const;
343
344 /// Allow the target to apply other metadata to an atomic instruction
346 llvm::Instruction &AtomicInst,
347 const AtomicExpr *Expr = nullptr) const {
348 }
349
350 /// Interface class for filling custom fields of a block literal for OpenCL.
352 public:
353 typedef std::pair<llvm::Value *, StringRef> ValueTy;
356 /// Get the custom field types for OpenCL blocks.
358 /// Get the custom field values for OpenCL blocks.
361 virtual bool areAllCustomFieldValuesConstant(const CGBlockInfo &Info) = 0;
362 /// Get the custom field values for OpenCL blocks if all values are LLVM
363 /// constants.
366 };
368 return nullptr;
369 }
370
371 /// Create an OpenCL kernel for an enqueued block. The kernel function is
372 /// a wrapper for the block invoke function with target-specific calling
373 /// convention and ABI as an OpenCL kernel. The wrapper function accepts
374 /// block context and block arguments in target-specific way and calls
375 /// the original block invoke function.
376 virtual llvm::Value *
378 llvm::Function *BlockInvokeFunc,
379 llvm::Type *BlockTy) const;
380
381 /// \return true if the target supports alias from the unmangled name to the
382 /// mangled name of functions declared within an extern "C" region and marked
383 /// as 'used', and having internal linkage.
384 virtual bool shouldEmitStaticExternCAliases() const { return true; }
385
386 /// \return true if annonymous zero-sized bitfields should be emitted to
387 /// correctly distinguish between struct types whose memory layout is the
388 /// same, but whose layout may differ when used as argument passed by value
389 virtual bool shouldEmitDWARFBitFieldSeparators() const { return false; }
390
391 virtual void setCUDAKernelCallingConvention(const FunctionType *&FT) const {}
392 virtual void setOCLKernelStubCallingConvention(const FunctionType *&FT) const;
393 /// Return the device-side type for the CUDA device builtin surface type.
394 virtual llvm::Type *getCUDADeviceBuiltinSurfaceDeviceType() const {
395 // By default, no change from the original one.
396 return nullptr;
397 }
398 /// Return the device-side type for the CUDA device builtin texture type.
399 virtual llvm::Type *getCUDADeviceBuiltinTextureDeviceType() const {
400 // By default, no change from the original one.
401 return nullptr;
402 }
403
404 /// Return the WebAssembly externref reference type.
405 virtual llvm::Type *getWasmExternrefReferenceType() const { return nullptr; }
406
407 /// Return the WebAssembly funcref reference type.
408 virtual llvm::Type *getWasmFuncrefReferenceType() const { return nullptr; }
409
410 /// Emit the device-side copy of the builtin surface type.
412 LValue Dst,
413 LValue Src) const {
414 // DO NOTHING by default.
415 return false;
416 }
417 /// Emit the device-side copy of the builtin texture type.
419 LValue Dst,
420 LValue Src) const {
421 // DO NOTHING by default.
422 return false;
423 }
424
425 /// Return an LLVM type that corresponds to an OpenCL type.
426 virtual llvm::Type *getOpenCLType(CodeGenModule &CGM, const Type *T) const {
427 return nullptr;
428 }
429
430 /// Return an LLVM type that corresponds to a HLSL type
431 virtual llvm::Type *getHLSLType(CodeGenModule &CGM, const Type *T,
432 const CGHLSLOffsetInfo &OffsetInfo) const {
433 return nullptr;
434 }
435
436 /// Return an LLVM type that corresponds to padding in HLSL types
437 virtual llvm::Type *getHLSLPadding(CodeGenModule &CGM,
438 CharUnits NumBytes) const {
439 return nullptr;
440 }
441
442 /// Return true if this is an HLSL padding type.
443 virtual bool isHLSLPadding(llvm::Type *Ty) const { return false; }
444
445 // Set the Branch Protection Attributes of the Function accordingly to the
446 // BPI. Remove attributes that contradict with current BPI.
447 static void
449 llvm::Function &F);
450
451 // Add the Branch Protection Attributes of the FuncAttrs.
452 static void
454 llvm::AttrBuilder &FuncAttrs);
455
456 // Set the ptrauth-* attributes of the Function accordingly to the Opts.
457 // Remove attributes that contradict with current Opts.
458 static void setPointerAuthFnAttributes(const PointerAuthOptions &Opts,
459 llvm::Function &F);
460
461 // Add the ptrauth-* Attributes to the FuncAttrs.
462 static void initPointerAuthFnAttributes(const PointerAuthOptions &Opts,
463 llvm::AttrBuilder &FuncAttrs);
464
465protected:
466 static std::string qualifyWindowsLibrary(StringRef Lib);
467
468 void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
469 CodeGen::CodeGenModule &CGM) const;
470};
471
472std::unique_ptr<TargetCodeGenInfo>
473createDefaultTargetCodeGenInfo(CodeGenModule &CGM);
474
481
482std::unique_ptr<TargetCodeGenInfo>
483createAArch64TargetCodeGenInfo(CodeGenModule &CGM, AArch64ABIKind Kind);
484
485std::unique_ptr<TargetCodeGenInfo>
487
488std::unique_ptr<TargetCodeGenInfo>
489createAMDGPUTargetCodeGenInfo(CodeGenModule &CGM);
490
491std::unique_ptr<TargetCodeGenInfo>
492createARCTargetCodeGenInfo(CodeGenModule &CGM);
493
494enum class ARMABIKind {
495 APCS = 0,
496 AAPCS = 1,
499};
500
501std::unique_ptr<TargetCodeGenInfo>
502createARMTargetCodeGenInfo(CodeGenModule &CGM, ARMABIKind Kind);
503
504std::unique_ptr<TargetCodeGenInfo>
505createWindowsARMTargetCodeGenInfo(CodeGenModule &CGM, ARMABIKind K);
506
507std::unique_ptr<TargetCodeGenInfo>
508createAVRTargetCodeGenInfo(CodeGenModule &CGM, unsigned NPR, unsigned NRR);
509
510std::unique_ptr<TargetCodeGenInfo>
511createBPFTargetCodeGenInfo(CodeGenModule &CGM);
512
513std::unique_ptr<TargetCodeGenInfo>
514createCSKYTargetCodeGenInfo(CodeGenModule &CGM, unsigned FLen);
515
516std::unique_ptr<TargetCodeGenInfo>
517createHexagonTargetCodeGenInfo(CodeGenModule &CGM);
518
519std::unique_ptr<TargetCodeGenInfo>
520createLanaiTargetCodeGenInfo(CodeGenModule &CGM);
521
522std::unique_ptr<TargetCodeGenInfo>
523createLoongArchTargetCodeGenInfo(CodeGenModule &CGM, unsigned GRLen,
524 unsigned FLen);
525
526std::unique_ptr<TargetCodeGenInfo>
527createM68kTargetCodeGenInfo(CodeGenModule &CGM);
528
529std::unique_ptr<TargetCodeGenInfo>
530createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
531
532std::unique_ptr<TargetCodeGenInfo>
533createWindowsMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
534
535std::unique_ptr<TargetCodeGenInfo>
536createMSP430TargetCodeGenInfo(CodeGenModule &CGM);
537
538std::unique_ptr<TargetCodeGenInfo>
539createNVPTXTargetCodeGenInfo(CodeGenModule &CGM);
540
542 ELFv1 = 0,
544};
545
546std::unique_ptr<TargetCodeGenInfo>
547createAIXTargetCodeGenInfo(CodeGenModule &CGM, bool Is64Bit);
548
549std::unique_ptr<TargetCodeGenInfo>
550createPPC32TargetCodeGenInfo(CodeGenModule &CGM, bool SoftFloatABI);
551
552std::unique_ptr<TargetCodeGenInfo>
553createPPC64TargetCodeGenInfo(CodeGenModule &CGM);
554
555std::unique_ptr<TargetCodeGenInfo>
557 bool SoftFloatABI);
558
559std::unique_ptr<TargetCodeGenInfo>
560createRISCVTargetCodeGenInfo(CodeGenModule &CGM, unsigned XLen, unsigned FLen,
561 bool EABI);
562
563std::unique_ptr<TargetCodeGenInfo>
564createCommonSPIRTargetCodeGenInfo(CodeGenModule &CGM);
565
566std::unique_ptr<TargetCodeGenInfo>
567createSPIRVTargetCodeGenInfo(CodeGenModule &CGM);
568
569std::unique_ptr<TargetCodeGenInfo>
570createSparcV8TargetCodeGenInfo(CodeGenModule &CGM);
571
572std::unique_ptr<TargetCodeGenInfo>
573createSparcV9TargetCodeGenInfo(CodeGenModule &CGM);
574
575std::unique_ptr<TargetCodeGenInfo>
576createSystemZTargetCodeGenInfo(CodeGenModule &CGM, bool HasVector,
577 bool SoftFloatABI);
578
579std::unique_ptr<TargetCodeGenInfo>
580createTCETargetCodeGenInfo(CodeGenModule &CGM);
581
582std::unique_ptr<TargetCodeGenInfo>
583createVETargetCodeGenInfo(CodeGenModule &CGM);
584
585std::unique_ptr<TargetCodeGenInfo>
586createDirectXTargetCodeGenInfo(CodeGenModule &CGM);
587
589 MVP = 0,
591};
592
593std::unique_ptr<TargetCodeGenInfo>
594createWebAssemblyTargetCodeGenInfo(CodeGenModule &CGM, WebAssemblyABIKind K);
595
596/// The AVX ABI level for X86 targets.
602
603std::unique_ptr<TargetCodeGenInfo> createX86_32TargetCodeGenInfo(
604 CodeGenModule &CGM, bool DarwinVectorABI, bool Win32StructABI,
605 unsigned NumRegisterParameters, bool SoftFloatABI);
606
607std::unique_ptr<TargetCodeGenInfo>
608createWinX86_32TargetCodeGenInfo(CodeGenModule &CGM, bool DarwinVectorABI,
609 bool Win32StructABI,
610 unsigned NumRegisterParameters);
611
612std::unique_ptr<TargetCodeGenInfo>
613createX86_64TargetCodeGenInfo(CodeGenModule &CGM, X86AVXABILevel AVXLevel);
614
615std::unique_ptr<TargetCodeGenInfo>
616createWinX86_64TargetCodeGenInfo(CodeGenModule &CGM, X86AVXABILevel AVXLevel);
617
618std::unique_ptr<TargetCodeGenInfo>
619createXCoreTargetCodeGenInfo(CodeGenModule &CGM);
620
621} // namespace CodeGen
622} // namespace clang
623
624#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:6928
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:275
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:351
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:353
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:411
virtual llvm::Type * getWasmFuncrefReferenceType() const
Return the WebAssembly funcref reference type.
Definition TargetInfo.h:408
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:405
virtual llvm::Type * getOpenCLType(CodeGenModule &CGM, const Type *T) const
Return an LLVM type that corresponds to an OpenCL type.
Definition TargetInfo.h:426
virtual bool emitCUDADeviceBuiltinTextureDeviceCopy(CodeGenFunction &CGF, LValue Dst, LValue Src) const
Emit the device-side copy of the builtin texture type.
Definition TargetInfo.h:418
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:391
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:394
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:443
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:324
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:399
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:389
virtual LangAS getAddrSpaceOfCxaAtexitPtrParam() const
Get address space of pointer parameter for __cxa_atexit.
Definition TargetInfo.h:329
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:437
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:431
virtual TargetOpenCLBlockHelper * getTargetOpenCLBlockHelper() const
Definition TargetInfo.h:367
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:345
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:384
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:4947
FunctionType - C99 6.7.5.3 - Function Declarators.
Definition TypeBase.h:4565
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:777
X86AVXABILevel
The AVX ABI level for X86 targets.
Definition TargetInfo.h:597
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:949
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:944
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