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