[all-commits] [llvm/llvm-project] a3d247: [MLIR][OpenMP] Enable BlockArgOpenMPOpInterface ac...

Sergio Afonso via All-commits all-commits at lists.llvm.org
Tue Mar 11 05:56:35 PDT 2025


  Branch: refs/heads/users/skatrak/omp-blockarg-iface-operands
  Home:   https://github.com/llvm/llvm-project
  Commit: a3d247dbe2d127dc493a7a915bde8ed25e63d23f
      https://github.com/llvm/llvm-project/commit/a3d247dbe2d127dc493a7a915bde8ed25e63d23f
  Author: Sergio Afonso <safonsof at amd.com>
  Date:   2025-03-11 (Tue, 11 Mar 2025)

  Changed paths:
    M mlir/include/mlir/Dialect/OpenMP/OpenMPClauses.td
    M mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
    M mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td
    M mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

  Log Message:
  -----------
  [MLIR][OpenMP] Enable BlockArgOpenMPOpInterface accessing operands

This patch makes additions to the `BlockArgOpenMPOpInterface` to simplify its
use by letting it handle the matching between operands and their associated
entry block arguments. Most significantly, the following is now possible:

```c++
SmallVector<std::pair<Value, BlockArgument>> pairs;
cast<BlockArgOpenMPOpInterface>(op).getBlockArgsPairs(pairs);
for (auto [var, arg] : pairs) {
  // var points to the operand (outside value) and arg points to the entry
  // block argument associated to that value.
}
```

This is achieved by making the interface define and use `getXyzVars()` methods,
which by default return empty `OperandRange`s and are overriden by getters
automatically produced for the `Variadic<...> $xyz_vars` tablegen argument of
the corresponding clause. These definitions can then be simplified, since they
no longer need to manually define `numXyzBlockArgs` functions as a result.

A side-effect of this is that all ops implementing this interface will now
publicly define `getXyzVars()` functions for all entry block
argument-generating clauses, even if they don't actually accept all clauses.
However, these would just return empty ranges, so it shouldn't cause issues.

This change uncovered some incorrect definitions of class declarations related
to the `ReductionClauseInterface`, and the `OpenMP_DetachClause` incorrectly
implementing the `BlockArgOpenMPOpInterface`, so these issues are also
addressed.



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