clang 8.0.0

Classes | Public Member Functions | List of all members
clang::CodeGen::TargetCodeGenInfo Class Reference

TargetCodeGenInfo - This class organizes various target-specific codegeneration issues, like target-specific attributes, builtins and so on. More...

`#include "/work/www-prereleases/8.0.0/rc2/builddocs/llvm.src/tools/clang/lib/CodeGen/TargetInfo.h"`

## Classes
class | TargetOpenCLBlockHelper
| Interface class for filling custom fields of a block literal for OpenCL. More...

## Public Member Functions
| TargetCodeGenInfo (ABIInfo *info=nullptr)
virtual | ~TargetCodeGenInfo ()
const ABIInfo & | getABIInfo () const
| getABIInfo() - Returns ABI info helper for the target. More...
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 given global. More...
virtual void | emitTargetMD (const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M) const
| emitTargetMD - Provides a convenient hook to handle extra target-specific metadata for the given global. More...
virtual unsigned | getSizeOfUnwindException () const
| Determines the size of struct _Unwind_Exception on this platform, in 8-bit units. More...
virtual bool | extendPointerWithSExt () const
| Controls whether __builtin_extend_pointer should sign-extend pointers to uint64_t or zero-extend them (the default). More...
virtual int | getDwarfEHStackPointer (CodeGen::CodeGenModule &M) const
| Determines the DWARF register number for the stack pointer, for exception-handling purposes. More...
virtual bool | initDwarfEHRegSizeTable (CodeGen::CodeGenFunction &CGF, llvm::Value *Address) const
| Initializes the given DWARF EH register-size table, a char*. More...
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 actual address of the next instruction that will be executed. More...
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 suitable for storage by the system in a return slot. More...
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. More...
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. More...
virtual bool | doesReturnSlotInterfereWithArgs () const
| doesReturnSlotInterfereWithArgs - Return true if the target uses an argument slot for an 'sret' type. More...
virtual StringRef | getARCRetainAutoreleasedReturnValueMarker () const
| Retrieve the address of a function to call immediately before calling objc_retainAutoreleasedReturnValue. More...
virtual llvm::Constant * | getUBSanFunctionSignature (CodeGen::CodeGenModule &CGM) const
| Return a constant used by UBSan as a signature to identify functions possessing type information, or 0 if the platform is unsupported. More...
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 the variadic convention or the non-variadic convention. More...
virtual void | getDependentLibraryOption (llvm::StringRef Lib, llvm::SmallString< 24 > &Opt) const
| Gets the linker options necessary to link a dependent library on this platform. More...
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. More...
virtual unsigned | getOpenCLKernelCallingConv () const
| Get LLVM calling convention for OpenCL kernel. More...
virtual llvm::Constant * | getNullPointer (const CodeGen::CodeGenModule &CGM, llvm::PointerType *T, QualType QT) const
| Get target specific null pointer. More...
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. More...
virtual LangAS | getASTAllocaAddressSpace () const
| Get the AST address space for alloca. More...
virtual llvm::Value * | performAddrSpaceCast (CodeGen::CodeGenFunction &CGF, llvm::Value *V, LangAS SrcAddr, LangAS DestAddr, llvm::Type *DestTy, bool IsNonNull=false) const
| Perform address space cast of an expression of pointer type. More...
virtual llvm::Constant * | performAddrSpaceCast (CodeGenModule &CGM, llvm::Constant *V, LangAS SrcAddr, LangAS DestAddr, llvm::Type *DestTy) const
| Perform address space cast of a constant expression of pointer type. More...
virtual llvm::SyncScope::ID | getLLVMSyncScopeID (SyncScope S, llvm::LLVMContext &C) const
| Get the syncscope used in LLVM IR. More...
virtual TargetOpenCLBlockHelper * | getTargetOpenCLBlockHelper () const
virtual llvm::Function * | createEnqueuedBlockKernel (CodeGenFunction &CGF, llvm::Function *BlockInvokeFunc, llvm::Value *BlockLiteral) const
| Create an OpenCL kernel for an enqueued block. More...
virtual bool | shouldEmitStaticExternCAliases () const
virtual void | setCUDAKernelCallingConvention (const FunctionType *&FT) const

