clang 19.0.0git
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
clang::CodeGen::ConstantEmitter Class Reference

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

Public Member Functions

 ConstantEmitter (CodeGenModule &CGM, CodeGenFunction *CGF=nullptr)
 
 ConstantEmitter (CodeGenFunction &CGF)
 Initialize this emission in the context of the given function.
 
 ConstantEmitter (const ConstantEmitter &other)=delete
 
ConstantEmitteroperator= (const ConstantEmitter &other)=delete
 
 ~ConstantEmitter ()
 
bool isAbstract () const
 Is the current emission context abstract?
 
bool isInConstantContext () const
 
void setInConstantContext (bool var)
 
llvm::Constant * tryEmitForInitializer (const VarDecl &D)
 Try to emit the initiaizer of the given declaration as an abstract constant.
 
llvm::Constant * tryEmitForInitializer (const Expr *E, LangAS destAddrSpace, QualType destType)
 
llvm::Constant * emitForInitializer (const APValue &value, LangAS destAddrSpace, QualType destType)
 
void finalize (llvm::GlobalVariable *global)
 
llvm::Constant * tryEmitAbstractForInitializer (const VarDecl &D)
 Try to emit the initializer of the given declaration as an abstract constant.
 
llvm::Constant * emitAbstract (const Expr *E, QualType T)
 Emit the result of the given expression as an abstract constant, asserting that it succeeded.
 
llvm::Constant * emitAbstract (SourceLocation loc, const APValue &value, QualType T)
 
llvm::Constant * tryEmitAbstract (const Expr *E, QualType T)
 Try to emit the result of the given expression as an abstract constant.
 
llvm::Constant * tryEmitAbstractForMemory (const Expr *E, QualType T)
 
llvm::Constant * tryEmitAbstract (const APValue &value, QualType T)
 
llvm::Constant * tryEmitAbstractForMemory (const APValue &value, QualType T)
 
llvm::Constant * tryEmitConstantExpr (const ConstantExpr *CE)
 
llvm::Constant * emitNullForMemory (QualType T)
 
llvm::Constant * emitForMemory (llvm::Constant *C, QualType T)
 
llvm::Constant * tryEmitPrivateForVarInit (const VarDecl &D)
 
llvm::Constant * tryEmitPrivate (const Expr *E, QualType T)
 
llvm::Constant * tryEmitPrivateForMemory (const Expr *E, QualType T)
 
llvm::Constant * tryEmitPrivate (const APValue &value, QualType T)
 
llvm::Constant * tryEmitPrivateForMemory (const APValue &value, QualType T)
 
llvm::GlobalValue * getCurrentAddrPrivate ()
 Get the address of the current location.
 
void registerCurrentAddrPrivate (llvm::Constant *signal, llvm::GlobalValue *placeholder)
 Register a 'signal' value with the emitter to inform it where to resolve a placeholder.
 

Static Public Member Functions

static llvm::Constant * emitNullForMemory (CodeGenModule &CGM, QualType T)
 
static llvm::Constant * emitForMemory (CodeGenModule &CGM, llvm::Constant *C, QualType T)
 

Public Attributes

CodeGenModuleCGM
 
CodeGenFunction *const CGF
 

Detailed Description

Definition at line 23 of file ConstantEmitter.h.

Constructor & Destructor Documentation

◆ ConstantEmitter() [1/3]

clang::CodeGen::ConstantEmitter::ConstantEmitter ( CodeGenModule CGM,
CodeGenFunction CGF = nullptr 
)
inline

Definition at line 51 of file ConstantEmitter.h.

◆ ConstantEmitter() [2/3]

clang::CodeGen::ConstantEmitter::ConstantEmitter ( CodeGenFunction CGF)
inline

Initialize this emission in the context of the given function.

Use this if the expression might contain contextual references like block addresses or PredefinedExprs.

Definition at line 57 of file ConstantEmitter.h.

◆ ConstantEmitter() [3/3]

clang::CodeGen::ConstantEmitter::ConstantEmitter ( const ConstantEmitter other)
delete

◆ ~ConstantEmitter()

