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