LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
AnalysisUtil.cpp
Go to the documentation of this file.
1//===-- AnalysisUtil.cpp - Data-flow analysis utils -------------*- C++ -*-===//
2//
3// Part of the LLZK Project, under the Apache License v2.0.
4// See LICENSE.txt for license information.
5// Copyright 2025 Veridise Inc.
6// SPDX-License-Identifier: Apache-2.0
7//
8//===----------------------------------------------------------------------===//
9
11
12#include <mlir/Analysis/DataFlow/ConstantPropagationAnalysis.h>
13#include <mlir/Analysis/DataFlow/DeadCodeAnalysis.h>
14#include <mlir/IR/Operation.h>
15
16using namespace mlir;
17
18using Executable = mlir::dataflow::Executable;
19
20namespace llzk::dataflow {
21
22void loadRequiredAnalyses(DataFlowSolver &solver) {
23 solver.load<mlir::dataflow::SparseConstantPropagation>();
24 solver.load<mlir::dataflow::DeadCodeAnalysis>();
25}
26
27LogicalResult loadAndRunRequiredAnalyses(DataFlowSolver &solver, Operation *op) {
29 return solver.initializeAndRun(op);
30}
31
32bool isOperationLive(DataFlowSolver &solver, Operation *op) {
33 if (!op->getBlock()) {
34 return true;
35 }
36 if (const auto *exec =
37 solver.lookupState<Executable>(solver.getProgramPointBefore(op->getBlock()))) {
38 return exec->isLive();
39 }
40 return true;
41}
42
43} // namespace llzk::dataflow
mlir::dataflow::Executable Executable
void loadRequiredAnalyses(DataFlowSolver &solver)
LogicalResult loadAndRunRequiredAnalyses(DataFlowSolver &solver, Operation *op)
bool isOperationLive(DataFlowSolver &solver, Operation *op)