MLIR 24.0.0git
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
13
14using namespace mlir;
15using namespace smt;
16
17Operation *SMTDialect::materializeConstant(OpBuilder &builder, Attribute value,
18 Type type, Location loc) {
19 // BitVectorType constants can materialize into smt.bv.constant
20 if (auto bvType = dyn_cast<BitVectorType>(type)) {
21 if (auto attrValue = dyn_cast<BitVectorAttr>(value)) {
22 assert(bvType == attrValue.getType() &&
23 "attribute and desired result types have to match");
24 return BVConstantOp::create(builder, loc, attrValue);
25 }
26 }
27
28 // BoolType constants can materialize into smt.constant
29 if (auto boolType = dyn_cast<BoolType>(type)) {
30 if (auto attrValue = dyn_cast<BoolAttr>(value))
31 return BoolConstantOp::create(builder, loc, attrValue);
32 }
33
34 return nullptr;
35}
36
37#include "mlir/Dialect/SMT/IR/SMTDialect.cpp.inc"
38#include "mlir/Dialect/SMT/IR/SMTEnums.cpp.inc"
Attributes are known-constant values of operations.
Definition Attributes.h:25
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition Location.h:76
This class helps build Operations.
Definition Builders.h:210
Operation is the basic unit of execution within MLIR.
Definition Operation.h:87
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition Types.h:74
Include the generated interface declarations.