namespace mlir {
-struct NestedPattern;
+class NestedPattern;
class Operation;
/// An NestedPattern captures nested patterns in the IR.
/// 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.
-struct NestedMatch {
+class NestedMatch {
+public:
static NestedMatch build(Operation *operation,
ArrayRef<NestedMatch> nestedMatches);
NestedMatch(const NestedMatch &) = default;
ArrayRef<NestedMatch> getMatchedChildren() { return matchedChildren; }
private:
- friend struct NestedPattern;
- friend struct NestedPatternContext;
+ friend class NestedPattern;
+ friend class NestedPatternContext;
/// Underlying global bump allocator managed by a NestedPatternContext.
static llvm::BumpPtrAllocator *&allocator();
/// implementation is competitive nonetheless.
using FilterFunctionType = std::function<bool(Operation &)>;
inline bool defaultFilterFunction(Operation &) { return true; }
-struct NestedPattern {
+class NestedPattern {
+public:
NestedPattern(ArrayRef<NestedPattern> nested,
FilterFunctionType filter = defaultFilterFunction);
NestedPattern(const NestedPattern &) = default;
unsigned getDepth() const;
private:
- friend struct NestedPatternContext;
- friend struct NestedMatch;
+ friend class NestedPatternContext;
+ friend class NestedMatch;
friend struct State;
/// Underlying global bump allocator managed by a NestedPatternContext.
/// RAII structure to transparently manage the bump allocator for
/// NestedPattern and NestedMatch classes. This avoids passing a context to
/// all the API functions.
-struct NestedPatternContext {
+class NestedPatternContext {
+public:
NestedPatternContext() {
assert(NestedMatch::allocator() == nullptr &&
"Only a single NestedPatternContext is supported");