LLZK 2.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
SMTAttributes.td
Go to the documentation of this file.
1//===- SMTAttributes.td - Attributes for SMT dialect -------*- tablegen -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines SMT dialect specific attributes.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef MLIR_DIALECT_SMT_IR_SMTATTRIBUTES_TD
14#define MLIR_DIALECT_SMT_IR_SMTATTRIBUTES_TD
15
16include "llzk/Dialect/SMT/IR/SMTDialect.td"
17include "llzk/Dialect/LLZK/IR/AttributeHelper.td"
18include "mlir/IR/EnumAttr.td"
19include "mlir/IR/BuiltinAttributeInterfaces.td"
20
21def BitVectorAttr
22 : AttrDef<SMTDialect,
23 "BitVector", [DeclareAttrInterfaceMethods<TypedAttrInterface>]> {
24 let mnemonic = "bv";
25 let description = [{
26 This attribute represents a constant value of the `(_ BitVec width)` sort as
27 described in the [SMT bit-vector
28 theory](https://smtlib.cs.uiowa.edu/theories-FixedSizeBitVectors.shtml).
29
30 The constant is as #bX (binary) or #xX (hexadecimal) in SMT-LIB
31 where X is the value in the corresponding format without any further
32 prefixing. Here, the bit-vector constant is given as a regular non-negative
33 integer literal and the associated bit-vector type indicating the bit-width.
34
35 Examples:
36 ```mlir
37 #smt.bv<5> : !smt.bv<4>
38 #smt.bv<92> : !smt.bv<8>
39 ```
40
41 The explicit type-suffix is mandatory to uniquely represent the attribute,
42 i.e., this attribute should always be used in the extended form (using the
43 `quantified` keyword in the operation assembly format string).
44
45 The bit-width must be greater than zero (i.e., at least one digit has to be
46 present).
47 }];
48
49 let parameters = (ins APIntParameter<"">:$value);
50
51 let hasCustomAssemblyFormat = true;
52 let genVerifyDecl = true;
53
54 let builders = [AttrBuilder<(ins "llvm::StringRef":$value)>,
55 AttrBuilder<(ins "uint64_t":$value, "unsigned":$width)>,
56 ];
57
58 let extraClassDeclaration = [{
59 /// Return the bit-vector constant as a SMT-LIB formatted string.
60 std::string getValueAsString(bool prefix = true) const;
61 }];
62}
63
64#endif // MLIR_DIALECT_SMT_IR_SMTATTRIBUTES_TD