## Detailed Description

TargetCodeGenInfo - This class organizes various target-specific codegeneration issues, like target-specific attributes, builtins and so on.

Definition at line 46 of file TargetInfo.h.

## Constructor & Destructor Documentation

## ◆ TargetCodeGenInfo()

clang::CodeGen::TargetCodeGenInfo::TargetCodeGenInfo | ( | ABIInfo * | info = `nullptr` | ) |
| inline

Definition at line 51 of file TargetInfo.h.

## ◆ ~TargetCodeGenInfo()

TargetCodeGenInfo::~TargetCodeGenInfo | ( |  | ) |
| virtual

Definition at line 387 of file TargetInfo.cpp.

## Member Function Documentation

## ◆ addReturnRegisterOutputs()

virtual void clang::CodeGen::TargetCodeGenInfo::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
| inline virtual

Adds constraints and types for result registers.

Definition at line 135 of file TargetInfo.h.

## ◆ adjustInlineAsmType()

virtual llvm::Type* clang::CodeGen::TargetCodeGenInfo::adjustInlineAsmType | ( | CodeGen::CodeGenFunction & | CGF,
|  | StringRef | Constraint,
|  | llvm::Type * | Ty
| ) |  | const
| inline virtual

Corrects the low-level LLVM type for a given constraint and "usual" type.

Returns
  A pointer to a new LLVM type, possibly the same as the original on success; 0 on failure.

Definition at line 128 of file TargetInfo.h.

## ◆ createEnqueuedBlockKernel()

llvm::Function * TargetCodeGenInfo::createEnqueuedBlockKernel | ( | CodeGenFunction & | CGF,
|  | llvm::Function * | Invoke,
|  | llvm::Value * | BlockLiteral
| ) |  | const
| virtual

Create an OpenCL kernel for an enqueued block.

The kernel function is a wrapper for the block invoke function with target-specific calling convention and ABI as an OpenCL kernel. The wrapper function accepts block context and block arguments in target-specific way and calls the original block invoke function.

The kernel has the same function type as the block invoke function. Its name is the name of the block invoke function postfixed with "_kernel". It simply calls the block invoke function then returns.

Definition at line 9427 of file TargetInfo.cpp.

References clang::CodeGen::CodeGenFunction::getLLVMContext(), and P.

Referenced by clang::CodeGen::CGOpenCLRuntime::emitOpenCLEnqueuedBlock().

## ◆ decodeReturnAddress()

virtual llvm::Value* clang::CodeGen::TargetCodeGenInfo::decodeReturnAddress | ( | CodeGen::CodeGenFunction & | CGF,
|  | llvm::Value * | Address
| ) |  | const
| inline virtual

Performs the code-generation required to convert a return address as stored by the system into the actual address of the next instruction that will be executed.

Used by __builtin_extract_return_addr().

Definition at line 108 of file TargetInfo.h.

## ◆ doesReturnSlotInterfereWithArgs()

virtual bool clang::CodeGen::TargetCodeGenInfo::doesReturnSlotInterfereWithArgs | ( |  | ) | const
| inline virtual

doesReturnSlotInterfereWithArgs - Return true if the target uses an argument slot for an 'sret' type.

Definition at line 144 of file TargetInfo.h.

## ◆ emitTargetMD()

virtual void clang::CodeGen::TargetCodeGenInfo::emitTargetMD | ( | const Decl * | D,
|  | llvm::GlobalValue * | GV,
|  | CodeGen::CodeGenModule & | M
| ) |  | const
| inline virtual

emitTargetMD - Provides a convenient hook to handle extra target-specific metadata for the given global.

Definition at line 64 of file TargetInfo.h.

Referenced by clang::CodeGen::CodeGenModule::lookupRepresentativeDecl().

## ◆ encodeReturnAddress()

virtual llvm::Value* clang::CodeGen::TargetCodeGenInfo::encodeReturnAddress | ( | CodeGen::CodeGenFunction & | CGF,
|  | llvm::Value * | Address
| ) |  | const
| inline virtual

Performs the code-generation required to convert the address of an instruction into a return address suitable for storage by the system in a return slot.

