clang 22.0.0git
clang::CIRGen::CIRGenModule Class Reference

This class organizes the cross-function state that is used while generating CIR code. More...

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

Inheritance diagram for clang::CIRGen::CIRGenModule:
[legend]

Public Member Functions

 CIRGenModule (mlir::MLIRContext &mlirContext, clang::ASTContext &astContext, const clang::CodeGenOptions &cgo, clang::DiagnosticsEngine &diags)
 ~CIRGenModule ()
mlir::ModuleOp getModule () const
CIRGenBuilderTygetBuilder ()
clang::ASTContextgetASTContext () const
const clang::TargetInfogetTarget () const
const clang::CodeGenOptionsgetCodeGenOpts () const
clang::DiagnosticsEnginegetDiags () const
CIRGenTypesgetTypes ()
const clang::LangOptionsgetLangOpts () const
CIRGenCXXABIgetCXXABI () const
mlir::MLIRContext & getMLIRContext ()
const cir::CIRDataLayout getDataLayout () const
void handleCXXStaticMemberVarInstantiation (VarDecl *vd)
 Tell the consumer that this variable has been instantiated.
mlir::Operation * getGlobalValue (llvm::StringRef ref)
cir::GlobalOp getStaticLocalDeclAddress (const VarDecl *d)
void setStaticLocalDeclAddress (const VarDecl *d, cir::GlobalOp c)
cir::GlobalOp getOrCreateStaticVarDecl (const VarDecl &d, cir::GlobalLinkageKind linkage)
cir::GlobalOp getOrCreateCIRGlobal (llvm::StringRef mangledName, mlir::Type ty, LangAS langAS, const VarDecl *d, ForDefinition_t isForDefinition)
 If the specified mangled name is not in the module, create and return an mlir::GlobalOp value.
cir::GlobalOp getOrCreateCIRGlobal (const VarDecl *d, mlir::Type ty, ForDefinition_t isForDefinition)
bool shouldZeroInitPadding () const
std::string getUniqueGlobalName (const std::string &baseName)
mlir::Value getAddrOfGlobalVar (const VarDecl *d, mlir::Type ty={}, ForDefinition_t isForDefinition=NotForDefinition)
 Return the mlir::Value for the address of the given global variable.
cir::GlobalViewAttr getAddrOfGlobalVarAttr (const VarDecl *d)
 Return the mlir::GlobalViewAttr for the address of the given global.
CharUnits computeNonVirtualBaseClassOffset (const CXXRecordDecl *derivedClass, llvm::iterator_range< CastExpr::path_const_iterator > path)
void constructAttributeList (CIRGenCalleeInfo calleeInfo, mlir::NamedAttrList &attrs)
 Get the CIR attributes and calling convention to use for a particular function type.
cir::GlobalOp createOrReplaceCXXRuntimeVariable (mlir::Location loc, llvm::StringRef name, mlir::Type ty, cir::GlobalLinkageKind linkage, clang::CharUnits alignment)
 Will return a global variable of the given type.
void emitVTable (const CXXRecordDecl *rd)
 This is a callback from Sema to tell us that a particular vtable is required to be emitted in this translation unit.
cir::GlobalLinkageKind getVTableLinkage (const CXXRecordDecl *rd)
 Return the appropriate linkage for the vtable, VTT, and type information of the given class.
mlir::Attribute getAddrOfRTTIDescriptor (mlir::Location loc, QualType ty, bool forEH=false)
 Get the address of the RTTI descriptor for the given type.
mlir::Attribute getConstantArrayFromStringLiteral (const StringLiteral *e)
 Return a constant array for the given string.
cir::GlobalOp getGlobalForStringLiteral (const StringLiteral *s, llvm::StringRef name=".str")
 Return a global symbol reference to a constant array for the given string literal.
cir::GlobalViewAttr getAddrOfConstantStringFromLiteral (const StringLiteral *s, llvm::StringRef name=".str")
 Return a global symbol reference to a constant array for the given string literal.
void setCommonAttributes (GlobalDecl gd, mlir::Operation *op)
 Set attributes which are common to any form of a global definition (alias, Objective-C method, function, global variable).
const TargetCIRGenInfogetTargetCIRGenInfo ()
mlir::Location getLoc (clang::SourceLocation cLoc)
 Helpers to convert the presumed location of Clang's SourceLocation to an MLIR Location.
mlir::Location getLoc (clang::SourceRange cRange)
clang::CharUnits getClassPointerAlignment (const clang::CXXRecordDecl *rd)
 Return the best known alignment for an unknown pointer to a particular class.
clang::CharUnits getNaturalTypeAlignment (clang::QualType t, LValueBaseInfo *baseInfo)
 FIXME: this could likely be a common helper and not necessarily related with codegen.
CharUnits getDynamicOffsetAlignment (CharUnits actualBaseAlign, const CXXRecordDecl *baseDecl, CharUnits expectedTargetAlign)
 TODO: Add TBAAAccessInfo.
CharUnits getVBaseAlignment (CharUnits derivedAlign, const CXXRecordDecl *derived, const CXXRecordDecl *vbase)
 Returns the assumed alignment of a virtual base of a class.
