LLVM 22.0.0git
Public Member Functions | Static Public Member Functions | Friends | List of all members
llvm::ConstantDataArray Class Referencefinal

An 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 "llvm/IR/Constants.h"

Inheritance diagram for llvm::ConstantDataArray:
[フレーム]
[legend]

Public Member Functions

  Specialize the getType() method to always return an ArrayType, which reduces the amount of casting needed in parts of the compiler.
Public Member Functions inherited from llvm::ConstantDataSequential
  If this is a sequential container of integers (of any size), return the specified element in the low bits of a uint64_t.
  If this is a sequential container of integers (of any size), return the specified element as an APInt.
  If this is a sequential container of floating point type, return the specified element as an APFloat.
  If this is an sequential container of floats, return the specified element as a float.
  If this is an sequential container of doubles, return the specified element as a double.
  Return a Constant for a specified index's element.
  Return the element type of the array/vector.
  Return the number of elements in the array or vector.
  Return the size (in bytes) of each element in the array/vector.
  This method returns true if this is an array of CharSize integers.
  This method returns true if the array "isString", ends with a null byte, and does not contains any other null bytes.
  If this array is isString(), then this method returns the array as a StringRef.
  If this array is isCString(), then this method returns the array (without the trailing null byte) as a StringRef.
  Return the raw, underlying, bytes of this data.
Public Member Functions inherited from llvm::ConstantData
void  operator delete (void *Ptr)
Public Member Functions inherited from llvm::Constant
void  operator= (const Constant &)=delete
  Constant (const Constant &)=delete
  Return true if this is the value that would be returned by getNullValue.
  Returns true if the value is one.
  Return true if the value is not the one value, or, for vectors, does not contain one value elements.
  Return true if this is the value that would be returned by getAllOnesValue.
  Return true if the value is what would be returned by getZeroValueForNegation.
  Return true if the value is negative zero or null value.
  Return true if the value is not the smallest signed value, or, for vectors, does not contain smallest signed value elements.
  Return true if the value is the smallest signed value.
  Return true if this is a finite and non-zero floating-point scalar constant or a fixed width vector constant with all finite and non-zero elements.
  Return true if this is a normal (as opposed to denormal, infinity, nan, or zero) floating-point scalar constant or a vector constant with all normal elements.
  Return true if this scalar has an exact multiplicative inverse or this vector has an exact multiplicative inverse for each element in the vector.
  Return true if this is a floating-point NaN constant or a vector floating-point constant with all NaN elements.
  Return true if this constant and a constant 'Y' are element-wise equal.
  Return true if this is a vector constant that includes any undef or poison elements.
  Return true if this is a vector constant that includes any poison elements.
  Return true if this is a vector constant that includes any strictly undef (not poison) elements.
  Return true if this is a fixed width vector constant that includes any constant expressions.
  Return true if the value can vary between threads.
  Return true if the value is dependent on a dllimport variable.
  Return true if the constant has users other than constant expressions and other dangling things.
  This method classifies the entry according to whether or not it may generate a relocation entry (either static or dynamic).
  For aggregates (struct/array/vector) return the constant that corresponds to the specified element if possible, or null if not.
LLVM_ABI ConstantgetSplatValue (bool AllowPoison=false) const
  If all elements of the vector constant have the same value, return that value.
  If C is a constant integer then return its value, otherwise C must be a vector of constant integers, all equal, and the common value is returned.
  Convert constant to an approximate constant range.
  Called if some element of this constant is no longer valid.
  This method is a special form of User::replaceUsesOfWith (which does not work on constants) that does work on constants.
  If there are any dead constant users dangling off of this constant, remove them.
  Return true if the constant has exactly one live use.
  Return true if the constant has no live uses.
  Return true if a constant is ConstantData or a ConstantAggregate or ConstantExpr that contain only ConstantData.
Public Member Functions inherited from llvm::User
  User (const User &)=delete
LLVM_ABI void  operator delete (void *Usr)
  Free memory allocated for User and Use objects.
  Placement delete - required by std, called if the ctor throws.
  Placement delete - required by std, called if the ctor throws.
  Placement delete - required by std, called if the ctor throws.