Used by __builtin_frob_return_addr().

Definition at line 118 of file TargetInfo.h.

## ◆ extendPointerWithSExt()

virtual bool clang::CodeGen::TargetCodeGenInfo::extendPointerWithSExt | ( |  | ) | const
| inline virtual

Controls whether __builtin_extend_pointer should sign-extend pointers to uint64_t or zero-extend them (the default).

Has no effect for targets:

- that have 64-bit pointers, or
- that cannot address through registers larger than pointers, or
- that implicitly ignore/truncate the top bits when addressing through such registers.

Definition at line 84 of file TargetInfo.h.

## ◆ getABIInfo()

const ABIInfo& clang::CodeGen::TargetCodeGenInfo::getABIInfo | ( |  | ) | const
| inline

getABIInfo() - Returns ABI info helper for the target.

Definition at line 55 of file TargetInfo.h.

Referenced by getSwiftABIInfo().

## ◆ getARCRetainAutoreleasedReturnValueMarker()

virtual StringRef clang::CodeGen::TargetCodeGenInfo::getARCRetainAutoreleasedReturnValueMarker | ( |  | ) | const
| inline virtual

Retrieve the address of a function to call immediately before calling objc_retainAutoreleasedReturnValue.

The implementation of objc_autoreleaseReturnValue sniffs the instruction stream following its return address to decide whether it's a call to objc_retainAutoreleasedReturnValue. This can be prohibitively expensive, depending on the relocation model, and so on some targets it instead sniffs for a particular instruction sequence. This functions returns that instruction sequence in inline assembly, which will be empty if none is required.

Definition at line 156 of file TargetInfo.h.

Referenced by emitAutoreleasedReturnValueMarker().

## ◆ getASTAllocaAddressSpace()

virtual LangAS clang::CodeGen::TargetCodeGenInfo::getASTAllocaAddressSpace | ( |  | ) | const
| inline virtual

Get the AST address space for alloca.

Definition at line 242 of file TargetInfo.h.

## ◆ getDependentLibraryOption()

void TargetCodeGenInfo::getDependentLibraryOption | ( | llvm::StringRef | Lib,
|  | llvm::SmallString< 24 > & | Opt
| ) |  | const
| virtual

Gets the linker options necessary to link a dependent library on this platform.

Definition at line 411 of file TargetInfo.cpp.

Referenced by clang::CodeGen::CodeGenModule::AddDependentLib(), and addLinkOptionsPostorder().

## ◆ getDetectMismatchOption()

virtual void clang::CodeGen::TargetCodeGenInfo::getDetectMismatchOption | ( | llvm::StringRef | Name,
|  | llvm::StringRef | Value,
|  | llvm::SmallString< 32 > & | Opt
| ) |  | const
| inline virtual

Gets the linker options necessary to detect object file mismatches on this platform.

Definition at line 219 of file TargetInfo.h.

## ◆ getDwarfEHStackPointer()

virtual int clang::CodeGen::TargetCodeGenInfo::getDwarfEHStackPointer | ( | CodeGen::CodeGenModule & | M | ) | const
| inline virtual

Determines the DWARF register number for the stack pointer, for exception-handling purposes.

Implements __builtin_dwarf_sp_column.

Returns -1 if the operation is unsupported by this target.

Definition at line 90 of file TargetInfo.h.

## ◆ getGlobalVarAddressSpace()

LangAS TargetCodeGenInfo::getGlobalVarAddressSpace | ( | CodeGenModule & | CGM,
|  | const VarDecl * | D
| ) |  | const
| virtual

Get target favored AST address space of a global variable for languages other than OpenCL and CUDA.

If `D` is nullptr, returns the default target favored address space for global variable.

Definition at line 439 of file TargetInfo.cpp.

References clang::Default, clang::QualType::getAddressSpace(), clang::CodeGen::CodeGenModule::getLangOpts(), and clang::ValueDecl::getType().

Referenced by clang::CodeGen::CodeGenModule::GetGlobalVarAddressSpace().

## ◆ getLLVMSyncScopeID()

llvm::SyncScope::ID TargetCodeGenInfo::getLLVMSyncScopeID | ( | SyncScope | S,
|  | llvm::LLVMContext & | C
| ) |  | const
| virtual