cir::FuncOp getAddrOfCXXStructor (clang::GlobalDecl gd, const CIRGenFunctionInfo *fnInfo=nullptr, cir::FuncType fnType=nullptr, bool dontDefer=false, ForDefinition_t isForDefinition=NotForDefinition)
std::pair< cir::FuncType, cir::FuncOp > getAddrAndTypeOfCXXStructor (clang::GlobalDecl gd, const CIRGenFunctionInfo *fnInfo=nullptr, cir::FuncType fnType=nullptr, bool dontDefer=false, ForDefinition_t isForDefinition=NotForDefinition)
mlir::Type getVTableComponentType ()
CIRGenVTablesgetVTables ()
ItaniumVTableContextgetItaniumVTableContext ()
const ItaniumVTableContextgetItaniumVTableContext () const
void addDeferredDeclToEmit (clang::GlobalDecl GD)
void emitTopLevelDecl (clang::Decl *decl)
bool mustBeEmitted (const clang::ValueDecl *d)
 Determine whether the definition must be emitted; if this returns false, the definition can be emitted lazily if it's used.
bool mayBeEmittedEagerly (const clang::ValueDecl *d)
 Determine whether the definition can be emitted eagerly, or should be delayed until the end of the translation unit.
bool verifyModule () const
cir::FuncOp getAddrOfFunction (clang::GlobalDecl gd, mlir::Type funcType=nullptr, bool forVTable=false, bool dontDefer=false, ForDefinition_t isForDefinition=NotForDefinition)
 Return the address of the given function.
mlir::Operation * getAddrOfGlobal (clang::GlobalDecl gd, ForDefinition_t isForDefinition=NotForDefinition)
bool shouldEmitRTTI (bool forEH=false)
void emitExplicitCastExprType (const ExplicitCastExpr *e, CIRGenFunction *cgf=nullptr)
 Emit type info if type of an expression is a variably modified type.
void emitGlobal (clang::GlobalDecl gd)
 Emit code for a single global function or variable declaration.
void emitAliasForGlobal (llvm::StringRef mangledName, mlir::Operation *op, GlobalDecl aliasGD, cir::FuncOp aliasee, cir::GlobalLinkageKind linkage)
mlir::Type convertType (clang::QualType type)
void setGlobalVisibility (mlir::Operation *op, const NamedDecl *d) const
 Set the visibility for the given global.
void setDSOLocal (mlir::Operation *op) const
void setDSOLocal (cir::CIRGlobalValueInterface gv) const
void setGVProperties (mlir::Operation *op, const NamedDecl *d) const
 Set visibility, dllimport/dllexport and dso_local.
void setGVPropertiesAux (mlir::Operation *op, const NamedDecl *d) const
void setFunctionAttributes (GlobalDecl gd, cir::FuncOp f, bool isIncompleteFunction, bool isThunk)
 Set function attributes for a function declaration.
void emitGlobalDefinition (clang::GlobalDecl gd, mlir::Operation *op=nullptr)
void emitGlobalFunctionDefinition (clang::GlobalDecl gd, mlir::Operation *op)
void emitGlobalVarDefinition (const clang::VarDecl *vd, bool isTentative=false)
void emitGlobalOpenACCDecl (const clang::OpenACCConstructDecl *cd)
void emitDeclContext (const DeclContext *dc)
mlir::Value emitNullConstant (QualType t, mlir::Location loc)
 Return the result of value-initializing the given type, i.e.
llvm::StringRef getMangledName (clang::GlobalDecl gd)
void emitTentativeDefinition (const VarDecl *d)
void updateCompletedType (const clang::TagDecl *td)
cir::FuncOp codegenCXXStructor (clang::GlobalDecl gd)
bool supportsCOMDAT () const
void maybeSetTrivialComdat (const clang::Decl &d, mlir::Operation *op)
void replaceUsesOfNonProtoTypeWithRealFunction (mlir::Operation *old, cir::FuncOp newFn)
 This function is called when we implement a function with no prototype, e.g.
cir::FuncOp getOrCreateCIRFunction (llvm::StringRef mangledName, mlir::Type funcType, clang::GlobalDecl gd, bool forVTable, bool dontDefer=false, bool isThunk=false, ForDefinition_t isForDefinition=NotForDefinition, mlir::ArrayAttr extraAttrs={})
cir::FuncOp createCIRFunction (mlir::Location loc, llvm::StringRef name, cir::FuncType funcType, const clang::FunctionDecl *funcDecl)
cir::FuncOp getBuiltinLibFunction (const FunctionDecl *fd, unsigned builtinID)
 Given a builtin id for a function like "__builtin_fabsf", return a Function* for "fabsf".
mlir::IntegerAttr getSize (CharUnits size)
void emitDeferred ()
 Emit any needed decls for which code generation was deferred.
void emitGlobalDecl (const clang::GlobalDecl &d)
 Helper for emitDeferred to apply actual codegen.
const llvm::Triple & getTriple () const
void release ()
cir::VisibilityAttr getGlobalVisibilityAttrFromDecl (const Decl *decl)
cir::GlobalLinkageKind getFunctionLinkage (GlobalDecl gd)
cir::GlobalLinkageKind getCIRLinkageForDeclarator (const DeclaratorDecl *dd, GVALinkage linkage, bool isConstantVariable)
void setFunctionLinkage (GlobalDecl gd, cir::FuncOp f)
cir::GlobalLinkageKind getCIRLinkageVarDefinition (const VarDecl *vd, bool isConstant)
void addReplacement (llvm::StringRef name, mlir::Operation *op)
DiagnosticBuilder errorNYI (SourceLocation, llvm::StringRef)
 Helpers to emit "not yet implemented" error diagnostics.
