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