[all-commits] [llvm/llvm-project] 242762: [mlir][pdl] Restructure how results are represented.

River Riddle via All-commits all-commits at lists.llvm.org
Tue Mar 16 13:20:44 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 242762c9a3313c8aea176ca76fb77adf8edf0907
      https://github.com/llvm/llvm-project/commit/242762c9a3313c8aea176ca76fb77adf8edf0907
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2021-03-16 (Tue, 16 Mar 2021)

  Changed paths:
    M mlir/include/mlir/Dialect/PDL/IR/PDLDialect.td
    M mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
    M mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
    M mlir/lib/Conversion/PDLToPDLInterp/Predicate.h
    M mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
    M mlir/lib/Dialect/PDL/IR/PDL.cpp
    M mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-matcher.mlir
    M mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-rewriter.mlir
    M mlir/test/Dialect/PDL/invalid.mlir
    M mlir/test/Dialect/PDL/ops.mlir

  Log Message:
  -----------
  [mlir][pdl] Restructure how results are represented.

Up until now, results have been represented as additional results to a pdl.operation. This is fairly clunky, as it mismatches the representation of the rest of the IR constructs(e.g. pdl.operand) and also isn't a viable representation for operations returned by pdl.create_native. This representation also creates much more difficult problems when factoring in support for variadic result groups, optional results, etc. To resolve some of these problems, and simplify adding support for variable length results, this revision extracts the representation for results out of pdl.operation in the form of a new `pdl.result` operation. This operation returns the result of an operation at a given index, e.g.:

```
%root = pdl.operation ...
%result = pdl.result 0 of %root
```

Differential Revision: https://reviews.llvm.org/D95719


  Commit: 02c4c0d5b2adc79c122bd2662a4458f75771aecf
      https://github.com/llvm/llvm-project/commit/02c4c0d5b2adc79c122bd2662a4458f75771aecf
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2021-03-16 (Tue, 16 Mar 2021)

  Changed paths:
    M mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
    M mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td
    M mlir/include/mlir/IR/PatternMatch.h
    M mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
    M mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
    M mlir/lib/Dialect/PDL/IR/PDL.cpp
    M mlir/lib/IR/PatternMatch.cpp
    M mlir/lib/Rewrite/ByteCode.cpp
    M mlir/lib/Rewrite/ByteCode.h
    M mlir/lib/Rewrite/FrozenRewritePatternList.cpp
    M mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-matcher.mlir
    M mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-rewriter.mlir
    M mlir/test/Dialect/PDL/invalid.mlir
    M mlir/test/Rewrite/pdl-bytecode.mlir
    M mlir/test/lib/Rewrite/TestPDLByteCode.cpp

  Log Message:
  -----------
  [mlir][pdl] Remove CreateNativeOp in favor of a more general ApplyNativeRewriteOp.

This has a numerous amount of benefits, given the overly clunky nature of CreateNativeOp:
* Users can now call into arbitrary rewrite functions from inside of PDL, allowing for more natural interleaving of PDL/C++ and enabling for more of the pattern to be in PDL.
* Removes the need for an additional set of C++ functions/registry/etc. The new ApplyNativeRewriteOp will use the same PDLRewriteFunction as the existing RewriteOp. This reduces the API surface area exposed to users.

This revision also introduces a new PDLResultList class. This class is used to provide results of native rewrite functions back to PDL. We introduce a new class instead of using a SmallVector to simplify the work necessary for variadics, given that ranges will require some changes to the structure of PDLValue.

Differential Revision: https://reviews.llvm.org/D95720


  Commit: 1eb6994d6ab18d5f6555acf515d27e2076fbea8a
      https://github.com/llvm/llvm-project/commit/1eb6994d6ab18d5f6555acf515d27e2076fbea8a
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2021-03-16 (Tue, 16 Mar 2021)

  Changed paths:
    M mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
    M mlir/include/mlir/Dialect/PDL/IR/PDLTypes.td
    M mlir/lib/Dialect/PDL/IR/PDL.cpp
    M mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-matcher.mlir
    M mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-rewriter.mlir
    M mlir/test/Dialect/PDL/invalid.mlir
    M mlir/test/Dialect/PDL/ops.mlir

  Log Message:
  -----------
  [mlir][PDL] Add support for variadic operands and results in PDL