template<typename T>
DiagnosticBuilder errorNYI (SourceLocation loc, llvm::StringRef feature, const T &name)
DiagnosticBuilder errorNYI (mlir::Location loc, llvm::StringRef feature)
DiagnosticBuilder errorNYI (llvm::StringRef feature) const
DiagnosticBuilder errorNYI (SourceRange, llvm::StringRef)
template<typename T>
DiagnosticBuilder errorNYI (SourceRange loc, llvm::StringRef feature, const T &name)
Public Member Functions inherited from clang::CIRGen::CIRGenTypeCache
 CIRGenTypeCache ()
clang::CharUnits getSizeAlign () const
clang::CharUnits getPointerAlign () const

Static Public Member Functions

static cir::GlobalOp createGlobalOp (CIRGenModule &cgm, mlir::Location loc, llvm::StringRef name, mlir::Type t, bool isConstant=false, mlir::Operation *insertPoint=nullptr)
static void setInitializer (cir::GlobalOp &op, mlir::Attribute value)
static mlir::SymbolTable::Visibility getMLIRVisibilityFromCIRLinkage (cir::GlobalLinkageKind GLK)
static cir::VisibilityKind getGlobalVisibilityKindFromClangVisibility (clang::VisibilityAttr::VisibilityType visibility)
static mlir::SymbolTable::Visibility getMLIRVisibility (cir::GlobalOp op)

Public Attributes

mlir::Operation * lastGlobalOp = nullptr
llvm::DenseMap< const Decl *, cir::GlobalOp > staticLocalDeclMap
llvm::StringMap< unsignedcgGlobalNames
std::map< llvm::StringRef, clang::GlobalDecldeferredDecls
 This contains all the decls which have definitions but which are deferred for emission and therefore should only be output if they are actually used.
std::vector< clang::GlobalDecldeferredDeclsToEmit
Public Attributes inherited from clang::CIRGen::CIRGenTypeCache
cir::VoidType VoidTy
cir::IntType SInt8Ty
cir::IntType SInt16Ty
cir::IntType SInt32Ty
cir::IntType SInt64Ty
cir::IntType SInt128Ty
cir::IntType UInt8Ty
cir::IntType UInt16Ty
cir::IntType UInt32Ty
cir::IntType UInt64Ty
cir::IntType UInt128Ty
cir::FP16Type FP16Ty
cir::BF16Type BFloat16Ty
cir::SingleType FloatTy
cir::DoubleType DoubleTy
cir::FP80Type FP80Ty
cir::FP128Type FP128Ty
mlir::Type UCharTy
 ClangIR char.
union { 
   mlir::Type   UIntPtrTy 
   mlir::Type   SizeTy 
}; 
 intptr_t, size_t, and ptrdiff_t, which we assume are the same size.
mlir::Type PtrDiffTy
cir::PointerType VoidPtrTy
 void* in address space 0
cir::PointerType UInt8PtrTy
union { 
   unsigned char   PointerAlignInBytes 
   unsigned char   PointerSizeInBytes 
}; 
 The size and alignment of a pointer into the generic address space.
unsigned char SizeAlignInBytes
 The alignment of size_t.

Detailed Description

This class organizes the cross-function state that is used while generating CIR code.

Definition at line 56 of file CIRGenModule.h.

Constructor & Destructor Documentation

◆ CIRGenModule()

◆ ~CIRGenModule()

CIRGenModule::~CIRGenModule ( )
default

Member Function Documentation

◆ addDeferredDeclToEmit()

void clang::CIRGen::CIRGenModule::addDeferredDeclToEmit ( clang::GlobalDecl GD)
inline

Definition at line 333 of file CIRGenModule.h.

References deferredDeclsToEmit.

Referenced by emitGlobal(), and getOrCreateCIRFunction().

◆ addReplacement()

void CIRGenModule::addReplacement ( llvm::StringRef name,
mlir::Operation * op )

Definition at line 941 of file CIRGenModule.cpp.

◆ codegenCXXStructor()

◆ computeNonVirtualBaseClassOffset()

CharUnits CIRGenModule::computeNonVirtualBaseClassOffset ( const CXXRecordDecl * derivedClass,
llvm::iterator_range< CastExpr::path_const_iterator > path )

◆ constructAttributeList()

void CIRGenModule::constructAttributeList ( CIRGenCalleeInfo calleeInfo,
mlir::NamedAttrList & attrs )

Get the CIR attributes and calling convention to use for a particular function type.

Construct the CIR attribute list of a function or call.

Parameters
calleeInfo- The callee information these attributes are being constructed for. If valid, the attributes applied to this decl may contribute to the function attributes and calling convention.

Definition at line 113 of file CIRGenCall.cpp.

References addAttributesFromFunctionProtoType(), clang::CIRGen::Decl, getBuilder(), clang::CIRGen::CIRGenCalleeInfo::getCalleeDecl(), clang::CIRGen::CIRGenCalleeInfo::getCalleeFunctionProtoType(), clang::GlobalDecl::getDecl(), getMLIRContext(), clang::Decl::hasAttr(), cir::MissingFeatures::opCallAttrs(), and cir::MissingFeatures::opCallCallConv().

◆ convertType()

◆ createCIRFunction()

cir::FuncOp CIRGenModule::createCIRFunction ( mlir::Location loc,
llvm::StringRef name,
cir::FuncType funcType,
const clang::FunctionDecl * funcDecl )

◆ createGlobalOp()

cir::GlobalOp CIRGenModule::createGlobalOp ( CIRGenModule & cgm,
mlir::Location loc,
llvm::StringRef name,
mlir::Type t,
bool isConstant = false,
mlir::Operation * insertPoint = nullptr )
static

◆ createOrReplaceCXXRuntimeVariable()

