LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
EffectHelper.h
Go to the documentation of this file.
1//===-- EffectHelper.h ------------------------------------------*- C++ -*-===//
2//
3// Part of the LLZK Project, under the Apache License v2.0.
4// See LICENSE.txt for license information.
5// Copyright 2026 Project LLZK
6// SPDX-License-Identifier: Apache-2.0
7//
8//===----------------------------------------------------------------------===//
9
10#pragma once
11
12#include <mlir/IR/Operation.h>
13#include <mlir/Interfaces/SideEffectInterfaces.h>
14
15#include <llvm/ADT/STLExtras.h>
16
17namespace llzk {
18
21inline bool hasReadEffect(mlir::Operation *op) {
22 auto effects = mlir::getEffectsRecursively(op);
23 return effects && llvm::any_of(*effects, [](const mlir::MemoryEffects::EffectInstance &effect) {
24 return llvm::isa<mlir::MemoryEffects::Read>(effect.getEffect());
25 });
26}
27
30inline bool hasUnknownOrNonReadEffect(mlir::Operation *op) {
31 auto effects = mlir::getEffectsRecursively(op);
32 return !effects || llvm::any_of(*effects, [](const mlir::MemoryEffects::EffectInstance &effect) {
33 return !llvm::isa<mlir::MemoryEffects::Read>(effect.getEffect());
34 });
35}
36
37} // namespace llzk
bool hasReadEffect(mlir::Operation *op)
Returns true when op has a memory read effect.
bool hasUnknownOrNonReadEffect(mlir::Operation *op)
Returns true when op may have an unknown effect or any effect other than memory read.