void  setOperand (unsigned i, Value *Val)
  Returns the descriptor co-allocated with this User instance.
  Returns the descriptor co-allocated with this User instance.
  Subclasses with hung off uses need to manage the operand count themselves.
  A droppable user is a user for which uses can be dropped without affecting correctness and should be dropped rather than preventing a transformation from happening.
  Drop all references to operands.
  Replace uses of one Value with another.
Public Member Functions inherited from llvm::Value
  Value (const Value &)=delete
Valueoperator= (const Value &)=delete
  Delete a pointer to a generic Value.
LLVM_ABI void  dump () const
  Support for debugging, callable in GDB: V->dump()
TypegetType () const
  All values are typed, get the type of this value.
  All values hold a context through their type.
  Return a constant reference to the value's name.
LLVM_ABI void  setName (const Twine &Name)
  Change the name of the value.
LLVM_ABI void  takeName (Value *V)
  Transfer the name from V to this value.
LLVM_ABI std::string  getNameOrAsOperand () const
  Change all uses of this to point to a new Value.
  Change non-metadata uses of this to point to a new Value.
LLVM_ABI void  replaceUsesWithIf (Value *New, llvm::function_ref< bool(Use &U)> ShouldReplace)
  Go through the uses list for this definition and make each use point to "V" if the callback ShouldReplace returns true for the given Use.
  replaceUsesOutsideBlock - Go through the uses list for this definition and make each use point to "V" instead of "this" when the use is outside the block.
  Check if this Value has a use-list.
Useruser_back ()
  Return true if there is exactly one use of this value.
  Return true if this Value has exactly N uses.
  Return true if this value has N uses or more.
  Return true if there is exactly one user of this value.
  Return true if there is exactly one use of this value that cannot be dropped.
  Return true if there is exactly one unique user of this value that cannot be dropped (that user can have multiple uses of this value).
  Return true if there this value.
  Return true if this value has N uses or more.
LLVM_ABI void  dropDroppableUses (llvm::function_ref< bool(const Use *)> ShouldDrop=[](const Use *) { return true;})
  Remove every uses that can safely be removed.
  Remove every use of this value in User that can safely be removed.
  Check if this value is used in the specified basic block.
  This method computes the number of uses of this Value.
void  addUse (Use &U)
  This method should only be used by the Use class.
  Return an ID for the concrete type of this object.
  Return the raw optional flags value contained in this value.
  Clear the optional flags contained in this value.
  Check the optional flags for equality.
  Return true if there is a value handle associated with this value.
  Return true if there is metadata referencing this value.
  Return true if this value is a swifterror value.
  Strip off pointer casts, all-zero GEPs and address space casts.
  Strip off pointer casts, all-zero GEPs, address space casts, and aliases.
  Strip off pointer casts, all-zero GEPs and address space casts but ensures the representation of the result stays the same.
  Strip off pointer casts, all-zero GEPs, single-argument phi nodes and invariant group info.
  Strip off pointer casts and all-constant inbounds GEPs.
LLVM_ABI const ValuestripAndAccumulateConstantOffsets (const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, bool AllowInvariantGroup=false, function_ref< bool(Value &Value, APInt &Offset)> ExternalAnalysis=nullptr, bool LookThroughIntToPtr=false) const
  Accumulate the constant offset this value has compared to a base pointer.
ValuestripAndAccumulateConstantOffsets (const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, bool AllowInvariantGroup=false, function_ref< bool(Value &Value, APInt &Offset)> ExternalAnalysis=nullptr, bool LookThroughIntToPtr=false)
  This is a wrapper around stripAndAccumulateConstantOffsets with the in-bounds requirement set to false.
  Strip off pointer casts and inbounds GEPs.
  If this ptr is provably equal to Other plus a constant offset, return that offset in bytes.
  Return true if the memory object referred to by V can by freed in the scope for which the SSA value defining the allocation is statically defined.
  Returns the number of bytes known to be dereferenceable for the pointer value.
  Returns an alignment of the pointer value.
  Translate PHI node to its predecessor from the given basic block.
