14#ifndef LLVM_TRANSFORMS_UTILS_LONGESTCOMMONSEQEUNCE_H
15#define LLVM_TRANSFORMS_UTILS_LONGESTCOMMONSEQEUNCE_H
39 FunctionMatchesProfile,
41 int32_t Size1 = AnchorList1.size(), Size2 = AnchorList2.size(),
42 MaxDepth = Size1 + Size2;
43 auto Index = [&](int32_t
I) {
return I + MaxDepth; };
51 int32_t
X = Size1,
Y = Size2;
56 if (K == -
Depth || (K !=
Depth &&
P[Index(K - 1)] <
P[Index(K + 1)]))
61 int32_t PrevX =
P[Index(PrevK)];
62 int32_t PrevY = PrevX - PrevK;
63 while (
X > PrevX &&
Y > PrevY) {
66 InsertMatching(AnchorList1[
X].first, AnchorList2[
Y].first);
84 std::vector<int32_t> V(2 * MaxDepth + 1, -1);
87 std::vector<std::vector<int32_t>>
Trace;
92 if (K == -
Depth || (K !=
Depth && V[Index(K - 1)] < V[Index(K + 1)]))
95 X = V[Index(K - 1)] + 1;
98 X < Size1 &&
Y < Size2 &&
99 FunctionMatchesProfile(AnchorList1[
X].second, AnchorList2[
Y].second))
104 if (
X >= Size1 &&
Y >= Size2) {
106 Backtrack(
Trace, AnchorList1, AnchorList2);
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
An efficient, type-erasing, non-owning reference to a callable.
This is an optimization pass for GlobalISel generic memory operations.
void longestCommonSequence(AnchorList AnchorList1, AnchorList AnchorList2, llvm::function_ref< bool(const Function &, const Function &)> FunctionMatchesProfile, llvm::function_ref< void(Loc, Loc)> InsertMatching)
std::vector< std::pair< LineLocation, FunctionId > > AnchorList