clang  6.0.0svn
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
clang::CodeGen::ConstantAggregateBuilderBase Class Reference

A concrete base class for struct and array aggregate initializer builders. More...

#include "clang/CodeGen/ConstantInitBuilder.h"

Collaboration diagram for clang::CodeGen::ConstantAggregateBuilderBase:
Collaboration graph
[legend]

Classes

class  PlaceholderPosition
 An opaque class to hold the abstract position of a placeholder. More...
 

Public Member Functions

 ConstantAggregateBuilderBase (const ConstantAggregateBuilderBase &)=delete
 
ConstantAggregateBuilderBaseoperator= (const ConstantAggregateBuilderBase &)=delete
 
 ConstantAggregateBuilderBase (ConstantAggregateBuilderBase &&other)
 
ConstantAggregateBuilderBaseoperator= (ConstantAggregateBuilderBase &&other)=delete
 
size_t size () const
 Return the number of elements that have been added to this struct or array. More...
 
bool empty () const
 Return true if no elements have yet been added to this struct or array. More...
 
void abandon ()
 Abandon this builder completely. More...
 
void add (llvm::Constant *value)
 Add a new value to this initializer. More...
 
void addSize (CharUnits size)
 Add an integer value of type size_t. More...
 
void addInt (llvm::IntegerType *intTy, uint64_t value, bool isSigned=false)
 Add an integer value of a specific type. More...
 
void addNullPointer (llvm::PointerType *ptrTy)
 Add a null pointer of a specific type. More...
 
void addBitCast (llvm::Constant *value, llvm::Type *type)
 Add a bitcast of a value to a specific type. More...
 
void addAll (llvm::ArrayRef< llvm::Constant *> values)
 Add a bunch of new values to this initializer. More...
 
void addRelativeOffset (llvm::IntegerType *type, llvm::Constant *target)
 Add a relative offset to the given target address, i.e. More...
 
void addTaggedRelativeOffset (llvm::IntegerType *type, llvm::Constant *address, unsigned tag)
 Add a relative offset to the target address, plus a small constant offset. More...
 
CharUnits getNextOffsetFromGlobal () const
 Return the offset from the start of the initializer to the next position, assuming no padding is required prior to it. More...
 
PlaceholderPosition addPlaceholder ()
 Add a placeholder value to the structure. More...
 
PlaceholderPosition addPlaceholderWithSize (llvm::Type *expectedType)
 Add a placeholder, giving the expected type that will be filled in. More...
 
void fillPlaceholderWithInt (PlaceholderPosition position, llvm::IntegerType *type, uint64_t value, bool isSigned=false)
 Fill a previously-added placeholder. More...
 
void fillPlaceholder (PlaceholderPosition position, llvm::Constant *value)
 Fill a previously-added placeholder. More...
 
llvm::Constant * getAddrOfCurrentPosition (llvm::Type *type)
 Produce an address which will eventually point to the the next position to be filled. More...
 
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

ConstantInitBuilderBaseBuilder
 
ConstantAggregateBuilderBaseParent
 
size_t Begin
 
size_t CachedOffsetEnd = 0
 
bool Finished = false
 
bool Frozen = false
 
bool Packed = false
 
CharUnits CachedOffsetFromGlobal
 

Detailed Description

A concrete base class for struct and array aggregate initializer builders.

Definition at line 98 of file ConstantInitBuilder.h.

Constructor & Destructor Documentation

◆ ConstantAggregateBuilderBase() [1/3]

clang::CodeGen::ConstantAggregateBuilderBase::ConstantAggregateBuilderBase ( ConstantInitBuilderBase builder,
ConstantAggregateBuilderBase parent 
)
inlineprotected

Definition at line 117 of file ConstantInitBuilder.h.

References Frozen.

◆ ~ConstantAggregateBuilderBase()

clang::CodeGen::ConstantAggregateBuilderBase::~ConstantAggregateBuilderBase ( )
inlineprotected

Definition at line 129 of file ConstantInitBuilder.h.

◆ ConstantAggregateBuilderBase() [2/3]

clang::CodeGen::ConstantAggregateBuilderBase::ConstantAggregateBuilderBase ( const ConstantAggregateBuilderBase )
delete

