[TableGen] Better support for predicate and rewrite rule specification
authorLei Zhang <antiagainst@google.com>
Fri, 12 Apr 2019 12:57:50 +0000 (05:57 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Thu, 18 Apr 2019 18:47:27 +0000 (11:47 -0700)
commit48a6aa6c513f471c5931c0f817beca5339ed2425
treef14ae969ec5ba3b74a02ba32fe2b79d8a4f92a1b
parent4d243f138a0462d226647aeab60df4f598a43f88
[TableGen] Better support for predicate and rewrite rule specification

    Currently predicates are written with positional placeholders `{N}` and rely on
    `formatv` as the engine to do substitution. The problem with this approach is that
    the definitions of those positional placeholders are not consistent; they are
    entirely up to the defining predicate of question. For example, `{0}` in various
    attribute constraints is used to mean the attribute, while it is used to main the
    builder for certain attribute transformations. This can become very confusing.

    This CL introduces `tgfmt` as a new mechanism to better support for predicate and
    rewrite rule specification. Instead of entirely relying on positional placeholders,
    `tgfmt` support both positional and special placeholders. The former is used for
    DAG operands. The latter, including $_builder, $_op, $_self, are used as special
    "hooks" to entities in the context. With this, the predicate and rewrite rules
    specification can be more consistent is more readable.

--

PiperOrigin-RevId: 243249671
mlir/include/mlir/TableGen/Format.h [new file with mode: 0644]
mlir/lib/TableGen/CMakeLists.txt
mlir/lib/TableGen/Format.cpp [new file with mode: 0644]
mlir/unittests/CMakeLists.txt
mlir/unittests/TableGen/CMakeLists.txt [new file with mode: 0644]
mlir/unittests/TableGen/FormatTest.cpp [new file with mode: 0644]