[all-commits] [llvm/llvm-project] 1075c8: [mlir] support isa/cast/dyn_cast<Operation *>(oper...

ftynse via All-commits all-commits at lists.llvm.org
Tue May 17 02:15:44 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1075c8ca49b467ec5e654a4322fbb36f63e8687f
      https://github.com/llvm/llvm-project/commit/1075c8ca49b467ec5e654a4322fbb36f63e8687f
  Author: Alex Zinenko <zinenko at google.com>
  Date:   2022-05-17 (Tue, 17 May 2022)

  Changed paths:
    M mlir/include/mlir/IR/Operation.h

  Log Message:
  -----------
  [mlir] support isa/cast/dyn_cast<Operation *>(operation) again

The support for this has been added by 946311b8938114a37db5c9d42fb9f5a1481ccae1
but then ignored by bc22b5c9a2f729460ffdf7627b3534a8d9f3f767.

This enables one to write generic code that can be instantiated for both
specific operation classes and the common base class without
specialization. Examples include functions that take/return ops, such
as:

```mlir
template <typename FnTy>
void applyIf(FnTy &&lambda, ...) {
  for (Operation *op : ...) {
    auto specific = dyn_cast<function_traits<FnTy>::template arg_t<0>>(op);
    if (specific)
      lambda(specific);
  }
}
```

that would otherwise need to rely on template specialization to support
lambdas that take specific operations and those that take `Operation *`.

Differential Revision: https://reviews.llvm.org/D125543

Reviewed by: rriddle




More information about the All-commits mailing list