LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
OpTraits.td
Go to the documentation of this file.
1//===-- OpTraits.td ----------------------------------------*- tablegen -*-===//
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//===----------------------------------------------------------------------===//
9
10#ifndef LLZK_FUNCTION_TRAITS
11#define LLZK_FUNCTION_TRAITS
12
13include "mlir/IR/OpBase.td"
14
15/// Marker for ops that are specific to witness generation. Op classes with
16/// this trait are valid only in functions that have the `AllowWitnessAttr`.
17def WitnessGen : NativeOpTrait<"WitnessGen">, StructuralOpTrait {
18 string cppNamespace = "::llzk::function";
19}
20
21/// Marker for ops that are specific to constraint generation. Op classes with
22/// this trait are valid only in functions that have the `AllowConstraintAttr`.
23def ConstraintGen : NativeOpTrait<"ConstraintGen">, StructuralOpTrait {
24 string cppNamespace = "::llzk::function";
25}
26
27/// Marker for ops over `llzk.felt` type operands that are not native to finite
28/// field arithmetic and thus must be rewritten or folded into a constant after
29/// the flattening and unrolling pass. Op classes with this trait are valid only
30/// in functions that have the `AllowNonNativeFieldOpsAttr`.
31def NotFieldNative : NativeOpTrait<"NotFieldNative">, StructuralOpTrait {
32 string cppNamespace = "::llzk::function";
33}
34
35/// Marker for ops in the `verif` dialect that can be inlined inside functions.
36/// The op can be marked with additional traits that must be satisfied if the op
37/// is inlined. The difference between this and passing the attribute as normal
38/// is that the extra traits are only checked if the op is inlined. This allows
39/// marking the op with very restrictive traits like `ConstraintGen`. If that
40/// trait was naively added to the inlinable op it will fail verification when
41/// the op is not inlined.
42///
43/// For example, an op that can only be inlined inside constrain functions can
44/// be marked with `Verification<["::llzk::function::ConstraintGen"]>`.
45class Verification<list<string> extra = []>
46 : ParamNativeOpTrait<"Verification", !interleave(extra, ",")>,
47 StructuralOpTrait {
48 string cppNamespace = "::llzk::function";
49}
50
51#endif // LLZK_FUNCTION_TRAITS