1//===-- TransformationPasses.td ----------------------------*- tablegen -*-===//
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
8//===----------------------------------------------------------------------===//
10#ifndef LLZK_DIALECT_STRUCT_TRANSFORMS_TRANSFORMATION_PASSES_TD
11#define LLZK_DIALECT_STRUCT_TRANSFORMS_TRANSFORMATION_PASSES_TD
13include "llzk/Pass/PassBase.td"
15def InlineStructsPass : LLZKPass<"llzk-inline-structs"> {
16 let summary = "Inlines nested structs (i.e., subcomponents).";
18 This pass inlines nested structs (i.e., subcomponents) at struct-type members and at calls to the
19 subcomponent compute/constrain functions. Inlining decisions are guided by the call graph of
20 "constrain" functions.
22 The `max-merge-complexity` parameter can be used to limit the complexity of the resulting structs such
23 that a potential inlining will not take place if doing so would push the sum of constraint and
24 multiplications in the combined struct over the limit. The default value `0` indicates no limits
25 which means all structs will be inlined into the Main struct.
27 This pass should be run after `llzk-flatten` to ensure structs do not have template parameters
28 because structs with template parameters cannot (currently) be inlined. Inlining is also not
29 (currently) supported for subcomponent structs stored in an array-type member.
31 This pass also assumes that all subcomponents that are created by calling a struct "@compute"
32 function are ultimately written to exactly one member within the current struct.
34 let options = [Option<"maxComplexity", "max-merge-complexity", "uint64_t",
35 /* default: no limit */ "0",
36 "Maximum allowed constraint+multiplications in merged "
37 "@constrain functions">,
41def ExposeChildMembersPass : LLZKPass<"llzk-expose-child-members"> {
42 let summary = "Expose members of concrete child storage reachable from a "
45 This pass makes subcomponent fields public, allowing the constraint body to
46 access felt leaves when flattening constraints without scalarizing struct members.
48 For family storage, matching member declarations on the rolled template are
49 also exposed. This legalizes ordinary reads through unchanged family handles;
50 template bodies are not traversed or expanded. Signal annotations are preserved.
52 The root's own member visibility is preserved because changing it would change
53 the circuit's public interface and hence its semantics.
55 Use `root-struct` to select a root explicitly; otherwise the pass uses `llzk.main`.
57 let options = [Option<"rootStruct", "root-struct", "std::string", "\"\"",
58 "Root struct symbol path (defaults to llzk.main)">];
61#endif // LLZK_DIALECT_STRUCT_TRANSFORMS_TRANSFORMATION_PASSES_TD