MLIR  21.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 
14 using namespace mlir;
15 using namespace smt;
16 
17 void SMTDialect::initialize() {
18  registerAttributes();
19  registerTypes();
20  addOperations<
21 #define GET_OP_LIST
22 #include "mlir/Dialect/SMT/IR/SMT.cpp.inc"
23  >();
24 }
25 
27  Type type, Location loc) {
28  // BitVectorType constants can materialize into smt.bv.constant
29  if (auto bvType = dyn_cast<BitVectorType>(type)) {
30  if (auto attrValue = dyn_cast<BitVectorAttr>(value)) {
31  assert(bvType == attrValue.getType() &&
32  "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  return nullptr;
44 }
45 
46 #include "mlir/Dialect/SMT/IR/SMTDialect.cpp.inc"
47 #include "mlir/Dialect/SMT/IR/SMTEnums.cpp.inc"
static Operation * materializeConstant(Dialect *dialect, OpBuilder &builder, Attribute value, Type type, Location loc)
A utility function used to materialize a constant for a given attribute and type.
Definition: FoldUtils.cpp:50
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:66
This class helps build Operations.
Definition: Builders.h:205
Operation * create(const OperationState &state)
Creates an operation given the fields represented as an OperationState.
Definition: Builders.cpp:453
Operation is the basic unit of execution within MLIR.
Definition: Operation.h:88
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.