cir::GlobalOp CIRGenModule::createOrReplaceCXXRuntimeVariable ( mlir::Location loc,
llvm::StringRef name,
mlir::Type ty,
cir::GlobalLinkageKind linkage,
clang::CharUnits alignment )

Will return a global variable of the given type.

If a variable with a different type already exists then a new variable with the right type will be created and all uses of the old variable will be replaced with a bitcast to the new variable.

Definition at line 1000 of file CIRGenModule.cpp.

References createGlobalOp(), errorNYI(), getMLIRContext(), getMLIRVisibility(), getSize(), cir::isWeakForLinker(), setDSOLocal(), and supportsCOMDAT().

◆ emitAliasForGlobal()

void CIRGenModule::emitAliasForGlobal ( llvm::StringRef mangledName,
mlir::Operation * op,
GlobalDecl aliasGD,
cir::FuncOp aliasee,
cir::GlobalLinkageKind linkage )

◆ emitDeclContext()

void CIRGenModule::emitDeclContext ( const DeclContext * dc)

◆ emitDeferred()

void CIRGenModule::emitDeferred ( )

Emit any needed decls for which code generation was deferred.

Definition at line 310 of file CIRGenModule.cpp.

References cir::MissingFeatures::cudaSupport(), deferredDeclsToEmit, cir::MissingFeatures::deferredVtables(), emitDeferred(), emitGlobalDecl(), and cir::MissingFeatures::openMP().

Referenced by emitDeferred(), and release().

◆ emitExplicitCastExprType()

void CIRGenModule::emitExplicitCastExprType ( const ExplicitCastExpr * e,
CIRGenFunction * cgf = nullptr )

Emit type info if type of an expression is a variably modified type.

Also emit proper debug info for cast types.

Definition at line 1366 of file CIRGenModule.cpp.

References clang::CIRGen::CIRGenFunction::emitVariablyModifiedType(), cir::MissingFeatures::generateDebugInfo(), clang::Expr::getType(), and clang::Type::isVariablyModifiedType().

◆ emitGlobal()

◆ emitGlobalDecl()

void CIRGenModule::emitGlobalDecl ( const clang::GlobalDecl & d)

Helper for emitDeferred to apply actual codegen.

Definition at line 272 of file CIRGenModule.cpp.

References emitGlobalDefinition(), clang::CIRGen::ForDefinition, getAddrOfGlobal(), getGlobalValue(), getMangledName(), getModule(), and cir::MissingFeatures::openMP().

Referenced by emitDeferred().

◆ emitGlobalDefinition()

◆ emitGlobalFunctionDefinition()

◆ emitGlobalOpenACCDecl()

void CIRGenModule::emitGlobalOpenACCDecl ( const clang::OpenACCConstructDecl * cd)

◆ emitGlobalVarDefinition()

◆ emitNullConstant()

mlir::Value CIRGenModule::emitNullConstant ( QualType t,
mlir::Location loc )

Return the result of value-initializing the given type, i.e.

a null expression of the given type.

Definition at line 1496 of file CIRGenExprConstant.cpp.

References errorNYI(), clang::Type::getAs(), getASTContext(), getTypes(), clang::Type::isMemberDataPointerType(), and clang::Type::isRecordType().

◆ emitTentativeDefinition()

void CIRGenModule::emitTentativeDefinition ( const VarDecl * d)

◆ emitTopLevelDecl()

◆ emitVTable()

void CIRGenModule::emitVTable ( const CXXRecordDecl * rd)

This is a callback from Sema to tell us that a particular vtable is required to be emitted in this translation unit.

This is only called for vtables that must be emitted (mainly due to key functions). For weak vtables, CodeGen tracks when they are needed and emits them as-needed.

Definition at line 56 of file CIRGenVTables.cpp.

◆ errorNYI() [1/6]

DiagnosticBuilder clang::CIRGen::CIRGenModule::errorNYI ( llvm::StringRef feature) const
inline

Definition at line 509 of file CIRGenModule.h.

References clang::DiagnosticsEngine::Error.

◆ errorNYI() [2/6]

DiagnosticBuilder clang::CIRGen::CIRGenModule::errorNYI ( mlir::Location loc,
llvm::StringRef feature )
inline

Definition at line 502 of file CIRGenModule.h.

References clang::DiagnosticsEngine::Error.

◆ errorNYI() [3/6]

template<typename T>
DiagnosticBuilder clang::CIRGen::CIRGenModule::errorNYI ( SourceLocation loc,
llvm::StringRef feature,
const T & name )
inline

Definition at line 494 of file CIRGenModule.h.

References clang::DiagnosticsEngine::Error, and clang::T.

◆ errorNYI() [4/6]

DiagnosticBuilder CIRGenModule::errorNYI ( SourceLocation loc,
llvm::StringRef feature )

Helpers to emit "not yet implemented" error diagnostics.

Definition at line 2204 of file CIRGenModule.cpp.

References clang::DiagnosticsEngine::Error.

