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

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. More...

#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
 getElementAsInteger - If this is a sequential container of integers (of any size), return the specified element in the low bits of a uint64_t.
APFloat getElementAsAPFloat (unsigned i) const
 getElementAsAPFloat - If this is a sequential container of floating point type, return the specified element as an APFloat.
float getElementAsFloat (unsigned i) const
 getElementAsFloat - If this is an sequential container of floats, return the specified element as a float.
double getElementAsDouble (unsigned i) const
 getElementAsDouble - If this is an sequential container of doubles, return the specified element as a double.
ConstantgetElementAsConstant (unsigned i) const
 getElementAsConstant - Return a Constant for a specified index's element.
SequentialTypegetType () const
 getType - Specialize the getType() method to always return a SequentialType, which reduces the amount of casting needed in parts of the compiler.
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 each element in the array/vector.
bool isString () const
 isString - This method returns true if this is an array of i8.
bool isCString () const
 isCString - This method returns true if the array "isString", ends with a nul byte, and does not contains any other nul bytes.
StringRef getAsString () const
 getAsString - If this array is isString(), then this method returns the array as a StringRef.
StringRef getAsCString () const
 getAsCString - If this array is isCString(), then this method returns the array (without the trailing null byte) as a StringRef.
StringRef getRawDataValues () const
 getRawDataValues - Return the raw, underlying, bytes of this data.

Static Public Member Functions

static bool isElementTypeCompatible (const Type *Ty)
 isElementTypeCompatible - Return true if a ConstantDataSequential can be formed with a vector or array of the specified element type.
static bool classof (const Value *V)
 Methods for support type inquiry through isa, cast, and dyn_cast:

Protected Member Functions

 ConstantDataSequential (Type *ty, ValueTy VT, const char *Data)
 ~ConstantDataSequential () override
void * operator new (size_t s)
 Allocate a User with an operand pointer co-allocated.

Static Protected Member Functions

static ConstantgetImpl (StringRef Bytes, Type *Ty)
 getImpl - This is the underlying implementation of all of the ConstantDataSequential::get methods.

Friends

class LLVMContextImpl
class Constant

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 556 of file Constants.h.


Constructor & Destructor Documentation

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

Definition at line 574 of file Constants.h.

llvm::ConstantDataSequential::~ConstantDataSequential ( ) [inline, override, protected]

Definition at line 576 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 665 of file Constants.h.

References llvm::Value::getValueID().

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 652 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 643 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 2743 of file Constants.cpp.

References llvm::lltok::APFloat, llvm::Type::DoubleTyID, llvm::Type::FloatTyID, getElementType(), getTypeID(), llvm::APFloat::IEEEdouble, llvm::APFloat::IEEEsingle, 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 2782 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 2771 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 2762 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 2721 of file Constants.cpp.

References getElementType(), and llvm_unreachable.

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

getElementByteSize - Return the size (in bytes) of each element in the array/vector.

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

The size of the elements is known to be a multiple of one byte.

Definition at line 2455 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 2478 of file Constants.cpp.

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

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

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 2423 of file Constants.cpp.

References getElementByteSize(), and getNumElements().

Referenced by 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 617 of file Constants.h.

Referenced by 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 2796 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 2431 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 2790 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  Size) [inline, protected]

Allocate a User with an operand pointer co-allocated.

This is used for subclasses which need to allocate a variable number of operands, ie, 'hung off uses'.

Reimplemented from llvm::User.

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

Definition at line 582 of file Constants.h.

References operator new().


Friends And Related Function Documentation

friend class Constant [friend]

Definition at line 570 of file Constants.h.

friend class LLVMContextImpl [friend]

Definition at line 557 of file Constants.h.


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