clang 24.0.0git
clang::CIRGen::TargetCIRGenInfo Class Reference

#include "/work/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/CIR/CodeGen/TargetInfo.h"

Public Member Functions

 TargetCIRGenInfo (std::unique_ptr< ABIInfo > info)
virtual ~TargetCIRGenInfo ()=default
const ABIInfo & getABIInfo () const
 Returns ABI info helper for the target.
virtual bool supportsLibCall () const
 Returns true if the target supports math library calls.
virtual clang::LangAS getGlobalVarAddressSpace (CIRGenModule &cgm, const clang::VarDecl *d) const
 Get target favored AST address space of a global variable for languages other than OpenCL and CUDA.
virtual mlir::ptr::MemorySpaceAttrInterface getCIRAllocaAddressSpace () const
 Get the address space for alloca.
virtual mlir::ptr::MemorySpaceAttrInterface getGlobalCIRAddressSpace (clang::LangAS as) const
 Get the CIR address space attribute for a global in AST address space as.
virtual mlir::Value getNullPointer (CIRGenModule &cgm, cir::PointerType ptrTy, QualType qt, mlir::Location loc) const
 Get the CIR value of a null pointer of type ptrTy, where qt is the source pointer type.
virtual mlir::Type getCUDADeviceBuiltinSurfaceDeviceType () const
virtual mlir::Type getCUDADeviceBuiltinTextureDeviceType () const
virtual bool isNoProtoCallVariadic (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.
virtual bool wouldInliningViolateFunctionCallABI (const FunctionDecl *Caller, const FunctionDecl *Callee) const
 Returns true if inlining the function call would produce incorrect code for the current target and should be ignored (even with the always_inline or flatten attributes).
virtual void setTargetAttributes (const clang::Decl *decl, mlir::Operation *global, CIRGenModule &module) const
 Provides a convenient hook to handle extra target-specific attributes for the given global.
virtual bool isScalarizableAsmOperand (CIRGenFunction &cgf, mlir::Type ty) const
virtual cir::CallingConv getDeviceKernelCallingConv () const
 Returns the calling convention used for device kernels on this target.
virtual void setCUDAKernelCallingConvention (const clang::FunctionType *&ft) const
virtual mlir::Type adjustInlineAsmType (CIRGenFunction &cgf, llvm::StringRef constraint, mlir::Type ty) const
 Corrects the MLIR type for a given constraint and "usual" type.

Detailed Description

Definition at line 46 of file TargetInfo.h.

Constructor & Destructor Documentation

◆ TargetCIRGenInfo()

clang::CIRGen::TargetCIRGenInfo::TargetCIRGenInfo ( std::unique_ptr< ABIInfo > info)
inline

Definition at line 50 of file TargetInfo.h.

Referenced by isNoProtoCallVariadic().

◆ ~TargetCIRGenInfo()

virtual clang::CIRGen::TargetCIRGenInfo::~TargetCIRGenInfo ( )
virtualdefault

Member Function Documentation

◆ adjustInlineAsmType()

virtual mlir::Type clang::CIRGen::TargetCIRGenInfo::adjustInlineAsmType ( CIRGenFunction & cgf,
llvm::StringRef constraint,
mlir::Type ty ) const
inlinevirtual

Corrects the MLIR type for a given constraint and "usual" type.

Returns
A new MLIR type, possibly the same as the original on success

Definition at line 180 of file TargetInfo.h.

◆ getABIInfo()

const ABIInfo & clang::CIRGen::TargetCIRGenInfo::getABIInfo ( ) const
inline

Returns ABI info helper for the target.

Definition at line 55 of file TargetInfo.h.

Referenced by getDeviceKernelCallingConv().

◆ getCIRAllocaAddressSpace()

virtual mlir::ptr::MemorySpaceAttrInterface clang::CIRGen::TargetCIRGenInfo::getCIRAllocaAddressSpace ( ) const
inlinevirtual

Get the address space for alloca.

Definition at line 68 of file TargetInfo.h.

Referenced by clang::CIRGen::CIRGenModule::CIRGenModule().

◆ getCUDADeviceBuiltinSurfaceDeviceType()

virtual mlir::Type clang::CIRGen::TargetCIRGenInfo::getCUDADeviceBuiltinSurfaceDeviceType ( ) const
inlinevirtual

Definition at line 85 of file TargetInfo.h.

◆ getCUDADeviceBuiltinTextureDeviceType()

virtual mlir::Type clang::CIRGen::TargetCIRGenInfo::getCUDADeviceBuiltinTextureDeviceType ( ) const
inlinevirtual

Definition at line 89 of file TargetInfo.h.

◆ getDeviceKernelCallingConv()

cir::CallingConv TargetCIRGenInfo::getDeviceKernelCallingConv ( ) const
virtual

Returns the calling convention used for device kernels on this target.

Definition at line 188 of file TargetInfo.cpp.

References getABIInfo().

◆ getGlobalCIRAddressSpace()

virtual mlir::ptr::MemorySpaceAttrInterface clang::CIRGen::TargetCIRGenInfo::getGlobalCIRAddressSpace ( clang::LangAS as) const
inlinevirtual

Get the CIR address space attribute for a global in AST address space as.

Definition at line 76 of file TargetInfo.h.

References cir::toCIRAddressSpaceAttr().

Referenced by clang::CIRGen::CIRGenModule::getGlobalCIRAddressSpace().

◆ getGlobalVarAddressSpace()

clang::LangAS TargetCIRGenInfo::getGlobalVarAddressSpace ( CIRGenModule & cgm,
const clang::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 204 of file TargetInfo.cpp.

References clang::Default, clang::QualType::getAddressSpace(), clang::CIRGen::CIRGenModule::getLangOpts(), and clang::ValueDecl::getType().

◆ getNullPointer()

mlir::Value TargetCIRGenInfo::getNullPointer ( CIRGenModule & cgm,
cir::PointerType ptrTy,
QualType qt,
mlir::Location loc ) const
virtual

Get the CIR value of a null pointer of type ptrTy, where qt is the source pointer type.

Definition at line 196 of file TargetInfo.cpp.

References clang::CIRGen::CIRGenModule::getBuilder(), and cir::CIRBaseBuilderTy::getNullPtr().

◆ isNoProtoCallVariadic()

bool TargetCIRGenInfo::isNoProtoCallVariadic ( 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 179 of file TargetInfo.cpp.

References isNoProtoCallVariadic(), and TargetCIRGenInfo().

Referenced by arrangeFreeFunctionLikeCall(), and isNoProtoCallVariadic().

◆ isScalarizableAsmOperand()

virtual bool clang::CIRGen::TargetCIRGenInfo::isScalarizableAsmOperand ( CIRGenFunction & cgf,
mlir::Type ty ) const
inlinevirtual

Definition at line 164 of file TargetInfo.h.

Referenced by emitAsmStores().

◆ setCUDAKernelCallingConvention()

virtual void clang::CIRGen::TargetCIRGenInfo::setCUDAKernelCallingConvention ( const clang::FunctionType *& ft) const
inlinevirtual

Definition at line 173 of file TargetInfo.h.

Referenced by setCUDAKernelCallingConvention().

◆ setTargetAttributes()

virtual void clang::CIRGen::TargetCIRGenInfo::setTargetAttributes ( const clang::Decl * decl,
mlir::Operation * global,
CIRGenModule & module ) const
inlinevirtual

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

In OG, the function receives an llvm::GlobalValue. However, functions and global variables are separate types in Clang IR, so we use a general mlir::Operation*.

Definition at line 160 of file TargetInfo.h.

References clang::ast_matchers::decl.

Referenced by clang::CIRGen::CIRGenModule::setFunctionAttributes().

◆ supportsLibCall()

virtual bool clang::CIRGen::TargetCIRGenInfo::supportsLibCall ( ) const
inlinevirtual

Returns true if the target supports math library calls.

Definition at line 58 of file TargetInfo.h.

Referenced by shouldEmitBuiltinAsIR().

◆ wouldInliningViolateFunctionCallABI()

virtual bool clang::CIRGen::TargetCIRGenInfo::wouldInliningViolateFunctionCallABI ( const FunctionDecl * Caller,
const FunctionDecl * Callee ) const
inlinevirtual

Returns true if inlining the function call would produce incorrect code for the current target and should be ignored (even with the always_inline or flatten attributes).

Note: This probably should be handled in LLVM. However, the LLVM alwaysinline attribute currently means the inliner will ignore mismatched attributes (which sometimes can generate invalid code). So, this hook allows targets to avoid adding the LLVM alwaysinline attribute based on C/C++ attributes or other target-specific reasons.

See previous discussion here: https://discourse.llvm.org/t/rfc-avoid-inlining-alwaysinline-functions-when-they-cannot-be-inlined/79528

Definition at line 150 of file TargetInfo.h.


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