llvm-project/mlir/lib
River Riddle faf42264e5 [PDLL] Add support for user defined constraint and rewrite functions
These functions allow for defining pattern fragments usable within the `match` and `rewrite` sections of a pattern. The main structure of Constraints and Rewrites functions are the same, and are similar to functions in other languages; they contain a signature (i.e. name, argument list, result list) and a body:

```pdll
// Constraint that takes a value as an input, and produces a value:
Constraint Cst(arg: Value) -> Value { ... }

// Constraint that returns multiple values:
Constraint Cst() -> (result1: Value, result2: ValueRange);
```

When returning multiple results, each result can be optionally be named (the result of a Constraint/Rewrite in the case of multiple results is a tuple).

These body of a Constraint/Rewrite functions can be specified in several ways:

* Externally
In this case we are importing an external function (registered by the user outside of PDLL):

```pdll
Constraint Foo(op: Op);
Rewrite Bar();
```

* In PDLL (using PDLL constructs)
In this case, the body is defined using PDLL constructs:

```pdll
Rewrite BuildFooOp() {
  // The result type of the Rewrite is inferred from the return.
  return op<my_dialect.foo>;
}
// Constraints/Rewrites can also implement a lambda/expression
// body for simple one line bodies.
Rewrite BuildFooOp() => op<my_dialect.foo>;
```

* In PDLL (using a native/C++ code block)
In this case the body is specified using a C++(or potentially other language at some point) code block. When building PDLL in AOT mode this will generate a native constraint/rewrite and register it with the PDL bytecode.

```pdll
Rewrite BuildFooOp() -> Op<my_dialect.foo> [{
  return rewriter.create<my_dialect::FooOp>(...);
}];
```

Differential Revision: https://reviews.llvm.org/D115836
2022-02-10 12:48:59 -08:00
..
Analysis [MLIR][Presburger] Factor out space information to PresburgerSpace 2022-02-10 18:24:40 +05:30
Bindings/Python [mlir][python] 8b/16b DenseIntElements access 2022-01-21 05:21:09 +00:00
CAPI [mlir][capi] Add DialectRegistry to MLIR C-API 2022-02-01 13:42:06 -07:00
Conversion [mlir][vector][NFC] Use CombiningKindAttr instead of StringAttr 2022-02-10 19:13:29 +09:00
Dialect [MLIR][GPU][lld] Use LLD bundled in ROCm, removing workaround 2022-02-10 19:37:30 +00:00
ExecutionEngine [mlir][sparse] Rename index_t to index_type again 2022-02-09 21:59:52 +01:00
IR [mlir] Update uses of `parser`/`printer` ODS op field to `hasCustomAssemblyFormat` 2022-02-07 19:03:58 -08:00
Interfaces [mlir] Add isa/dyn_cast support for dialect interfaces 2022-01-31 19:24:34 -08:00
Parser [mlir] Silence warnings when building with MSVC 2022-01-30 17:31:35 -05:00
Pass [mlir][NFC] Add a using for llvm::SMLoc/llvm::SMRange to LLVM.h 2022-01-26 21:37:23 -08:00
Reducer Apply clang-tidy fixes for performance-move-const-arg in ReductionNode.cpp (NFC) 2022-01-10 01:05:14 +00:00
Rewrite [MLIR][PDL] Integration test of multi-root matching and related fixes. 2022-01-04 08:03:45 +05:30
Support Replace OwningModuleRef with OwningOpRef<ModuleOp> 2022-01-30 14:07:10 -08:00
TableGen [mlir][ods] Optional Attribute or Type Parameters 2022-02-08 20:09:44 +00:00
Target [mlir] Add missing dep to new cf dialect 2022-02-10 14:15:20 +00:00
Tools [PDLL] Add support for user defined constraint and rewrite functions 2022-02-10 12:48:59 -08:00
Transforms [mlir] Add pass to privatize symbols unless excluded. 2022-02-03 20:20:54 -08:00
Translation [mlir-translate] Teach these tools about --allow-unregistered-dialect 2022-02-03 09:00:38 -08:00
CMakeLists.txt [mlir] Ensure a newline at the end of a file (NFC) 2022-01-23 13:59:59 -08:00