[all-commits] [llvm/llvm-project] 930916: [MLIR][PDL] Add PDLL support for negated native co...

Jeff Niu via All-commits all-commits at lists.llvm.org
Fri Sep 1 16:12:32 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 930916c7f3622870b40138dafcc5f94740404e8c
      https://github.com/llvm/llvm-project/commit/930916c7f3622870b40138dafcc5f94740404e8c
  Author: Mogball <jeff at modular.com>
  Date:   2023-09-01 (Fri, 01 Sep 2023)

  Changed paths:
    M mlir/include/mlir/Tools/PDLL/AST/Nodes.h
    M mlir/lib/Tools/PDLL/AST/NodePrinter.cpp
    M mlir/lib/Tools/PDLL/AST/Nodes.cpp
    M mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp
    M mlir/lib/Tools/PDLL/Parser/Lexer.cpp
    M mlir/lib/Tools/PDLL/Parser/Lexer.h
    M mlir/lib/Tools/PDLL/Parser/Parser.cpp
    M mlir/test/mlir-pdll/CodeGen/MLIR/expr.pdll
    M mlir/test/mlir-pdll/Parser/expr-failure.pdll
    M mlir/test/mlir-pdll/Parser/expr.pdll

  Log Message:
  -----------
  [MLIR][PDL] Add PDLL support for negated native constraints

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




More information about the All-commits mailing list