ConstantEmitter::~ConstantEmitter ( )

Definition at line 1663 of file CGExprConstant.cpp.

Member Function Documentation

◆ emitAbstract() [1/2]

llvm::Constant * ConstantEmitter::emitAbstract ( const Expr E,
QualType  T 
)

Emit the result of the given expression as an abstract constant, asserting that it succeeded.

This is only safe to do when the expression is known to be a constant expression with either a fairly simple type or a known simple form.

Definition at line 1450 of file CGExprConstant.cpp.

References clang::C, CGM, clang::CodeGen::CodeGenModule::EmitNullConstant(), clang::CodeGen::CodeGenModule::Error(), clang::Expr::getExprLoc(), and tryEmitPrivate().

Referenced by clang::CodeGen::CodeGenModule::createOpenCLIntToSamplerConversion(), clang::CodeGen::CodeGenModule::EmitAnnotationArgs(), and tryEmitConstantExpr().

◆ emitAbstract() [2/2]

llvm::Constant * ConstantEmitter::emitAbstract ( SourceLocation  loc,
const APValue value,
QualType  T 
)

◆ emitForInitializer()

llvm::Constant * ConstantEmitter::emitForInitializer ( const APValue value,
LangAS  destAddrSpace,
QualType  destType 
)

Definition at line 1488 of file CGExprConstant.cpp.

References clang::C, and tryEmitPrivateForMemory().

◆ emitForMemory() [1/2]

llvm::Constant * ConstantEmitter::emitForMemory ( CodeGenModule CGM,
llvm::Constant *  C,
QualType  T 
)
static

◆ emitForMemory() [2/2]

llvm::Constant * clang::CodeGen::ConstantEmitter::emitForMemory ( llvm::Constant *  C,
QualType  T 
)
inline

◆ emitNullForMemory() [1/2]

llvm::Constant * ConstantEmitter::emitNullForMemory ( CodeGenModule CGM,
QualType  T 
)
static

◆ emitNullForMemory() [2/2]

llvm::Constant * clang::CodeGen::ConstantEmitter::emitNullForMemory ( QualType  T)
inline

◆ finalize()

void ConstantEmitter::finalize ( llvm::GlobalVariable *  global)

Definition at line 1647 of file CGExprConstant.cpp.

References CGM.

Referenced by clang::CodeGen::CodeGenModule::GetOrCreateLLVMGlobal().

◆ getCurrentAddrPrivate()

llvm::GlobalValue * ConstantEmitter::getCurrentAddrPrivate ( )

Get the address of the current location.

This is a constant that will resolve, after finalization, to the address of the 'signal' value that is registered with the emitter later.

Definition at line 1497 of file CGExprConstant.cpp.

References CGM, clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::CodeGenModule::getModule(), clang::ASTContext::getTargetAddressSpace(), and clang::CodeGen::CodeGenTypeCache::Int8Ty.

◆ isAbstract()

bool clang::CodeGen::ConstantEmitter::isAbstract ( ) const
inline

Is the current emission context abstract?

Definition at line 66 of file ConstantEmitter.h.

◆ isInConstantContext()

bool clang::CodeGen::ConstantEmitter::isInConstantContext ( ) const
inline

Definition at line 70 of file ConstantEmitter.h.

◆ operator=()

ConstantEmitter & clang::CodeGen::ConstantEmitter::operator= ( const ConstantEmitter other)
delete

◆ registerCurrentAddrPrivate()

void ConstantEmitter::registerCurrentAddrPrivate ( llvm::Constant *  signal,
llvm::GlobalValue *  placeholder 
)

Register a 'signal' value with the emitter to inform it where to resolve a placeholder.

The signal value must be unique in the initializer; it might, for example, be the address of a global that refers to the current-address value in its own initializer.

Uses of the placeholder must be properly anchored before finalizing the emitter, e.g. by being installed as the initializer of a global variable. That is, it must be possible to replaceAllUsesWith the placeholder with the proper address of the signal.

Definition at line 1517 of file CGExprConstant.cpp.

◆ setInConstantContext()

void clang::CodeGen::ConstantEmitter::setInConstantContext ( bool  var)
inline

