class TargetCodeGenInfo

Declaration

class TargetCodeGenInfo { /* full declaration omitted */ };

Description

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

Declared at: clang/lib/CodeGen/TargetInfo.h:45

Member Variables

private std::unique_ptr<ABIInfo> Info

Method Overview

Methods

TargetCodeGenInfo(std::unique_ptr<ABIInfo> Info)

Declared at: clang/lib/CodeGen/TargetInfo.h:49

Parameters

std::unique_ptr<ABIInfo> Info

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 int NumOutputs) const

Description

Adds constraints and types for result registers.

Declared at: clang/lib/CodeGen/TargetInfo.h:158

Parameters

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 int NumOutputs

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

Description

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

Declared at: clang/lib/CodeGen/TargetInfo.h:144

Parameters

CodeGen::CodeGenFunction& CGF
llvm::StringRef Constraint
llvm::Type* Ty

Returns

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

virtual void checkFunctionCallABI(
    clang::CodeGen::CodeGenModule& CGM,
    clang::SourceLocation CallLoc,
    const clang::FunctionDecl* Caller,
    const clang::FunctionDecl* Callee,
    const clang::CodeGen::CallArgList& Args) const

Description

Any further codegen related checks that need to be done on a function call in a target specific manner.

Declared at: clang/lib/CodeGen/TargetInfo.h:68

Parameters

clang::CodeGen::CodeGenModule& CGM
clang::SourceLocation CallLoc
const clang::FunctionDecl* Caller
const clang::FunctionDecl* Callee
const clang::CodeGen::CallArgList& Args

virtual llvm::Function* createEnqueuedBlockKernel(
    clang::CodeGen::CodeGenFunction& CGF,
    llvm::Function* BlockInvokeFunc,
    llvm::Type* BlockTy) const

Description

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.

Declared at: clang/lib/CodeGen/TargetInfo.h:330

Parameters

clang::CodeGen::CodeGenFunction& CGF
llvm::Function* BlockInvokeFunc
llvm::Type* BlockTy

virtual llvm::Value* decodeReturnAddress(
    CodeGen::CodeGenFunction& CGF,
    llvm::Value* Address) const

Description

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().

Declared at: clang/lib/CodeGen/TargetInfo.h:114

Parameters

CodeGen::CodeGenFunction& CGF
llvm::Value* Address

virtual bool doesReturnSlotInterfereWithArgs()
    const

Description

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

Declared at: clang/lib/CodeGen/TargetInfo.h:167

virtual bool
emitCUDADeviceBuiltinSurfaceDeviceCopy(
    clang::CodeGen::CodeGenFunction& CGF,
    clang::CodeGen::LValue Dst,
    clang::CodeGen::LValue Src) const

Description

Emit the device-side copy of the builtin surface type.

Declared at: clang/lib/CodeGen/TargetInfo.h:353

Parameters

clang::CodeGen::CodeGenFunction& CGF
clang::CodeGen::LValue Dst
clang::CodeGen::LValue Src

virtual bool
emitCUDADeviceBuiltinTextureDeviceCopy(
    clang::CodeGen::CodeGenFunction& CGF,
    clang::CodeGen::LValue Dst,
    clang::CodeGen::LValue Src) const

Description

Emit the device-side copy of the builtin texture type.

Declared at: clang/lib/CodeGen/TargetInfo.h:360

Parameters

clang::CodeGen::CodeGenFunction& CGF
clang::CodeGen::LValue Dst
clang::CodeGen::LValue Src

virtual void emitTargetMetadata(
    CodeGen::CodeGenModule& CGM,
    const llvm::MapVector<GlobalDecl, StringRef>&
        MangledDeclNames) const

Description

emitTargetMetadata - Provides a convenient hook to handle extra target-specific metadata for the given globals.

Declared at: clang/lib/CodeGen/TargetInfo.h:62

Parameters

CodeGen::CodeGenModule& CGM
const llvm::MapVector<GlobalDecl, StringRef>& MangledDeclNames

virtual llvm::Value* encodeReturnAddress(
    CodeGen::CodeGenFunction& CGF,
    llvm::Value* Address) const

Description

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().

Declared at: clang/lib/CodeGen/TargetInfo.h:124

Parameters

CodeGen::CodeGenFunction& CGF
llvm::Value* Address

virtual bool extendPointerWithSExt() const

Description

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.

Declared at: clang/lib/CodeGen/TargetInfo.h:90

const clang::CodeGen::ABIInfo& getABIInfo() const

Description

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

Declared at: clang/lib/CodeGen/TargetInfo.h:53

virtual llvm::StringRef
getARCRetainAutoreleasedReturnValueMarker() const

Description

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.

Declared at: clang/lib/CodeGen/TargetInfo.h:179

virtual clang::LangAS getASTAllocaAddressSpace()
    const

Description

Get the AST address space for alloca.

Declared at: clang/lib/CodeGen/TargetInfo.h:269

virtual clang::LangAS
getAddrSpaceOfCxaAtexitPtrParam() const

Description

Get address space of pointer parameter for __cxa_atexit.

Declared at: clang/lib/CodeGen/TargetInfo.h:293

virtual llvm::Type*
getCUDADeviceBuiltinSurfaceDeviceType() const

Description

Return the device-side type for the CUDA device builtin surface type.

Declared at: clang/lib/CodeGen/TargetInfo.h:342

virtual llvm::Type*
getCUDADeviceBuiltinTextureDeviceType() const

Description

Return the device-side type for the CUDA device builtin texture type.

Declared at: clang/lib/CodeGen/TargetInfo.h:347

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

Description

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

Declared at: clang/lib/CodeGen/TargetInfo.h:241

Parameters

llvm::StringRef Lib
llvm::SmallString<24>& Opt

