106f32e7eSjoerg //===---- TargetInfo.h - Encapsulate target details -------------*- C++ -*-===//
206f32e7eSjoerg //
306f32e7eSjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
406f32e7eSjoerg // See https://llvm.org/LICENSE.txt for license information.
506f32e7eSjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
606f32e7eSjoerg //
706f32e7eSjoerg //===----------------------------------------------------------------------===//
806f32e7eSjoerg //
906f32e7eSjoerg // These classes wrap the information about a call or function
1006f32e7eSjoerg // definition used to handle ABI compliancy.
1106f32e7eSjoerg //
1206f32e7eSjoerg //===----------------------------------------------------------------------===//
1306f32e7eSjoerg 
1406f32e7eSjoerg #ifndef LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
1506f32e7eSjoerg #define LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
1606f32e7eSjoerg 
17*13fbcb42Sjoerg #include "CGBuilder.h"
1806f32e7eSjoerg #include "CodeGenModule.h"
1906f32e7eSjoerg #include "CGValue.h"
2006f32e7eSjoerg #include "clang/AST/Type.h"
2106f32e7eSjoerg #include "clang/Basic/LLVM.h"
2206f32e7eSjoerg #include "clang/Basic/SyncScope.h"
2306f32e7eSjoerg #include "llvm/ADT/SmallString.h"
2406f32e7eSjoerg #include "llvm/ADT/StringRef.h"
2506f32e7eSjoerg 
2606f32e7eSjoerg namespace llvm {
2706f32e7eSjoerg class Constant;
2806f32e7eSjoerg class GlobalValue;
2906f32e7eSjoerg class Type;
3006f32e7eSjoerg class Value;
3106f32e7eSjoerg }
3206f32e7eSjoerg 
3306f32e7eSjoerg namespace clang {
3406f32e7eSjoerg class Decl;
3506f32e7eSjoerg 
3606f32e7eSjoerg namespace CodeGen {
3706f32e7eSjoerg class ABIInfo;
3806f32e7eSjoerg class CallArgList;
3906f32e7eSjoerg class CodeGenFunction;
4006f32e7eSjoerg class CGBlockInfo;
4106f32e7eSjoerg class CGFunctionInfo;
4206f32e7eSjoerg 
4306f32e7eSjoerg /// TargetCodeGenInfo - This class organizes various target-specific
4406f32e7eSjoerg /// codegeneration issues, like target-specific attributes, builtins and so
4506f32e7eSjoerg /// on.
4606f32e7eSjoerg class TargetCodeGenInfo {
47*13fbcb42Sjoerg   std::unique_ptr<ABIInfo> Info = nullptr;
4806f32e7eSjoerg 
4906f32e7eSjoerg public:
TargetCodeGenInfo(std::unique_ptr<ABIInfo> Info)50*13fbcb42Sjoerg   TargetCodeGenInfo(std::unique_ptr<ABIInfo> Info) : Info(std::move(Info)) {}
5106f32e7eSjoerg   virtual ~TargetCodeGenInfo();
5206f32e7eSjoerg 
5306f32e7eSjoerg   /// getABIInfo() - Returns ABI info helper for the target.
getABIInfo()5406f32e7eSjoerg   const ABIInfo &getABIInfo() const { return *Info; }
5506f32e7eSjoerg 
5606f32e7eSjoerg   /// setTargetAttributes - Provides a convenient hook to handle extra
5706f32e7eSjoerg   /// target-specific attributes for the given global.
setTargetAttributes(const Decl * D,llvm::GlobalValue * GV,CodeGen::CodeGenModule & M)5806f32e7eSjoerg   virtual void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
5906f32e7eSjoerg                                    CodeGen::CodeGenModule &M) const {}
6006f32e7eSjoerg 
61*13fbcb42Sjoerg   /// emitTargetMetadata - Provides a convenient hook to handle extra
62*13fbcb42Sjoerg   /// target-specific metadata for the given globals.
emitTargetMetadata(CodeGen::CodeGenModule & CGM,const llvm::MapVector<GlobalDecl,StringRef> & MangledDeclNames)63*13fbcb42Sjoerg   virtual void emitTargetMetadata(
64*13fbcb42Sjoerg       CodeGen::CodeGenModule &CGM,
65*13fbcb42Sjoerg       const llvm::MapVector<GlobalDecl, StringRef> &MangledDeclNames) const {}
66*13fbcb42Sjoerg 
67*13fbcb42Sjoerg   /// Any further codegen related checks that need to be done on a function call
68*13fbcb42Sjoerg   /// in a target specific manner.
checkFunctionCallABI(CodeGenModule & CGM,SourceLocation CallLoc,const FunctionDecl * Caller,const FunctionDecl * Callee,const CallArgList & Args)69*13fbcb42Sjoerg   virtual void checkFunctionCallABI(CodeGenModule &CGM, SourceLocation CallLoc,
70*13fbcb42Sjoerg                                     const FunctionDecl *Caller,
71*13fbcb42Sjoerg                                     const FunctionDecl *Callee,
72*13fbcb42Sjoerg                                     const CallArgList &Args) const {}
7306f32e7eSjoerg 
7406f32e7eSjoerg   /// Determines the size of struct _Unwind_Exception on this platform,
7506f32e7eSjoerg   /// in 8-bit units.  The Itanium ABI defines this as:
7606f32e7eSjoerg   ///   struct _Unwind_Exception {
7706f32e7eSjoerg   ///     uint64 exception_class;
7806f32e7eSjoerg   ///     _Unwind_Exception_Cleanup_Fn exception_cleanup;
7906f32e7eSjoerg   ///     uint64 private_1;
8006f32e7eSjoerg   ///     uint64 private_2;
8106f32e7eSjoerg   ///   };
8206f32e7eSjoerg   virtual unsigned getSizeOfUnwindException() const;
8306f32e7eSjoerg 
8406f32e7eSjoerg   /// Controls whether __builtin_extend_pointer should sign-extend
8506f32e7eSjoerg   /// pointers to uint64_t or zero-extend them (the default).  Has
8606f32e7eSjoerg   /// no effect for targets:
8706f32e7eSjoerg   ///   - that have 64-bit pointers, or
8806f32e7eSjoerg   ///   - that cannot address through registers larger than pointers, or
8906f32e7eSjoerg   ///   - that implicitly ignore/truncate the top bits when addressing
9006f32e7eSjoerg   ///     through such registers.
extendPointerWithSExt()9106f32e7eSjoerg   virtual bool extendPointerWithSExt() const { return false; }
9206f32e7eSjoerg 
9306f32e7eSjoerg   /// Determines the DWARF register number for the stack pointer, for
9406f32e7eSjoerg   /// exception-handling purposes.  Implements __builtin_dwarf_sp_column.
9506f32e7eSjoerg   ///
9606f32e7eSjoerg   /// Returns -1 if the operation is unsupported by this target.
getDwarfEHStackPointer(CodeGen::CodeGenModule & M)9706f32e7eSjoerg   virtual int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const {
9806f32e7eSjoerg     return -1;
9906f32e7eSjoerg   }
10006f32e7eSjoerg 
10106f32e7eSjoerg   /// Initializes the given DWARF EH register-size table, a char*.
10206f32e7eSjoerg   /// Implements __builtin_init_dwarf_reg_size_table.
10306f32e7eSjoerg   ///
10406f32e7eSjoerg   /// Returns true if the operation is unsupported by this target.
initDwarfEHRegSizeTable(CodeGen::CodeGenFunction & CGF,llvm::Value * Address)10506f32e7eSjoerg   virtual bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
10606f32e7eSjoerg                                        llvm::Value *Address) const {
10706f32e7eSjoerg     return true;
10806f32e7eSjoerg   }
10906f32e7eSjoerg 
11006f32e7eSjoerg   /// Performs the code-generation required to convert a return
11106f32e7eSjoerg   /// address as stored by the system into the actual address of the
11206f32e7eSjoerg   /// next instruction that will be executed.
11306f32e7eSjoerg   ///
11406f32e7eSjoerg   /// Used by __builtin_extract_return_addr().
decodeReturnAddress(CodeGen::CodeGenFunction & CGF,llvm::Value * Address)11506f32e7eSjoerg   virtual llvm::Value *decodeReturnAddress(CodeGen::CodeGenFunction &CGF,
11606f32e7eSjoerg                                            llvm::Value *Address) const {
11706f32e7eSjoerg     return Address;
11806f32e7eSjoerg   }
11906f32e7eSjoerg 
12006f32e7eSjoerg   /// Performs the code-generation required to convert the address
12106f32e7eSjoerg   /// of an instruction into a return address suitable for storage
12206f32e7eSjoerg   /// by the system in a return slot.
12306f32e7eSjoerg   ///
12406f32e7eSjoerg   /// Used by __builtin_frob_return_addr().
encodeReturnAddress(CodeGen::CodeGenFunction & CGF,llvm::Value * Address)12506f32e7eSjoerg   virtual llvm::Value *encodeReturnAddress(CodeGen::CodeGenFunction &CGF,
12606f32e7eSjoerg                                            llvm::Value *Address) const {
12706f32e7eSjoerg     return Address;
12806f32e7eSjoerg   }
12906f32e7eSjoerg 
130*13fbcb42Sjoerg   /// Performs a target specific test of a floating point value for things
131*13fbcb42Sjoerg   /// like IsNaN, Infinity, ... Nullptr is returned if no implementation
132*13fbcb42Sjoerg   /// exists.
133*13fbcb42Sjoerg   virtual llvm::Value *
testFPKind(llvm::Value * V,unsigned BuiltinID,CGBuilderTy & Builder,CodeGenModule & CGM)134*13fbcb42Sjoerg   testFPKind(llvm::Value *V, unsigned BuiltinID, CGBuilderTy &Builder,
135*13fbcb42Sjoerg              CodeGenModule &CGM) const {
136*13fbcb42Sjoerg     assert(V->getType()->isFloatingPointTy() && "V should have an FP type.");
137*13fbcb42Sjoerg     return nullptr;
138*13fbcb42Sjoerg   }
139*13fbcb42Sjoerg 
14006f32e7eSjoerg   /// Corrects the low-level LLVM type for a given constraint and "usual"
14106f32e7eSjoerg   /// type.
14206f32e7eSjoerg   ///
14306f32e7eSjoerg   /// \returns A pointer to a new LLVM type, possibly the same as the original
14406f32e7eSjoerg   /// on success; 0 on failure.
adjustInlineAsmType(CodeGen::CodeGenFunction & CGF,StringRef Constraint,llvm::Type * Ty)14506f32e7eSjoerg   virtual llvm::Type *adjustInlineAsmType(CodeGen::CodeGenFunction &CGF,
14606f32e7eSjoerg                                           StringRef Constraint,
14706f32e7eSjoerg                                           llvm::Type *Ty) const {
14806f32e7eSjoerg     return Ty;
14906f32e7eSjoerg   }
15006f32e7eSjoerg 
15106f32e7eSjoerg   /// Adds constraints and types for result registers.
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)15206f32e7eSjoerg   virtual void addReturnRegisterOutputs(
15306f32e7eSjoerg       CodeGen::CodeGenFunction &CGF, CodeGen::LValue ReturnValue,
15406f32e7eSjoerg       std::string &Constraints, std::vector<llvm::Type *> &ResultRegTypes,
15506f32e7eSjoerg       std::vector<llvm::Type *> &ResultTruncRegTypes,
15606f32e7eSjoerg       std::vector<CodeGen::LValue> &ResultRegDests, std::string &AsmString,
15706f32e7eSjoerg       unsigned NumOutputs) const {}
15806f32e7eSjoerg 
15906f32e7eSjoerg   /// doesReturnSlotInterfereWithArgs - Return true if the target uses an
16006f32e7eSjoerg   /// argument slot for an 'sret' type.
doesReturnSlotInterfereWithArgs()16106f32e7eSjoerg   virtual bool doesReturnSlotInterfereWithArgs() const { return true; }
16206f32e7eSjoerg 
16306f32e7eSjoerg   /// Retrieve the address of a function to call immediately before
16406f32e7eSjoerg   /// calling objc_retainAutoreleasedReturnValue.  The
16506f32e7eSjoerg   /// implementation of objc_autoreleaseReturnValue sniffs the
16606f32e7eSjoerg   /// instruction stream following its return address to decide
16706f32e7eSjoerg   /// whether it's a call to objc_retainAutoreleasedReturnValue.
16806f32e7eSjoerg   /// This can be prohibitively expensive, depending on the
16906f32e7eSjoerg   /// relocation model, and so on some targets it instead sniffs for
17006f32e7eSjoerg   /// a particular instruction sequence.  This functions returns
17106f32e7eSjoerg   /// that instruction sequence in inline assembly, which will be
17206f32e7eSjoerg   /// empty if none is required.
getARCRetainAutoreleasedReturnValueMarker()17306f32e7eSjoerg   virtual StringRef getARCRetainAutoreleasedReturnValueMarker() const {
17406f32e7eSjoerg     return "";
17506f32e7eSjoerg   }
17606f32e7eSjoerg 
177*13fbcb42Sjoerg   /// Determine whether a call to objc_retainAutoreleasedReturnValue or
178*13fbcb42Sjoerg   /// objc_unsafeClaimAutoreleasedReturnValue should be marked as 'notail'.
markARCOptimizedReturnCallsAsNoTail()179*13fbcb42Sjoerg   virtual bool markARCOptimizedReturnCallsAsNoTail() const { return false; }
18006f32e7eSjoerg 
18106f32e7eSjoerg   /// Return a constant used by UBSan as a signature to identify functions
18206f32e7eSjoerg   /// possessing type information, or 0 if the platform is unsupported.
18306f32e7eSjoerg   virtual llvm::Constant *
getUBSanFunctionSignature(CodeGen::CodeGenModule & CGM)18406f32e7eSjoerg   getUBSanFunctionSignature(CodeGen::CodeGenModule &CGM) const {
18506f32e7eSjoerg     return nullptr;
18606f32e7eSjoerg   }
18706f32e7eSjoerg 
18806f32e7eSjoerg   /// Determine whether a call to an unprototyped functions under
18906f32e7eSjoerg   /// the given calling convention should use the variadic
19006f32e7eSjoerg   /// convention or the non-variadic convention.
19106f32e7eSjoerg   ///
19206f32e7eSjoerg   /// There's a good reason to make a platform's variadic calling
19306f32e7eSjoerg   /// convention be different from its non-variadic calling
19406f32e7eSjoerg   /// convention: the non-variadic arguments can be passed in
19506f32e7eSjoerg   /// registers (better for performance), and the variadic arguments
19606f32e7eSjoerg   /// can be passed on the stack (also better for performance).  If
19706f32e7eSjoerg   /// this is done, however, unprototyped functions *must* use the
19806f32e7eSjoerg   /// non-variadic convention, because C99 states that a call
19906f32e7eSjoerg   /// through an unprototyped function type must succeed if the
20006f32e7eSjoerg   /// function was defined with a non-variadic prototype with
20106f32e7eSjoerg   /// compatible parameters.  Therefore, splitting the conventions
20206f32e7eSjoerg   /// makes it impossible to call a variadic function through an
20306f32e7eSjoerg   /// unprototyped type.  Since function prototypes came out in the
20406f32e7eSjoerg   /// late 1970s, this is probably an acceptable trade-off.
20506f32e7eSjoerg   /// Nonetheless, not all platforms are willing to make it, and in
20606f32e7eSjoerg   /// particularly x86-64 bends over backwards to make the
20706f32e7eSjoerg   /// conventions compatible.
20806f32e7eSjoerg   ///
20906f32e7eSjoerg   /// The default is false.  This is correct whenever:
21006f32e7eSjoerg   ///   - the conventions are exactly the same, because it does not
21106f32e7eSjoerg   ///     matter and the resulting IR will be somewhat prettier in
21206f32e7eSjoerg   ///     certain cases; or
21306f32e7eSjoerg   ///   - the conventions are substantively different in how they pass
21406f32e7eSjoerg   ///     arguments, because in this case using the variadic convention
21506f32e7eSjoerg   ///     will lead to C99 violations.
21606f32e7eSjoerg   ///
21706f32e7eSjoerg   /// However, some platforms make the conventions identical except
21806f32e7eSjoerg   /// for passing additional out-of-band information to a variadic
21906f32e7eSjoerg   /// function: for example, x86-64 passes the number of SSE
22006f32e7eSjoerg   /// arguments in %al.  On these platforms, it is desirable to
22106f32e7eSjoerg   /// call unprototyped functions using the variadic convention so
22206f32e7eSjoerg   /// that unprototyped calls to varargs functions still succeed.
22306f32e7eSjoerg   ///
22406f32e7eSjoerg   /// Relatedly, platforms which pass the fixed arguments to this:
22506f32e7eSjoerg   ///   A foo(B, C, D);
22606f32e7eSjoerg   /// differently than they would pass them to this:
22706f32e7eSjoerg   ///   A foo(B, C, D, ...);
22806f32e7eSjoerg   /// may need to adjust the debugger-support code in Sema to do the
22906f32e7eSjoerg   /// right thing when calling a function with no know signature.
23006f32e7eSjoerg   virtual bool isNoProtoCallVariadic(const CodeGen::CallArgList &args,
23106f32e7eSjoerg                                      const FunctionNoProtoType *fnType) const;
23206f32e7eSjoerg 
23306f32e7eSjoerg   /// Gets the linker options necessary to link a dependent library on this
23406f32e7eSjoerg   /// platform.
23506f32e7eSjoerg   virtual void getDependentLibraryOption(llvm::StringRef Lib,
23606f32e7eSjoerg                                          llvm::SmallString<24> &Opt) const;
23706f32e7eSjoerg 
23806f32e7eSjoerg   /// Gets the linker options necessary to detect object file mismatches on
23906f32e7eSjoerg   /// this platform.
getDetectMismatchOption(llvm::StringRef Name,llvm::StringRef Value,llvm::SmallString<32> & Opt)24006f32e7eSjoerg   virtual void getDetectMismatchOption(llvm::StringRef Name,
24106f32e7eSjoerg                                        llvm::StringRef Value,
24206f32e7eSjoerg                                        llvm::SmallString<32> &Opt) const {}
24306f32e7eSjoerg 
24406f32e7eSjoerg   /// Get LLVM calling convention for OpenCL kernel.
24506f32e7eSjoerg   virtual unsigned getOpenCLKernelCallingConv() const;
24606f32e7eSjoerg 
24706f32e7eSjoerg   /// Get target specific null pointer.
24806f32e7eSjoerg   /// \param T is the LLVM type of the null pointer.
24906f32e7eSjoerg   /// \param QT is the clang QualType of the null pointer.
25006f32e7eSjoerg   /// \return ConstantPointerNull with the given type \p T.
25106f32e7eSjoerg   /// Each target can override it to return its own desired constant value.
25206f32e7eSjoerg   virtual llvm::Constant *getNullPointer(const CodeGen::CodeGenModule &CGM,
25306f32e7eSjoerg       llvm::PointerType *T, QualType QT) const;
25406f32e7eSjoerg 
25506f32e7eSjoerg   /// Get target favored AST address space of a global variable for languages
25606f32e7eSjoerg   /// other than OpenCL and CUDA.
25706f32e7eSjoerg   /// If \p D is nullptr, returns the default target favored address space
25806f32e7eSjoerg   /// for global variable.
25906f32e7eSjoerg   virtual LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
26006f32e7eSjoerg                                           const VarDecl *D) const;
26106f32e7eSjoerg 
26206f32e7eSjoerg   /// Get the AST address space for alloca.
getASTAllocaAddressSpace()26306f32e7eSjoerg   virtual LangAS getASTAllocaAddressSpace() const { return LangAS::Default; }
26406f32e7eSjoerg 
26506f32e7eSjoerg   /// Perform address space cast of an expression of pointer type.
26606f32e7eSjoerg   /// \param V is the LLVM value to be casted to another address space.
26706f32e7eSjoerg   /// \param SrcAddr is the language address space of \p V.
26806f32e7eSjoerg   /// \param DestAddr is the targeted language address space.
26906f32e7eSjoerg   /// \param DestTy is the destination LLVM pointer type.
27006f32e7eSjoerg   /// \param IsNonNull is the flag indicating \p V is known to be non null.
27106f32e7eSjoerg   virtual llvm::Value *performAddrSpaceCast(CodeGen::CodeGenFunction &CGF,
27206f32e7eSjoerg                                             llvm::Value *V, LangAS SrcAddr,
27306f32e7eSjoerg                                             LangAS DestAddr, llvm::Type *DestTy,
27406f32e7eSjoerg                                             bool IsNonNull = false) const;
27506f32e7eSjoerg 
27606f32e7eSjoerg   /// Perform address space cast of a constant expression of pointer type.
27706f32e7eSjoerg   /// \param V is the LLVM constant to be casted to another address space.
27806f32e7eSjoerg   /// \param SrcAddr is the language address space of \p V.
27906f32e7eSjoerg   /// \param DestAddr is the targeted language address space.
28006f32e7eSjoerg   /// \param DestTy is the destination LLVM pointer type.
28106f32e7eSjoerg   virtual llvm::Constant *performAddrSpaceCast(CodeGenModule &CGM,
28206f32e7eSjoerg                                                llvm::Constant *V,
28306f32e7eSjoerg                                                LangAS SrcAddr, LangAS DestAddr,
28406f32e7eSjoerg                                                llvm::Type *DestTy) const;
28506f32e7eSjoerg 
28606f32e7eSjoerg   /// Get address space of pointer parameter for __cxa_atexit.
getAddrSpaceOfCxaAtexitPtrParam()28706f32e7eSjoerg   virtual LangAS getAddrSpaceOfCxaAtexitPtrParam() const {
28806f32e7eSjoerg     return LangAS::Default;
28906f32e7eSjoerg   }
29006f32e7eSjoerg 
29106f32e7eSjoerg   /// Get the syncscope used in LLVM IR.
29206f32e7eSjoerg   virtual llvm::SyncScope::ID getLLVMSyncScopeID(const LangOptions &LangOpts,
29306f32e7eSjoerg                                                  SyncScope Scope,
29406f32e7eSjoerg                                                  llvm::AtomicOrdering Ordering,
29506f32e7eSjoerg                                                  llvm::LLVMContext &Ctx) const;
29606f32e7eSjoerg 
29706f32e7eSjoerg   /// Interface class for filling custom fields of a block literal for OpenCL.
29806f32e7eSjoerg   class TargetOpenCLBlockHelper {
29906f32e7eSjoerg   public:
30006f32e7eSjoerg     typedef std::pair<llvm::Value *, StringRef> ValueTy;
TargetOpenCLBlockHelper()30106f32e7eSjoerg     TargetOpenCLBlockHelper() {}
~TargetOpenCLBlockHelper()30206f32e7eSjoerg     virtual ~TargetOpenCLBlockHelper() {}
30306f32e7eSjoerg     /// Get the custom field types for OpenCL blocks.
30406f32e7eSjoerg     virtual llvm::SmallVector<llvm::Type *, 1> getCustomFieldTypes() = 0;
30506f32e7eSjoerg     /// Get the custom field values for OpenCL blocks.
30606f32e7eSjoerg     virtual llvm::SmallVector<ValueTy, 1>
30706f32e7eSjoerg     getCustomFieldValues(CodeGenFunction &CGF, const CGBlockInfo &Info) = 0;
30806f32e7eSjoerg     virtual bool areAllCustomFieldValuesConstant(const CGBlockInfo &Info) = 0;
30906f32e7eSjoerg     /// Get the custom field values for OpenCL blocks if all values are LLVM
31006f32e7eSjoerg     /// constants.
31106f32e7eSjoerg     virtual llvm::SmallVector<llvm::Constant *, 1>
31206f32e7eSjoerg     getCustomFieldValues(CodeGenModule &CGM, const CGBlockInfo &Info) = 0;
31306f32e7eSjoerg   };
getTargetOpenCLBlockHelper()31406f32e7eSjoerg   virtual TargetOpenCLBlockHelper *getTargetOpenCLBlockHelper() const {
31506f32e7eSjoerg     return nullptr;
31606f32e7eSjoerg   }
31706f32e7eSjoerg 
31806f32e7eSjoerg   /// Create an OpenCL kernel for an enqueued block. The kernel function is
31906f32e7eSjoerg   /// a wrapper for the block invoke function with target-specific calling
32006f32e7eSjoerg   /// convention and ABI as an OpenCL kernel. The wrapper function accepts
32106f32e7eSjoerg   /// block context and block arguments in target-specific way and calls
32206f32e7eSjoerg   /// the original block invoke function.
32306f32e7eSjoerg   virtual llvm::Function *
32406f32e7eSjoerg   createEnqueuedBlockKernel(CodeGenFunction &CGF,
32506f32e7eSjoerg                             llvm::Function *BlockInvokeFunc,
32606f32e7eSjoerg                             llvm::Value *BlockLiteral) const;
32706f32e7eSjoerg 
32806f32e7eSjoerg   /// \return true if the target supports alias from the unmangled name to the
32906f32e7eSjoerg   /// mangled name of functions declared within an extern "C" region and marked
33006f32e7eSjoerg   /// as 'used', and having internal linkage.
shouldEmitStaticExternCAliases()33106f32e7eSjoerg   virtual bool shouldEmitStaticExternCAliases() const { return true; }
33206f32e7eSjoerg 
setCUDAKernelCallingConvention(const FunctionType * & FT)33306f32e7eSjoerg   virtual void setCUDAKernelCallingConvention(const FunctionType *&FT) const {}
334*13fbcb42Sjoerg 
335*13fbcb42Sjoerg   /// Return the device-side type for the CUDA device builtin surface type.
getCUDADeviceBuiltinSurfaceDeviceType()336*13fbcb42Sjoerg   virtual llvm::Type *getCUDADeviceBuiltinSurfaceDeviceType() const {
337*13fbcb42Sjoerg     // By default, no change from the original one.
338*13fbcb42Sjoerg     return nullptr;
339*13fbcb42Sjoerg   }
340*13fbcb42Sjoerg   /// Return the device-side type for the CUDA device builtin texture type.
getCUDADeviceBuiltinTextureDeviceType()341*13fbcb42Sjoerg   virtual llvm::Type *getCUDADeviceBuiltinTextureDeviceType() const {
342*13fbcb42Sjoerg     // By default, no change from the original one.
343*13fbcb42Sjoerg     return nullptr;
344*13fbcb42Sjoerg   }
345*13fbcb42Sjoerg 
346*13fbcb42Sjoerg   /// Emit the device-side copy of the builtin surface type.
emitCUDADeviceBuiltinSurfaceDeviceCopy(CodeGenFunction & CGF,LValue Dst,LValue Src)347*13fbcb42Sjoerg   virtual bool emitCUDADeviceBuiltinSurfaceDeviceCopy(CodeGenFunction &CGF,
348*13fbcb42Sjoerg                                                       LValue Dst,
349*13fbcb42Sjoerg                                                       LValue Src) const {
350*13fbcb42Sjoerg     // DO NOTHING by default.
351*13fbcb42Sjoerg     return false;
352*13fbcb42Sjoerg   }
353*13fbcb42Sjoerg   /// Emit the device-side copy of the builtin texture type.
emitCUDADeviceBuiltinTextureDeviceCopy(CodeGenFunction & CGF,LValue Dst,LValue Src)354*13fbcb42Sjoerg   virtual bool emitCUDADeviceBuiltinTextureDeviceCopy(CodeGenFunction &CGF,
355*13fbcb42Sjoerg                                                       LValue Dst,
356*13fbcb42Sjoerg                                                       LValue Src) const {
357*13fbcb42Sjoerg     // DO NOTHING by default.
358*13fbcb42Sjoerg     return false;
359*13fbcb42Sjoerg   }
36006f32e7eSjoerg };
36106f32e7eSjoerg 
36206f32e7eSjoerg } // namespace CodeGen
36306f32e7eSjoerg } // namespace clang
36406f32e7eSjoerg 
36506f32e7eSjoerg #endif // LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
366