LLVM API Documentation

llvm::ConstantArray Class Reference

#include <Constants.h>

Inheritance diagram for llvm::ConstantArray:

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

Collaboration graph
[legend]

List of all members.

Public Member Functions

 DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Constant)
 Transparently provide more efficient getOperand methods.
const ArrayTypegetType () const
bool isString () const
bool isCString () const
std::string getAsString () const
virtual bool isNullValue () const
virtual void destroyConstant ()
virtual void replaceUsesOfWithOnConstant (Value *From, Value *To, Use *U)

Static Public Member Functions

static Constantget (const ArrayType *T, const std::vector< Constant * > &)
 get() - Static factory methods - Return objects of the specified value
static Constantget (const ArrayType *T, Constant *const *Vals, unsigned NumVals)
static Constantget (const std::string &Initializer, bool AddNull=true)
static bool classof (const ConstantArray *)
 Methods for support type inquiry through isa, cast, and dyn_cast:.
static bool classof (const Value *V)

Protected Member Functions

 ConstantArray (const ArrayType *T, const std::vector< Constant * > &Val)

Friends

struct ConstantCreator< ConstantArray, ArrayType, std::vector< Constant * > >


Detailed Description

ConstantArray - Constant Array Declarations

Definition at line 320 of file Constants.h.


Constructor & Destructor Documentation

ConstantArray::ConstantArray ( const ArrayType T,
const std::vector< Constant * > &  Val 
) [protected]


Member Function Documentation

Constant * ConstantArray::get ( const ArrayType T,
const std::vector< Constant * > &  V 
) [static]

static Constant* llvm::ConstantArray::get ( const ArrayType T,
Constant *const *  Vals,
unsigned  NumVals 
) [inline, static]

Definition at line 329 of file Constants.h.

References T, and Vals.

Constant * ConstantArray::get ( const std::string &  Str,
bool  AddNull = true 
) [static]

This method constructs a ConstantArray and initializes it with a text string. The default behavior (AddNull==true) causes a null terminator to be placed at the end of the array. This effectively increases the length of the array by one (you've been warned). However, in some situations this is not desired so if AddNull==false then the string is copied without null termination.

ConstantArray::get(const string&) - Return an array that is initialized to contain the specified string. If length is zero then a null terminator is added to the specified string so that it may be used in a natural way. Otherwise, the length parameter specifies how much of the string to use and it won't be null terminated.

Definition at line 1341 of file Constants.cpp.

References get(), llvm::ArrayType::get(), llvm::ConstantInt::get(), and llvm::Type::Int8Ty.

llvm::ConstantArray::DECLARE_TRANSPARENT_OPERAND_ACCESSORS ( Constant   ) 

Transparently provide more efficient getOperand methods.

const ArrayType* llvm::ConstantArray::getType (  )  const [inline]

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

Reimplemented from llvm::Value.

Definition at line 349 of file Constants.h.

References llvm::Intrinsic::getType().

Referenced by llvm::GetConstantStringInfo(), GetStringLengthH(), isCString(), isString(), llvm::ELFTargetAsmInfo::MergeableStringSection(), and replaceUsesOfWithOnConstant().

bool ConstantArray::isString (  )  const

isString - This method returns true if the array is an array of i8 and the elements of the array are all ConstantInt's.

isString - This method returns true if the array is an array of i8, and if the elements of the array are all ConstantInt's.

Definition at line 1357 of file Constants.cpp.

References llvm::User::getNumOperands(), llvm::Constant::getOperand(), getType(), and llvm::Type::Int8Ty.

Referenced by getAsString(), isStringValue(), and printAsCString().

bool ConstantArray::isCString (  )  const

isCString - This method returns true if the array is a string (see

  /// isString) and it ends in a null byte \0 and does not contains any other
  /// 
null bytes except its terminator.

isCString - This method returns true if the array is a string (see isString) and it ends in a null byte and does not contains any other null bytes except its terminator.

Definition at line 1372 of file Constants.cpp.

References llvm::Constant::getNullValue(), llvm::User::getNumOperands(), llvm::Constant::getOperand(), getType(), and llvm::Type::Int8Ty.

Referenced by llvm::TargetAsmInfo::SectionKindForGlobal().

std::string ConstantArray::getAsString (  )  const

getAsString - If this array is isString(), then this method converts the array to an std::string and returns it. Otherwise, it asserts out.

Definition at line 1395 of file Constants.cpp.

References llvm::User::getNumOperands(), llvm::Constant::getOperand(), and isString().

virtual bool llvm::ConstantArray::isNullValue (  )  const [inline, virtual]

isNullValue - Return true if this is the value that would be returned by getNullValue. This always returns false because zero arrays are always created as ConstantAggregateZero objects.

Implements llvm::Constant.

Definition at line 372 of file Constants.h.

void ConstantArray::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 1330 of file Constants.cpp.

References llvm::Constant::destroyConstantImpl().

Referenced by llvm::ConvertConstantType< ConstantArray, ArrayType >::convert(), and replaceUsesOfWithOnConstant().

void ConstantArray::replaceUsesOfWithOnConstant ( Value From,
Value To,
Use U 
) [virtual]

replaceUsesOfWithOnConstant - Update this constant array to change uses of 'From' to be uses of 'To'. This must update the uniquing data structures etc.

Note that we intentionally replace all uses of From with To here. Consider a large array that uses 'From' 1000 times. By handling this case all here, ConstantArray::replaceUsesOfWithOnConstant is only invoked once, and that single invocation handles all 1000 uses. Handling them one at a time would work, but would be really slow because it would have to unique each updated array instance.

Reimplemented from llvm::Constant.

Definition at line 2445 of file Constants.cpp.

References destroyConstant(), E, llvm::ConstantAggregateZero::get(), llvm::User::getNumOperands(), llvm::Constant::getOperand(), getType(), llvm::Constant::isNullValue(), Lookup(), llvm::User::OperandList, llvm::Constant::setOperand(), llvm::Value::uncheckedReplaceAllUsesWith(), Val, and Values.

static bool llvm::ConstantArray::classof ( const ConstantArray  )  [inline, static]

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

Definition at line 378 of file Constants.h.

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

Reimplemented from llvm::Constant.

Definition at line 379 of file Constants.h.

References llvm::Value::ConstantArrayVal, and llvm::Value::getValueID().


Friends And Related Function Documentation

friend struct ConstantCreator< ConstantArray, ArrayType,std::vector< Constant * > > [friend]

Definition at line 322 of file Constants.h.


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



This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.