summaryrefslogtreecommitdiff
path: root/mlir/lib/Tools/PDLL/AST/NodePrinter.cpp
AgeCommit message (Collapse)Author
2025-10-06[mlir] Simplify unreachable type switch cases. NFC. (#162032)Jakub Kuderski
Use `DefaultUnreachable` from https://github.com/llvm/llvm-project/pull/161970.
2025-07-24[mlir] Remove unused includes (NFC) (#150476)Kazu Hirata
These are identified by misc-include-cleaner. I've filtered out those that break builds. Also, I'm staying away from llvm-config.h, config.h, and Compiler.h, which likely cause platform- or compiler-specific build failures.
2023-09-01[MLIR][PDL] Add PDLL support for negated native constraintsMogball
This commit enables the expression of negated native constraints in PDLL: If a constraint is prefixed with "not" it is parsed as a negated constraint and hence the attribute `isNegated` of the emitted `pdl.apply_native_constraint` operation is set to `true`. In first instance this is only supported for the calling of external native C++ constraints and generation of PDL patterns. Previously, negating a native constraint would have been handled by creating an additional native call, e.g. ```PDLL Constraint checkA(input: Attr); Constarint checkNotA(input: Attr); ``` or by including an explicit additional operand for negation, e.g. `Constraint checkA(input: Attr, negated: Attr);` With this a constraint can simply be negated by prefixing it with `not`. e.g. ```PDLL Constraint simpleConstraint(op: Op); Pattern example { let inputOp = op<test.bar>() ->(type: Type); let root = op<test.foo>(inputOp.0) -> (); not simpleConstraint(inputOp); simpleConstraint(root); erase root; } ``` Depends on [[ https://reviews.llvm.org/D153871 | D153871 ]] Reviewed By: Mogball Differential Revision: https://reviews.llvm.org/D153959
2023-01-14[mlir] Use std::optional instead of llvm::Optional (NFC)Kazu Hirata
This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to remove #include "llvm/ADT/Optional.h". This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-13[mlir] Add #include <optional> (NFC)Kazu Hirata
This patch adds #include <optional> to those files containing llvm::Optional<...> or Optional<...>. I'll post a separate patch to actually replace llvm::Optional with std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-10Move from llvm::makeArrayRef to ArrayRef deduction guides - last partserge-sans-paille
This is a follow-up to https://reviews.llvm.org/D140896, split into several parts as it touches a lot of files. Differential Revision: https://reviews.llvm.org/D141298
2022-12-16[mlir] Drop uses of operator<<(raw_ostream &OS, const Optional<T> &O)Fangrui Song
2022-12-02Use CTAD on llvm::SaveAndRestoreJan Svoboda
Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D139229
2022-11-08[mlir:PDLL] Add support for building a range from a tuple within a rewriteRiver Riddle
This allows for constructing type and value ranges from various sub elements, which makes it easier to construct operations that take a range as an operand or result type. Range construction is currently limited to within rewrites, to match the current constraint on the PDL side. Differential Revision: https://reviews.llvm.org/D133720
2022-09-18[mlir] Use x.empty() instead of llvm::empty(x) (NFC)Kazu Hirata
I'm planning to deprecate and eventually remove llvm::empty. Note that no use of llvm::empty requires the ability of llvm::empty to determine the emptiness from begin/end only.
2022-02-10[PDLL] Add support for user defined constraint and rewrite functionsRiver Riddle
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
2021-12-16[PDLL] Add a `rewrite` statement to enable complex rewritesRiver Riddle
The `rewrite` statement allows for rewriting a given root operation with a block of nested rewriters. The root operation is not implicitly erased or replaced, and any transformations to it must be expressed within the nested rewrite block. The inner body may contain any number of other rewrite statements, variables, or expressions. Differential Revision: https://reviews.llvm.org/D115299
2021-12-16[PDLL] Add a `replace` rewrite statement for replacing operationsRiver Riddle
This statement acts as a companion to the existing `erase` statement, and is the corresponding PDLL construct for the `PatternRewriter::replaceOp` C++ API. This statement replaces a given operation with a set of values. Differential Revision: https://reviews.llvm.org/D115298
2021-12-16[PDLL] Add support for tuple types and expressionsRiver Riddle
Tuples are used to group multiple elements into a single compound value. The values in a tuple can be of any type, and do not need to be of the same type. There is also no limit to the number of elements held by a tuple. Tuples will be used to support multiple results from Constraints and Rewrites (added in a followup), and will also make it easier to support more complex primitives (such as range based maps that can operate on multiple values). Differential Revision: https://reviews.llvm.org/D115297
2021-12-16[PDLL] Add support for `op` Operation expressionsRiver Riddle
An operation expression in PDLL represents an MLIR operation. In the match section of a pattern, this expression models one of the input operations to the pattern. In the rewrite section of a pattern, this expression models one of the operations to create. The general structure of the operation expression is very similar to that of the "generic form" of textual MLIR assembly: ``` let root = op<my_dialect.foo>(operands: ValueRange) {attr = attr: Attr} -> (resultTypes: TypeRange); ``` For now we only model the components that are within PDL, as PDL gains support for blocks and regions so will this expression. Differential Revision: https://reviews.llvm.org/D115296
2021-12-16[PDLL] Add support for literal Attribute and Type expressionsRiver Riddle
This allows for using literal attributes and types within PDLL, which simplifies building both constraints and rewriters. For example, checking if an attribute is true is as simple as `attr<"true">`. Differential Revision: https://reviews.llvm.org/D115295
2021-12-16[mlir][PDLL] Add an initial frontend for PDLLRiver Riddle
This is a new pattern rewrite frontend designed from the ground up to support MLIR constructs, and to target PDL. This frontend language was proposed in https://llvm.discourse.group/t/rfc-pdll-a-new-declarative-rewrite-frontend-for-mlir/4798 This commit starts sketching out the base structure of the frontend, and is intended to be a minimal starting point for building up the language. It essentially contains support for defining a pattern, variables, and erasing an operation. The features mentioned in the proposal RFC (including IDE support) will be added incrementally in followup commits. I intend to upstream the documentation for the language in a followup when a bit more of the pieces have been landed. Differential Revision: https://reviews.llvm.org/D115093