[all-commits] [llvm/llvm-project] 9b63bd: [mlir] Improve mlir-query tool by implementing `ge...

Denzel-Brian Budii via All-commits all-commits at lists.llvm.org
Tue May 13 04:18:35 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9b63bdd15418e90d0c6889d26e490db89ae744d1
      https://github.com/llvm/llvm-project/commit/9b63bdd15418e90d0c6889d26e490db89ae744d1
  Author: Denzel-Brian Budii <73462654+chios202 at users.noreply.github.com>
  Date:   2025-05-13 (Tue, 13 May 2025)

  Changed paths:
    M mlir/include/mlir/Query/Matcher/Marshallers.h
    M mlir/include/mlir/Query/Matcher/MatchFinder.h
    M mlir/include/mlir/Query/Matcher/MatchersInternal.h
    A mlir/include/mlir/Query/Matcher/SliceMatchers.h
    M mlir/include/mlir/Query/Matcher/VariantValue.h
    M mlir/lib/Query/Matcher/CMakeLists.txt
    A mlir/lib/Query/Matcher/MatchFinder.cpp
    M mlir/lib/Query/Matcher/Parser.cpp
    M mlir/lib/Query/Matcher/Parser.h
    M mlir/lib/Query/Matcher/RegistryManager.cpp
    M mlir/lib/Query/Matcher/VariantValue.cpp
    M mlir/lib/Query/Query.cpp
    A mlir/test/mlir-query/complex-test.mlir
    M mlir/tools/mlir-query/mlir-query.cpp

  Log Message:
  -----------
  [mlir] Improve mlir-query tool by implementing `getBackwardSlice` and `getForwardSlice` matchers (#115670)

Improve mlir-query tool by implementing `getBackwardSlice` and
`getForwardSlice` matchers. As an addition `SetQuery` also needed to be
added to enable custom configuration for each query. e.g: `inclusive`,
`omitUsesFromAbove`, `omitBlockArguments`.

Note: backwardSlice and forwardSlice algoritms are the same as the ones
in `mlir/lib/Analysis/SliceAnalysis.cpp`
Example of current matcher. The query was made to the file:
`mlir/test/mlir-query/complex-test.mlir`

```mlir
./mlir-query /home/dbudii/personal/llvm-project/mlir/test/mlir-query/complex-test.mlir -c "match getDefinitions(hasOpName(\"arith.add
f\"),2)"

Match #1:

/home/dbudii/personal/llvm-project/mlir/test/mlir-query/complex-test.mlir:5:8:
  %0 = linalg.generic {indexing_maps = [#map, #map], iterator_types = ["parallel", "parallel"]} ins(%arg0 : tensor<5x5xf32>) outs(%arg1 : tensor<5x5xf32>) {
       ^
/home/dbudii/personal/llvm-project/mlir/test/mlir-query/complex-test.mlir:7:10: note: "root" binds here
    %2 = arith.addf %in, %in : f32
         ^
Match #2:

/home/dbudii/personal/llvm-project/mlir/test/mlir-query/complex-test.mlir:10:16:
  %collapsed = tensor.collapse_shape %0 [[0, 1]] : tensor<5x5xf32> into tensor<25xf32>
               ^
/home/dbudii/personal/llvm-project/mlir/test/mlir-query/complex-test.mlir:13:11:
    %c2 = arith.constant 2 : index
          ^
/home/dbudii/personal/llvm-project/mlir/test/mlir-query/complex-test.mlir:14:18:
    %extracted = tensor.extract %collapsed[%c2] : tensor<25xf32>
                 ^
/home/dbudii/personal/llvm-project/mlir/test/mlir-query/complex-test.mlir:15:10: note: "root" binds here
    %2 = arith.addf %extracted, %extracted : f32
         ^
2 matches.
```



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list