LLZK 0.1.0
Veridise's ZK Language IR
Loading...
Searching...
No Matches
Attrs.td
Go to the documentation of this file.
1//===-- Attrs.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_ATTRS
11#define LLZK_ATTRS
12
13include "llzk/Dialect/LLZK/IR/Dialect.td"
14include "llzk/Dialect/LLZK/IR/AttributeHelper.td"
15
16include "mlir/IR/AttrTypeBase.td"
17include "mlir/IR/BuiltinAttributeInterfaces.td"
18include "mlir/IR/EnumAttr.td"
19
20class LLZKDialectAttr<string name, string attrMnemonic, list<Trait> traits = []>
21 : AttrDef<LLZKDialect, name, traits> {
22 let mnemonic = attrMnemonic;
23}
24
25def LLZK_PublicAttr : LLZKDialectAttr<"Public", "pub"> {
26 let summary = "A unit attribute to mark a type as public";
27 let description = [{
28 Examples:
29
30 ```llzk
31 struct.field @field_name : !felt.type {llzk.pub}
32
33 function.def @func_name(%0: !felt.type {llzk.pub})
34 ```
35 }];
36}
37
38def LLZK_LoopBoundsAttr : LLZKDialectAttr<"LoopBounds", "loopbounds"> {
39 let summary = "Annotation with the bounds of a loop";
40 let description = [{
41 This attribute holds information useful for the analysis of loops.
42 Holds the bounds of the loop and the step size.
43
44 Example:
45
46 ```llzk
47 scf.while ... {
48 ...
49 } do {
50 ...
51 } attributes { llzk.loopbounds = #llzk.loopbounds<0 to 10 step 1> }
52 ```
53 }];
54
55 let parameters =
56 (ins APIntParameter<"Loop variable lower bound (inclusive)">:$lower,
57 APIntParameter<"Loop variable upper bound (exclusive)">:$upper,
58 APIntParameter<"Loop variable step/increment">:$step);
59
60 let assemblyFormat = "`<` $lower `to` $upper `step` $step `>`";
61}
62
63#endif // LLZK_ATTRS