Definition at line 71 of file ConstantEmitter.h.

◆ tryEmitAbstract() [1/2]

llvm::Constant * ConstantEmitter::tryEmitAbstract ( const APValue value,
QualType  T 
)

Definition at line 1432 of file CGExprConstant.cpp.

References clang::C, and tryEmitPrivate().

◆ tryEmitAbstract() [2/2]

llvm::Constant * ConstantEmitter::tryEmitAbstract ( const Expr E,
QualType  T 
)

Try to emit the result of the given expression as an abstract constant.

Definition at line 1425 of file CGExprConstant.cpp.

References clang::C, and tryEmitPrivate().

Referenced by EmitCXXNewAllocSize(), and tryEmitAbstractForMemory().

◆ tryEmitAbstractForInitializer()

llvm::Constant * ConstantEmitter::tryEmitAbstractForInitializer ( const VarDecl D)

Try to emit the initializer of the given declaration as an abstract constant.

Definition at line 1418 of file CGExprConstant.cpp.

References clang::C, and tryEmitPrivateForVarInit().

Referenced by tryCaptureAsConstant().

◆ tryEmitAbstractForMemory() [1/2]

llvm::Constant * ConstantEmitter::tryEmitAbstractForMemory ( const APValue value,
QualType  T 
)

Definition at line 1720 of file CGExprConstant.cpp.

References clang::C, CGM, emitForMemory(), getNonMemoryType(), and tryEmitAbstract().

◆ tryEmitAbstractForMemory() [2/2]

llvm::Constant * ConstantEmitter::tryEmitAbstractForMemory ( const Expr E,
QualType  T 
)

Definition at line 1713 of file CGExprConstant.cpp.

References clang::C, CGM, emitForMemory(), getNonMemoryType(), and tryEmitAbstract().

Referenced by tryEmitPrivate().

◆ tryEmitConstantExpr()

llvm::Constant * ConstantEmitter::tryEmitConstantExpr ( const ConstantExpr CE)

◆ tryEmitForInitializer() [1/2]

llvm::Constant * ConstantEmitter::tryEmitForInitializer ( const Expr E,
LangAS  destAddrSpace,
QualType  destType 
)

Definition at line 1481 of file CGExprConstant.cpp.

References tryEmitPrivateForMemory().

◆ tryEmitForInitializer() [2/2]

llvm::Constant * ConstantEmitter::tryEmitForInitializer ( const VarDecl D)

Try to emit the initiaizer of the given declaration as an abstract constant.

If this succeeds, the emission must be finalized.

Definition at line 1476 of file CGExprConstant.cpp.

References clang::QualType::getAddressSpace(), clang::ValueDecl::getType(), and tryEmitPrivateForVarInit().

Referenced by clang::CodeGen::CodeGenModule::GetOrCreateLLVMGlobal().

◆ tryEmitPrivate() [1/2]

llvm::Constant * ConstantEmitter::tryEmitPrivate ( const APValue value,
QualType  T 
)

◆ tryEmitPrivate() [2/2]

llvm::Constant * ConstantEmitter::tryEmitPrivate ( const Expr E,
QualType  T 
)

◆ tryEmitPrivateForMemory() [1/2]

llvm::Constant * ConstantEmitter::tryEmitPrivateForMemory ( const APValue value,
QualType  T 
)

Definition at line 1734 of file CGExprConstant.cpp.

References clang::C, CGM, emitForMemory(), getNonMemoryType(), and tryEmitPrivate().

◆ tryEmitPrivateForMemory() [2/2]

llvm::Constant * ConstantEmitter::tryEmitPrivateForMemory ( const Expr E,
QualType  T 
)

◆ tryEmitPrivateForVarInit()

llvm::Constant * ConstantEmitter::tryEmitPrivateForVarInit ( const VarDecl D)

Member Data Documentation

◆ CGF

CodeGenFunction* const clang::CodeGen::ConstantEmitter::CGF

Definition at line 26 of file ConstantEmitter.h.

◆ CGM

CodeGenModule& clang::CodeGen::ConstantEmitter::CGM

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