1//===-- Attrs.td -------------------------------------------*- tablegen -*-===//
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
8//===----------------------------------------------------------------------===//
10#ifndef LLZK_FELT_ATTRS
11#define LLZK_FELT_ATTRS
13include "llzk/Dialect/Felt/IR/Dialect.td"
14include "llzk/Dialect/LLZK/IR/AttributeHelper.td"
16include "mlir/IR/AttrTypeBase.td"
17include "mlir/IR/BuiltinAttributeInterfaces.td"
20 : AttrDef<FeltDialect, "FeltConst", [TypedAttrInterface]> {
21 let mnemonic = "const";
22 let summary = "finite field element";
24 A felt attribute represents a finite field element.
27 let parameters = (ins APIntParameter<"The felt constant value">:$value);
29 let returnType = "::llvm::APInt";
30 let convertFromStorage = "$_self.getValue()";
32 let assemblyFormat = [{ $value }];
35 [AttrBuilder<(ins "unsigned":$numBits, "::llvm::StringRef":$str), [{
36 return $_get(context, ::llvm::APInt(numBits, str, 10));
39 (ins "unsigned":$numBits, "::llvm::ArrayRef<uint64_t>":$parts), [{
40 return $_get(context, ::llvm::APInt(numBits, parts));
43 let extraClassDeclaration = [{
44 ::mlir::Type getType() const;
48#endif // LLZK_FELT_ATTRS