From 870d7783503962a7043b2654ab82a9d4f4f1a961 Mon Sep 17 00:00:00 2001 From: River Riddle Date: Sun, 3 Feb 2019 10:03:46 -0800 Subject: Begin the process of fully removing OperationInst. This patch cleans up references to OperationInst in the /include, /AffineOps, and lib/Analysis. PiperOrigin-RevId: 232199262 --- mlir/lib/Analysis/NestedMatcher.cpp | 59 +++++++++++++++---------------------- 1 file changed, 24 insertions(+), 35 deletions(-) (limited to 'mlir/lib/Analysis/NestedMatcher.cpp') diff --git a/mlir/lib/Analysis/NestedMatcher.cpp b/mlir/lib/Analysis/NestedMatcher.cpp index 214b4ce403c..ec1b60ee437 100644 --- a/mlir/lib/Analysis/NestedMatcher.cpp +++ b/mlir/lib/Analysis/NestedMatcher.cpp @@ -48,10 +48,9 @@ llvm::BumpPtrAllocator *&NestedPattern::allocator() { return allocator; } -NestedPattern::NestedPattern(Instruction::Kind k, - ArrayRef nested, +NestedPattern::NestedPattern(ArrayRef nested, FilterFunctionType filter) - : kind(k), nestedPatterns(), filter(filter), skip(nullptr) { + : nestedPatterns(), filter(filter), skip(nullptr) { if (!nested.empty()) { auto *newNested = allocator()->Allocate(nested.size()); std::uninitialized_copy(nested.begin(), nested.end(), newNested); @@ -85,10 +84,6 @@ void NestedPattern::matchOne(Instruction *inst, if (skip == inst) { return; } - // Structural filter - if (inst->getKind() != kind) { - return; - } // Local custom filter function if (!filter(*inst)) { return; @@ -116,74 +111,68 @@ void NestedPattern::matchOne(Instruction *inst, } static bool isAffineForOp(const Instruction &inst) { - return cast(inst).isa(); + return inst.isa(); } static bool isAffineIfOp(const Instruction &inst) { - return isa(inst) && - cast(inst).isa(); + return inst.isa(); } namespace mlir { namespace matcher { NestedPattern Op(FilterFunctionType filter) { - return NestedPattern(Instruction::Kind::OperationInst, {}, filter); + return NestedPattern({}, filter); } NestedPattern If(NestedPattern child) { - return NestedPattern(Instruction::Kind::OperationInst, child, isAffineIfOp); + return NestedPattern(child, isAffineIfOp); } NestedPattern If(FilterFunctionType filter, NestedPattern child) { - return NestedPattern(Instruction::Kind::OperationInst, child, - [filter](const Instruction &inst) { - return isAffineIfOp(inst) && filter(inst); - }); + return NestedPattern(child, [filter](const Instruction &inst) { + return isAffineIfOp(inst) && filter(inst); + }); } NestedPattern If(ArrayRef nested) { - return NestedPattern(Instruction::Kind::OperationInst, nested, isAffineIfOp); + return NestedPattern(nested, isAffineIfOp); } NestedPattern If(FilterFunctionType filter, ArrayRef nested) { - return NestedPattern(Instruction::Kind::OperationInst, nested, - [filter](const Instruction &inst) { - return isAffineIfOp(inst) && filter(inst); - }); + return NestedPattern(nested, [filter](const Instruction &inst) { + return isAffineIfOp(inst) && filter(inst); + }); } NestedPattern For(NestedPattern child) { - return NestedPattern(Instruction::Kind::OperationInst, child, isAffineForOp); + return NestedPattern(child, isAffineForOp); } NestedPattern For(FilterFunctionType filter, NestedPattern child) { - return NestedPattern(Instruction::Kind::OperationInst, child, - [=](const Instruction &inst) { - return isAffineForOp(inst) && filter(inst); - }); + return NestedPattern(child, [=](const Instruction &inst) { + return isAffineForOp(inst) && filter(inst); + }); } NestedPattern For(ArrayRef nested) { - return NestedPattern(Instruction::Kind::OperationInst, nested, isAffineForOp); + return NestedPattern(nested, isAffineForOp); } NestedPattern For(FilterFunctionType filter, ArrayRef nested) { - return NestedPattern(Instruction::Kind::OperationInst, nested, - [=](const Instruction &inst) { - return isAffineForOp(inst) && filter(inst); - }); + return NestedPattern(nested, [=](const Instruction &inst) { + return isAffineForOp(inst) && filter(inst); + }); } // TODO(ntv): parallel annotation on loops. bool isParallelLoop(const Instruction &inst) { - auto loop = cast(inst).cast(); + auto loop = inst.cast(); return loop || true; // loop->isParallel(); }; // TODO(ntv): reduction annotation on loops. bool isReductionLoop(const Instruction &inst) { - auto loop = cast(inst).cast(); + auto loop = inst.cast(); return loop || true; // loop->isReduction(); }; bool isLoadOrStore(const Instruction &inst) { - const auto *opInst = dyn_cast(&inst); - return opInst && (opInst->isa() || opInst->isa()); + return inst.isa() || inst.isa(); }; } // end namespace matcher -- cgit v1.2.3