[Mlir-commits] [mlir] [mlir] MLIR-QUERY slice-matchers implementation (PR #115670)
Denzel-Brian Budii
llvmlistbot at llvm.org
Wed Feb 26 22:51:48 PST 2025
================
@@ -363,8 +366,267 @@ struct RecursivePatternMatcher {
std::tuple<OperandMatchers...> operandMatchers;
};
+/// Fills `backwardSlice` with the computed backward slice (i.e.
+/// all the transitive defs of op)
+///
+/// The implementation traverses the def chains in postorder traversal for
+/// efficiency reasons: if an operation is already in `backwardSlice`, no
+/// need to traverse its definitions again. Since use-def chains form a DAG,
+/// this terminates.
+///
+/// Upon return to the root call, `backwardSlice` is filled with a
+/// postorder list of defs. This happens to be a topological order, from the
+/// point of view of the use-def chains.
+///
+/// Example starting from node 8
+/// ============================
+///
+/// 1 2 3 4
+/// |_______| |______|
+/// | | |
+/// | 5 6
+/// |___|_____________|
+/// | |
+/// 7 8
+/// |_______________|
+/// |
+/// 9
+///
+/// Assuming all local orders match the numbering order:
+/// {1, 2, 5, 3, 4, 6}
+///
+
+class BackwardSliceMatcher {
----------------
chios202 wrote:
Yes, implementations would be better in a .cpp file
https://github.com/llvm/llvm-project/pull/115670
More information about the Mlir-commits
mailing list