LLVM API Documentation

Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends
llvm::ConstantDataSequential Class Reference

#include <Constants.h>

Inheritance diagram for llvm::ConstantDataSequential:
Inheritance graph
[legend]
Collaboration diagram for llvm::ConstantDataSequential:
Collaboration graph
[legend]

List of all members.

Public Member Functions

uint64_t getElementAsInteger (unsigned i) const
APFloat getElementAsAPFloat (unsigned i) const
float getElementAsFloat (unsigned i) const
double getElementAsDouble (unsigned i) const
ConstantgetElementAsConstant (unsigned i) const
SequentialTypegetType () const
TypegetElementType () const
 getElementType - Return the element type of the array/vector.
unsigned getNumElements () const
 getNumElements - Return the number of elements in the array or vector.
uint64_t getElementByteSize () const
 getElementByteSize - Return the size in bytes of the elements in the data.
bool isString () const
 isString - This method returns true if this is an array of i8.
bool isCString () const
StringRef getAsString () const
StringRef getAsCString () const
StringRef getRawDataValues () const
void destroyConstant () override

Static Public Member Functions

static bool isElementTypeCompatible (const Type *Ty)
static bool classof (const Value *V)

Protected Member Functions

 ConstantDataSequential (Type *ty, ValueTy VT, const char *Data)
 ~ConstantDataSequential ()
void * operator new (size_t s)

Static Protected Member Functions

static ConstantgetImpl (StringRef Bytes, Type *Ty)

Friends

class LLVMContextImpl

Detailed Description

ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integer or float/double, and whose elements are just simple data values (i.e. ConstantInt/ConstantFP). This Constant node has no operands because it stores all of the elements of the constant as densely packed data, instead of as Value*'s.

This is the common base class of ConstantDataArray and ConstantDataVector.

Definition at line 528 of file Constants.h.


Constructor & Destructor Documentation

llvm::ConstantDataSequential::ConstantDataSequential ( Type ty,
ValueTy  VT,
const char *  Data 
) [inline, explicit, protected]

Definition at line 542 of file Constants.h.

Definition at line 544 of file Constants.h.


Member Function Documentation

static bool llvm::ConstantDataSequential::classof ( const Value V) [inline, static]

Methods for support type inquiry through isa, cast, and dyn_cast:

Reimplemented from llvm::Constant.

Reimplemented in llvm::ConstantDataVector, and llvm::ConstantDataArray.

Definition at line 635 of file Constants.h.

References llvm::Value::ConstantDataArrayVal, llvm::Value::ConstantDataVectorVal, and llvm::Value::getValueID().

void ConstantDataSequential::destroyConstant ( ) [override, virtual]

destroyConstant - Called if some element of this constant is no longer valid. At this point only other constants may be on the use_list for this constant. Any constants on our Use list must also be destroy'd. The implementation must be sure to remove the constant from the list of available cached constants. Implementations should call destroyConstantImpl as the last thing they do, to destroy all users and delete this.

Reimplemented from llvm::Constant.

Definition at line 2461 of file Constants.cpp.

References llvm::LLVMContextImpl::CDSConstants, llvm::Constant::destroyConstantImpl(), llvm::StringMap< ValueTy, AllocatorTy >::end(), llvm::StringMap< ValueTy, AllocatorTy >::erase(), llvm::StringMap< ValueTy, AllocatorTy >::find(), llvm::Type::getContext(), llvm::Value::getContext(), getRawDataValues(), getType(), Node, and llvm::LLVMContext::pImpl.

getAsCString - If this array is isCString(), then this method returns the array (without the trailing null byte) as a StringRef. Otherwise, it asserts out.

Definition at line 620 of file Constants.h.

References getAsString(), isCString(), llvm::StringRef::size(), and llvm::StringRef::substr().

getAsString - If this array is isString(), then this method returns the array as a StringRef. Otherwise, it asserts out.

Definition at line 611 of file Constants.h.

References getRawDataValues(), and isString().

Referenced by emitGlobalConstantDataSequential(), getAsCString(), llvm::getConstantStringInfo(), and isCString().

getElementAsAPFloat - If this is a sequential container of floating point type, return the specified element as an APFloat.

Definition at line 2648 of file Constants.cpp.

References llvm::lltok::APFloat, llvm::Type::DoubleTyID, llvm::Type::FloatTyID, getElementType(), getTypeID(), and llvm_unreachable.

Referenced by getElementAsConstant().

getElementAsConstant - Return a Constant for a specified index's element. Note that this has to compute a new constant to return, so it isn't as efficient as getElementAsInteger/Float/Double.

Definition at line 2687 of file Constants.cpp.

References llvm::ConstantInt::get(), llvm::ConstantFP::get(), llvm::Value::getContext(), getElementAsAPFloat(), getElementAsInteger(), and getElementType().

