clang 20.0.0git
|
#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 | |
ConstantEmitter & | operator= (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, bool EnablePtrAuthFunctionTypeDiscrimination=true) |
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 * | tryEmitConstantSignedPointer (llvm::Constant *Ptr, PointerAuthQualifier Auth) |
Try to emit a constant signed pointer, given a raw pointer and the destination ptrauth qualifier. | |
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, bool EnablePtrAuthFunctionTypeDiscrimination=true) |
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 | |
CodeGenModule & | CGM |
CodeGenFunction *const | CGF |
Definition at line 23 of file ConstantEmitter.h.
|
inline |
Definition at line 51 of file ConstantEmitter.h.
|
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.
|
delete |
ConstantEmitter::~ConstantEmitter | ( | ) |
Definition at line 1842 of file CGExprConstant.cpp.
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 1627 of file CGExprConstant.cpp.
References clang::C, CGM, E, 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().
llvm::Constant * ConstantEmitter::emitAbstract | ( | SourceLocation | loc, |
const APValue & | value, | ||
QualType | T, | ||
bool | EnablePtrAuthFunctionTypeDiscrimination = true |
||
) |
Definition at line 1640 of file CGExprConstant.cpp.
References clang::C, CGM, clang::CodeGen::CodeGenModule::EmitNullConstant(), clang::CodeGen::CodeGenModule::Error(), and tryEmitPrivate().
llvm::Constant * ConstantEmitter::emitForInitializer | ( | const APValue & | value, |
LangAS | destAddrSpace, | ||
QualType | destType | ||
) |
Definition at line 1667 of file CGExprConstant.cpp.
References clang::C, and tryEmitPrivateForMemory().
|
static |
Definition at line 1956 of file CGExprConstant.cpp.
References clang::C, CGM, clang::CodeGen::CodeGenTypes::convertTypeForLoadStore(), clang::CodeGen::CodeGenTypes::ConvertTypeForMem(), emitForMemory(), clang::Type::getAs(), clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::CodeGenModule::getDataLayout(), clang::CodeGen::CodeGenModule::getTypes(), clang::ASTContext::getTypeSize(), clang::CodeGen::CodeGenTypeCache::Int8Ty, clang::Type::isBitIntType(), clang::Type::isSignedIntegerOrEnumerationType(), and clang::CodeGen::CodeGenTypes::typeRequiresSplitIntoByteArray().
|
inline |
Definition at line 125 of file ConstantEmitter.h.
References clang::C, CGM, emitForMemory(), and clang::T.
Referenced by emitForMemory(), emitNullForMemory(), tryEmitAbstractForMemory(), tryEmitPrivateForMemory(), and tryEmitPrivateForVarInit().
|
static |
Definition at line 2691 of file CGExprConstant.cpp.
References CGM, emitForMemory(), clang::CodeGen::CodeGenModule::EmitNullConstant(), and clang::T.
|
inline |
Definition at line 122 of file ConstantEmitter.h.
References CGM, emitNullForMemory(), and clang::T.
Referenced by clang::CodeGen::CodeGenModule::EmitNullConstant(), and emitNullForMemory().
void ConstantEmitter::finalize | ( | llvm::GlobalVariable * | global | ) |
Definition at line 1826 of file CGExprConstant.cpp.
References CGM.
Referenced by clang::CodeGen::CodeGenModule::GetOrCreateLLVMGlobal().
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 1676 of file CGExprConstant.cpp.
References CGM, clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::CodeGenModule::getModule(), clang::ASTContext::getTargetAddressSpace(), and clang::CodeGen::CodeGenTypeCache::Int8Ty.
Referenced by tryEmitConstantSignedPointer().
|
inline |
Is the current emission context abstract?
Definition at line 66 of file ConstantEmitter.h.
Referenced by tryEmitConstantSignedPointer().
|
inline |
Definition at line 70 of file ConstantEmitter.h.
|
delete |
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 1696 of file CGExprConstant.cpp.
Referenced by tryEmitConstantSignedPointer().
|
inline |
Definition at line 71 of file ConstantEmitter.h.
Definition at line 1609 of file CGExprConstant.cpp.
References clang::C, and tryEmitPrivate().
Try to emit the result of the given expression as an abstract constant.
Definition at line 1602 of file CGExprConstant.cpp.
References clang::C, E, and tryEmitPrivate().
Referenced by EmitCXXNewAllocSize(), and tryEmitAbstractForMemory().
llvm::Constant * ConstantEmitter::tryEmitAbstractForInitializer | ( | const VarDecl & | D | ) |
Try to emit the initializer of the given declaration as an abstract constant.
Definition at line 1595 of file CGExprConstant.cpp.
References clang::C, D, and tryEmitPrivateForVarInit().
Referenced by tryCaptureAsConstant().
Definition at line 1898 of file CGExprConstant.cpp.
References clang::C, CGM, emitForMemory(), getNonMemoryType(), and tryEmitAbstract().
Definition at line 1891 of file CGExprConstant.cpp.
References clang::C, CGM, E, emitForMemory(), getNonMemoryType(), and tryEmitAbstract().
Referenced by tryEmitPrivate().
llvm::Constant * ConstantEmitter::tryEmitConstantExpr | ( | const ConstantExpr * | CE | ) |
Definition at line 1615 of file CGExprConstant.cpp.
References CGM, emitAbstract(), clang::ConstantExpr::getAPValueResult(), clang::ConstantExpr::getBeginLoc(), clang::CodeGen::CodeGenModule::getContext(), clang::ASTContext::getLValueReferenceType(), clang::Expr::getType(), clang::ConstantExpr::hasAPValueResult(), and clang::Expr::isGLValue().
llvm::Constant * ConstantEmitter::tryEmitConstantSignedPointer | ( | llvm::Constant * | UnsignedPointer, |
PointerAuthQualifier | Schema | ||
) |
Try to emit a constant signed pointer, given a raw pointer and the destination ptrauth qualifier.
This can fail if the qualifier needs address discrimination and the emitter is in an abstract mode.
Definition at line 1925 of file CGExprConstant.cpp.
References CGM, clang::CodeGen::CodeGenModule::getConstantSignedPointer(), getCurrentAddrPrivate(), clang::PointerAuthQualifier::getExtraDiscriminator(), clang::PointerAuthQualifier::getKey(), clang::PointerAuthQualifier::hasKeyNone(), clang::CodeGen::CodeGenTypeCache::IntPtrTy, isAbstract(), clang::PointerAuthQualifier::isAddressDiscriminated(), and registerCurrentAddrPrivate().
llvm::Constant * ConstantEmitter::tryEmitForInitializer | ( | const Expr * | E, |
LangAS | destAddrSpace, | ||
QualType | destType | ||
) |
Definition at line 1660 of file CGExprConstant.cpp.
References E, and tryEmitPrivateForMemory().
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 1655 of file CGExprConstant.cpp.
References D, and tryEmitPrivateForVarInit().
Referenced by clang::CodeGen::CodeGenModule::GetOrCreateLLVMGlobal().
llvm::Constant * ConstantEmitter::tryEmitPrivate | ( | const APValue & | value, |
QualType | T, | ||
bool | EnablePtrAuthFunctionTypeDiscrimination = true |
||
) |
Definition at line 2410 of file CGExprConstant.cpp.
References clang::APValue::AddrLabelDiff, clang::APValue::Array, clang::C, clang::Type::castAs(), CGM, Complex, clang::APValue::ComplexFloat, clang::APValue::ComplexInt, clang::CodeGen::CodeGenTypes::ConvertType(), clang::CodeGen::CGCXXABI::EmitMemberPointer(), clang::APValue::FixedPoint, clang::APValue::Float, clang::ASTContext::getAsArrayType(), clang::CodeGen::CodeGenModule::getContext(), clang::CodeGen::CodeGenModule::getCXXABI(), clang::ArrayType::getElementType(), clang::VectorType::getElementType(), clang::APValue::getFloat(), clang::APValue::getInt(), clang::Value::getKind(), clang::ASTContext::getLangOpts(), clang::CodeGen::CodeGenModule::getLLVMContext(), clang::ASTContext::getTargetInfo(), clang::Expr::getType(), clang::CodeGen::CodeGenModule::getTypes(), clang::APValue::Indeterminate, clang::Init, clang::APValue::Int, clang::CodeGen::CodeGenTypeCache::IntPtrTy, clang::APValue::isFloat(), clang::Type::isIncompleteArrayType(), clang::APValue::isIndeterminate(), clang::APValue::isInt(), clang::APValue::LValue, clang::APValue::MemberPointer, clang::APValue::None, clang::APValue::Struct, tryEmitAbstractForMemory(), tryEmitPrivate(), tryEmitPrivateForMemory(), clang::APValue::Union, clang::TargetInfo::useFP16ConversionIntrinsics(), and clang::APValue::Vector.
Definition at line 2011 of file CGExprConstant.cpp.
References clang::C, CGM, E, clang::Expr::EvaluateAsLValue(), clang::Expr::EvaluateAsRValue(), clang::CodeGen::CodeGenModule::getContext(), clang::Type::isReferenceType(), clang::Type::isVoidType(), clang::Result, clang::Success, and tryEmitPrivate().
Referenced by emitAbstract(), tryEmitAbstract(), tryEmitPrivate(), and tryEmitPrivateForMemory().
Definition at line 1912 of file CGExprConstant.cpp.
References clang::C, CGM, emitForMemory(), getNonMemoryType(), and tryEmitPrivate().
Definition at line 1905 of file CGExprConstant.cpp.
References clang::C, CGM, E, emitForMemory(), getNonMemoryType(), and tryEmitPrivate().
Referenced by emitForInitializer(), tryEmitForInitializer(), tryEmitPrivate(), and tryEmitPrivateForVarInit().
llvm::Constant * ConstantEmitter::tryEmitPrivateForVarInit | ( | const VarDecl & | D | ) |
Definition at line 1856 of file CGExprConstant.cpp.
References clang::C, CGM, D, E, emitForMemory(), clang::CodeGen::CodeGenModule::EmitNullConstant(), clang::ASTContext::getBaseElementType(), clang::CodeGen::CodeGenModule::getContext(), getNonMemoryType(), clang::CXXConstructorDecl::isDefaultConstructor(), clang::Type::isRecordType(), clang::Type::isReferenceType(), clang::FunctionDecl::isTrivial(), and tryEmitPrivateForMemory().
Referenced by tryEmitAbstractForInitializer(), and tryEmitForInitializer().
CodeGenFunction* const clang::CodeGen::ConstantEmitter::CGF |
Definition at line 26 of file ConstantEmitter.h.
CodeGenModule& clang::CodeGen::ConstantEmitter::CGM |
Definition at line 25 of file ConstantEmitter.h.
Referenced by emitAbstract(), emitForMemory(), emitNullForMemory(), finalize(), getCurrentAddrPrivate(), tryEmitAbstractForMemory(), tryEmitConstantExpr(), tryEmitConstantSignedPointer(), tryEmitPrivate(), tryEmitPrivateForMemory(), and tryEmitPrivateForVarInit().