Referenced by appendParameterTypes(), arrangeFreeFunctionLikeCall(), createCXXABI(), createOrReplaceCXXRuntimeVariable(), createReferenceTemporary(), emitAliasForGlobal(), emitAtomicCmpXchgFailureSet(), emitAtomicOp(), emitCXXNewAllocSize(), emitDeclContext(), emitGlobal(), emitGlobalDefinition(), emitGlobalFunctionDefinition(), emitGlobalOpenACCDecl(), emitGlobalVarDeclLValue(), emitGlobalVarDefinition(), clang::CIRGen::CIRGenFunction::emitLabelStmt(), clang::CIRGen::CIRGenFunction::emitLValue(), emitMemberInitializer(), emitNewInitializer(), emitNullConstant(), clang::CIRGen::CIRGenFunction::emitOpenACCDeclare(), clang::CIRGen::CIRGenFunction::emitOpenACCRoutine(), emitPointerArithmetic(), clang::CIRGen::CIRGenFunction::emitReturnStmt(), emitTopLevelDecl(), errorNYI(), errorNYI(), clang::CIRGen::CIRGenFunction::generateCode(), getAddrAndTypeOfCXXStructor(), getAddrOfFunction(), getAddrOfRTTIDescriptor(), getCIRLinkageForDeclarator(), getConstantArrayFromStringLiteral(), getGlobalForStringLiteral(), getMangledName(), getMangledNameImpl(), getOrCreateCIRFunction(), getOrCreateStaticVarDecl(), clang::CIRGen::CIRGenFunction::ConstantEmission::getReferenceLValue(), getStaticDeclName(), getVTableLinkage(), mayBeEmittedEagerly(), pushTemporaryCleanup(), replaceUsesOfNonProtoTypeWithRealFunction(), shouldAssumeDSOLocal(), and storeAnyExprIntoOneUnit().

◆ errorNYI() [5/6]

template<typename T>
DiagnosticBuilder clang::CIRGen::CIRGenModule::errorNYI ( SourceRange loc,
llvm::StringRef feature,
const T & name )
inline

Definition at line 519 of file CIRGenModule.h.

References errorNYI(), clang::SourceRange::getBegin(), and clang::T.

◆ errorNYI() [6/6]

DiagnosticBuilder CIRGenModule::errorNYI ( SourceRange loc,
llvm::StringRef feature )

Definition at line 2211 of file CIRGenModule.cpp.

References errorNYI(), and clang::SourceRange::getBegin().

◆ getAddrAndTypeOfCXXStructor()

◆ getAddrOfConstantStringFromLiteral()

cir::GlobalViewAttr CIRGenModule::getAddrOfConstantStringFromLiteral ( const StringLiteral * s,
llvm::StringRef name = ".str" )

Return a global symbol reference to a constant array for the given string literal.

Return a pointer to a constant array for the given string literal.

Definition at line 1355 of file CIRGenModule.cpp.

References cir::MissingFeatures::addressSpace(), getBuilder(), getGlobalForStringLiteral(), cir::CIRBaseBuilderTy::getPointerTo(), and s.

◆ getAddrOfCXXStructor()

cir::FuncOp clang::CIRGen::CIRGenModule::getAddrOfCXXStructor ( clang::GlobalDecl gd,
const CIRGenFunctionInfo * fnInfo = nullptr,
cir::FuncType fnType = nullptr,
bool dontDefer = false,
ForDefinition_t isForDefinition = NotForDefinition )
inline

◆ getAddrOfFunction()

cir::FuncOp CIRGenModule::getAddrOfFunction ( clang::GlobalDecl gd,
mlir::Type funcType = nullptr,
bool forVTable = false,
bool dontDefer = false,
ForDefinition_t isForDefinition = NotForDefinition )

Return the address of the given function.

If funcType is non-null, then this function will use the specified type if it has to create it.

Definition at line 1523 of file CIRGenModule.cpp.

References clang::cast(), convertType(), clang::Dtor_Complete, errorNYI(), getCXXABI(), clang::GlobalDecl::getDecl(), clang::GlobalDecl::getDtorType(), getMangledName(), getOrCreateCIRFunction(), and getTarget().

Referenced by emitFunctionDeclPointer(), emitGlobalFunctionDefinition(), emitNewDeleteCall(), and getAddrOfGlobal().

◆ getAddrOfGlobal()

◆ getAddrOfGlobalVar()

mlir::Value CIRGenModule::getAddrOfGlobalVar ( const VarDecl * d,
mlir::Type ty = {},
ForDefinition_t isForDefinition = NotForDefinition )

Return the mlir::Value for the address of the given global variable.

If Ty is non-null and if the global doesn't exist, then it will be created with the specified type instead of whatever the normal requested type would be. If IsForDefinition is true, it is guaranteed that an actual global with type Ty will be returned, not conversion of a variable with the same mangled name but some other type.

If ty is non-null and if the global doesn't exist, then it will be created with the specified type instead of whatever the normal requested type would be. If isForDefinition is true, it is guaranteed that an actual global with type ty will be returned, not conversion of a variable with the same mangled name but some other type.

Definition at line 683 of file CIRGenModule.cpp.

References clang::CIRGen::CIRGenTypes::convertTypeForMem(), getLoc(), getOrCreateCIRGlobal(), clang::VarDecl::getSourceRange(), clang::ValueDecl::getType(), getTypes(), clang::VarDecl::hasGlobalStorage(), and cir::MissingFeatures::opGlobalThreadLocal().

Referenced by emitGlobal(), emitGlobalVarDeclLValue(), getAddrOfGlobal(), and handleCXXStaticMemberVarInstantiation().

◆ getAddrOfGlobalVarAttr()

cir::GlobalViewAttr CIRGenModule::getAddrOfGlobalVarAttr ( const VarDecl * d)

◆ getAddrOfRTTIDescriptor()

mlir::Attribute CIRGenModule::getAddrOfRTTIDescriptor ( mlir::Location loc,
QualType ty,
bool forEH = false )

Get the address of the RTTI descriptor for the given type.

Definition at line 2166 of file CIRGenModule.cpp.

References errorNYI(), and shouldEmitRTTI().

◆ getASTContext()

