llvm-project/mlir/lib/Parser
River Riddle 3fb3927bd3 [mlir] Add a new "Pattern Descriptor Language" (PDL) dialect.
PDL presents a high level abstraction for the rewrite pattern infrastructure available in MLIR. This abstraction allows for representing patterns transforming MLIR, as MLIR. This allows for applying all of the benefits that the general MLIR infrastructure provides, to the infrastructure itself. This means that pattern matching can be more easily verified for correctness, targeted by frontends, and optimized.

PDL abstracts over various different aspects of patterns and core MLIR data structures. Patterns are specified via a `pdl.pattern` operation. These operations contain a region body for the "matcher" code, and terminate with a `pdl.rewrite` that either dispatches to an external rewriter or contains a region for the rewrite specified via `pdl`. The types of values in `pdl` are handle types to MLIR C++ types, with `!pdl.attribute`, `!pdl.operation`, and `!pdl.type` directly mapping to `mlir::Attribute`, `mlir::Operation*`, and `mlir::Value` respectively.

An example pattern is shown below:

```mlir
// pdl.pattern contains metadata similarly to a `RewritePattern`.
pdl.pattern : benefit(1) {
  // External input operand values are specified via `pdl.input` operations.
  // Result types are constrainted via `pdl.type` operations.

  %resultType = pdl.type
  %inputOperand = pdl.input
  %root, %results = pdl.operation "foo.op"(%inputOperand) -> %resultType
  pdl.rewrite(%root) {
    pdl.replace %root with (%inputOperand)
  }
}
```

This is a culmination of the work originally discussed here: https://groups.google.com/a/tensorflow.org/g/mlir/c/j_bn74ByxlQ

Differential Revision: https://reviews.llvm.org/D84578
2020-08-19 13:13:06 -07:00
..
AffineParser.cpp [mlir][NFC] Split Parser into several different files. 2020-06-10 17:17:13 -07:00
AttributeParser.cpp Separate the Registration from Loading dialects in the Context 2020-08-19 01:19:03 +00:00
CMakeLists.txt [mlir][NFC] Split Parser into several different files. 2020-06-10 17:17:13 -07:00
DialectSymbolParser.cpp Separate the Registration from Loading dialects in the Context 2020-08-19 01:19:03 +00:00
Lexer.cpp Fix a bug in the .mlir lexer, where a \0 character in a file is treated as a colon (due to an accidental fall through) instead of whitespace. 2020-03-23 17:35:17 -07:00
Lexer.h Mass update the MLIR license header to mention "Part of the LLVM project" 2020-01-26 03:58:30 +00:00
LocationParser.cpp [mlir][NFC] Split Parser into several different files. 2020-06-10 17:17:13 -07:00
Parser.cpp [mlir] Add a new "Pattern Descriptor Language" (PDL) dialect. 2020-08-19 13:13:06 -07:00
Parser.h [mlir] Add support for parsing optional Attribute values. 2020-07-14 13:14:59 -07:00
ParserState.h [mlir][NFC] Split Parser into several different files. 2020-06-10 17:17:13 -07:00
Token.cpp [mlir][NFC] Split Parser into several different files. 2020-06-10 17:17:13 -07:00
Token.h [mlir][NFC] Split Parser into several different files. 2020-06-10 17:17:13 -07:00
TokenKinds.def Fix a bug in the .mlir lexer, where a \0 character in a file is treated as a colon (due to an accidental fall through) instead of whitespace. 2020-03-23 17:35:17 -07:00
TypeParser.cpp [mlir] Allow index as element type of memref 2020-07-30 14:35:22 +02:00