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// Shared utilities for lowering passes in the LLZK project.
4//
5//===----------------------------------------------------------------------===//
6
7#pragma once
8
12
13#include <mlir/IR/Builders.h>
14#include <mlir/IR/BuiltinOps.h>
15#include <mlir/IR/Types.h>
16#include <mlir/IR/Value.h>
17#include <mlir/Support/LogicalResult.h>
18
19#include <llvm/ADT/DenseMap.h>
20
21namespace llzk {
22
24 std::string auxMemberName;
25 mlir::Value computedValue;
26};
27
34 mlir::Value val, function::FuncDefOp computeFunc, mlir::OpBuilder &builder,
35 llvm::DenseMap<mlir::Value, mlir::Value> &memo
36);
37
38mlir::LogicalResult
39checkForAuxMemberConflicts(component::StructDefOp structDef, llvm::StringRef auxPrefix);
40
45mlir::LogicalResult checkFuncBodyIsStraightLine(function::FuncDefOp func, llvm::StringRef passName);
46
48addAuxMember(component::StructDefOp structDef, llvm::StringRef name, mlir::Type type);
49
50unsigned getFeltDegree(mlir::Value val, llvm::DenseMap<mlir::Value, unsigned> &memo);
51
66void replaceSubsequentUsesWith(mlir::Value oldVal, mlir::Value newVal, mlir::Operation *afterOp);
67
68} // 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)