void  mutateType (Type *Ty)
  Mutate the type of this Value to be of the specified type.
template<class Compare>
void  sortUseList (Compare Cmp)
  Sort the use-list.
  Reverse the use-list.
LLVM_ABI void  print (raw_ostream &O, bool IsForDebug=false) const
  Implement operator<< on Value.
LLVM_ABI void  print (raw_ostream &O, ModuleSlotTracker &MST, bool IsForDebug=false) const
LLVM_ABI void  printAsOperand (raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
  Print the name of this Value out to the specified raw_ostream.

Static Public Member Functions

template<typename ElementTy>
static Constantget (LLVMContext &Context, ArrayRef< ElementTy > Elts)
  get() constructor - Return a constant with array type with an element count and element type matching the ArrayRef passed in.
template<typename ArrayTy>
static Constantget (LLVMContext &Context, ArrayTy &Elts)
  get() constructor - ArrayTy needs to be compatible with ArrayRef<ElementTy>.
static ConstantgetRaw (StringRef Data, uint64_t NumElements, Type *ElementTy)
  getRaw() constructor - Return a constant with array type with an element count and element type matching the NumElements and ElementTy parameters passed in.
static LLVM_ABI ConstantgetFP (Type *ElementType, ArrayRef< uint16_t > Elts)
  getFP() constructors - Return a constant of array type with a float element type taken from argument ‘ElementType’, and count taken from / argument ‘Elts’.
static LLVM_ABI ConstantgetFP (Type *ElementType, ArrayRef< uint32_t > Elts)
static LLVM_ABI ConstantgetFP (Type *ElementType, ArrayRef< uint64_t > Elts)
static LLVM_ABI ConstantgetString (LLVMContext &Context, StringRef Initializer, bool AddNull=true)
  This method constructs a CDS and initializes it with a text string.
static bool  classof (const Value *V)
  Methods for support type inquiry through isa, cast, and dyn_cast:
Static Public Member Functions inherited from llvm::ConstantDataSequential
  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:
Static Public Member Functions inherited from llvm::ConstantData
static bool  classof (const Value *V)
  Methods to support type inquiry through isa, cast, and dyn_cast.
Static Public Member Functions inherited from llvm::Constant
static bool  classof (const Value *V)
  Constructor to create a '0' constant of arbitrary type.
  Return the value for an integer or pointer constant, or a vector thereof, with the given scalar value.
static LLVM_ABI ConstantreplaceUndefsWith (Constant *C, Constant *Replacement)
  Try to replace undefined constant C or undefined elements in C with Replacement.
  Merges undefs of a Constant with another Constant, along with the undefs already present.
Static Public Member Functions inherited from llvm::User
static bool  classof (const Value *V)
Static Public Member Functions inherited from llvm::Value
static LLVM_ABI void  dropDroppableUse (Use &U)
  Remove the droppable use U.

Friends

Additional Inherited Members

Public Types inherited from llvm::User
using  op_iterator = Use*
Public Types inherited from llvm::Value
enum   ValueTy
  Concrete subclass of this. More...
using  use_iterator = use_iterator_impl<Use>
using  const_use_iterator = use_iterator_impl<const Use>
using  user_iterator = user_iterator_impl<User>
using  const_user_iterator = user_iterator_impl<const User>
Static Public Attributes inherited from llvm::Value
static constexpr unsigned  MaxAlignmentExponent = 32
  The maximum alignment for instructions.
static constexpr uint64_t  MaximumAlignment = 1ULL << MaxAlignmentExponent
Protected Types inherited from llvm::Value
enum   : unsigned { NumUserOperandsBits = 27 }
  The number of operands in the subclass. More...
Protected Member Functions inherited from llvm::ConstantDataSequential
Protected Member Functions inherited from llvm::ConstantData
  ConstantData (Type *Ty, ValueTy VT)
void *  operator new (size_t S)
Protected Member Functions inherited from llvm::Constant
  ~Constant ()=default
Protected Member Functions inherited from llvm::User
void *  operator new (size_t Size)=delete
  Allocate a User with an operand pointer co-allocated.
  Allocate a User with the operands co-allocated.
  Allocate a User with the operands co-allocated.
LLVM_ABI void  allocHungoffUses (unsigned N, bool IsPhi=false)
  Allocate the array of Uses, followed by a pointer (with bottom bit set) to the User.
LLVM_ABI void  growHungoffUses (unsigned N, bool IsPhi=false)
  Grow the number of hung off uses.
  ~User ()=default
template<int Idx>
UseOp ()
template<int Idx>
const UseOp () const
Protected Member Functions inherited from llvm::Value
LLVM_ABI  Value (Type *Ty, unsigned scid)
  Value's destructor should be virtual by design, but that would require that Value and all of its subclasses have a vtable that effectively duplicates the information in the value ID.
LLVM_ABI void  getAllMetadata (SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
  Appends all metadata attached to this value to MDs, sorting by KindID.
  Return true if this value has any metadata attached to it.
  Erase all metadata attachments with the given kind.
  Erase all metadata attachments matching the given predicate.
  Erase all metadata attached to this Value.
  Get metadata for the given kind, if any.
  Get the current metadata attachments for the given kind, if any.
  Appends all attachments with the given ID to MDs in insertion order.
  Return true if this value has the given type of metadata attached.
  Set a particular kind of metadata attachment.
LLVM_ABI void  addMetadata (unsigned KindID, MDNode &MD)
  Add a metadata attachment.
LLVM_ABI void  addMetadata (StringRef Kind, MDNode &MD)
Static Protected Member Functions inherited from llvm::ConstantDataSequential
static LLVM_ABI ConstantgetImpl (StringRef Bytes, Type *Ty)
  This is the underlying implementation of all of the ConstantDataSequential::get methods.
Static Protected Member Functions inherited from llvm::User
template<int Idx, typename U>
static UseOpFrom (const U *that)
Protected Attributes inherited from llvm::Value
  Hold subclass data that can be dropped.

Detailed Description

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

Definition at line 702 of file Constants.h.

Constructor & Destructor Documentation

◆  ConstantDataArray()

llvm::ConstantDataArray::ConstantDataArray ( const ConstantDataArray & )
delete

Member Function Documentation

◆  classof()

bool llvm::ConstantDataArray::classof ( const Value * V )
inlinestatic

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

Definition at line 765 of file Constants.h.

◆  get() [1/2]

template<typename ElementTy>
Constant * llvm::ConstantDataArray::get ( LLVMContext & Context,
ArrayRef< ElementTy > Elts )
inlinestatic

get() constructor - Return a constant with array type with an element count and element type matching the ArrayRef passed in.

Note that this can return a ConstantAggregateZero object.

Definition at line 715 of file Constants.h.

References llvm::ConstantDataSequential::Constant, llvm::Data, llvm::ArrayRef< T >::data(), getRaw(), llvm::Type::getScalarTy(), and llvm::ArrayRef< T >::size().

Referenced by llvm::TargetLowering::CTTZTableLookup(), llvm::embedBitcodeInModule(), llvm::embedBufferInModule(), get(), llvm::sandboxir::ConstantDataArray::get(), getString(), promoteToConstantPool(), llvm::ReadByteArrayFromGlobal(), and tagGlobalDefinition().

◆  get() [2/2]

template<typename ArrayTy>
Constant * llvm::ConstantDataArray::get ( LLVMContext & Context,
ArrayTy & Elts )
inlinestatic

get() constructor - ArrayTy needs to be compatible with ArrayRef<ElementTy>.

Calls get(LLVMContext, ArrayRef<ElementTy>).

Definition at line 724 of file Constants.h.

References llvm::ArrayRef(), llvm::ConstantDataSequential::Constant, and get().

◆  getFP() [1/3]

Constant * ConstantDataArray::getFP ( Type * ElementType,
ArrayRef< uint16_t > Elts )
static

getFP() constructors - Return a constant of array type with a float element type taken from argument ‘ElementType’, and count taken from / argument ‘Elts’.

The amount of bits of the contained type must match the number of bits of the type contained in the passed in ArrayRef. (i.e. half or bfloat for 16bits, float for 32bits, double for 64bits) Note that this can return a ConstantAggregateZero object.

Definition at line 2971 of file Constants.cpp.

References assert(), llvm::ConstantDataSequential::Constant, llvm::Data, llvm::ArrayRef< T >::data(), llvm::ArrayType::get(), llvm::ConstantDataSequential::getImpl(), and llvm::ArrayRef< T >::size().

Referenced by llvm::sandboxir::ConstantDataArray::getFP(), llvm::sandboxir::ConstantDataArray::getFP(), and llvm::sandboxir::ConstantDataArray::getFP().

◆  getFP() [2/3]

Constant * ConstantDataArray::getFP ( Type * ElementType,
ArrayRef< uint32_t > Elts )
static

Definition at line 2978 of file Constants.cpp.

References assert(), llvm::ConstantDataSequential::Constant, llvm::Data, llvm::ArrayRef< T >::data(), llvm::ArrayType::get(), llvm::ConstantDataSequential::getImpl(), and llvm::ArrayRef< T >::size().

◆  getFP() [3/3]

Constant * ConstantDataArray::getFP ( Type * ElementType,
ArrayRef< uint64_t > Elts )
static

Definition at line 2984 of file Constants.cpp.

References assert(), llvm::ConstantDataSequential::Constant, llvm::Data, llvm::ArrayRef< T >::data(), llvm::ArrayType::get(), llvm::ConstantDataSequential::getImpl(), and llvm::ArrayRef< T >::size().

◆  getRaw()

Constant * llvm::ConstantDataArray::getRaw ( StringRef Data,
uint64_t NumElements,
Type * ElementTy )
inlinestatic

getRaw() constructor - Return a constant with array type with an element count and element type matching the NumElements and ElementTy parameters passed in.

Note that this can return a ConstantAggregateZero object. ElementTy must be one of i8/i16/i32/i64/half/bfloat/float/double. Data is the buffer containing the elements. Be careful to make sure Data uses the right endianness, the buffer will be used as-is.

Definition at line 734 of file Constants.h.

References llvm::ConstantDataSequential::Constant, llvm::Data, llvm::ArrayType::get(), and llvm::ConstantDataSequential::getImpl().

Referenced by get(), llvm::sandboxir::ConstantDataArray::getRaw(), and LLVMConstDataArray().

◆  getString()

Constant * ConstantDataArray::getString ( LLVMContext & Context,
StringRef Initializer,
bool AddNull = true )
static

This method constructs a CDS 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 (increasing the length of the string by one more than the StringRef would normally indicate. Pass AddNull=false to disable this behavior.

Definition at line 2992 of file Constants.cpp.

References llvm::SmallVectorImpl< T >::append(), llvm::ArrayRef(), llvm::ConstantDataSequential::Constant, llvm::Data, get(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced by llvm::IRBuilderBase::CreateGlobalString(), createMemprofDefaultOptionsVar(), llvm::createPGOFuncNameVar(), createPrivateConstGlobalForString(), llvm::createPrivateGlobalForString(), createProfileFileNameVar(), llvm::createProfileFileNameVar(), getGlobalForName(), llvm::offloading::getOffloadingEntryInitializer(), llvm::sandboxir::ConstantDataArray::getString(), LLVMConstStringInContext(), and LLVMConstStringInContext2().

◆  getType()

ArrayType * llvm::ConstantDataArray::getType ( ) const
inline

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

Definition at line 760 of file Constants.h.

References llvm::cast(), and llvm::Value::getType().

◆  ConstantDataSequential

friend class ConstantDataSequential
friend

Definition at line 703 of file Constants.h.

References ConstantDataSequential, and llvm::Data.

Referenced by ConstantDataSequential.


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

Generated on for LLVM by doxygen 1.14.0

AltStyle によって変換されたページ (->オリジナル) /