CIRCT 24.0.0git
Loading...
Searching...
No Matches
RTGTestDialect.cpp
Go to the documentation of this file.
1//===- RTGTestDialect.cpp - Implement the RTGTest 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 RTGTest dialect.
10//
11//===----------------------------------------------------------------------===//
12
17#include "mlir/IR/Builders.h"
18#include "mlir/IR/BuiltinTypes.h"
19#include "mlir/IR/DialectImplementation.h"
20#include "llvm/ADT/TypeSwitch.h"
21
22using namespace circt;
23using namespace rtgtest;
24
25//===----------------------------------------------------------------------===//
26// Dialect specification.
27//===----------------------------------------------------------------------===//
28
29void RTGTestDialect::initialize() {
30 registerTypes();
31 registerAttributes();
32}
33
34/// Registered hook to materialize a single constant operation from a given
35/// attribute value with the desired resultant type. This method should use
36/// the provided builder to create the operation without changing the
37/// insertion position. The generated operation is expected to be constant
38/// like, i.e. single result, zero operands, non side-effecting, etc. On
39/// success, this hook should return the value generated to represent the
40/// constant value. Otherwise, it should return null on failure.
41Operation *RTGTestDialect::materializeConstant(OpBuilder &builder,
42 Attribute value, Type type,
43 Location loc) {
44 if (auto attr = dyn_cast<TypedAttr>(value))
45 if (type == attr.getType())
46 return rtg::ConstantOp::create(builder, loc, attr);
47 return nullptr;
48}
49
50#include "circt/Dialect/RTGTest/IR/RTGTestEnums.cpp.inc"
51
52#include "circt/Dialect/RTGTest/IR/RTGTestDialect.cpp.inc"
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.