Skip to content

Commit 63d13ea

Browse files
committed
Add slicing function extraction test; improve documentation; use lowercase for errors
1 parent 08b2671 commit 63d13ea

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

mlir/include/mlir/Query/Matcher/Marshallers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class VariadicOperatorMatcherDescriptor : public MatcherDescriptor {
182182
const VariantValue &value = arg.value;
183183
if (!value.isMatcher()) {
184184
addError(error, arg.range, ErrorType::RegistryWrongArgType,
185-
{llvm::Twine(i + 1), llvm::Twine("Matcher: "),
185+
{llvm::Twine(i + 1), llvm::Twine("matcher: "),
186186
llvm::Twine(value.getTypeAsString())});
187187
return VariantMatcher();
188188
}

mlir/include/mlir/Query/Matcher/MatchersInternal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
//
99
// Implements the base layer of the matcher framework.
1010
//
11-
// Matchers are methods that return a Matcher which provide a method
12-
// `match(...)` method. The method's parameters define the context of the match.
13-
// Support includes simple (unary) matchers as well as matcher combinators.
11+
// Matchers are methods that return a Matcher which provides a
12+
// `match(...)` method whose parameters define the context of the match.
13+
// Support includes simple (unary) matchers as well as matcher combinators
1414
// (anyOf, allOf, etc.)
1515
//
1616
// This file contains the wrapper classes needed to construct matchers for

mlir/include/mlir/Query/Matcher/SliceMatchers.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ class PredicateBackwardSliceMatcher {
143143
options.filter = [&](Operation *subOp) {
144144
return !filterMatcher.match(subOp);
145145
};
146-
getBackwardSlice(rootOp, &backwardSlice, options);
146+
LogicalResult result = getBackwardSlice(rootOp, &backwardSlice, options);
147+
assert(result.succeeded() && "expected backward slice to succeed");
148+
(void)result;
147149
return options.inclusive ? backwardSlice.size() > 1
148150
: backwardSlice.size() >= 1;
149151
}

mlir/test/mlir-query/forward-slice-by-predicate.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: mlir-query %s -c "m getUsersByPredicate(anyOf(hasOpName(\"memref.alloc\"),isConstantOp()),hasOpName(\"affine.load\"),true)" | FileCheck %s
1+
// RUN: mlir-query %s -c "m getUsersByPredicate(anyOf(hasOpName(\"memref.alloc\"),isConstantOp()),anyOf(hasOpName(\"affine.load\"), hasOpName(\"memref.dealloc\")),true)" | FileCheck %s
22

33
func.func @slice_depth1_loop_nest_with_offsets() {
44
%0 = memref.alloc() : memref<100xf32>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: mlir-query %s -c "m getDefinitionsByPredicate(hasOpName(\"memref.store\"),hasOpName(\"memref.alloc\"),true,false,false).extract(\"backward_slice\")" | FileCheck %s
2+
3+
// CHECK: func.func @backward_slice(%{{.*}}: memref<10xf32>) -> (f32, index, index, f32, index, index, f32) {
4+
// CHECK: %[[CST0:.*]] = arith.constant 0.000000e+00 : f32
5+
// CHECK-NEXT: %[[C0:.*]] = arith.constant 0 : index
6+
// CHECK-NEXT: %[[I0:.*]] = affine.apply affine_map<()[s0] -> (s0)>()[%[[C0]]]
7+
// CHECK-NEXT: memref.store %[[CST0]], %{{.*}}[%[[I0]]] : memref<10xf32>
8+
// CHECK-NEXT: %[[CST2:.*]] = arith.constant 0.000000e+00 : f32
9+
// CHECK-NEXT: %[[I1:.*]] = affine.apply affine_map<() -> (0)>()
10+
// CHECK-NEXT: memref.store %[[CST2]], %{{.*}}[%[[I1]]] : memref<10xf32>
11+
// CHECK-NEXT: %[[C1:.*]] = arith.constant 0 : index
12+
// CHECK-NEXT: %[[LOAD:.*]] = memref.load %{{.*}}[%[[C1]]] : memref<10xf32>
13+
// CHECK-NEXT: memref.store %[[LOAD]], %{{.*}}[%[[C1]]] : memref<10xf32>
14+
// CHECK-NEXT: return %[[CST0]], %[[C0]], %[[I0]], %[[CST2]], %[[I1]], %[[C1]], %[[LOAD]] : f32, index, index, f32, index, index, f32
15+
16+
func.func @slicing_memref_store_trivial() {
17+
%0 = memref.alloc() : memref<10xf32>
18+
%c0 = arith.constant 0 : index
19+
%cst = arith.constant 0.000000e+00 : f32
20+
affine.for %i1 = 0 to 10 {
21+
%1 = affine.apply affine_map<()[s0] -> (s0)>()[%c0]
22+
memref.store %cst, %0[%1] : memref<10xf32>
23+
%2 = memref.load %0[%c0] : memref<10xf32>
24+
%3 = affine.apply affine_map<()[] -> (0)>()[]
25+
memref.store %cst, %0[%3] : memref<10xf32>
26+
memref.store %2, %0[%c0] : memref<10xf32>
27+
}
28+
return
29+
}

0 commit comments

Comments
 (0)