CIRCT  20.0.0git
ESIDialect.cpp
Go to the documentation of this file.
1 //===- ESIDialect.cpp - ESI dialect code defs -------------------*- C++ -*-===//
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 // Dialect definitions. Should be relatively standard boilerplate.
10 //
11 //===----------------------------------------------------------------------===//
12 
21 #include "circt/Support/LLVM.h"
22 #include "mlir/IR/Builders.h"
23 #include "mlir/IR/DialectImplementation.h"
24 #include "mlir/IR/ImplicitLocOpBuilder.h"
25 #include "llvm/ADT/DenseMap.h"
26 #include "llvm/ADT/StringMap.h"
27 #include "llvm/ADT/StringSet.h"
28 #include "llvm/Support/FormatVariadic.h"
29 
30 using namespace circt;
31 using namespace circt::esi;
32 
33 void ESIDialect::initialize() {
34  registerAttributes();
35  registerTypes();
36  addOperations<
37 #define GET_OP_LIST
38 #include "circt/Dialect/ESI/ESI.cpp.inc"
39  >();
40 }
41 
42 Operation *ESIDialect::materializeConstant(OpBuilder &builder, Attribute value,
43  Type type, Location loc) {
44  // Integer constants.
45  if (auto intType = dyn_cast<IntegerType>(type))
46  if (auto attrValue = dyn_cast<IntegerAttr>(value))
47  return builder.create<hw::ConstantOp>(loc, attrValue.getType(),
48  attrValue);
49  if (isa<mlir::UnitAttr>(value))
50  return builder.create<hw::ConstantOp>(loc, builder.getI1Type(), 1);
51  return nullptr;
52 }
53 
54 // Provide implementations for the enums we use.
55 #include "circt/Dialect/ESI/ESIEnums.cpp.inc"
56 
57 #include "circt/Dialect/ESI/ESIDialect.cpp.inc"
def create(data_type, value)
Definition: hw.py:433
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21