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