◆ getBuilder()

CIRGenBuilderTy & clang::CIRGen::CIRGenModule::getBuilder ( )
inline

◆ getBuiltinLibFunction()

cir::FuncOp CIRGenModule::getBuiltinLibFunction ( const FunctionDecl * fd,
unsigned builtinID )

Given a builtin id for a function like "__builtin_fabsf", return a Function* for "fabsf".

Definition at line 446 of file CIRGenBuiltin.cpp.

References cir::MissingFeatures::asmLabelAttr(), convertType(), getOrCreateCIRFunction(), clang::ValueDecl::getType(), and clang::ast_matchers::type.

◆ getCIRLinkageForDeclarator()

◆ getCIRLinkageVarDefinition()

cir::GlobalLinkageKind CIRGenModule::getCIRLinkageVarDefinition ( const VarDecl * vd,
bool isConstant )

Definition at line 1249 of file CIRGenModule.cpp.

References getCIRLinkageForDeclarator().

Referenced by emitGlobalVarDefinition().

◆ getClassPointerAlignment()

CharUnits CIRGenModule::getClassPointerAlignment ( const clang::CXXRecordDecl * rd)

Return the best known alignment for an unknown pointer to a particular class.

FIXME: this could likely be a common helper and not necessarily related with codegen.

Return the best known alignment for an unknown pointer to a particular class.

Definition at line 130 of file CIRGenModule.cpp.

References clang::CXXRecordDecl::hasDefinition(), clang::CXXRecordDecl::isEffectivelyFinal(), and clang::CharUnits::One().

◆ getCodeGenOpts()

const clang::CodeGenOptions & clang::CIRGen::CIRGenModule::getCodeGenOpts ( ) const
inline

◆ getConstantArrayFromStringLiteral()

mlir::Attribute CIRGenModule::getConstantArrayFromStringLiteral ( const StringLiteral * e)

◆ getCXXABI()

◆ getDataLayout()

const cir::CIRDataLayout clang::CIRGen::CIRGenModule::getDataLayout ( ) const
inline

Definition at line 112 of file CIRGenModule.h.

Referenced by isFullSizeType().

◆ getDiags()

clang::DiagnosticsEngine & clang::CIRGen::CIRGenModule::getDiags ( ) const
inline

Definition at line 105 of file CIRGenModule.h.

Referenced by collectClobbers().

◆ getDynamicOffsetAlignment()

CharUnits CIRGenModule::getDynamicOffsetAlignment ( CharUnits actualBaseAlign,
const CXXRecordDecl * baseDecl,
CharUnits expectedTargetAlign )

◆ getFunctionLinkage()

◆ getGlobalForStringLiteral()

cir::GlobalOp CIRGenModule::getGlobalForStringLiteral ( const StringLiteral * s,
llvm::StringRef name = ".str" )

Return a global symbol reference to a constant array for the given string literal.

Return a pointer to a constant array for the given string literal.

Definition at line 1317 of file CIRGenModule.cpp.

References c, errorNYI(), generateStringLiteral(), getConstantArrayFromStringLiteral(), getCXXABI(), getLangOpts(), getLoc(), getUniqueGlobalName(), s, cir::MissingFeatures::sanitizers(), and setDSOLocal().

Referenced by getAddrOfConstantStringFromLiteral().

◆ getGlobalValue()

mlir::Operation * CIRGenModule::getGlobalValue ( llvm::StringRef ref)

◆ getGlobalVisibilityAttrFromDecl()

cir::VisibilityAttr CIRGenModule::getGlobalVisibilityAttrFromDecl ( const Decl * decl)

◆ getGlobalVisibilityKindFromClangVisibility()

cir::VisibilityKind CIRGenModule::getGlobalVisibilityKindFromClangVisibility ( clang::VisibilityAttr::VisibilityType visibility)
static

Definition at line 2078 of file CIRGenModule.cpp.

Referenced by getGlobalVisibilityAttrFromDecl().

◆ getItaniumVTableContext() [1/2]

ItaniumVTableContext & clang::CIRGen::CIRGenModule::getItaniumVTableContext ( )
inline

Definition at line 317 of file CIRGenModule.h.

◆ getItaniumVTableContext() [2/2]

const ItaniumVTableContext & clang::CIRGen::CIRGenModule::getItaniumVTableContext ( ) const
inline

Definition at line 320 of file CIRGenModule.h.

◆ getLangOpts()

◆ getLoc() [1/2]

◆ getLoc() [2/2]

mlir::Location CIRGenModule::getLoc ( clang::SourceRange cRange)

◆ getMangledName()

◆ getMLIRContext()

mlir::MLIRContext & clang::CIRGen::CIRGenModule::getMLIRContext ( )
inline

◆ getMLIRVisibility()

mlir::SymbolTable::Visibility CIRGenModule::getMLIRVisibility ( cir::GlobalOp op)
static

◆ getMLIRVisibilityFromCIRLinkage()

mlir::SymbolTable::Visibility CIRGenModule::getMLIRVisibilityFromCIRLinkage ( cir::GlobalLinkageKind GLK)
static

Visibility and Linkage

Definition at line 2056 of file CIRGenModule.cpp.

Referenced by emitGlobalVarDefinition(), getMLIRVisibility(), getOrCreateStaticVarDecl(), and setFunctionLinkage().

◆ getModule()

mlir::ModuleOp clang::CIRGen::CIRGenModule::getModule ( ) const
inline

Definition at line 100 of file CIRGenModule.h.

Referenced by createGlobalOp(), emitGlobalDecl(), and getOrCreateStaticVarDecl().

