LLZK
3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Toggle main menu visibility
Loading...
Searching...
No Matches
ConstraintDependencyGraphPass.cpp
Go to the documentation of this file.
1
//===-- ConstraintDependencyGraphPass.cpp -----------------------*- 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
//===----------------------------------------------------------------------===//
13
//===----------------------------------------------------------------------===//
14
15
#include "
llzk/Analysis/AnalysisPasses.h
"
16
#include "
llzk/Analysis/ConstraintDependencyGraph.h
"
17
#include "
llzk/Util/SymbolHelper.h
"
18
19
#include <llvm/ADT/SmallVector.h>
20
#include <llvm/Support/ErrorHandling.h>
21
22
namespace
llzk
{
23
#define GEN_PASS_DEF_CONSTRAINTDEPENDENCYGRAPHPRINTERPASS
24
#include "
llzk/Analysis/AnalysisPasses.h.inc
"
25
}
// namespace llzk
26
27
using namespace
mlir
;
28
29
namespace
{
30
31
class
PassImpl :
public
llzk::impl::ConstraintDependencyGraphPrinterPassBase
<PassImpl> {
32
using
Base = ConstraintDependencyGraphPrinterPassBase<PassImpl>;
33
using
Base::Base;
34
35
void
runOnOperation()
override
{
36
markAllAnalysesPreserved();
37
38
if
(!llvm::isa<ModuleOp>(getOperation())) {
39
const
char
*msg =
"ConstraintDependencyGraphPrinterPass error: should be run on ModuleOp!"
;
40
getOperation()->emitError(msg).report();
41
llvm::report_fatal_error(msg);
42
}
43
44
auto
&cs = getAnalysis<llzk::ConstraintDependencyGraphModuleAnalysis>();
45
cs.setIntraprocedural(runIntraprocedural);
46
auto
am = getAnalysisManager();
47
cs.ensureAnalysisRun(am);
48
49
auto
&os =
llzk::toStream
(outputStream);
50
for
(
const
auto
&[s, cdg] : cs.getCurrentResults()) {
51
auto
&structDef =
const_cast<
llzk::component::StructDefOp &
>
(s);
52
FailureOr<SymbolRefAttr> fullName =
llzk::getPathFromTopRoot
(structDef);
53
llzk::ensure
(
54
succeeded(fullName),
55
"could not resolve fully qualified name of struct "
+ Twine(structDef.getName())
56
);
57
os << fullName.value() <<
' '
;
58
cdg.get().print(os);
59
}
60
}
61
};
62
63
}
// namespace
AnalysisPasses.h.inc
AnalysisPasses.h
ConstraintDependencyGraph.h
SymbolHelper.h
llzk::impl::ConstraintDependencyGraphPrinterPassBase
Definition
ConstraintDependencyGraphPass.cpp:268
llzk
Definition
AnalysisPassEnums.cpp:19
llzk::toStream
llvm::raw_ostream & toStream(OutputStream val)
Definition
AnalysisPassEnums.cpp:21
llzk::ensure
void ensure(bool condition, const llvm::Twine &errMsg)
Definition
ErrorHelper.h:159
llzk::getPathFromTopRoot
FailureOr< SymbolRefAttr > getPathFromTopRoot(SymbolOpInterface to, ModuleOp *foundRoot)
Definition
SymbolHelper.cpp:328
mlir
Definition
ValueModel.h:30
lib
Analysis
ConstraintDependencyGraphPass.cpp
Generated by
1.17.0
Copyright 2025 Veridise Inc. under the Apache License v2.0. Copyright 2026 Project LLZK under the Apache License v2.0.