Referenced by getLogBase2Vector(), and llvm::ConstantDataVector::getSplatValue().

getElementAsDouble - If this is an sequential container of doubles, return the specified element as a double.

getElementAsDouble - If this is an sequential container of doubles, return the specified element as a float.

Definition at line 2676 of file Constants.cpp.

References getElementType().

Referenced by emitGlobalConstantDataSequential(), and llvm::ExecutionEngine::getConstantValue().

getElementAsFloat - If this is an sequential container of floats, return the specified element as a float.

Definition at line 2667 of file Constants.cpp.

References getElementType().

Referenced by emitGlobalConstantDataSequential(), and llvm::ExecutionEngine::getConstantValue().

getElementAsInteger - If this is a sequential container of integers (of any size), return the specified element in the low bits of a uint64_t.

Definition at line 2626 of file Constants.cpp.

References getElementType(), and llvm_unreachable.

Referenced by llvm::DecodePSHUFBMask(), emitGlobalConstantDataSequential(), FoldBitCast(), llvm::ExecutionEngine::getConstantValue(), getElementAsConstant(), and WriteConstants().

getElementByteSize - Return the size in bytes of the elements in the data.

getElementByteSize - Return the size (in bytes) of each element in the array/vector. The size of the elements is known to be a multiple of one byte.

Definition at line 2408 of file Constants.cpp.

References getElementType(), and llvm::Type::getPrimitiveSizeInBits().

Referenced by emitGlobalConstantDataSequential(), getRawDataValues(), and llvm::ConstantDataVector::getSplatValue().

Constant * ConstantDataSequential::getImpl ( StringRef  Elements,
Type Ty 
) [static, protected]

getImpl - This is the underlying implementation of all of the ConstantDataSequential::get methods. They all thunk down to here, providing the correct element type. We take the bytes in as a StringRef because we *want* an underlying "char*" to avoid TBAA type punning violations.

StringMap bucket, linked up by their Next pointers. Walk the list.

Definition at line 2431 of file Constants.cpp.

References llvm::LLVMContextImpl::CDSConstants, llvm::ConstantAggregateZero::get(), llvm::Type::getContext(), llvm::StringMap< ValueTy, AllocatorTy >::GetOrCreateValue(), llvm::Type::getSequentialElementType(), isAllZeros(), isElementTypeCompatible(), Node, and llvm::LLVMContext::pImpl.

Referenced by llvm::ConstantDataArray::get(), and llvm::ConstantDataVector::get().

getRawDataValues - Return the raw, underlying, bytes of this data. Note that this is an extremely tricky thing to work with, as it exposes the host endianness of the data elements.

Definition at line 2376 of file Constants.cpp.

References getElementByteSize(), and getNumElements().

Referenced by destroyConstant(), getAsString(), llvm::ConstantDataVector::getSplatValue(), and isRepeatedByteSequence().

getType - Specialize the getType() method to always return a SequentialType, which reduces the amount of casting needed in parts of the compiler.

Reimplemented from llvm::Value.

Reimplemented in llvm::ConstantDataVector, and llvm::ConstantDataArray.

Definition at line 585 of file Constants.h.

Referenced by llvm::DecodePSHUFBMask(), destroyConstant(), emitGlobalConstantDataSequential(), getElementType(), getNumElements(), and isString().

isCString - This method returns true if the array "isString", ends with a nul byte, and does not contains any other nul bytes.

Definition at line 2701 of file Constants.cpp.

References llvm::StringRef::back(), llvm::StringRef::drop_back(), llvm::StringRef::find(), getAsString(), isString(), and llvm::StringRef::npos.

Referenced by getAsCString(), and WriteConstants().

isElementTypeCompatible - Return true if a ConstantDataSequential can be formed with a vector or array of the specified element type. ConstantDataArray only works with normal float and int types that are stored densely in memory, not with things like i42 or x86_f80.

Definition at line 2384 of file Constants.cpp.

References llvm::Type::isDoubleTy(), llvm::Type::isFloatTy(), and IT().

Referenced by getImpl(), llvm::ConstantVector::getSplat(), and llvm::ConstantDataVector::getSplat().

isString - This method returns true if this is an array of i8.

Definition at line 2695 of file Constants.cpp.

References getElementType(), getType(), and llvm::Type::isIntegerTy().

Referenced by emitGlobalConstantDataSequential(), getAsString(), llvm::getConstantStringInfo(), and isCString().

void* llvm::ConstantDataSequential::operator new ( size_t  s) [inline, protected]

Reimplemented from llvm::User.

Reimplemented in llvm::ConstantDataVector, and llvm::ConstantDataArray.

Definition at line 550 of file Constants.h.

References operator new().


Friends And Related Function Documentation

friend class LLVMContextImpl [friend]

Definition at line 529 of file Constants.h.


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