clang 20.0.0git
|
A concrete base class for struct and array aggregate initializer builders. More...
#include "clang/CodeGen/ConstantInitBuilder.h"
Classes | |
class | PlaceholderPosition |
An opaque class to hold the abstract position of a placeholder. More... | |
Public Member Functions | |
ConstantAggregateBuilderBase (const ConstantAggregateBuilderBase &)=delete | |
ConstantAggregateBuilderBase & | operator= (const ConstantAggregateBuilderBase &)=delete |
ConstantAggregateBuilderBase (ConstantAggregateBuilderBase &&other) | |
ConstantAggregateBuilderBase & | operator= (ConstantAggregateBuilderBase &&other)=delete |
size_t | size () const |
Return the number of elements that have been added to this struct or array. | |
bool | empty () const |
Return true if no elements have yet been added to this struct or array. | |
void | abandon () |
Abandon this builder completely. | |
void | add (llvm::Constant *value) |
Add a new value to this initializer. | |
void | addSize (CharUnits size) |
Add an integer value of type size_t. | |
void | addInt (llvm::IntegerType *intTy, uint64_t value, bool isSigned=false) |
Add an integer value of a specific type. | |
void | addSignedPointer (llvm::Constant *Pointer, const PointerAuthSchema &Schema, GlobalDecl CalleeDecl, QualType CalleeType) |
Add a signed pointer using the given pointer authentication schema. | |
void | addNullPointer (llvm::PointerType *ptrTy) |
Add a null pointer of a specific type. | |
void | addAll (llvm::ArrayRef< llvm::Constant * > values) |
Add a bunch of new values to this initializer. | |
void | addRelativeOffset (llvm::IntegerType *type, llvm::Constant *target) |
Add a relative offset to the given target address, i.e. | |
void | addRelativeOffsetToPosition (llvm::IntegerType *type, llvm::Constant *target, size_t position) |
Same as addRelativeOffset(), but instead relative to an element in this aggregate, identified by its index. | |
void | addTaggedRelativeOffset (llvm::IntegerType *type, llvm::Constant *address, unsigned tag) |
Add a relative offset to the target address, plus a small constant offset. | |
CharUnits | getNextOffsetFromGlobal () const |
Return the offset from the start of the initializer to the next position, assuming no padding is required prior to it. | |
PlaceholderPosition | addPlaceholder () |
Add a placeholder value to the structure. | |
PlaceholderPosition | addPlaceholderWithSize (llvm::Type *expectedType) |
Add a placeholder, giving the expected type that will be filled in. | |
void | fillPlaceholderWithInt (PlaceholderPosition position, llvm::IntegerType *type, uint64_t value, bool isSigned=false) |
Fill a previously-added placeholder. | |
void | fillPlaceholder (PlaceholderPosition position, llvm::Constant *value) |
Fill a previously-added placeholder. | |
llvm::Constant * | getAddrOfCurrentPosition (llvm::Type *type) |
Produce an address which will eventually point to the next position to be filled. | |
llvm::Constant * | getAddrOfPosition (llvm::Type *type, size_t position) |
Produce an address which points to a position in the aggregate being constructed. | |
llvm::ArrayRef< llvm::Constant * > | getGEPIndicesToCurrentPosition (llvm::SmallVectorImpl< llvm::Constant * > &indices) |
Protected Member Functions | |
llvm::SmallVectorImpl< llvm::Constant * > & | getBuffer () |
const llvm::SmallVectorImpl< llvm::Constant * > & | getBuffer () const |
ConstantAggregateBuilderBase (ConstantInitBuilderBase &builder, ConstantAggregateBuilderBase *parent) | |
~ConstantAggregateBuilderBase () | |
void | markFinished () |
llvm::Constant * | finishArray (llvm::Type *eltTy) |
llvm::Constant * | finishStruct (llvm::StructType *structTy) |
Protected Attributes | |
ConstantInitBuilderBase & | Builder |
ConstantAggregateBuilderBase * | Parent |
size_t | Begin |
size_t | CachedOffsetEnd = 0 |
bool | Finished = false |
bool | Frozen = false |
bool | Packed = false |
CharUnits | CachedOffsetFromGlobal |
A concrete base class for struct and array aggregate initializer builders.
Definition at line 100 of file ConstantInitBuilder.h.
|
inlineprotected |
Definition at line 119 of file ConstantInitBuilder.h.
References Frozen.
|
inlineprotected |
Definition at line 131 of file ConstantInitBuilder.h.
References Finished.
|
delete |
|
inline |
Definition at line 158 of file ConstantInitBuilder.h.
|
inline |
Abandon this builder completely.
Definition at line 183 of file ConstantInitBuilder.h.
References Begin, and markFinished().
|
inline |
Add a new value to this initializer.
Definition at line 189 of file ConstantInitBuilder.h.
References Builder, Finished, and Frozen.
Referenced by addInt(), addNullPointer(), addRelativeOffset(), addRelativeOffsetToPosition(), addSignedPointer(), addSize(), and addTaggedRelativeOffset().
|
inline |
Add a bunch of new values to this initializer.
Definition at line 216 of file ConstantInitBuilder.h.
|
inline |
Add an integer value of a specific type.
Definition at line 200 of file ConstantInitBuilder.h.
References add().
|
inline |
Add a null pointer of a specific type.
Definition at line 211 of file ConstantInitBuilder.h.
References add().
|
inline |
Add a placeholder value to the structure.
The returned position can be used to set the value later; it will not be invalidated by any intermediate operations except (1) filling the same position or (2) finishing the entire builder.
This is useful for emitting certain kinds of structure which contain some sort of summary field, generally a count, before any of the data. By emitting a placeholder first, the structure can be emitted eagerly.
Definition at line 281 of file ConstantInitBuilder.h.
References Builder, Finished, and Frozen.
Referenced by addPlaceholderWithSize().
ConstantAggregateBuilderBase::PlaceholderPosition ConstantAggregateBuilderBase::addPlaceholderWithSize | ( | llvm::Type * | expectedType | ) |
Add a placeholder, giving the expected type that will be filled in.
Definition at line 202 of file ConstantInitBuilder.cpp.
References addPlaceholder(), clang::CharUnits::alignTo(), Builder, CachedOffsetEnd, CachedOffsetFromGlobal, clang::CharUnits::fromQuantity(), clang::CodeGen::CodeGenModule::getDataLayout(), getNextOffsetFromGlobal(), Packed, and clang::ast_matchers::type.
|
inline |
Add a relative offset to the given target address, i.e.
the static difference between the target address and the address of the relative offset. The target must be known to be defined in the current linkage unit. The offset will have the given integer type, which must be no wider than intptr_t. Some targets may not fully support this operation.
Definition at line 228 of file ConstantInitBuilder.h.
References add(), and clang::ast_matchers::type.
|
inline |
Same as addRelativeOffset(), but instead relative to an element in this aggregate, identified by its index.
Definition at line 234 of file ConstantInitBuilder.h.
References add(), and clang::ast_matchers::type.
void ConstantAggregateBuilderBase::addSignedPointer | ( | llvm::Constant * | Pointer, |
const PointerAuthSchema & | Schema, | ||
GlobalDecl | CalleeDecl, | ||
QualType | CalleeType | ||
) |
Add a signed pointer using the given pointer authentication schema.
Sign the given pointer and add it to the constant initializer currently being built.
Definition at line 302 of file ConstantInitBuilder.cpp.
References add(), Builder, getAddrOfCurrentPosition(), clang::CodeGen::CodeGenModule::getConstantSignedPointer(), clang::PointerAuthSchema::isAddressDiscriminated(), Pointer, and clang::CodeGen::CodeGenModule::shouldSignPointer().
void ConstantAggregateBuilderBase::addSize | ( | CharUnits | size | ) |
Add an integer value of type size_t.
Definition at line 124 of file ConstantInitBuilder.cpp.
References add(), Builder, clang::CodeGen::CodeGenModule::getSize(), and size().
|
inline |
Add a relative offset to the target address, plus a small constant offset.
This is primarily useful when the relative offset is known to be a multiple of (say) four and therefore the tag can be used to express an extra two bits of information.
Definition at line 243 of file ConstantInitBuilder.h.
References add(), and clang::ast_matchers::type.
|
inline |
Return true if no elements have yet been added to this struct or array.
Definition at line 178 of file ConstantInitBuilder.h.
References size().
|
inline |
Fill a previously-added placeholder.
Definition at line 299 of file ConstantInitBuilder.h.
References Builder, Finished, and Frozen.
Referenced by fillPlaceholderWithInt().
|
inline |
Fill a previously-added placeholder.
Definition at line 292 of file ConstantInitBuilder.h.
References fillPlaceholder(), and clang::ast_matchers::type.
|
protected |
Definition at line 263 of file ConstantInitBuilder.cpp.
References Begin, getBuffer(), markFinished(), and clang::ast_matchers::type.
|
protected |
Definition at line 279 of file ConstantInitBuilder.cpp.
References Begin, Builder, getBuffer(), clang::CodeGen::CodeGenModule::getLLVMContext(), markFinished(), and Packed.
llvm::Constant * ConstantAggregateBuilderBase::getAddrOfCurrentPosition | ( | llvm::Type * | type | ) |
Produce an address which will eventually point to the next position to be filled.
This is computed with an indexed getelementptr rather than by computing offsets.
The returned pointer will have type T*, where T is the given type. This type can differ from the type of the actual element.
Definition at line 168 of file ConstantInitBuilder.cpp.
References Builder, getGEPIndicesToCurrentPosition(), clang::CodeGen::CodeGenModule::getModule(), and clang::ast_matchers::type.
Referenced by addSignedPointer().
llvm::Constant * ConstantAggregateBuilderBase::getAddrOfPosition | ( | llvm::Type * | type, |
size_t | position | ||
) |
Produce an address which points to a position in the aggregate being constructed.
This is computed with an indexed getelementptr rather than by computing offsets.
The returned pointer will have type T*, where T is the given type. This type can differ from the type of the actual element.
Definition at line 154 of file ConstantInitBuilder.cpp.
References Begin, Builder, clang::CodeGen::CodeGenModule::getModule(), and clang::ast_matchers::type.
|
inlineprotected |
Definition at line 111 of file ConstantInitBuilder.h.
References Builder.
Referenced by finishArray(), finishStruct(), and size().
|
inlineprotected |
Definition at line 115 of file ConstantInitBuilder.h.
References Builder.
|
inline |
Definition at line 323 of file ConstantInitBuilder.h.
References Builder.
Referenced by getAddrOfCurrentPosition().
|
inline |
Return the offset from the start of the initializer to the next position, assuming no padding is required prior to it.
This operation will not succeed if any unsized placeholders are currently in place in the initializer.
Definition at line 259 of file ConstantInitBuilder.h.
References Builder, Finished, and Frozen.
Referenced by addPlaceholderWithSize().
|
inlineprotected |
Definition at line 135 of file ConstantInitBuilder.h.
References Builder, Finished, Frozen, and Parent.
Referenced by abandon(), finishArray(), and finishStruct().
|
delete |
|
delete |
|
inline |
Return the number of elements that have been added to this struct or array.
Definition at line 170 of file ConstantInitBuilder.h.
References Begin, getBuffer(), and size().
|
protected |
Definition at line 104 of file ConstantInitBuilder.h.
Referenced by abandon(), finishArray(), finishStruct(), getAddrOfPosition(), and size().
|
protected |
Definition at line 102 of file ConstantInitBuilder.h.
Referenced by add(), addAll(), addPlaceholder(), addPlaceholderWithSize(), addSignedPointer(), addSize(), fillPlaceholder(), finishStruct(), getAddrOfCurrentPosition(), getAddrOfPosition(), getBuffer(), getGEPIndicesToCurrentPosition(), getNextOffsetFromGlobal(), and markFinished().
|
mutableprotected |
Definition at line 105 of file ConstantInitBuilder.h.
Referenced by addPlaceholderWithSize().
|
mutableprotected |
Definition at line 109 of file ConstantInitBuilder.h.
Referenced by addPlaceholderWithSize().
Definition at line 106 of file ConstantInitBuilder.h.
Referenced by add(), addAll(), addPlaceholder(), fillPlaceholder(), getNextOffsetFromGlobal(), markFinished(), and ~ConstantAggregateBuilderBase().
Definition at line 107 of file ConstantInitBuilder.h.
Referenced by add(), addAll(), addPlaceholder(), ConstantAggregateBuilderBase(), fillPlaceholder(), getNextOffsetFromGlobal(), and markFinished().
Definition at line 108 of file ConstantInitBuilder.h.
Referenced by addPlaceholderWithSize(), and finishStruct().
|
protected |
Definition at line 103 of file ConstantInitBuilder.h.
Referenced by markFinished().