LLZK 2.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
SMTDialect.cpp
Go to the documentation of this file.
1//===- SMTDialect.cpp - SMT dialect implementation ------------------------===//
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
10
14
15using namespace mlir;
16using namespace llzk::smt;
17
18void SMTDialect::initialize() {
21 addOperations<
22#define GET_OP_LIST
24 >();
25}
26
27Operation *
28SMTDialect::materializeConstant(OpBuilder &builder, Attribute value, Type type, Location loc) {
29 // BitVectorType constants can materialize into smt.bv.constant
30 if (auto bvType = dyn_cast<BitVectorType>(type)) {
31 if (auto attrValue = dyn_cast<BitVectorAttr>(value)) {
32 assert(bvType == attrValue.getType() && "attribute and desired result types have to match");
33 return builder.create<BVConstantOp>(loc, attrValue);
34 }
35 }
36
37 // BoolType constants can materialize into smt.constant
38 if (auto boolType = dyn_cast<BoolType>(type)) {
39 if (auto attrValue = dyn_cast<BoolAttr>(value)) {
40 return builder.create<BoolConstantOp>(loc, attrValue);
41 }
42 }
43
44 return nullptr;
45}
46
::mlir::Operation * materializeConstant(::mlir::OpBuilder &builder, ::mlir::Attribute value, ::mlir::Type type, ::mlir::Location loc) override
Materialize a single constant operation from a given attribute value with the desired resultant type.