Skip to content

Commit

Permalink
mlir: fix regions view
Browse files Browse the repository at this point in the history
  • Loading branch information
xlauko committed Aug 15, 2024
1 parent 107767b commit 471324e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
15 changes: 12 additions & 3 deletions mlir/include/gap/mlir/views.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,18 @@

namespace gap::mlir::views
{
auto regions(operation op) -> decltype(std::views::all(op->getRegions()));
auto blocks(operation op) -> decltype(std::views::join(regions(op)));
auto operations(operation op) -> decltype(std::views::join(blocks(op)));
static inline auto regions(operation op) -> decltype(auto) {
auto regs = op->getRegions();
return std::ranges::subrange{regs.begin(), regs.end()};
}

static inline auto blocks(operation op) -> decltype(auto) {
return regions(op) | std::views::join;
}

static inline auto operations(operation op) -> decltype(auto) {
return blocks(op) | std::views::join;
}

template< typename T >
auto isa = std::views::filter(::gap::mlir::isa< T >);
Expand Down
11 changes: 0 additions & 11 deletions mlir/src/views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,5 @@

namespace gap::mlir::views
{
auto regions(operation op) -> decltype(std::views::all(op->getRegions())) {
return op->getRegions() | std::views::all;
}

auto blocks(operation op) -> decltype(std::views::join(regions(op))) {
return regions(op) | std::views::join;
}

auto operations(operation op) -> decltype(std::views::join(blocks(op))) {
return blocks(op) | std::views::join;
}

} // namespace gap::mlir::views

0 comments on commit 471324e

Please sign in to comment.