◆ ConstantAggregateBuilderBase() [3/3]

clang::CodeGen::ConstantAggregateBuilderBase::ConstantAggregateBuilderBase ( ConstantAggregateBuilderBase &&  other)
inline

Definition at line 156 of file ConstantInitBuilder.h.

Member Function Documentation

◆ abandon()

void clang::CodeGen::ConstantAggregateBuilderBase::abandon ( )
inline

Abandon this builder completely.

Definition at line 181 of file ConstantInitBuilder.h.

◆ add()

void clang::CodeGen::ConstantAggregateBuilderBase::add ( llvm::Constant *  value)
inline

Add a new value to this initializer.

Definition at line 187 of file ConstantInitBuilder.h.

◆ addAll()

void clang::CodeGen::ConstantAggregateBuilderBase::addAll ( llvm::ArrayRef< llvm::Constant *>  values)
inline

Add a bunch of new values to this initializer.

Definition at line 214 of file ConstantInitBuilder.h.

◆ addBitCast()

void clang::CodeGen::ConstantAggregateBuilderBase::addBitCast ( llvm::Constant *  value,
llvm::Type type 
)
inline

Add a bitcast of a value to a specific type.

Definition at line 209 of file ConstantInitBuilder.h.

◆ addInt()

void clang::CodeGen::ConstantAggregateBuilderBase::addInt ( llvm::IntegerType *  intTy,
uint64_t  value,
bool  isSigned = false 
)
inline

Add an integer value of a specific type.

Definition at line 198 of file ConstantInitBuilder.h.

◆ addNullPointer()

void clang::CodeGen::ConstantAggregateBuilderBase::addNullPointer ( llvm::PointerType *  ptrTy)
inline

Add a null pointer of a specific type.

Definition at line 204 of file ConstantInitBuilder.h.

◆ addPlaceholder()

PlaceholderPosition clang::CodeGen::ConstantAggregateBuilderBase::addPlaceholder ( )
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, generaly a count, before any of the data. By emitting a placeholder first, the structure can be emitted eagerly.

Definition at line 272 of file ConstantInitBuilder.h.

References clang::CodeGen::Type.

◆ addPlaceholderWithSize()

ConstantAggregateBuilderBase::PlaceholderPosition ConstantAggregateBuilderBase::addPlaceholderWithSize ( llvm::Type expectedType)

Add a placeholder, giving the expected type that will be filled in.

Definition at line 183 of file ConstantInitBuilder.cpp.

◆ addRelativeOffset()

void clang::CodeGen::ConstantAggregateBuilderBase::addRelativeOffset ( llvm::IntegerType *  type,
llvm::Constant *  target 
)
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 226 of file ConstantInitBuilder.h.

◆ addSize()

void ConstantAggregateBuilderBase::addSize ( CharUnits  size)

Add an integer value of type size_t.

Definition at line 125 of file ConstantInitBuilder.cpp.

◆ addTaggedRelativeOffset()

void clang::CodeGen::ConstantAggregateBuilderBase::addTaggedRelativeOffset ( llvm::IntegerType *  type,
llvm::Constant *  address,
unsigned  tag 
)
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 234 of file ConstantInitBuilder.h.

◆ empty()

bool clang::CodeGen::ConstantAggregateBuilderBase::empty ( ) const
inline

Return true if no elements have yet been added to this struct or array.

Definition at line 176 of file ConstantInitBuilder.h.

◆ fillPlaceholder()

void clang::CodeGen::ConstantAggregateBuilderBase::fillPlaceholder ( PlaceholderPosition  position,
llvm::Constant *  value 
)
inline

Fill a previously-added placeholder.

Definition at line 290 of file ConstantInitBuilder.h.

References clang::CodeGen::Type.

◆ fillPlaceholderWithInt()

void clang::CodeGen::ConstantAggregateBuilderBase::fillPlaceholderWithInt ( PlaceholderPosition  position,
llvm::IntegerType *  type,
uint64_t  value,
bool  isSigned = false 
)
inline

Fill a previously-added placeholder.

Definition at line 283 of file ConstantInitBuilder.h.

◆ finishArray()

