clang 22.0.0git
Public Types | Public Member Functions | Public Attributes | List of all members
clang::CIRGen::CIRGenTypes Class Reference

This class organizes the cross-module state that is used while lowering AST types to CIR types. More...

#include "/home/buildbot/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/CIR/CodeGen/CIRGenTypes.h"

Public Types

using TypeCacheTy = llvm::DenseMap< const clang::Type *, mlir::Type >
 This map of clang::Type to mlir::Type (which includes CIR type) is a cache of types that have already been processed.
 

Public Member Functions

 CIRGenTypes (CIRGenModule &cgm)
 
 ~CIRGenTypes ()
 
CIRGenBuilderTygetBuilder () const
 
CIRGenModulegetCGModule () const
 
bool isFuncTypeConvertible (const clang::FunctionType *ft)
 Utility to check whether a function type can be converted to a CIR type (i.e.
 
bool isFuncParamTypeConvertible (clang::QualType type)
 Return true if the specified type in a function parameter or result position can be converted to a CIR type at this point.
 
clang::CanQualType deriveThisType (const clang::CXXRecordDecl *rd, const clang::CXXMethodDecl *md)
 Derives the 'this' type for CIRGen purposes, i.e.
 
mlir::MLIRContext & getMLIRContext () const
 
clang::ASTContextgetASTContext () const
 
bool isRecordLayoutComplete (const clang::Type *ty) const
 Return true if the specified type is already completely laid out.
 
bool noRecordsBeingLaidOut () const
 
bool isRecordBeingLaidOut (const clang::Type *ty) const
 
const ABIInfogetABIInfo () const
 
mlir::Type convertType (clang::QualType type)
 Convert a Clang type into a mlir::Type.
 
mlir::Type convertRecordDeclType (const clang::RecordDecl *recordDecl)
 Lay out a tagged decl type like struct or union.
 
std::unique_ptr< CIRGenRecordLayoutcomputeRecordLayout (const clang::RecordDecl *rd, cir::RecordType *ty)
 
std::string getRecordTypeName (const clang::RecordDecl *, llvm::StringRef suffix)
 
const CIRGenRecordLayoutgetCIRGenRecordLayout (const clang::RecordDecl *rd)
 Return record layout info for the given record decl.
 
mlir::Type convertTypeForMem (clang::QualType, bool forBitField=false)
 Convert type T into an mlir::Type.
 
cir::FuncType getFunctionType (const CIRGenFunctionInfo &info)
 Get the CIR function type for.
 
cir::FuncType getFunctionType (clang::GlobalDecl gd)
 
cir::FuncType getFunctionTypeForVTable (clang::GlobalDecl gd)
 Get the CIR function type for use in a vtable, given a CXXMethodDecl.
 
const CIRGenFunctionInfoarrangeGlobalDeclaration (GlobalDecl gd)
 
void updateCompletedType (const clang::TagDecl *td)
 UpdateCompletedType - when we find the full definition for a TagDecl, replace the 'opaque' type we previously made for it if applicable.
 
const CIRGenFunctionInfoarrangeFunctionDeclaration (const clang::FunctionDecl *fd)
 Free functions are functions that are compatible with an ordinary C function pointer type.
 
bool isZeroInitializable (clang::QualType ty)
 Return whether a type can be zero-initialized (in the C++ sense) with an LLVM zeroinitializer.
 
bool isZeroInitializable (const RecordDecl *rd)
 
const CIRGenFunctionInfoarrangeCXXConstructorCall (const CallArgList &args, const clang::CXXConstructorDecl *d, clang::CXXCtorType ctorKind, bool passProtoArgs=true)
 Arrange a call to a C++ method, passing the given arguments.
 
const CIRGenFunctionInfoarrangeCXXMethodCall (const CallArgList &args, const clang::FunctionProtoType *type, RequiredArgs required, unsigned numPrefixArgs)
 Arrange a call to a C++ method, passing the given arguments.
 
const CIRGenFunctionInfoarrangeCXXMethodDeclaration (const clang::CXXMethodDecl *md)
 C++ methods have some special rules and also have implicit parameters.
 
const CIRGenFunctionInfoarrangeCXXStructorDeclaration (clang::GlobalDecl gd)
 
const CIRGenFunctionInfoarrangeCXXMethodType (const clang::CXXRecordDecl *rd, const clang::FunctionProtoType *ftp, const clang::CXXMethodDecl *md)
 Arrange the argument and result information for a call to an unknown C++ non-static member function of the given abstract type.
 
const CIRGenFunctionInfoarrangeFreeFunctionCall (const CallArgList &args, const FunctionType *fnType)
 
const CIRGenFunctionInfoarrangeCIRFunctionInfo (CanQualType returnType, llvm::ArrayRef< CanQualType > argTypes, RequiredArgs required)
 
const CIRGenFunctionInfoarrangeFreeFunctionType (CanQual< FunctionProtoType > fpt)
 
const CIRGenFunctionInfoarrangeFreeFunctionType (CanQual< FunctionNoProtoType > fnpt)
 

Public Attributes

TypeCacheTy typeCache
 

Detailed Description

This class organizes the cross-module state that is used while lowering AST types to CIR types.

Definition at line 48 of file CIRGenTypes.h.

Member Typedef Documentation

◆ TypeCacheTy

using clang::CIRGen::CIRGenTypes::TypeCacheTy = llvm::DenseMap<const clang::Type *, mlir::Type>

This map of clang::Type to mlir::Type (which includes CIR type) is a cache of types that have already been processed.

Definition at line 96 of file CIRGenTypes.h.

Constructor & Destructor Documentation

◆ CIRGenTypes()

CIRGenTypes::CIRGenTypes ( CIRGenModule cgm)

Definition at line 16 of file CIRGenTypes.cpp.

◆ ~CIRGenTypes()

CIRGenTypes::~CIRGenTypes ( )

Definition at line 21 of file CIRGenTypes.cpp.

Member Function Documentation

◆ arrangeCIRFunctionInfo()

const CIRGenFunctionInfo & CIRGenTypes::arrangeCIRFunctionInfo ( CanQualType  returnType,
llvm::ArrayRef< CanQualType argTypes,
RequiredArgs  required 
)

◆ arrangeCXXConstructorCall()

const CIRGenFunctionInfo & CIRGenTypes::arrangeCXXConstructorCall ( const CallArgList args,
const clang::CXXConstructorDecl d,
clang::CXXCtorType  ctorKind,
bool  passProtoArgs = true 
)

◆ arrangeCXXMethodCall()

const CIRGenFunctionInfo & CIRGenTypes::arrangeCXXMethodCall ( const CallArgList args,
const clang::FunctionProtoType type,
RequiredArgs  required,
unsigned  numPrefixArgs 
)

Arrange a call to a C++ method, passing the given arguments.

numPrefixArgs is the number of the ABI-specific prefix arguments we have. It does not count this.

Definition at line 367 of file CIRGenCall.cpp.

References arrangeCIRFunctionInfo(), clang::ASTContext::getCanonicalParamType(), clang::Type::getCanonicalTypeUnqualified(), clang::FunctionType::getReturnType(), clang::CanQual< T >::getUnqualifiedType(), cir::MissingFeatures::opCallExtParameterInfo(), and cir::MissingFeatures::opCallFnInfoOpts().

Referenced by clang::CIRGen::CIRGenFunction::emitCXXMemberOrOperatorCall().

◆ arrangeCXXMethodDeclaration()

const CIRGenFunctionInfo & CIRGenTypes::arrangeCXXMethodDeclaration ( const clang::CXXMethodDecl md)

C++ methods have some special rules and also have implicit parameters.

Arrange the argument and result information for a declaration or definition of the given C++ non-static member function.

The member function must be an ordinary function, i.e. not a constructor or destructor.

Definition at line 396 of file CIRGenCall.cpp.

References arrangeCXXMethodType(), arrangeFreeFunctionType(), cir::MissingFeatures::cudaSupport(), clang::CanQual< T >::getAs(), clang::Type::getCanonicalTypeUnqualified(), clang::CIRGen::CIRGenCXXABI::getThisArgumentTypeForMethod(), clang::ValueDecl::getType(), and clang::CXXMethodDecl::isInstance().

Referenced by arrangeFunctionDeclaration(), clang::CIRGen::CIRGenFunction::emitCXXMemberOrOperatorMemberCallExpr(), and clang::CIRGen::CIRGenModule::getAddrOfGlobal().

◆ arrangeCXXMethodType()

const CIRGenFunctionInfo & CIRGenTypes::arrangeCXXMethodType ( const clang::CXXRecordDecl rd,
const clang::FunctionProtoType ftp,
const clang::CXXMethodDecl md 
)

Arrange the argument and result information for a call to an unknown C++ non-static member function of the given abstract type.

(A null RD means we don't have any meaningful "this" argument type, so fall back to a generic pointer type). The member fucntion must be an ordinary function, i.e. not a constructor or destructor.

Definition at line 419 of file CIRGenCall.cpp.

References deriveThisType(), clang::CanQual< T >::getAs(), clang::Type::getCanonicalTypeUnqualified(), and cir::MissingFeatures::opCallFnInfoOpts().

Referenced by arrangeCXXMethodDeclaration().

◆ arrangeCXXStructorDeclaration()

const CIRGenFunctionInfo & CIRGenTypes::arrangeCXXStructorDeclaration ( clang::GlobalDecl  gd)

◆ arrangeFreeFunctionCall()

const CIRGenFunctionInfo & CIRGenTypes::arrangeFreeFunctionCall ( const CallArgList args,
const FunctionType fnType 
)

◆ arrangeFreeFunctionType() [1/2]

const CIRGenFunctionInfo & CIRGenTypes::arrangeFreeFunctionType ( CanQual< FunctionNoProtoType fnpt)

◆ arrangeFreeFunctionType() [2/2]

const CIRGenFunctionInfo & CIRGenTypes::arrangeFreeFunctionType ( CanQual< FunctionProtoType fpt)

◆ arrangeFunctionDeclaration()

const CIRGenFunctionInfo & CIRGenTypes::arrangeFunctionDeclaration ( const clang::FunctionDecl fd)

Free functions are functions that are compatible with an ordinary C function pointer type.

Arrange the argument and result information for the declaration or definition of the given function.

Definition at line 436 of file CIRGenCall.cpp.

References clang::CIRGen::RequiredArgs::All, arrangeCIRFunctionInfo(), arrangeCXXMethodDeclaration(), arrangeFreeFunctionType(), clang::CanQual< T >::castAs(), cir::MissingFeatures::cudaSupport(), clang::CanQual< T >::getAs(), clang::Type::getCanonicalTypeUnqualified(), clang::ValueDecl::getType(), cir::MissingFeatures::opCallCIRGenFuncInfoExtParamInfo(), and cir::MissingFeatures::opCallFnInfoOpts().

Referenced by arrangeGlobalDeclaration().

◆ arrangeGlobalDeclaration()

const CIRGenFunctionInfo & CIRGenTypes::arrangeGlobalDeclaration ( GlobalDecl  gd)

◆ computeRecordLayout()

std::unique_ptr< CIRGenRecordLayout > CIRGenTypes::computeRecordLayout ( const clang::RecordDecl rd,
cir::RecordType *  ty 
)

◆ convertRecordDeclType()

mlir::Type CIRGenTypes::convertRecordDeclType ( const clang::RecordDecl recordDecl)

◆ convertType()

mlir::Type CIRGenTypes::convertType ( clang::QualType  type)

Convert a Clang type into a mlir::Type.

Definition at line 276 of file CIRGenTypes.cpp.

References clang::CIRGen::CIRGenTypeCache::BFloat16Ty, clang::Type::castAsEnumDecl(), convertRecordDeclType(), convertType(), convertTypeForMem(), clang::CIRGen::CIRGenTypeCache::DoubleTy, clang::CIRGen::CIRGenModule::errorNYI(), clang::CIRGen::CIRGenTypeCache::FloatTy, clang::CIRGen::CIRGenTypeCache::FP128Ty, clang::CIRGen::CIRGenTypeCache::FP16Ty, clang::ASTContext::getCanonicalType(), clang::ArrayType::getElementType(), clang::VectorType::getElementType(), clang::ASTContext::getFloatTypeSemantics(), clang::ArrayType::getIndexTypeCVRQualifiers(), getKind(), clang::ASTContext::getLangOpts(), clang::CIRGen::CIRGenBuilderTy::getLongDoubleTy(), getMLIRContext(), clang::VectorType::getNumElements(), clang::PointerType::getPointeeType(), clang::ReferenceType::getPointeeType(), cir::CIRBaseBuilderTy::getPointerTo(), clang::ConstantArrayType::getSize(), clang::ASTContext::getTargetInfo(), clang::Type::getTypeClass(), clang::ASTContext::getTypeSize(), cir::CIRBaseBuilderTy::getVoidPtrTy(), clang::Type::isConstantMatrixType(), cir::isSized(), clang::ast_matchers::recordType, clang::CIRGen::CIRGenTypeCache::SInt32Ty, clang::CIRGen::CIRGenTypeCache::SInt8Ty, clang::ast_matchers::type, typeCache, clang::CIRGen::CIRGenTypeCache::UInt32Ty, clang::TargetInfo::useFP16ConversionIntrinsics(), and clang::CIRGen::CIRGenTypeCache::VoidTy.

Referenced by clang::CIRGen::CIRGenFunction::convertType(), clang::CIRGen::CIRGenModule::convertType(), convertType(), convertTypeForMem(), getFunctionType(), and updateCompletedType().

◆ convertTypeForMem()

mlir::Type CIRGenTypes::convertTypeForMem ( clang::QualType  qualType,
bool  forBitField = false 
)

Convert type T into an mlir::Type.

This differs from convertType in that it is used to convert to the memory representation for a type. For example, the scalar representation for bool is i1, but the memory representation is usually i8 or i32, depending on the target.

Definition at line 519 of file CIRGenTypes.cpp.

References convertType(), and clang::ast_matchers::qualType.

Referenced by convertType(), clang::CIRGen::CIRGenFunction::convertTypeForMem(), clang::CIRGen::CIRGenModule::getAddrOfGlobalVar(), clang::CIRGen::CIRGenModule::getAddrOfGlobalVarAttr(), clang::CIRGen::CIRGenModule::getOrCreateCIRGlobal(), and clang::CIRGen::CIRGenModule::getOrCreateStaticVarDecl().

◆ deriveThisType()

CanQualType CIRGenTypes::deriveThisType ( const clang::CXXRecordDecl rd,
const clang::CXXMethodDecl md 
)

Derives the 'this' type for CIRGen purposes, i.e.

ignoring method CVR qualification.

ignoring method CVR qualification. Either or both of rd and md may be null. A null rd indicates that there is no meaningful 'this' type, and a null md can occur when calling a method pointer.

Definition at line 224 of file CIRGenCall.cpp.

References clang::CanQual< Type >::CreateUnsafe(), clang::CIRGen::CIRGenModule::errorNYI(), clang::Qualifiers::getAddressSpace(), getASTContext(), clang::ASTContext::getCanonicalTagType(), clang::CXXMethodDecl::getMethodQualifiers(), clang::ASTContext::getPointerType(), and clang::ASTContext::VoidTy.

Referenced by arrangeCXXMethodType(), arrangeCXXStructorDeclaration(), and commonBuildCXXMemberOrOperatorCall().

◆ getABIInfo()

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

Definition at line 108 of file CIRGenTypes.h.

◆ getASTContext()

clang::ASTContext & clang::CIRGen::CIRGenTypes::getASTContext ( ) const
inline

◆ getBuilder()

CIRGenBuilderTy & clang::CIRGen::CIRGenTypes::getBuilder ( ) const
inline

Definition at line 81 of file CIRGenTypes.h.

◆ getCGModule()

CIRGenModule & clang::CIRGen::CIRGenTypes::getCGModule ( ) const
inline

Definition at line 82 of file CIRGenTypes.h.

Referenced by appendParameterTypes().

◆ getCIRGenRecordLayout()

const CIRGenRecordLayout & CIRGenTypes::getCIRGenRecordLayout ( const clang::RecordDecl rd)

◆ getFunctionType() [1/2]

cir::FuncType CIRGenTypes::getFunctionType ( clang::GlobalDecl  gd)

Definition at line 45 of file CIRGenCall.cpp.

References arrangeGlobalDeclaration(), and getFunctionType().

◆ getFunctionType() [2/2]

cir::FuncType CIRGenTypes::getFunctionType ( const CIRGenFunctionInfo info)

◆ getFunctionTypeForVTable()

cir::FuncType CIRGenTypes::getFunctionTypeForVTable ( clang::GlobalDecl  gd)

Get the CIR function type for use in a vtable, given a CXXMethodDecl.

If the method has an incomplete return type, and/or incomplete argument types, this will return the opaque type.

Definition at line 63 of file CIRGenCall.cpp.

References clang::CIRGen::CIRGenModule::errorNYI(), clang::Type::getAs(), clang::GlobalDecl::getDecl(), getFunctionType(), clang::ValueDecl::getType(), and isFuncTypeConvertible().

◆ getMLIRContext()

mlir::MLIRContext & CIRGenTypes::getMLIRContext ( ) const

Definition at line 26 of file CIRGenTypes.cpp.

Referenced by convertType().

◆ getRecordTypeName()

std::string CIRGenTypes::getRecordTypeName ( const clang::RecordDecl ,
llvm::StringRef  suffix 
)

◆ isFuncParamTypeConvertible()

bool CIRGenTypes::isFuncParamTypeConvertible ( clang::QualType  type)

Return true if the specified type in a function parameter or result position can be converted to a CIR type at this point.

This boils down to being whether it is complete, as well as whether we've temporarily deferred expanding the type because we're in a recursive context.

Definition at line 34 of file CIRGenTypes.cpp.

References clang::ast_matchers::tagType, and clang::ast_matchers::type.

Referenced by isFuncTypeConvertible().

◆ isFuncTypeConvertible()

bool CIRGenTypes::isFuncTypeConvertible ( const clang::FunctionType ft)

Utility to check whether a function type can be converted to a CIR type (i.e.

Code to verify a given function type is complete, i.e.

doesn't depend on an incomplete tag type).

the return type and all of the parameter types are complete. Also check to see if we are in a RS_StructPointer context, and if so whether any struct types have been pended. If so, we don't want to ask the ABI lowering code to handle a type that cannot be converted to a CIR type.

Definition at line 53 of file CIRGenTypes.cpp.

References clang::FunctionType::getReturnType(), and isFuncParamTypeConvertible().

Referenced by getFunctionTypeForVTable().

◆ isRecordBeingLaidOut()

bool clang::CIRGen::CIRGenTypes::isRecordBeingLaidOut ( const clang::Type ty) const
inline

Definition at line 104 of file CIRGenTypes.h.

Referenced by isSafeToConvert().

◆ isRecordLayoutComplete()

bool CIRGenTypes::isRecordLayoutComplete ( const clang::Type ty) const

Return true if the specified type is already completely laid out.

Definition at line 120 of file CIRGenTypes.cpp.

Referenced by isSafeToConvert().

◆ isZeroInitializable() [1/2]

bool CIRGenTypes::isZeroInitializable ( clang::QualType  ty)

◆ isZeroInitializable() [2/2]

bool CIRGenTypes::isZeroInitializable ( const RecordDecl rd)

◆ noRecordsBeingLaidOut()

bool clang::CIRGen::CIRGenTypes::noRecordsBeingLaidOut ( ) const
inline

Definition at line 103 of file CIRGenTypes.h.

Referenced by isSafeToConvert().

◆ updateCompletedType()

void CIRGenTypes::updateCompletedType ( const clang::TagDecl td)

UpdateCompletedType - when we find the full definition for a TagDecl, replace the 'opaque' type we previously made for it if applicable.

Definition at line 632 of file CIRGenTypes.cpp.

References convertRecordDeclType(), convertType(), cir::MissingFeatures::generateDebugInfo(), clang::ASTContext::getCanonicalTagType(), clang::CanQual< T >::getTypePtr(), and typeCache.

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

Member Data Documentation

◆ typeCache

TypeCacheTy clang::CIRGen::CIRGenTypes::typeCache

Definition at line 97 of file CIRGenTypes.h.

Referenced by convertType(), and updateCompletedType().


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