virtual void getDetectMismatchOption(
    llvm::StringRef Name,
    llvm::StringRef Value,
    llvm::SmallString<32>& Opt) const

Description

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

Declared at: clang/lib/CodeGen/TargetInfo.h:246

Parameters

llvm::StringRef Name
llvm::StringRef Value
llvm::SmallString<32>& Opt

virtual int getDwarfEHStackPointer(
    CodeGen::CodeGenModule& M) const

Description

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.

Declared at: clang/lib/CodeGen/TargetInfo.h:96

Parameters

CodeGen::CodeGenModule& M

virtual clang::LangAS getGlobalVarAddressSpace(
    clang::CodeGen::CodeGenModule& CGM,
    const clang::VarDecl* D) const

Description

Get target favored AST address space of a global variable for languages other than OpenCL and CUDA. If \p D is nullptr, returns the default target favored address space for global variable.

Declared at: clang/lib/CodeGen/TargetInfo.h:265

Parameters

clang::CodeGen::CodeGenModule& CGM
const clang::VarDecl* D

virtual llvm::SyncScope::ID getLLVMSyncScopeID(
    const clang::LangOptions& LangOpts,
    clang::SyncScope Scope,
    llvm::AtomicOrdering Ordering,
    llvm::LLVMContext& Ctx) const

Description

Get the syncscope used in LLVM IR.

Declared at: clang/lib/CodeGen/TargetInfo.h:298

Parameters

const clang::LangOptions& LangOpts
clang::SyncScope Scope
llvm::AtomicOrdering Ordering
llvm::LLVMContext& Ctx

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

Description

Get target specific null pointer.

Declared at: clang/lib/CodeGen/TargetInfo.h:258

Parameters

const CodeGen::CodeGenModule& CGM
llvm::PointerType* T
is the LLVM type of the null pointer.
clang::QualType QT
is the clang QualType of the null pointer.

Returns

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

virtual unsigned int getOpenCLKernelCallingConv()
    const

Description

Get LLVM calling convention for OpenCL kernel.

Declared at: clang/lib/CodeGen/TargetInfo.h:251

virtual unsigned int getSizeOfUnwindException()
    const

Description

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; };

Declared at: clang/lib/CodeGen/TargetInfo.h:81

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

Declared at: clang/lib/CodeGen/TargetInfo.h:320

virtual llvm::Constant* getUBSanFunctionSignature(
    CodeGen::CodeGenModule& CGM) const

Description

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

Declared at: clang/lib/CodeGen/TargetInfo.h:190

Parameters

CodeGen::CodeGenModule& CGM

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

Description

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.

Declared at: clang/lib/CodeGen/TargetInfo.h:104

Parameters

CodeGen::CodeGenFunction& CGF
llvm::Value* Address

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

Description

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.

Declared at: clang/lib/CodeGen/TargetInfo.h:236

Parameters

const CodeGen::CallArgList& args
const clang::FunctionNoProtoType* fnType

virtual bool isScalarizableAsmOperand(
    CodeGen::CodeGenFunction& CGF,
    llvm::Type* Ty) const

Description

Target hook to decide whether an inline asm operand can be passed by value.

Declared at: clang/lib/CodeGen/TargetInfo.h:152

Parameters

CodeGen::CodeGenFunction& CGF
llvm::Type* Ty

virtual bool markARCOptimizedReturnCallsAsNoTail()
    const

Description

Determine whether a call to objc_retainAutoreleasedReturnValue or objc_unsafeClaimAutoreleasedReturnValue should be marked as 'notail'.

Declared at: clang/lib/CodeGen/TargetInfo.h:185

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

Description

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

Declared at: clang/lib/CodeGen/TargetInfo.h:287

Parameters

clang::CodeGen::CodeGenModule& CGM
llvm::Constant* V
is the LLVM constant to be casted to another address space.
clang::LangAS SrcAddr
is the language address space of \p V.
clang::LangAS DestAddr
is the targeted language address space.
llvm::Type* DestTy
is the destination LLVM pointer type.

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

Description

Perform address space cast of an expression of pointer type.

Declared at: clang/lib/CodeGen/TargetInfo.h:277

Parameters

CodeGen::CodeGenFunction& CGF
llvm::Value* V
is the LLVM value to be casted to another address space.
clang::LangAS SrcAddr
is the language address space of \p V.
clang::LangAS DestAddr
is the targeted language address space.
llvm::Type* DestTy
is the destination LLVM pointer type.
bool IsNonNull = false
is the flag indicating \p V is known to be non null.

virtual void setCUDAKernelCallingConvention(
    const clang::FunctionType*& FT) const

Declared at: clang/lib/CodeGen/TargetInfo.h:339

Parameters

const clang::FunctionType*& FT

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

Description

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

Declared at: clang/lib/CodeGen/TargetInfo.h:57

Parameters

const clang::Decl* D
llvm::GlobalValue* GV
CodeGen::CodeGenModule& M

virtual bool shouldEmitStaticExternCAliases()
    const

Declared at: clang/lib/CodeGen/TargetInfo.h:337

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.

virtual llvm::Value* testFPKind(
    llvm::Value* V,
    unsigned int BuiltinID,
    clang::CodeGen::CGBuilderTy& Builder,
    clang::CodeGen::CodeGenModule& CGM) const

Description

Performs a target specific test of a floating point value for things like IsNaN, Infinity, ... Nullptr is returned if no implementation exists.

Declared at: clang/lib/CodeGen/TargetInfo.h:133

Parameters

llvm::Value* V
unsigned int BuiltinID
clang::CodeGen::CGBuilderTy& Builder
clang::CodeGen::CodeGenModule& CGM

virtual ~TargetCodeGenInfo()

Declared at: clang/lib/CodeGen/TargetInfo.h:50