llvm::Constant * ConstantAggregateBuilderBase::finishArray ( llvm::Type eltTy)
protected

Definition at line 245 of file ConstantInitBuilder.cpp.

References Begin.

◆ finishStruct()

llvm::Constant * ConstantAggregateBuilderBase::finishStruct ( llvm::StructType *  structTy)
protected

Definition at line 261 of file ConstantInitBuilder.cpp.

References Begin.

◆ getAddrOfCurrentPosition()

llvm::Constant * ConstantAggregateBuilderBase::getAddrOfCurrentPosition ( llvm::Type type)

Produce an address which will eventually point to the 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 position.

Definition at line 149 of file ConstantInitBuilder.cpp.

◆ getBuffer() [1/2]

llvm::SmallVectorImpl<llvm::Constant*>& clang::CodeGen::ConstantAggregateBuilderBase::getBuffer ( )
inlineprotected

Definition at line 109 of file ConstantInitBuilder.h.

◆ getBuffer() [2/2]

const llvm::SmallVectorImpl<llvm::Constant*>& clang::CodeGen::ConstantAggregateBuilderBase::getBuffer ( ) const
inlineprotected

Definition at line 113 of file ConstantInitBuilder.h.

◆ getGEPIndicesToCurrentPosition()

llvm::ArrayRef<llvm::Constant*> clang::CodeGen::ConstantAggregateBuilderBase::getGEPIndicesToCurrentPosition ( llvm::SmallVectorImpl< llvm::Constant *> &  indices)
inline

Definition at line 306 of file ConstantInitBuilder.h.

References clang::CodeGen::Type.

◆ getNextOffsetFromGlobal()

CharUnits clang::CodeGen::ConstantAggregateBuilderBase::getNextOffsetFromGlobal ( ) const
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 250 of file ConstantInitBuilder.h.

◆ markFinished()

void clang::CodeGen::ConstantAggregateBuilderBase::markFinished ( )
inlineprotected

◆ operator=() [1/2]

ConstantAggregateBuilderBase& clang::CodeGen::ConstantAggregateBuilderBase::operator= ( const ConstantAggregateBuilderBase )
delete

◆ operator=() [2/2]

ConstantAggregateBuilderBase& clang::CodeGen::ConstantAggregateBuilderBase::operator= ( ConstantAggregateBuilderBase &&  other)
delete

◆ size()

size_t clang::CodeGen::ConstantAggregateBuilderBase::size ( ) const
inline

Return the number of elements that have been added to this struct or array.

Definition at line 168 of file ConstantInitBuilder.h.

References Begin.

Member Data Documentation

◆ Begin

size_t clang::CodeGen::ConstantAggregateBuilderBase::Begin
protected

Definition at line 102 of file ConstantInitBuilder.h.

◆ Builder

ConstantInitBuilderBase& clang::CodeGen::ConstantAggregateBuilderBase::Builder
protected

Definition at line 100 of file ConstantInitBuilder.h.

◆ CachedOffsetEnd

size_t clang::CodeGen::ConstantAggregateBuilderBase::CachedOffsetEnd = 0
mutableprotected

Definition at line 103 of file ConstantInitBuilder.h.

◆ CachedOffsetFromGlobal

CharUnits clang::CodeGen::ConstantAggregateBuilderBase::CachedOffsetFromGlobal
mutableprotected

Definition at line 107 of file ConstantInitBuilder.h.

◆ Finished

bool clang::CodeGen::ConstantAggregateBuilderBase::Finished = false
protected

Definition at line 104 of file ConstantInitBuilder.h.

◆ Frozen

bool clang::CodeGen::ConstantAggregateBuilderBase::Frozen = false
protected

Definition at line 105 of file ConstantInitBuilder.h.

Referenced by ConstantAggregateBuilderBase(), and markFinished().

◆ Packed

bool clang::CodeGen::ConstantAggregateBuilderBase::Packed = false
protected

Definition at line 106 of file ConstantInitBuilder.h.

◆ Parent

ConstantAggregateBuilderBase* clang::CodeGen::ConstantAggregateBuilderBase::Parent
protected

Definition at line 101 of file ConstantInitBuilder.h.


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