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_FELT_ATTRS
11#define LLZK_FELT_ATTRS
12
13include "llzk/Dialect/Felt/IR/Dialect.td"
14include "llzk/Dialect/LLZK/IR/AttributeHelper.td"
15
16include "mlir/IR/AttrTypeBase.td"
17include "mlir/IR/BuiltinAttributeInterfaces.td"
18
19def LLZK_FeltConstAttr
20 : AttrDef<FeltDialect, "FeltConst", [TypedAttrInterface]> {
21 let mnemonic = "const";
22 let summary = "finite field element";
23 let description = [{
24 A felt attribute represents a finite field element.
25 }];
26
27 let parameters = (ins APIntParameter<"The felt constant value">:$value);
28
29 let returnType = "::llvm::APInt";
30 let convertFromStorage = "$_self.getValue()";
31
32 let assemblyFormat = [{ $value }];
33
34 let builders =
35 [AttrBuilder<(ins "unsigned":$numBits, "::llvm::StringRef":$str), [{
36 return $_get(context, ::llvm::APInt(numBits, str, 10));
37 }]>,
38 AttrBuilder<
39 (ins "unsigned":$numBits, "::llvm::ArrayRef<uint64_t>":$parts), [{
40 return $_get(context, ::llvm::APInt(numBits, parts));
41 }]>];
42
43 let extraClassDeclaration = [{
44 ::mlir::Type getType() const;
45 }];
46}
47
48#endif // LLZK_FELT_ATTRS