Get the syncscope used in LLVM IR.

Definition at line 467 of file TargetInfo.cpp.

Referenced by EmitAtomicOp().

## ◆ getNullPointer()

llvm::Constant * TargetCodeGenInfo::getNullPointer | ( | const CodeGen::CodeGenModule & | CGM,
|  | llvm::PointerType * | T,
|  | QualType | QT
| ) |  | const
| virtual

Get target specific null pointer.

Parameters

  T | is the LLVM type of the null pointer.
  QT | is the clang QualType of the null pointer.

Returns
  ConstantPointerNull with the given type `T`. Each target can override it to return its own desired constant value.

Definition at line 434 of file TargetInfo.cpp.

## ◆ getOpenCLKernelCallingConv()

unsigned TargetCodeGenInfo::getOpenCLKernelCallingConv | ( |  | ) | const
| virtual

Get LLVM calling convention for OpenCL kernel.

Definition at line 420 of file TargetInfo.cpp.

Referenced by clang::CodeGen::CodeGenTypes::ClangCallConvToLLVMCallConv().

## ◆ getSizeOfUnwindException()

unsigned TargetCodeGenInfo::getSizeOfUnwindException | ( |  | ) | const
| virtual

Determines the size of struct _Unwind_Exception on this platform, in 8-bit units.

The Itanium ABI defines this as: struct _Unwind_Exception { uint64 exception_class; _Unwind_Exception_Cleanup_Fn exception_cleanup; uint64 private_1; uint64 private_2; };

Definition at line 391 of file TargetInfo.cpp.

Referenced by InitCatchParam().

## ◆ getTargetOpenCLBlockHelper()

virtual TargetOpenCLBlockHelper* clang::CodeGen::TargetCodeGenInfo::getTargetOpenCLBlockHelper | ( |  | ) | const
| inline virtual

Definition at line 286 of file TargetInfo.h.

Referenced by buildGlobalBlock(), computeBlockInfo(), and initializeForBlockHeader().

## ◆ getUBSanFunctionSignature()

virtual llvm::Constant* clang::CodeGen::TargetCodeGenInfo::getUBSanFunctionSignature | ( | CodeGen::CodeGenModule & | CGM | ) | const
| inline virtual

Return a constant used by UBSan as a signature to identify functions possessing type information, or 0 if the platform is unsupported.

Definition at line 163 of file TargetInfo.h.

Referenced by clang::CodeGen::CodeGenFunction::EmitCall(), and getPrologueSignature().

## ◆ initDwarfEHRegSizeTable()

virtual bool clang::CodeGen::TargetCodeGenInfo::initDwarfEHRegSizeTable | ( | CodeGen::CodeGenFunction & | CGF,
|  | llvm::Value * | Address
| ) |  | const
| inline virtual

Initializes the given DWARF EH register-size table, a char*.

Implements __builtin_init_dwarf_reg_size_table.

Returns true if the operation is unsupported by this target.

Definition at line 98 of file TargetInfo.h.

## ◆ isNoProtoCallVariadic()

bool TargetCodeGenInfo::isNoProtoCallVariadic | ( | const CodeGen::CallArgList & | args,
|  | const FunctionNoProtoType * | fnType
| ) |  | const
| virtual

Determine whether a call to an unprototyped functions under the given calling convention should use the variadic convention or the non-variadic convention.

There's a good reason to make a platform's variadic calling convention be different from its non-variadic calling convention: the non-variadic arguments can be passed in registers (better for performance), and the variadic arguments can be passed on the stack (also better for performance). If this is done, however, unprototyped functions must use the non-variadic convention, because C99 states that a call through an unprototyped function type must succeed if the function was defined with a non-variadic prototype with compatible parameters. Therefore, splitting the conventions makes it impossible to call a variadic function through an unprototyped type. Since function prototypes came out in the late 1970s, this is probably an acceptable trade-off. Nonetheless, not all platforms are willing to make it, and in particularly x86-64 bends over backwards to make the conventions compatible.

The default is false. This is correct whenever:

