LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
LLZKLoweringUtils.h
Go to the documentation of this file.
1//===-- LLZKLoweringUtils.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//===----------------------------------------------------------------------===//
13//===----------------------------------------------------------------------===//
14
15#pragma once
16
20
21#include <mlir/IR/Builders.h>
22#include <mlir/IR/BuiltinOps.h>
23#include <mlir/IR/Types.h>
24#include <mlir/IR/Value.h>
25#include <mlir/Support/LogicalResult.h>
26
27#include <llvm/ADT/DenseMap.h>
28
29namespace llzk {
30
32 std::string auxMemberName;
33 mlir::Value computedValue;
34};
35
42 mlir::Value val, function::FuncDefOp computeFunc, mlir::OpBuilder &builder,
43 llvm::DenseMap<mlir::Value, mlir::Value> &memo
44);
45
46mlir::LogicalResult
47checkForAuxMemberConflicts(component::StructDefOp structDef, llvm::StringRef auxPrefix);
48
53mlir::LogicalResult checkFuncBodyIsStraightLine(function::FuncDefOp func, llvm::StringRef passName);
54
56addAuxMember(component::StructDefOp structDef, llvm::StringRef name, mlir::Type type);
57
58unsigned getFeltDegree(mlir::Value val, llvm::DenseMap<mlir::Value, unsigned> &memo);
59
74void replaceSubsequentUsesWith(mlir::Value oldVal, mlir::Value newVal, mlir::Operation *afterOp);
75
76} // namespace llzk
Value rebuildExprInCompute(Value val, FuncDefOp computeFunc, OpBuilder &builder, DenseMap< Value, Value > &memo)
void replaceSubsequentUsesWith(Value oldVal, Value newVal, Operation *afterOp)
MemberDefOp addAuxMember(StructDefOp structDef, StringRef name, Type type)
LogicalResult checkFuncBodyIsStraightLine(FuncDefOp func, StringRef passName)
unsigned getFeltDegree(Value val, DenseMap< Value, unsigned > &memo)
LogicalResult checkForAuxMemberConflicts(StructDefOp structDef, StringRef prefix)