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