This revision extends the PDL dialect to add support for variadic operands and results, with ranges of these values represented via the recently added !pdl.range type. To support this extension, three new operations have been added that closely match the single variant:
* pdl.operands : Define a range of input operands.
* pdl.results : Extract a result group from an operation.
* pdl.types : Define a handle to a range of types.

Support for these in the pdl interpreter dialect and byte code will be added in followup revisions.

Differential Revision: https://reviews.llvm.org/D95721


  Commit: 3a833a0e0e526d4ef3f0037eaa2ace3511f216ce
      https://github.com/llvm/llvm-project/commit/3a833a0e0e526d4ef3f0037eaa2ace3511f216ce
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2021-03-16 (Tue, 16 Mar 2021)

  Changed paths:
    M mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td
    M mlir/include/mlir/IR/OpBase.td
    M mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
    M mlir/lib/Conversion/PDLToPDLInterp/Predicate.cpp
    M mlir/lib/Conversion/PDLToPDLInterp/Predicate.h
    M mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
    M mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.h
    M mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp
    M mlir/lib/Rewrite/ByteCode.cpp
    M mlir/lib/TableGen/Predicate.cpp
    M mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-matcher.mlir
    M mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-rewriter.mlir
    M mlir/test/Dialect/PDLInterp/ops.mlir
    M mlir/test/Rewrite/pdl-bytecode.mlir
    M mlir/test/mlir-tblgen/op-attribute.td

  Log Message:
  -----------
  [mlir][PDL] Add support for variadic operands and results in the PDL Interpreter

This revision extends the PDL Interpreter dialect to add support for variadic operands and results, with ranges of these values represented via the recently added !pdl.range type. To support this extension, three new operations have been added that closely match the single variant:
* pdl_interp.check_types : Compare a range of types with a known range.
* pdl_interp.create_types : Create a constant range of types.
* pdl_interp.get_operands : Get a range of operands from an operation.
* pdl_interp.get_results : Get a range of results from an operation.
* pdl_interp.switch_types : Switch on a range of types.

This revision handles adding support in the interpreter dialect and the conversion from PDL to PDLInterp. Support for variadic operands and results in the bytecode will be added in a followup revision.

Differential Revision: https://reviews.llvm.org/D95722


  Commit: 85ab413b53aeb135eb58dab066afcbf20bef0cf8
      https://github.com/llvm/llvm-project/commit/85ab413b53aeb135eb58dab066afcbf20bef0cf8
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2021-03-16 (Tue, 16 Mar 2021)

  Changed paths:
    M mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td
    M mlir/include/mlir/IR/PatternMatch.h
    M mlir/include/mlir/IR/TypeRange.h
    M mlir/lib/IR/PatternMatch.cpp
    M mlir/lib/Rewrite/ByteCode.cpp
    M mlir/lib/Rewrite/ByteCode.h
    M mlir/lib/Rewrite/PatternApplicator.cpp
    M mlir/test/Rewrite/pdl-bytecode.mlir
    M mlir/test/lib/Rewrite/TestPDLByteCode.cpp

  Log Message:
  -----------
  [mlir][PDL] Add support for variadic operands and results in the PDL byte code

Supporting ranges in the byte code requires additional complexity, given that a range can't be easily representable as an opaque void *, as is possible with the existing bytecode value types (Attribute, Type, Value, etc.). To enable representing a range with void *, an auxillary storage is used for the actual range itself, with the pointer being passed around in the normal byte code memory. For type ranges, a TypeRange is stored. For value ranges, a ValueRange is stored. The above problem represents a majority of the complexity involved in this revision, the rest is adapting/adding byte code operations to support the changes made to the PDL interpreter in the parent revision.

After this revision, PDL will have initial end-to-end support for variadic operands/results.

Differential Revision: https://reviews.llvm.org/D95723


Compare: https://github.com/llvm/llvm-project/compare/1bc8f5fbb4d4...85ab413b53ae


More information about the All-commits mailing list