xref: /llvm-project/clang/lib/CodeGen/TargetInfo.h (revision 71d6287f5b1e65466de5fe5c093852fa7903cdbe)
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 
27 namespace llvm {
28 class Constant;
29 class GlobalValue;
30 class Type;
31 class Value;
32 }
33 
34 namespace clang {
35 class Decl;
36 
37 namespace CodeGen {
38 class ABIInfo;
39 class CallArgList;
40 class CodeGenFunction;
41 class CGBlockInfo;
42 class SwiftABIInfo;
43 
44 /// TargetCodeGenInfo - This class organizes various target-specific
45 /// codegeneration issues, like target-specific attributes, builtins and so
46 /// on.
47 class TargetCodeGenInfo {
48   std::unique_ptr<ABIInfo> Info;
49 
50 protected:
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 
61 public:
62   TargetCodeGenInfo(std::unique_ptr<ABIInfo> Info);
63   virtual ~TargetCodeGenInfo();
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.
69   const SwiftABIInfo &getSwiftABIInfo() const {
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(
82       CodeGen::CodeGenModule &CGM,
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.
90   virtual void checkFunctionABI(CodeGenModule &CGM,
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.
95   virtual void checkFunctionCallABI(CodeGenModule &CGM, SourceLocation CallLoc,
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
114   wouldInliningViolateFunctionCallABI(const FunctionDecl *Caller,
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.
142   virtual int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const {
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.
150   virtual bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
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().
160   virtual llvm::Value *decodeReturnAddress(CodeGen::CodeGenFunction &CGF,
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().
170   virtual llvm::Value *encodeReturnAddress(CodeGen::CodeGenFunction &CGF,
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.
190   virtual llvm::Type *adjustInlineAsmType(CodeGen::CodeGenFunction &CGF,
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.
198   virtual bool isScalarizableAsmOperand(CodeGen::CodeGenFunction &CGF,
199                                         llvm::Type *Ty) const {
200     return false;
201   }
202 
203   /// Adds constraints and types for result registers.
204   virtual void addReturnRegisterOutputs(
205       CodeGen::CodeGenFunction &CGF, CodeGen::LValue ReturnValue,
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.
225   virtual StringRef getARCRetainAutoreleasedReturnValueMarker() const {
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 *
237   getUBSanFunctionSignature(CodeGen::CodeGenModule &CGM) const {
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.
312   virtual LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
313                                           const VarDecl *D) const;
314 
315   /// Get the AST address space for alloca.
316   virtual LangAS getASTAllocaAddressSpace() const { return LangAS::Default; }
317 
318   Address performAddrSpaceCast(CodeGen::CodeGenFunction &CGF, Address Addr,
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.
345   virtual LangAS getAddrSpaceOfCxaAtexitPtrParam() const {
346     return LangAS::Default;
347   }
348 
349   /// Get the syncscope used in LLVM IR.
350   virtual llvm::SyncScope::ID getLLVMSyncScopeID(const LangOptions &LangOpts,
351                                                  SyncScope Scope,
352                                                  llvm::AtomicOrdering Ordering,
353                                                  llvm::LLVMContext &Ctx) const;
354 
355   /// Allow the target to apply other metadata to an atomic instruction
356   virtual void setTargetAtomicMetadata(CodeGenFunction &CGF,
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.
362   class TargetOpenCLBlockHelper {
363   public:
364     typedef std::pair<llvm::Value *, StringRef> ValueTy;
365     TargetOpenCLBlockHelper() {}
366     virtual ~TargetOpenCLBlockHelper() {}
367     /// Get the custom field types for OpenCL blocks.
368     virtual llvm::SmallVector<llvm::Type *, 1> getCustomFieldTypes() = 0;
369     /// Get the custom field values for OpenCL blocks.
370     virtual llvm::SmallVector<ValueTy, 1>
371     getCustomFieldValues(CodeGenFunction &CGF, const CGBlockInfo &Info) = 0;
372     virtual bool areAllCustomFieldValuesConstant(const CGBlockInfo &Info) = 0;
373     /// Get the custom field values for OpenCL blocks if all values are LLVM
374     /// constants.
375     virtual llvm::SmallVector<llvm::Constant *, 1>
376     getCustomFieldValues(CodeGenModule &CGM, const CGBlockInfo &Info) = 0;
377   };
378   virtual TargetOpenCLBlockHelper *getTargetOpenCLBlockHelper() const {
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 *
388   createEnqueuedBlockKernel(CodeGenFunction &CGF,
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.
422   virtual bool emitCUDADeviceBuiltinSurfaceDeviceCopy(CodeGenFunction &CGF,
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.
429   virtual bool emitCUDADeviceBuiltinTextureDeviceCopy(CodeGenFunction &CGF,
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
449   setBranchProtectionFnAttributes(const TargetInfo::BranchProtectionInfo &BPI,
450                                   llvm::Function &F);
451 
452   // Add the Branch Protection Attributes of the FuncAttrs.
453   static void
454   initBranchProtectionFnAttributes(const TargetInfo::BranchProtectionInfo &BPI,
455                                    llvm::AttrBuilder &FuncAttrs);
456 
457 protected:
458   static std::string qualifyWindowsLibrary(StringRef Lib);
459 
460   void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
461                                      CodeGen::CodeGenModule &CGM) const;
462 };
463 
464 std::unique_ptr<TargetCodeGenInfo>
465 createDefaultTargetCodeGenInfo(CodeGenModule &CGM);
466 
467 enum class AArch64ABIKind {
468   AAPCS = 0,
469   DarwinPCS,
470   Win64,
471   AAPCSSoft,
472   PAuthTest,
473 };
474 
475 std::unique_ptr<TargetCodeGenInfo>
476 createAArch64TargetCodeGenInfo(CodeGenModule &CGM, AArch64ABIKind Kind);
477 
478 std::unique_ptr<TargetCodeGenInfo>
479 createWindowsAArch64TargetCodeGenInfo(CodeGenModule &CGM, AArch64ABIKind K);
480 
481 std::unique_ptr<TargetCodeGenInfo>
482 createAMDGPUTargetCodeGenInfo(CodeGenModule &CGM);
483 
484 std::unique_ptr<TargetCodeGenInfo>
485 createARCTargetCodeGenInfo(CodeGenModule &CGM);
486 
487 enum class ARMABIKind {
488   APCS = 0,
489   AAPCS = 1,
490   AAPCS_VFP = 2,
491   AAPCS16_VFP = 3,
492 };
493 
494 std::unique_ptr<TargetCodeGenInfo>
495 createARMTargetCodeGenInfo(CodeGenModule &CGM, ARMABIKind Kind);
496 
497 std::unique_ptr<TargetCodeGenInfo>
498 createWindowsARMTargetCodeGenInfo(CodeGenModule &CGM, ARMABIKind K);
499 
500 std::unique_ptr<TargetCodeGenInfo>
501 createAVRTargetCodeGenInfo(CodeGenModule &CGM, unsigned NPR, unsigned NRR);
502 
503 std::unique_ptr<TargetCodeGenInfo>
504 createBPFTargetCodeGenInfo(CodeGenModule &CGM);
505 
506 std::unique_ptr<TargetCodeGenInfo>
507 createCSKYTargetCodeGenInfo(CodeGenModule &CGM, unsigned FLen);
508 
509 std::unique_ptr<TargetCodeGenInfo>
510 createHexagonTargetCodeGenInfo(CodeGenModule &CGM);
511 
512 std::unique_ptr<TargetCodeGenInfo>
513 createLanaiTargetCodeGenInfo(CodeGenModule &CGM);
514 
515 std::unique_ptr<TargetCodeGenInfo>
516 createLoongArchTargetCodeGenInfo(CodeGenModule &CGM, unsigned GRLen,
517                                  unsigned FLen);
518 
519 std::unique_ptr<TargetCodeGenInfo>
520 createM68kTargetCodeGenInfo(CodeGenModule &CGM);
521 
522 std::unique_ptr<TargetCodeGenInfo>
523 createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
524 
525 std::unique_ptr<TargetCodeGenInfo>
526 createWindowsMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
527 
528 std::unique_ptr<TargetCodeGenInfo>
529 createMSP430TargetCodeGenInfo(CodeGenModule &CGM);
530 
531 std::unique_ptr<TargetCodeGenInfo>
532 createNVPTXTargetCodeGenInfo(CodeGenModule &CGM);
533 
534 std::unique_ptr<TargetCodeGenInfo>
535 createPNaClTargetCodeGenInfo(CodeGenModule &CGM);
536 
537 enum class PPC64_SVR4_ABIKind {
538   ELFv1 = 0,
539   ELFv2,
540 };
541 
542 std::unique_ptr<TargetCodeGenInfo>
543 createAIXTargetCodeGenInfo(CodeGenModule &CGM, bool Is64Bit);
544 
545 std::unique_ptr<TargetCodeGenInfo>
546 createPPC32TargetCodeGenInfo(CodeGenModule &CGM, bool SoftFloatABI);
547 
548 std::unique_ptr<TargetCodeGenInfo>
549 createPPC64TargetCodeGenInfo(CodeGenModule &CGM);
550 
551 std::unique_ptr<TargetCodeGenInfo>
552 createPPC64_SVR4_TargetCodeGenInfo(CodeGenModule &CGM, PPC64_SVR4_ABIKind Kind,
553                                    bool SoftFloatABI);
554 
555 std::unique_ptr<TargetCodeGenInfo>
556 createRISCVTargetCodeGenInfo(CodeGenModule &CGM, unsigned XLen, unsigned FLen,
557                              bool EABI);
558 
559 std::unique_ptr<TargetCodeGenInfo>
560 createCommonSPIRTargetCodeGenInfo(CodeGenModule &CGM);
561 
562 std::unique_ptr<TargetCodeGenInfo>
563 createSPIRVTargetCodeGenInfo(CodeGenModule &CGM);
564 
565 std::unique_ptr<TargetCodeGenInfo>
566 createSparcV8TargetCodeGenInfo(CodeGenModule &CGM);
567 
568 std::unique_ptr<TargetCodeGenInfo>
569 createSparcV9TargetCodeGenInfo(CodeGenModule &CGM);
570 
571 std::unique_ptr<TargetCodeGenInfo>
572 createSystemZTargetCodeGenInfo(CodeGenModule &CGM, bool HasVector,
573                                bool SoftFloatABI);
574 
575 std::unique_ptr<TargetCodeGenInfo>
576 createTCETargetCodeGenInfo(CodeGenModule &CGM);
577 
578 std::unique_ptr<TargetCodeGenInfo>
579 createVETargetCodeGenInfo(CodeGenModule &CGM);
580 
581 std::unique_ptr<TargetCodeGenInfo>
582 createDirectXTargetCodeGenInfo(CodeGenModule &CGM);
583 
584 enum class WebAssemblyABIKind {
585   MVP = 0,
586   ExperimentalMV = 1,
587 };
588 
589 std::unique_ptr<TargetCodeGenInfo>
590 createWebAssemblyTargetCodeGenInfo(CodeGenModule &CGM, WebAssemblyABIKind K);
591 
592 /// The AVX ABI level for X86 targets.
593 enum class X86AVXABILevel {
594   None,
595   AVX,
596   AVX512,
597 };
598 
599 std::unique_ptr<TargetCodeGenInfo> createX86_32TargetCodeGenInfo(
600     CodeGenModule &CGM, bool DarwinVectorABI, bool Win32StructABI,
601     unsigned NumRegisterParameters, bool SoftFloatABI);
602 
603 std::unique_ptr<TargetCodeGenInfo>
604 createWinX86_32TargetCodeGenInfo(CodeGenModule &CGM, bool DarwinVectorABI,
605                                  bool Win32StructABI,
606                                  unsigned NumRegisterParameters);
607 
608 std::unique_ptr<TargetCodeGenInfo>
609 createX86_64TargetCodeGenInfo(CodeGenModule &CGM, X86AVXABILevel AVXLevel);
610 
611 std::unique_ptr<TargetCodeGenInfo>
612 createWinX86_64TargetCodeGenInfo(CodeGenModule &CGM, X86AVXABILevel AVXLevel);
613 
614 std::unique_ptr<TargetCodeGenInfo>
615 createXCoreTargetCodeGenInfo(CodeGenModule &CGM);
616 
617 } // namespace CodeGen
618 } // namespace clang
619 
620 #endif // LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
621