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

ftynse via All-commits all-commits at lists.llvm.org
Mon May 2 01:07:25 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 946311b8938114a37db5c9d42fb9f5a1481ccae1
      https://github.com/llvm/llvm-project/commit/946311b8938114a37db5c9d42fb9f5a1481ccae1
  Author: Alex Zinenko <zinenko at google.com>
  Date:   2022-05-02 (Mon, 02 May 2022)

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

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

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 *`.

Reviewed By: rriddle

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




More information about the All-commits mailing list