◆ getNaturalTypeAlignment()

◆ getOrCreateCIRFunction()

◆ getOrCreateCIRGlobal() [1/2]

cir::GlobalOp CIRGenModule::getOrCreateCIRGlobal ( const VarDecl * d,
mlir::Type ty,
ForDefinition_t isForDefinition )

◆ getOrCreateCIRGlobal() [2/2]

cir::GlobalOp clang::CIRGen::CIRGenModule::getOrCreateCIRGlobal ( llvm::StringRef mangledName,
mlir::Type ty,
LangAS langAS,
const VarDecl * d,
ForDefinition_t isForDefinition )

If the specified mangled name is not in the module, create and return an mlir::GlobalOp value.

Referenced by emitGlobalVarDefinition(), getAddrOfGlobalVar(), getAddrOfGlobalVarAttr(), and getOrCreateCIRGlobal().

◆ getOrCreateStaticVarDecl()

◆ getSize()

mlir::IntegerAttr clang::CIRGen::CIRGenModule::getSize ( CharUnits size)
inline

Definition at line 449 of file CIRGenModule.h.

Referenced by createOrReplaceCXXRuntimeVariable(), and generateStringLiteral().

◆ getStaticLocalDeclAddress()

cir::GlobalOp clang::CIRGen::CIRGenModule::getStaticLocalDeclAddress ( const VarDecl * d)
inline

Definition at line 131 of file CIRGenModule.h.

References staticLocalDeclMap.

Referenced by getOrCreateStaticVarDecl().

◆ getTarget()

const clang::TargetInfo & clang::CIRGen::CIRGenModule::getTarget ( ) const
inline

◆ getTargetCIRGenInfo()

◆ getTriple()

const llvm::Triple & clang::CIRGen::CIRGenModule::getTriple ( ) const
inline

Definition at line 459 of file CIRGenModule.h.

Referenced by CIRGenModule(), shouldAssumeDSOLocal(), shouldEmitRTTI(), and supportsCOMDAT().

◆ getTypes()

◆ getUniqueGlobalName()

std::string CIRGenModule::getUniqueGlobalName ( const std::string & baseName)

Definition at line 1300 of file CIRGenModule.cpp.

References cgGlobalNames.

Referenced by getGlobalForStringLiteral().

◆ getVBaseAlignment()

clang::CharUnits CIRGenModule::getVBaseAlignment ( CharUnits derivedAlign,
const CXXRecordDecl * derived,
const CXXRecordDecl * vbase )

Returns the assumed alignment of a virtual base of a class.

Return the best known alignment for a pointer to a virtual base, given the alignment of a pointer to the derived class.

Definition at line 591 of file CIRGenClass.cpp.

References getASTContext(), clang::ASTContext::getASTRecordLayout(), getDynamicOffsetAlignment(), clang::ASTRecordLayout::getNonVirtualAlignment(), and clang::TagDecl::isCompleteDefinition().

◆ getVTableComponentType()

mlir::Type CIRGenModule::getVTableComponentType ( )

Definition at line 29 of file CIRGenVTables.cpp.

References cir::MissingFeatures::vtableRelativeLayout().

◆ getVTableLinkage()

cir::GlobalLinkageKind CIRGenModule::getVTableLinkage ( const CXXRecordDecl * rd)

◆ getVTables()

CIRGenVTables & clang::CIRGen::CIRGenModule::getVTables ( )
inline

Definition at line 315 of file CIRGenModule.h.

Referenced by emitGlobalDefinition().

◆ handleCXXStaticMemberVarInstantiation()

void CIRGenModule::handleCXXStaticMemberVarInstantiation ( VarDecl * vd)

◆ mayBeEmittedEagerly()

bool CIRGenModule::mayBeEmittedEagerly ( const clang::ValueDecl * d)

Determine whether the definition can be emitted eagerly, or should be delayed until the end of the translation unit.

This is relevant for definitions whose linkage can change, e.g. implicit function instantiations which may later be explicitly instantiated.

Definition at line 1663 of file CIRGenModule.cpp.

References errorNYI(), clang::ValueDecl::getType(), clang::isa(), clang::QualType::isConstantStorage(), clang::TSK_ImplicitInstantiation, and clang::ASTContext::WeakUnknown.

Referenced by emitGlobal().

◆ maybeSetTrivialComdat()

void CIRGenModule::maybeSetTrivialComdat ( const clang::Decl & d,
mlir::Operation * op )

◆ mustBeEmitted()

bool CIRGenModule::mustBeEmitted ( const clang::ValueDecl * d)

Determine whether the definition must be emitted; if this returns false, the definition can be emitted lazily if it's used.

Definition at line 1646 of file CIRGenModule.cpp.

References clang::ASTContext::DeclMustBeEmitted(), getASTContext(), clang::SD_Static, and clang::SD_Thread.

Referenced by emitGlobal(), and emitTentativeDefinition().

◆ release()

void CIRGenModule::release ( )

Definition at line 2104 of file CIRGenModule.cpp.

References cir::MissingFeatures::cgmRelease(), and emitDeferred().

◆ replaceUsesOfNonProtoTypeWithRealFunction()

void CIRGenModule::replaceUsesOfNonProtoTypeWithRealFunction ( mlir::Operation * old,
cir::FuncOp newFn )

This function is called when we implement a function with no prototype, e.g.

"int foo() {}". If there are existing call uses of the old function in the module, this adjusts them to call the new function directly.

