[all-commits] [llvm/llvm-project] 06bbbf: [MLIR] Cyclic AttrType Replacer (#98206)

Billy Zhu via All-commits all-commits at lists.llvm.org
Fri Jul 12 09:24:22 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 06bbbf1ee01fae55faf68f14c2c3e45d5b863da1
      https://github.com/llvm/llvm-project/commit/06bbbf1ee01fae55faf68f14c2c3e45d5b863da1
  Author: Billy Zhu <billyzhu at modular.com>
  Date:   2024-07-12 (Fri, 12 Jul 2024)

  Changed paths:
    M mlir/include/mlir/IR/AttrTypeSubElements.h
    M mlir/lib/IR/AttrTypeSubElements.cpp
    A mlir/unittests/IR/AttrTypeReplacerTest.cpp
    M mlir/unittests/IR/CMakeLists.txt

  Log Message:
  -----------
  [MLIR] Cyclic AttrType Replacer (#98206)

The current `AttrTypeReplacer` does not allow for custom handling of
replacer functions that may cause self-recursion. For example, the
replacement of one attr/type may depend on the replacement of another
attr/type (by calling into the replacer manually again), which in turn
may depend on the replacement of the original attr/type.

To enable this functionality, this PR broke out the original
AttrTypeReplacer into two parts:
- An uncached base version (`detail::AttrTypeReplacerBase`) that allows
registering replacer functions and has logic for invoking it on
attr/types & their sub-elements
- A cached version (`AttrTypeReplacer`) that provides the same caching
as the original one. This is still the one used everywhere and behavior
is unchanged.

On top of the uncached base version, a `CyclicAttrTypeReplacer` is
introduced that provides caching & cycle-handling for replacer logic
that is cyclic. Cycle-breaking & caching is provided by the
`CyclicReplacerCache` from
https://github.com/llvm/llvm-project/pull/98202.

Both concrete implementations of the uncached base version use CRTP to
avoid dynamic dispatch. The base class merely provides replacer
registration & invocation, and is not meant to be used, or otherwise
extended elsewhere.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list