An NestedPattern captures nested patterns in the IR. It is used in conjunction with a scoped NestedPatternContext which is an llvm::BumpPtrAllocator that handles memory allocations efficiently and avoids ownership issues.
In order to use NestedPatterns, first create a scoped context. When the context goes out of scope, everything is freed. This design simplifies the API by avoiding references to the context and makes it clear that references to matchers must not escape.
Example: { NestedPatternContext context; auto gemmLike = Doall(Doall(Red(LoadStores()))); auto matches = gemmLike.match(f); // do work on matches } // everything is freed
Nested abstraction for matching results. Provides access to the nested Operation* captured by a Matcher.
A NestedMatch contains an Operation* and the children NestedMatch and is thus cheap to copy. NestedMatch is stored in a scoped bumper allocator whose lifetime is managed by an RAII NestedPatternContext.