- the conventions are exactly the same, because it does not matter and the resulting IR will be somewhat prettier in certain cases; or
- the conventions are substantively different in how they pass arguments, because in this case using the variadic convention will lead to C99 violations.

However, some platforms make the conventions identical except for passing additional out-of-band information to a variadic function: for example, x86-64 passes the number of SSE arguments in al. On these platforms, it is desirable to call unprototyped functions using the variadic convention so that unprototyped calls to varargs functions still succeed.

Relatedly, platforms which pass the fixed arguments to this: A foo(B, C, D); differently than they would pass them to this: A foo(B, C, D, ...); may need to adjust the debugger-support code in Sema to do the right thing when calling a function with no know signature.

Definition at line 401 of file TargetInfo.cpp.

Referenced by arrangeFreeFunctionLikeCall().

## ◆ performAddrSpaceCast() [1/2]

llvm::Value * TargetCodeGenInfo::performAddrSpaceCast | ( | CodeGen::CodeGenFunction & | CGF,
|  | llvm::Value * | V,
|  | LangAS | SrcAddr,
|  | LangAS | DestAddr,
|  | llvm::Type * | DestTy,
|  | bool | IsNonNull = `false`
| ) |  | const
| virtual

Perform address space cast of an expression of pointer type.

Parameters

  V | is the LLVM value to be casted to another address space.
  SrcAddr | is the language address space of `V`.
  DestAddr | is the targeted language address space.
  DestTy | is the destination LLVM pointer type.
  IsNonNull | is the flag indicating `V` is known to be non null.

Definition at line 447 of file TargetInfo.cpp.

References clang::CodeGen::CodeGenFunction::Builder, clang::CodeGen::CodeGenFunction::CGM, and clang::CodeGen::CGBuilderTy::CreatePointerBitCastOrAddrSpaceCast().

Referenced by castStringLiteralToDefaultAddressSpace(), clang::CodeGen::CodeGenFunction::EmitCastLValue(), clang::CodeGen::CodeGenModule::isTypeConstant(), and clang::CodeGen::CodeGenFunction::ShouldNullCheckClassCastValue().

## ◆ performAddrSpaceCast() [2/2]

llvm::Constant * TargetCodeGenInfo::performAddrSpaceCast | ( | CodeGenModule & | CGM,
|  | llvm::Constant * | V,
|  | LangAS | SrcAddr,
|  | LangAS | DestAddr,
|  | llvm::Type * | DestTy
| ) |  | const
| virtual

Perform address space cast of a constant expression of pointer type.

Parameters

  V | is the LLVM constant to be casted to another address space.
  SrcAddr | is the language address space of `V`.
  DestAddr | is the targeted language address space.
  DestTy | is the destination LLVM pointer type.

Definition at line 458 of file TargetInfo.cpp.

## ◆ setCUDAKernelCallingConvention()

virtual void clang::CodeGen::TargetCodeGenInfo::setCUDAKernelCallingConvention | ( | const FunctionType *& | FT | ) | const
| inline virtual

Definition at line 305 of file TargetInfo.h.

Referenced by setCUDAKernelCallingConvention().

## ◆ setTargetAttributes()

virtual void clang::CodeGen::TargetCodeGenInfo::setTargetAttributes | ( | const Decl * | D,
|  | llvm::GlobalValue * | GV,
|  | CodeGen::CodeGenModule & | M
| ) |  | const
| inline virtual

setTargetAttributes - Provides a convenient hook to handle extra target-specific attributes for the given global.

Definition at line 59 of file TargetInfo.h.

Referenced by clang::CodeGen::CodeGenModule::CreateFunctionTypeMetadataForIcall(), and clang::CodeGen::CodeGenModule::SetCommonAttributes().

## ◆ shouldEmitStaticExternCAliases()

virtual bool clang::CodeGen::TargetCodeGenInfo::shouldEmitStaticExternCAliases | ( |  | ) | const
| inline virtual

Returns
  true if the target supports alias from the unmangled name to the mangled name of functions declared within an extern "C" region and marked as 'used', and having internal linkage.

Definition at line 303 of file TargetInfo.h.

The documentation for this class was generated from the following files:

- lib/CodeGen/TargetInfo.h
- lib/CodeGen/TargetInfo.cpp