llvm::ArrayRef

A constant reference to consecutive elements in memory.

Synopsis

Declared in <llvm/ADT/ArrayRef.h>

template<typename T>
class [[nodiscard]] ArrayRef;

Description

Represents a constant reference to an array (0 or more elements consecutively in memory), i.e. a start pointer and a length. It allows various APIs to take consecutive elements easily and conveniently.

This class does not own the underlying data; it is expected to be used in situations where the data resides in some other buffer whose lifetime extends past that of the ArrayRef. For this reason, it is not in general safe to store an ArrayRef.

This is intended to be trivially copyable, so it should be passed by value.

Type Aliases

NameDescription
const_iterator Const iterator over the referenced array elements.
const_pointer Pointer to a const element.
const_reference Const reference to an element.
const_reverse_iterator Const reverse iterator over the referenced array elements.
difference_type Signed type used to express distances between iterators.
iterator Iterator over the referenced array elements.
pointer Mutable pointer to an element.
reference Mutable reference to an element.
reverse_iterator Reverse iterator over the referenced array elements.
size_type Unsigned type used to express the size of the array.
value_type Element type stored in the referenced array.

Member Functions

NameDescription
ArrayRef [constructor]Constructors
operator= Disallow accidental assignment from a temporary.
back Get the last element.
begin Return an iterator to the first element.
consume_back consume_back() - Returns the last element and drops it from ArrayRef.
consume_front consume_front() - Returns the first element and drops it from ArrayRef.
copy Allocate a mutable copy in A and return a reference to it.
data Return a pointer to the first element of the array.
drop_back Drop the last N elements of the array.
drop_front Drop the first N elements of the array.
drop_until Return a copy of *this with the first N elements not satisfying the given predicate removed.
drop_while Return a copy of *this with the first N elements satisfying the given predicate removed.
empty Check if the array is empty.
end Return an iterator past the last element.
equals Check for element-wise equality.
front Get the first element.
operator[] Return a const reference to the element at Index.
rbegin Return a reverse iterator to the last element.
rend Return a reverse iterator to the element before the first element.
size Get the array size.
slice slice overloads
take_back Return a copy of *this with only the last N elements.
take_front Return a copy of *this with only the first N elements.
take_until Return the first N elements of this Array that don't satisfy the given predicate.
take_while Return the first N elements of this Array that satisfy the given predicate.
vec Copy the referenced elements into a new std::vector.
operator std::vector<T> Convert this ArrayRef into a std::vector copy of its elements.

Deduction Guides

