CIRCT 23.0.0git
Loading...
Searching...
No Matches
SimDialect.cpp
Go to the documentation of this file.
1//===- SimDialect.cpp - Implement the Sim dialect -----------------------===//
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 implements the Sim dialect.
10//
11//===----------------------------------------------------------------------===//
12
17#include "mlir/IR/Builders.h"
18#include "mlir/IR/BuiltinTypes.h"
19#include "mlir/IR/DialectImplementation.h"
20
21using namespace circt;
22using namespace sim;
23
24//===----------------------------------------------------------------------===//
25// Dialect specification.
26//===----------------------------------------------------------------------===//
27
28void SimDialect::initialize() {
29 addOperations<
30#define GET_OP_LIST
31#include "circt/Dialect/Sim/Sim.cpp.inc"
32 >();
33
34 registerTypes();
35}
36
37#include "circt/Dialect/Sim/SimDialect.cpp.inc"
38
39Operation *SimDialect::materializeConstant(::mlir::OpBuilder &builder,
40 ::mlir::Attribute value,
41 ::mlir::Type type,
42 ::mlir::Location loc) {
43
44 if (auto fmtStrType = llvm::dyn_cast<FormatStringType>(type))
45 return FormatLiteralOp::create(builder, loc, fmtStrType,
46 llvm::cast<StringAttr>(value));
47 if (auto dynStrType = llvm::dyn_cast<DynamicStringType>(type))
48 return StringConstantOp::create(builder, loc, dynStrType,
49 llvm::cast<StringAttr>(value));
50 if (auto intAttr = dyn_cast<IntegerAttr>(value))
51 return hw::ConstantOp::create(builder, loc, type, intAttr);
52 return nullptr;
53}
create(data_type, value)
Definition hw.py:433
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition sim.py:1