[mlir] add readonly/consume annotations to transform named sequences
authorAlex Zinenko <zinenko@google.com>
Thu, 30 Mar 2023 12:31:48 +0000 (12:31 +0000)
committerAlex Zinenko <zinenko@google.com>
Tue, 4 Apr 2023 09:38:00 +0000 (09:38 +0000)
commit4110934120ed4e4309099be3389faef128f72c03
tree9d91bf18eb1b5dcd7b6ae38b01dbe02671b60fa3
parentebd579ccae97c060a309a8a212281d46cf8538a1
[mlir] add readonly/consume annotations to transform named sequences

Use the argument attribute mechanism for function-like operations to
annotate the arguments of named transform sequences as consuming or only
reading the handles passed as arguments. This makes it possible to
correctly specify handle invalidation for external named sequences by
requiring their declarations to always provide such annotations.
Additionally, these annotations remove the need to analyze the body of
a named sequence to understand its effects on the arguments. Make them
required for named sequences that are called from the same file, in
addition to external sequences.

Provide a convenience pass that infers annotations by analyzing bodies
of named sequences provided they are not called from the same file.

Reviewed By: springerm

Differential Revision: https://reviews.llvm.org/D147223
17 files changed:
mlir/include/mlir/Dialect/Transform/IR/TransformDialect.td
mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h
mlir/include/mlir/Dialect/Transform/Transforms/Passes.h
mlir/include/mlir/Dialect/Transform/Transforms/Passes.td
mlir/lib/Dialect/Transform/IR/TransformDialect.cpp
mlir/lib/Dialect/Transform/IR/TransformInterfaces.cpp
mlir/lib/Dialect/Transform/IR/TransformOps.cpp
mlir/lib/Dialect/Transform/Transforms/CMakeLists.txt
mlir/lib/Dialect/Transform/Transforms/InferEffects.cpp [new file with mode: 0644]
mlir/lib/Dialect/Transform/Transforms/TransformInterpreterPassBase.cpp
mlir/test/Dialect/Transform/infer-effects.mlir [new file with mode: 0644]
mlir/test/Dialect/Transform/ops-invalid.mlir
mlir/test/Dialect/Transform/test-interpreter-external-symbol-decl-and-schedule.mlir
mlir/test/Dialect/Transform/test-interpreter-external-symbol-decl-invalid.mlir
mlir/test/Dialect/Transform/test-interpreter-external-symbol-decl.mlir
mlir/test/Dialect/Transform/test-interpreter-external-symbol-def.mlir
mlir/test/Dialect/Transform/test-interpreter.mlir