NameDescription
ArrayRef<T> Deduction guide to construct an ArrayRef from an ArrayRef
ArrayRef<T> @{ Deduction guide to construct an ArrayRef from a single element.
ArrayRef<T> Deduction guide to construct an ArrayRef from an ArrayRef (const)
ArrayRef<T> Deduction guide to construct an ArrayRef from a SmallVector
ArrayRef<T> Deduction guide to construct an ArrayRef from a std::vector
ArrayRef<T> Deduction guide to construct an ArrayRef from a SmallVector
ArrayRef<T> Deduction guide to construct an ArrayRef from a std::array
ArrayRef<T> Deduction guide to construct an ArrayRef from a C array.
ArrayRef<T> Deduction guide to construct an ArrayRef from a pointer and length
ArrayRef<T> Deduction guide to construct an ArrayRef from a range

Non-Member Functions

NameDescription
ComputeEditDistanceDetermine the edit distance between two sequences.
ComputeMappedEditDistanceDetermine the edit distance between two sequences.
ConvertCostTableLookupFind in type conversion cost table.
CostTableLookupFind in cost table.
DeleteDeadBlocksDelete the specified blocks, which must have no live predecessors.
PrintErrorPrint an error diagnostic at source location(s) ErrorLoc.
PrintFatalErrorPrint an error at ErrorLoc and then exit the process.
PrintFatalNotePrint a note at ErrorLoc and then exit the process.
PrintNotePrint a note diagnostic at source location(s) NoteLoc.
PrintWarningPrint a warning diagnostic at source location(s) WarningLoc.
PromoteMemToRegPromote the specified list of alloca instructions into scalar registers, inserting PHI nodes as appropriate.
StrCmpOptionPrefixesCompare two option prefix sequences for sorting.
arrayRefFromStringRefConstruct an array ref of bytes from a string ref.
canConvertToMinOrMaxIntrinsicCheck if values in VL are selects convertible to a min/max intrinsic.
cleanUpTempFilesRemoves the temporary files named in FileName.
cloneAndAdaptNoAliasScopesClone noalias scopes and adapt instructions in a range.
cloneAndAdaptNoAliasScopesClone noalias scopes and adapt instructions in new blocks.
cloneNoAliasScopesDuplicate the listed noalias declaration scopes.
collectGlobalObjectNameStringsSerialize global-object name strings into a profile-ready blob.
collectPGOFuncNameStringsSerialize referenced PGO function-name variables into Result.
collectVTableStringsSerialize vtable name strings into a profile-ready blob.
computeExpressionSizeCompute a saturated expression-size estimate from operand sizes.
computeMinimumValueSizesCompute a map of integer instructions to their minimum legal type size.
convertUTF16ToUTF8StringConverts a UTF16 string into a UTF8 std::string.
convertUTF16ToUTF8StringConverts a stream of raw bytes assumed to be UTF16 into a UTF8 std::string.
convertUTF32ToUTF8StringConverts a stream of raw bytes assumed to be UTF32 into a UTF8 std::string.
convertUTF32ToUTF8StringConverts a UTF32 string into a UTF8 std::string.
convertUsersOfConstantsToInstructionsReplace constant expressions users of the given constants with instructions.
crc32Compute the CRC-32 of Data.
createMacroFusionDAGMutationCreate a DAG mutation that fuses instruction pairs matching the given predicates.
createPHIsForSplitLoopExitInsert LCSSA PHI nodes required after splitting a loop exit edge.
createUnaryMaskCreate a unary shuffle mask from a binary shuffle mask.
detachDeadBlocksReplace every block in BBs with a single unreachable instruction.
dlltoolDriverMainEntry point for the dlltool.exe-compatible driver used by llvm-dlltool.
downscaleWeightsdownscale the given weights preserving the ratio. If the maximum value is not already known and not provided via
dumpBytesConvert Bytes' to a hex string and output to OS'
dumpRegSetPressureDump non-zero entries of SetPressure to the debug stream.
eraseInstrsErase a list of dead instructions, optionally notifying a debug observer.
fitWeightsPush the weights right to fit in uint32_t.
format_bytesFormat Bytes as a hex dump without an ASCII column.
format_bytes_with_asciiFormat Bytes as hex with an ASCII column.
fullyRecomputeLiveInsConvenience function for recomputing live-in's for a set of MBBs until the computation converges.
getContainedTypesReturns the types contained in Ty. For struct types, it returns the elements, all other types are returned directly.
getShuffleMaskWithWidestEltsRepetitively apply widenShuffleMaskElts() for as long as it succeeds, to get the shuffle mask with widest possible elements.
getSipHash_2_4_128Computes a SipHash-2-4 128-bit result.
getSipHash_2_4_64Computes a SipHash-2-4 64-bit result.
getSplatIndexReturn the common non-negative splat index in Mask, or -1.
hasUTF16ByteOrderMarkReturns true if a blob of text starts with a UTF-16 big or little endian byte order mark.
hash_valueCompute a hash_code for an ArrayRef.
identifyNoAliasScopesToCloneCollect noalias scopes declared in the given basic blocks.
isMaskedSlidePairReturn true if Mask is one slide or a masked pair of slides.
libDriverMainEntry point for the lib.exe-compatible driver used by llvm-lib and lld-link /lib.
operator!=Return true if LHS and RHS differ in length or element values.
operator<Lexicographically compare two ArrayRefs.
operator<=Return true if LHS is lexicographically less than or equal to RHS.
operator==Return true if LHS and RHS contain equal elements.
operator>Lexicographically compare two ArrayRefs.
operator>=Return true if LHS is lexicographically greater than or equal to RHS.
processShuffleMasksSplit and process a shuffle mask across real input and output registers.
readWideAPIntDecode a wide APInt from a sequence of 64-bit words.
remapInstructionsInBlocksRemaps instructions in Blocks using the mapping in VMap.
sortPtrAccessesAttempt to sort the pointers in VL and return the sorted indices in SortedIndices, if reordering is required.
stable_hash_combineCombine the hashes in Buffer into a single stable hash.
toHexConvert buffer Input to its hexadecimal representation. The returned string is double the size of Input.
toHexConvert the bytes in Input to a hexadecimal string.
toStringRefConstruct a string ref from an array ref of unsigned chars.
toStringRefConstruct a string ref from an array ref of chars.
widenShuffleMaskEltsWiden a shuffle mask with Scale=2, treating -1 as undef.
writeArchiveToBufferWrite an archive into a memory buffer.
xxh3_128bitsCompute the XXH3 128-bit hash of the bytes in data.
xxh3_64bitsCompute the XXH3 64-bit hash of the bytes in data.
AArch64::getCpuSupportsMaskCompute the CPU-supports bitmask for the given FMV feature names.
AArch64::getFMVPriorityCompute the FMV priority bitmask for the given feature names.
BBAddrMapYAML::encodePayloadEncodes the BBAddrMap payload into a contiguous blob.
CodeViewYAML::fromDebugHParse a .debug$H section blob into a YAML DebugHSection.
CodeViewYAML::fromDebugSParse a .debug$S section blob into YAML debug subsections.
CodeViewYAML::fromDebugTParse a .debug$T or .debug$P section blob into YAML leaf records.
CodeViewYAML::initializeStringsAndChecksumsPopulate string and checksum tables from YAML debug subsections.
CodeViewYAML::toDebugHSerialize a YAML DebugHSection into a .debug$H section blob.
CodeViewYAML::toDebugTSerialize YAML leaf records into a .debug$T or .debug$P section blob.
ELFYAML::shouldAllocateFileSpaceReturn whether SHT_NOBITS section S should allocate file space.
IntegerInclusiveIntervalUtils::containsCheck if a value is contained in any of the intervals.
IntegerInclusiveIntervalUtils::mergeAdjacentIntervalsMerge adjacent/consecutive intervals into single intervals. Example: [1-3, 4-6, 8-10]-> [1-6, 8-10].
Intrinsic::getIntrinsicInfoTableEntriesFill the IIT table descriptors for an intrinsic into T.
MachO::mapToArchitectureSetMap a list of targets to the set of architectures.
MachO::mapToPlatformSetMap a list of targets to the set of platforms.
MachO::mapToPlatformSetMap a list of target triples to the set of platforms they represent.
MachO::mapToPlatformVersionSetMap a list of targets to the set of platform and version pairs.
PatternMatch::matchMatch shuffle mask Mask against pattern P.
Win64EH::decodeUnwindInfoV3Parse a V3 UNWIND_INFO from raw bytes. Returns an error on malformed data.
Win64EH::decodeWODDecode one WOD from the pool at the given byte offset. Returns an error on malformed data.
X86::getCpuSupportsMaskBuild the 128-bit feature mask for __builtin_cpu_supports from feature names.
cfg::LegalizeUpdatesSimplify a sequence of CFG edge updates by removing redundancy and cancels.
cgdata::mergeCodeGenDataMerge the codegen data from the scratch objects from the first codegen round.
cl::HideUnrelatedOptionsMark all options not part of the categories as cl::ReallyHidden.
cl::getCompilerBuildConfigReturn enabled LLVM build-configuration tags such as +assertions.
cl::list_initBuild a list_initializer modifier for default elements Vals.
codelayout::calcExtTspScoreEstimate the quality of a given node order in a CFG.
codelayout::calcExtTspScoreEstimate the quality of the current node order in a CFG.
codelayout::computeCacheDirectedLayoutApply a Cache-Directed Sort to a call graph of functions.
codelayout::computeExtTspLayoutFind a CFG node layout that optimizes jump locality.
codeview::discoverTypeIndicesDiscover TypeIndex references in raw type-record bytes.
codeview::discoverTypeIndicesCollect every TypeIndex referenced by raw type-record bytes.
codeview::discoverTypeIndicesInSymbolDiscover TypeIndex references in raw symbol-record bytes.
codeview::discoverTypeIndicesInSymbolCollect every TypeIndex referenced by raw symbol-record bytes.
codeview::fmt_guidAdapt a GUID byte sequence for use with formatv.
codeview::forEachCodeViewRecordInvoke F for each contiguous CodeView record in StreamBuffer.
codeview::getBytesAsCStringReinterpret a byte array as a null-terminated C string.
codeview::getBytesAsCharactersReinterpret a byte array as an array of characters. Does not interpret as a C string, as StringRef has several helpers (split) that make that easy.
codeview::serialize_arrayBuild an array serialization helper whose length comes from Func.
codeview::serialize_array_tailBuild a helper that deserializes the remaining stream as an array of T.
codeview::visitMemberRecordStreamVisit every member record in a field-list byte stream.
dwarf::toBlockTake an optional DWARFFormValue and try to extract block data.
irsymtab::buildFills in Symtab and StrtabBuilder with a valid symbol and string table for Mods.
lto::generateModulesOrderingProduces a container ordering for optimal multi-threaded processing.
memprof::buildCallstackMetadataBuild callstack metadata from the provided list of call stack ids.
memprof::computeFullStackIdGenerate a single hash id for a given callstack.
object::decodeCrelDecode a CREL relocation blob, invoking handlers for the header and entries.
object::doesXCOFFTracebackTableBeginTrue when Bytes begin with the XCOFF traceback-table initial zeros.
object::writeUniversalBinaryWrite a Mach-O universal binary containing Slices to OutputFileName.
object::writeUniversalBinaryToStreamWrite a Mach-O universal binary containing Slices to Out.
omp::getCompoundConstructReturn the compound directive formed by Parts, or OMPD_unknown.
omp::getLeafConstructsReturn the leaf constructs that make up compound directive D.
omp::getLeafConstructsOrSelfReturn the leaf constructs of D, or D itself if it is a leaf.
omp::getLeafOrCompositeConstructsAppend the leaf and composite constituents of D to Output.
omp::getOpenMPVersionsReturn the OpenMP language versions supported by this frontend.
omp::getReservedLocatorNamesReturn the reserved OpenMP locator names (lowercase).
orc::makeJITDylibSearchOrderConvenience function for creating a search order from an ArrayRef of JITDylib*, all with the same flags.
pdb::hashBufferV8Compute the PDB V8 buffer hash (CRC-32) of raw bytes.
pdb::typesetItemListJoin strings into lines of at most GroupSize items each.
wholeprogramdevirt::findLowestOffsetFind the lowest offset at which a value of Size bits may be stored.
compression::zlib::compressCompress Input with zlib into CompressedBuffer.
compression::zlib::decompressDecompress zlib-compressed Input into a caller-provided buffer.
compression::zlib::decompressDecompress zlib-compressed Input into Output.
compression::zstd::compressCompress Input with zstd into CompressedBuffer.
compression::zstd::decompressDecompress zstd-compressed Input into a caller-provided buffer.
compression::zstd::decompressDecompress zstd-compressed Input into Output.
jitlink::loongarch::getGOTEntryBlockContentReturn null-pointer bytes sized for a GOT entry in G.
jitlink::loongarch::getStubBlockContentReturn the pointer-jump stub content for the architecture of G.
jitlink::systemz::getGOTEntryBlockContentReturn the content used to initialize a GOT entry block.
jitlink::systemz::getStubBlockContentReturn the instruction bytes for a pointer jump stub block.
offloading::sycl::writeSymbolTableSerialize Names into Out.
orc::shared::runDeallocActionsRun deallocation actions. Dealloc actions will be run in reverse order (from last element of DAs to first).

Derived Classes

NameDescription
MutableArrayRef A mutable reference to consecutive elements in memory.

Return Value

NOTE

The return value should not be discarded.

Template Parameters

NameDescription
TElement type of the referenced array.