CIRCT 24.0.0git
Loading...
Searching...
No Matches
ESITypes.h
Go to the documentation of this file.
1//===- ESITypes.h - types for the ESI dialect -------------------*- 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// Types for ESI are mostly in tablegen. This file should contain C++ types used
10// in MLIR type parameters and other supporting declarations.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef CIRCT_DIALECT_ESI_ESITYPES_H
15#define CIRCT_DIALECT_ESI_ESITYPES_H
16
18#include "circt/Support/LLVM.h"
19#include "mlir/IR/AttrTypeSubElements.h"
20#include "mlir/IR/Dialect.h"
21#include "mlir/IR/Operation.h"
22
23#include "ESIDialect.h"
24
25namespace circt {
26namespace esi {
27struct BundledChannel;
28} // namespace esi
29} // namespace circt
30
31#define GET_TYPEDEF_CLASSES
32#include "circt/Dialect/ESI/ESITypes.h.inc"
33
34namespace circt {
35namespace esi {
36
38 StringAttr name;
39 ChannelDirection direction;
40 ChannelType type;
41
42 int operator==(const BundledChannel &that) const {
43 return name == that.name && direction == that.direction &&
44 type == that.type;
45 }
46};
47
48// NOLINTNEXTLINE(readability-identifier-naming)
49inline llvm::hash_code hash_value(const BundledChannel channel) {
50 return llvm::hash_combine(channel.name, channel.direction, channel.type);
51}
52
53// If 'type' is an esi:ChannelType, will return the inner type of said channel.
54// Else, returns 'type'.
55mlir::Type innerType(mlir::Type type);
56} // namespace esi
57} // namespace circt
58
59namespace mlir {
60template <>
61struct AttrTypeSubElementHandler<circt::esi::BundledChannel> {
62 static void walk(const circt::esi::BundledChannel &channel,
63 AttrTypeImmediateSubElementWalker &walker) {
64 walker.walk(channel.name);
65 walker.walk(channel.type);
66 }
67
70 AttrSubElementReplacements &attrRepls,
71 TypeSubElementReplacements &typeRepls) {
72 return {cast<StringAttr>(attrRepls.take_front(1)[0]), channel.direction,
73 cast<circt::esi::ChannelType>(typeRepls.take_front(1)[0])};
74 }
75};
76} // namespace mlir
77
78#endif
llvm::hash_code hash_value(const BundledChannel channel)
Definition ESITypes.h:49
mlir::Type innerType(mlir::Type type)
Definition ESITypes.cpp:423
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition esi.py:1
int operator==(const BundledChannel &that) const
Definition ESITypes.h:42
ChannelDirection direction
Definition ESITypes.h:39
static circt::esi::BundledChannel replace(const circt::esi::BundledChannel &channel, AttrSubElementReplacements &attrRepls, TypeSubElementReplacements &typeRepls)
Definition ESITypes.h:69
static void walk(const circt::esi::BundledChannel &channel, AttrTypeImmediateSubElementWalker &walker)
Definition ESITypes.h:62