clang 22.0.0git
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, unsigned extraPrefixArgs, unsigned extraSuffixArgs, 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.

References getABIInfo(), getASTContext(), and getBuilder().

◆ ~CIRGenTypes()

CIRGenTypes::~CIRGenTypes ( )

Definition at line 21 of file CIRGenTypes.cpp.

Member Function Documentation

◆ arrangeCIRFunctionInfo()

◆ arrangeCXXConstructorCall()

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

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

extraPrefixArgs is the number of ABI-specific args passed after the this parameter. passProtoArgs indicates whether args has args for the parameters in the given CXXConstructorDecl.

Definition at line 334 of file CIRGenCall.cpp.

References clang::CIRGen::RequiredArgs::All, arrangeCIRFunctionInfo(), getFormalType(), clang::CIRGen::RequiredArgs::getFromProtoWithExtraSlots(), clang::FunctionDecl::getSourceRange(), cir::MissingFeatures::opCallCIRGenFuncInfoExtParamInfo(), and cir::MissingFeatures::opCallFnInfoOpts().

◆ 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 371 of file CIRGenCall.cpp.

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

◆ 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 400 of file CIRGenCall.cpp.

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

Referenced by arrangeFunctionDeclaration(), 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 423 of file CIRGenCall.cpp.

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

Referenced by arrangeCXXMethodDeclaration().

◆ arrangeCXXStructorDeclaration()

◆ arrangeFreeFunctionCall()

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

Definition at line 391 of file CIRGenCall.cpp.

References arrangeFreeFunctionLikeCall().

Referenced by emitNewDeleteCall().

◆ 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)

◆ arrangeGlobalDeclaration()

◆ computeRecordLayout()

◆ convertRecordDeclType()

◆ convertType()

◆ 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::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 227 of file CIRGenCall.cpp.

References clang::CanQual< Type >::CreateUnsafe(), 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.

Referenced by CIRGenTypes().

◆ 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.

Referenced by CIRGenTypes().

◆ 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)

Return record layout info for the given record decl.

Definition at line 537 of file CIRGenTypes.cpp.

References convertRecordDeclType().

Referenced by isZeroInitializable().

◆ 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]

◆ 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::cast(), 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()

◆ 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.

References clang::CIRGen::Type.

Referenced by isSafeToConvert().

◆ isZeroInitializable() [1/2]

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

Return whether a type can be zero-initialized (in the C++ sense) with an LLVM zeroinitializer.

Definition at line 556 of file CIRGenTypes.cpp.

References clang::Type::getAs(), clang::Type::getAsRecordDecl(), clang::isa(), and isZeroInitializable().

Referenced by isZeroInitializable().

◆ 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 clang::cast(), convertRecordDeclType(), convertType(), cir::MissingFeatures::generateDebugInfo(), and typeCache.

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: