32#ifndef LLVM_SUPPORT_SUFFIXTREE_H
33#define LLVM_SUPPORT_SUFFIXTREE_H
64 static constexpr unsigned MinLength = 2;
66 const std::optional<unsigned> BoundaryStart;
68 bool isBoundary(
unsigned Value)
const {
69 return BoundaryStart &&
Value >= *BoundaryStart;
110 SuffixTreeNode *insertLeaf(SuffixTreeInternalNode &Parent,
unsigned StartIdx,
121 SuffixTreeInternalNode *insertInternalNode(SuffixTreeInternalNode *Parent,
122 unsigned StartIdx,
unsigned EndIdx,
128 SuffixTreeInternalNode *insertRoot();
144 unsigned extend(
unsigned EndIdx,
unsigned SuffixesToAdd);
150 std::vector<SuffixTreeLeafNode *> LeafNodes;
169 std::optional<unsigned> BoundaryStart = std::nullopt);
184 const std::vector<SuffixTreeLeafNode *> &LeafNodes;
187 bool OutlinerLeafDescendants = !LeafNodes.
empty();
211 return !(*
this ==
Other);
216 const std::vector<SuffixTreeLeafNode *> &LeafNodes = {})
217 :
N(
N), LeafNodes(LeafNodes) {
This file defines the BumpPtrAllocator interface.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A BumpPtrAllocator that allows only elements of a specific type to be allocated.
LLVM_ABI SuffixTree(const ArrayRef< unsigned > &Str, bool OutlinerLeafDescendants=false, std::optional< unsigned > BoundaryStart=std::nullopt)
Construct a suffix tree from a sequence of unsigned integers.
ArrayRef< unsigned > Str
Each element is an integer representing an instruction in the module.
RepeatedSubstringIterator iterator
bool OutlinerLeafDescendants
Whether to consider leaf descendants or only leaf children.
LLVM Value Representation.
This is an optimization pass for GlobalISel generic memory operations.
A node in a suffix tree which represents a substring or suffix.
static const unsigned EmptyIdx
Represents an undefined index in the suffix tree.
Iterator for finding all repeated substrings in the suffix tree.
RepeatedSubstringIterator operator++(int I)
RepeatedSubstringIterator(SuffixTreeInternalNode *N, const std::vector< SuffixTreeLeafNode * > &LeafNodes={})
bool operator!=(const RepeatedSubstringIterator &Other) const
RepeatedSubstring & operator*()
Return the current repeated substring.
bool operator==(const RepeatedSubstringIterator &Other) const
RepeatedSubstringIterator & operator++()
A repeated substring in the tree.
SmallVector< unsigned > StartIndices
The start indices of each occurrence.
unsigned Length
The length of the string.