LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
llvm::ConstantDataSequential Class Reference

#include <Constants.h>

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

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. More...
 
unsigned getNumElements () const
 getNumElements - Return the number of elements in the array or vector. More...
 
uint64_t getElementByteSize () const
 getElementByteSize - Return the size in bytes of the elements in the data. More...
 
bool isString () const
 isString - This method returns true if this is an array of i8. More...
 
bool isCString () const
 
StringRef getAsString () const
 
StringRef getAsCString () const
 
StringRef getRawDataValues () const
 
virtual void destroyConstant ()
 
- Public Member Functions inherited from llvm::Constant
bool isNullValue () const
 
bool isAllOnesValue () const
 
bool isNegativeZeroValue () const
 
bool isZeroValue () const
 Return true if the value is negative zero or null value. More...
 
bool canTrap () const
 
bool isThreadDependent () const
 isThreadDependent - Return true if the value can vary between threads. More...
 
bool isConstantUsed () const
 
PossibleRelocationsTy getRelocationInfo () const
 
ConstantgetAggregateElement (unsigned Elt) const
 
ConstantgetAggregateElement (Constant *Elt) const
 
ConstantgetSplatValue () const
 
const APIntgetUniqueInteger () const
 
virtual void replaceUsesOfWithOnConstant (Value *, Value *, Use *)
 
void removeDeadConstantUsers () const
 
- Public Member Functions inherited from llvm::User
 ~User ()
 
void operator delete (void *Usr)
 operator delete - free memory allocated for User and Use objects More...
 
void operator delete (void *, unsigned)
 placement delete - required by std, but never called. More...
 
void operator delete (void *, unsigned, bool)
 placement delete - required by std, but never called. More...
 
ValuegetOperand (unsigned i) const
 
void setOperand (unsigned i, Value *Val)
 
const UsegetOperandUse (unsigned i) const
 
UsegetOperandUse (unsigned i)
 
unsigned getNumOperands () const
 
op_iterator op_begin ()
 
const_op_iterator op_begin () const
 
op_iterator op_end ()
 
const_op_iterator op_end () const
 
value_op_iterator value_op_begin ()
 
value_op_iterator value_op_end ()
 
void dropAllReferences ()
 
void replaceUsesOfWith (Value *From, Value *To)
 
- Public Member Functions inherited from llvm::Value
virtual ~Value ()
 
void dump () const
 dump - Support for debugging, callable in GDB: V->dump() More...
 
void print (raw_ostream &O, AssemblyAnnotationWriter *AAW=0) const
 
TypegetType () const
 
LLVMContextgetContext () const
 All values hold a context through their type. More...
 
bool hasName () const
 
ValueNamegetValueName () const
 
void setValueName (ValueName *VN)
 
StringRef getName () const
 
void setName (const Twine &Name)
 
void takeName (Value *V)
 
void replaceAllUsesWith (Value *V)
 
bool use_empty () const
 
use_iterator use_begin ()
 
const_use_iterator use_begin () const
 
use_iterator use_end ()
 
const_use_iterator use_end () const
 
Useruse_back ()
 
const Useruse_back () const
 
bool hasOneUse () const
 
bool hasNUses (unsigned N) const
 
bool hasNUsesOrMore (unsigned N) const
 
bool isUsedInBasicBlock (const BasicBlock *BB) const
 
unsigned getNumUses () const
 
void addUse (Use &U)
 
unsigned getValueID () const
 
unsigned getRawSubclassOptionalData () const
 
void clearSubclassOptionalData ()
 
bool hasSameSubclassOptionalData (const Value *V) const
 
void intersectOptionalDataWith (const Value *V)
 
bool hasValueHandle () const
 
ValuestripPointerCasts ()
 Strips off any unneeded pointer casts, all-zero GEPs and aliases from the specified value, returning the original uncasted value. More...
 
const ValuestripPointerCasts () const
 
ValuestripPointerCastsNoFollowAliases ()
 Strips off any unneeded pointer casts and all-zero GEPs from the specified value, returning the original uncasted value. More...
 
const ValuestripPointerCastsNoFollowAliases () const
 
ValuestripInBoundsConstantOffsets ()
 Strips off unneeded pointer casts and all-constant GEPs from the specified value, returning the original pointer value. More...
 
const ValuestripInBoundsConstantOffsets () const
 
ValuestripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset)
 Strips like stripInBoundsConstantOffsets but also accumulates the constant offset stripped. More...
 
const ValuestripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset) const
 
ValuestripInBoundsOffsets ()
 Strips off unneeded pointer casts and any in-bounds offsets from the specified value, returning the original pointer value. More...
 
const ValuestripInBoundsOffsets () const
 
bool isDereferenceablePointer () const
 
ValueDoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB)
 
const ValueDoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB) const
 
void mutateType (Type *Ty)
 

Static Public Member Functions

static bool isElementTypeCompatible (const Type *Ty)
 
static bool classof (const Value *V)
 
- Static Public Member Functions inherited from llvm::Constant
static bool classof (const Value *V)
 
static ConstantgetNullValue (Type *Ty)
 
static ConstantgetAllOnesValue (Type *Ty)
 Get the all ones value. More...
 
static ConstantgetIntegerValue (Type *Ty, const APInt &V)
 
- Static Public Member Functions inherited from llvm::User
static bool classof (const Value *V)
 

Protected Member Functions

 ConstantDataSequential (Type *ty, ValueTy VT, const char *Data)
 
 ~ConstantDataSequential ()
 
void * operator new (size_t s)
 
