LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
LLZKLayout.h
Go to the documentation of this file.
1//===-- LLZKLayout.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/BuiltinAttributes.h>
13#include <mlir/IR/BuiltinOps.h>
14#include <mlir/Support/LogicalResult.h>
15
16#include <llvm/ADT/DenseMap.h>
17#include <llvm/ADT/SmallVector.h>
18
19#include <cstdint>
20#include <optional>
21
22namespace llvm {
23class raw_ostream;
24} // namespace llvm
25
26namespace llzk {
27
29inline constexpr char LAYOUT_MAIN_ROOT[] = "main";
31inline constexpr char LAYOUT_ARGUMENT_ROOT[] = "arg";
32
45struct LLZKLayout {
47 llvm::SmallVector<mlir::ArrayAttr> signalPaths;
49 llvm::DenseMap<mlir::ArrayAttr, uint64_t> signalIds;
52 llvm::SmallVector<mlir::StringAttr> argumentNames;
53
56 std::optional<uint64_t> getSignalId(mlir::ArrayAttr path) const;
57};
58
68mlir::FailureOr<LLZKLayout> buildLLZKLayout(mlir::ModuleOp module);
69
72void printLLZKLayout(const LLZKLayout &layout, llvm::raw_ostream &output);
73
74} // namespace llzk
void printLLZKLayout(const LLZKLayout &layout, llvm::raw_ostream &output)
Print the logical signal section of the .llzk-layout format.
mlir::FailureOr< LLZKLayout > buildLLZKLayout(mlir::ModuleOp module)
Enumerate the signal leaves of llzk.main and its constrain arguments.
constexpr char LAYOUT_ARGUMENT_ROOT[]
Structural path root for a constrain argument, followed by its position.
Definition LLZKLayout.h:31
constexpr char LAYOUT_MAIN_ROOT[]
Structural path root for storage in the main instance.
Definition LLZKLayout.h:29
Logical felt-signal paths in a monomorphized LLZK circuit.
Definition LLZKLayout.h:45
llvm::SmallVector< mlir::ArrayAttr > signalPaths
Structural paths indexed by logical signal ID.
Definition LLZKLayout.h:47
llvm::SmallVector< mlir::StringAttr > argumentNames
Optional display names indexed by constrain argument position.
Definition LLZKLayout.h:52
std::optional< uint64_t > getSignalId(mlir::ArrayAttr path) const
Look up a structural path in this layout.
llvm::DenseMap< mlir::ArrayAttr, uint64_t > signalIds
Reverse mapping from structural storage paths to logical signal IDs.
Definition LLZKLayout.h:49