This is not just a cleanup: the always_inline pass requires direct calls to functions to be able to inline them. If there is a bitcast in the way, it won't inline them. Instcombine normally deletes these calls, but it isn't run at -O0.

Definition at line 1202 of file CIRGenModule.cpp.

References errorNYI(), cir::MissingFeatures::opFuncExceptions(), cir::MissingFeatures::opFuncOperandBundles(), and cir::MissingFeatures::opFuncParameterAttributes().

Referenced by getOrCreateCIRFunction().

◆ setCommonAttributes()

void CIRGenModule::setCommonAttributes ( GlobalDecl gd,
mlir::Operation * op )

Set attributes which are common to any form of a global definition (alias, Objective-C method, function, global variable).

NOTE: This should only be called for definitions.

Definition at line 502 of file CIRGenModule.cpp.

References clang::CIRGen::Decl, cir::MissingFeatures::defaultVisibility(), clang::GlobalDecl::getDecl(), cir::MissingFeatures::opGlobalUsedOrCompilerUsed(), and setGVProperties().

Referenced by emitAliasForGlobal().

◆ setDSOLocal() [1/2]

void CIRGenModule::setDSOLocal ( cir::CIRGlobalValueInterface gv) const

Definition at line 1818 of file CIRGenModule.cpp.

References shouldAssumeDSOLocal().

◆ setDSOLocal() [2/2]

void CIRGenModule::setDSOLocal ( mlir::Operation * op) const

◆ setFunctionAttributes()

void CIRGenModule::setFunctionAttributes ( GlobalDecl gd,
cir::FuncOp f,
bool isIncompleteFunction,
bool isThunk )

◆ setFunctionLinkage()

void clang::CIRGen::CIRGenModule::setFunctionLinkage ( GlobalDecl gd,
cir::FuncOp f )
inline

◆ setGlobalVisibility()

void CIRGenModule::setGlobalVisibility ( mlir::Operation * op,
const NamedDecl * d ) const

Set the visibility for the given global.

Definition at line 1813 of file CIRGenModule.cpp.

References cir::MissingFeatures::opGlobalVisibility().

Referenced by setGVPropertiesAux().

◆ setGVProperties()

void CIRGenModule::setGVProperties ( mlir::Operation * op,
const NamedDecl * d ) const

Set visibility, dllimport/dllexport and dso_local.

This must be called after dllimport/dllexport is set.

Definition at line 1827 of file CIRGenModule.cpp.

References cir::MissingFeatures::opGlobalDLLImportExport(), and setGVPropertiesAux().

Referenced by emitGlobalFunctionDefinition(), getOrCreateStaticVarDecl(), and setCommonAttributes().

◆ setGVPropertiesAux()

void CIRGenModule::setGVPropertiesAux ( mlir::Operation * op,
const NamedDecl * d ) const

◆ setInitializer()

void CIRGenModule::setInitializer ( cir::GlobalOp & op,
mlir::Attribute value )
static

◆ setStaticLocalDeclAddress()

void clang::CIRGen::CIRGenModule::setStaticLocalDeclAddress ( const VarDecl * d,
cir::GlobalOp c )
inline

Definition at line 135 of file CIRGenModule.h.

References c, and staticLocalDeclMap.

◆ shouldEmitRTTI()

bool clang::CIRGen::CIRGenModule::shouldEmitRTTI ( bool forEH = false)
inline

Definition at line 364 of file CIRGenModule.h.

References getLangOpts(), and getTriple().

Referenced by getAddrOfRTTIDescriptor().

◆ shouldZeroInitPadding()

bool clang::CIRGen::CIRGenModule::shouldZeroInitPadding ( ) const
inline

Definition at line 156 of file CIRGenModule.h.

References getLangOpts().

◆ supportsCOMDAT()

bool CIRGenModule::supportsCOMDAT ( ) const

◆ updateCompletedType()

void CIRGenModule::updateCompletedType ( const clang::TagDecl * td)

Definition at line 936 of file CIRGenModule.cpp.

◆ verifyModule()

bool CIRGenModule::verifyModule ( ) const

Definition at line 2159 of file CIRGenModule.cpp.

Member Data Documentation

◆ cgGlobalNames

llvm::StringMap<unsigned> clang::CIRGen::CIRGenModule::cgGlobalNames

Definition at line 206 of file CIRGenModule.h.

Referenced by getUniqueGlobalName().

◆ deferredDecls

std::map<llvm::StringRef, clang::GlobalDecl> clang::CIRGen::CIRGenModule::deferredDecls

This contains all the decls which have definitions but which are deferred for emission and therefore should only be output if they are actually used.

If a decl is in this, then it is known to have not been referenced yet.

Definition at line 328 of file CIRGenModule.h.

Referenced by emitGlobal(), emitTentativeDefinition(), and getOrCreateCIRFunction().

◆ deferredDeclsToEmit

std::vector<clang::GlobalDecl> clang::CIRGen::CIRGenModule::deferredDeclsToEmit

Definition at line 332 of file CIRGenModule.h.

Referenced by addDeferredDeclToEmit(), and emitDeferred().

◆ lastGlobalOp

mlir::Operation* clang::CIRGen::CIRGenModule::lastGlobalOp = nullptr

Handling globals

Definition at line 122 of file CIRGenModule.h.

Referenced by createGlobalOp().

◆ staticLocalDeclMap

llvm::DenseMap<const Decl *, cir::GlobalOp> clang::CIRGen::CIRGenModule::staticLocalDeclMap

Definition at line 127 of file CIRGenModule.h.

Referenced by getStaticLocalDeclAddress(), and setStaticLocalDeclAddress().


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