- Protected Member Functions inherited from llvm::Constant
 Constant (Type *ty, ValueTy vty, Use *Ops, unsigned NumOps)
 
void destroyConstantImpl ()
 
- Protected Member Functions inherited from llvm::User
void * operator new (size_t s, unsigned Us)
 
 User (Type *ty, unsigned vty, Use *OpList, unsigned NumOps)
 
UseallocHungoffUses (unsigned) const
 
void dropHungoffUses ()
 
template<int Idx>
UseOp ()
 
template<int Idx>
const UseOp () const
 
- Protected Member Functions inherited from llvm::Value
virtual void printCustom (raw_ostream &O) const
 
 Value (Type *Ty, unsigned scid)
 
unsigned short getSubclassDataFromValue () const
 
void setValueSubclassData (unsigned short D)
 

Static Protected Member Functions

static ConstantgetImpl (StringRef Bytes, Type *Ty)
 
- Static Protected Member Functions inherited from llvm::User
template<int Idx, typename U >
static UseOpFrom (const U *that)
 

Friends

class LLVMContextImpl
 

Additional Inherited Members

- Public Types inherited from llvm::Constant
enum  PossibleRelocationsTy { NoRelocation = 0, LocalRelocation = 1, GlobalRelocations = 2 }
 
- Public Types inherited from llvm::User
typedef Useop_iterator
 
typedef const Useconst_op_iterator
 
- Public Types inherited from llvm::Value
enum  ValueTy {
  ArgumentVal, BasicBlockVal, FunctionVal, GlobalAliasVal,
  GlobalVariableVal, UndefValueVal, BlockAddressVal, ConstantExprVal,
  ConstantAggregateZeroVal, ConstantDataArrayVal, ConstantDataVectorVal, ConstantIntVal,
  ConstantFPVal, ConstantArrayVal, ConstantStructVal, ConstantVectorVal,
  ConstantPointerNullVal, MDNodeVal, MDStringVal, InlineAsmVal,
  PseudoSourceValueVal, FixedStackPseudoSourceValueVal, InstructionVal, ConstantFirstVal = FunctionVal,
  ConstantLastVal = ConstantPointerNullVal
}
 
typedef value_use_iterator< Useruse_iterator
 
typedef value_use_iterator
< const User
const_use_iterator
 
- Static Public Attributes inherited from llvm::Value
static const unsigned MaximumAlignment = 1u << 29
 
- Protected Attributes inherited from llvm::User
UseOperandList
 
unsigned NumOperands
 
- Protected Attributes inherited from llvm::Value
unsigned char SubclassOptionalData: 7
 

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

Constructor & Destructor Documentation

llvm::ConstantDataSequential::ConstantDataSequential ( Type ty,
ValueTy  VT,
const char *  Data 
)
inlineexplicitprotected

Definition at line 538 of file Constants.h.

llvm::ConstantDataSequential::~ConstantDataSequential ( )
inlineprotected

Definition at line 540 of file Constants.h.

Member Function Documentation

static bool llvm::ConstantDataSequential::classof ( const Value V)
inlinestatic

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

Definition at line 631 of file Constants.h.

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

void ConstantDataSequential::destroyConstant ( )
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 2278 of file Constants.cpp.

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

StringRef llvm::ConstantDataSequential::getAsCString ( ) const
inline

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

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

StringRef llvm::ConstantDataSequential::getAsString ( ) const
inline

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

Definition at line 607 of file Constants.h.

References getRawDataValues(), and isString().

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

APFloat ConstantDataSequential::getElementAsAPFloat ( unsigned  Elt) const

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

Definition at line 2465 of file Constants.cpp.

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

Referenced by getElementAsConstant().

Constant * ConstantDataSequential::getElementAsConstant ( unsigned  Elt) const

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 2504 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().

double ConstantDataSequential::getElementAsDouble ( unsigned  Elt) const

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

References getElementType().

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

float ConstantDataSequential::getElementAsFloat ( unsigned  Elt) const

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

Definition at line 2484 of file Constants.cpp.

References getElementType().

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

uint64_t ConstantDataSequential::getElementAsInteger ( unsigned  Elt) 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.

Definition at line 2443 of file Constants.cpp.

References getElementType(), and llvm_unreachable.

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

uint64_t ConstantDataSequential::getElementByteSize ( ) const

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

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

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

Type * ConstantDataSequential::getElementType ( ) const
Constant * ConstantDataSequential::getImpl ( StringRef  Elements,
Type Ty 
)
staticprotected

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

References llvm::LLVMContextImpl::CDSConstants, llvm::ConstantAggregateZero::get(), llvm::Type::getContext(), llvm::StringMapEntry< ValueTy >::getKeyData(), llvm::Type::getSequentialElementType(), llvm::StringMapEntry< ValueTy >::getValue(), isAllZeros(), isElementTypeCompatible(), and llvm::LLVMContext::pImpl.

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

unsigned ConstantDataSequential::getNumElements ( ) const
StringRef ConstantDataSequential::getRawDataValues ( ) const

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

References getElementByteSize(), and getNumElements().

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

SequentialType* llvm::ConstantDataSequential::getType ( ) const
inline

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

Definition at line 581 of file Constants.h.

References llvm::Value::getType().

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

bool ConstantDataSequential::isCString ( ) const

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 2518 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().

bool ConstantDataSequential::isElementTypeCompatible ( const Type Ty)
static

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

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

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

bool ConstantDataSequential::isString ( ) const

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

Definition at line 2512 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)
inlineprotected

Definition at line 546 of file Constants.h.

Friends And Related Function Documentation

friend class LLVMContextImpl
friend

Definition at line 525 of file Constants.h.


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