15#include "mlir/IR/BuiltinTypes.h"
16#include "mlir/IR/ImplicitLocOpBuilder.h"
26 StringRef reqName, Type reqType,
27 StringRef respName, Type respType) {
28 assert(reqType && respType);
29 auto *ctxt = reqType ? reqType.getContext() : respType.getContext();
30 auto bundle = ChannelBundleType::get(
32 {
BundledChannel{StringAttr::get(ctxt, reqName), ChannelDirection::from,
33 ChannelType::get(ctxt, reqType)},
34 BundledChannel{StringAttr::get(ctxt, respName), ChannelDirection::to,
35 ChannelType::get(ctxt, respType)}},
37 return {hw::InnerRefAttr::get(sym, StringAttr::get(ctxt, name)), bundle};
41 auto *
ctxt = getContext();
43 IntegerType::get(ctxt, llvm::Log2_64_Ceil(getDepth()),
44 IntegerType::SignednessSemantics::Unsigned);
47 hw::StructType writeType = hw::StructType::get(
49 {hw::StructType::FieldInfo{StringAttr::get(ctxt,
"address"), addressType},
50 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"data"),
52 return createReqResp(getSymNameAttr(),
"write",
"req", writeType,
"ack",
53 IntegerType::get(ctxt, 0));
57 auto *
ctxt = getContext();
59 IntegerType::get(ctxt, llvm::Log2_64_Ceil(getDepth()),
60 IntegerType::SignednessSemantics::Unsigned);
62 return createReqResp(getSymNameAttr(),
"read",
"address", addressType,
"data",
66void RandomAccessMemoryDeclOp::getPortList(
67 SmallVectorImpl<ServicePortInfo> &ports) {
68 ports.push_back(writePortInfo());
69 ports.push_back(readPortInfo());
72void CallServiceDeclOp::getPortList(SmallVectorImpl<ServicePortInfo> &ports) {
73 auto *
ctxt = getContext();
75 hw::InnerRefAttr::get(getSymNameAttr(), StringAttr::get(ctxt,
"call")),
76 ChannelBundleType::get(
78 {
BundledChannel{StringAttr::get(ctxt,
"arg"), ChannelDirection::from,
79 ChannelType::get(ctxt, AnyType::get(ctxt))},
80 BundledChannel{StringAttr::get(ctxt,
"result"), ChannelDirection::to,
81 ChannelType::get(ctxt, AnyType::get(ctxt))}},
85void FuncServiceDeclOp::getPortList(SmallVectorImpl<ServicePortInfo> &ports) {
86 auto *
ctxt = getContext();
88 hw::InnerRefAttr::get(getSymNameAttr(), StringAttr::get(ctxt,
"call")),
89 ChannelBundleType::get(
91 {
BundledChannel{StringAttr::get(ctxt,
"arg"), ChannelDirection::to,
92 ChannelType::get(ctxt, AnyType::get(ctxt))},
94 ChannelDirection::from,
95 ChannelType::get(ctxt, AnyType::get(ctxt))}},
99void MMIOServiceDeclOp::getPortList(SmallVectorImpl<ServicePortInfo> &ports) {
100 auto *
ctxt = getContext();
103 hw::InnerRefAttr::get(getSymNameAttr(), StringAttr::get(ctxt,
"read")),
104 ChannelBundleType::get(
107 StringAttr::get(ctxt,
"offset"), ChannelDirection::to,
111 ctxt, 32, IntegerType::SignednessSemantics::Unsigned))},
112 BundledChannel{StringAttr::get(ctxt,
"data"), ChannelDirection::from,
113 ChannelType::get(ctxt, IntegerType::get(ctxt, 64))}},
116 auto cmdType = hw::StructType::get(
118 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"write"),
119 IntegerType::get(ctxt, 1)},
120 hw::StructType::FieldInfo{
121 StringAttr::get(ctxt,
"offset"),
123 ctxt, 32, IntegerType::SignednessSemantics::Unsigned)},
124 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"data"),
125 IntegerType::get(ctxt, 64)},
128 hw::InnerRefAttr::get(getSymNameAttr(),
129 StringAttr::get(ctxt,
"read_write")),
130 ChannelBundleType::get(
132 {
BundledChannel{StringAttr::get(ctxt,
"cmd"), ChannelDirection::to,
133 ChannelType::get(ctxt, cmdType)},
134 BundledChannel{StringAttr::get(ctxt,
"data"), ChannelDirection::from,
135 ChannelType::get(ctxt, IntegerType::get(ctxt, 64))}},
140 auto *
ctxt = getContext();
142 IntegerType::get(ctxt, 64, IntegerType::SignednessSemantics::Unsigned);
145 hw::StructType writeType = hw::StructType::get(
147 {hw::StructType::FieldInfo{StringAttr::get(ctxt,
"address"), addressType},
148 hw::StructType::FieldInfo{
149 StringAttr::get(ctxt,
"tag"),
150 IntegerType::get(ctxt, 8,
151 IntegerType::SignednessSemantics::Unsigned)},
152 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"data"),
153 AnyType::get(ctxt)}});
155 getSymNameAttr(),
"write",
"req", writeType,
"ackTag",
156 IntegerType::get(ctxt, 8, IntegerType::SignednessSemantics::Unsigned));
160 auto *
ctxt = getContext();
162 IntegerType::get(ctxt, 64, IntegerType::SignednessSemantics::Unsigned);
164 hw::StructType readReqType = hw::StructType::get(
166 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"address"),
168 hw::StructType::FieldInfo{
169 StringAttr::get(ctxt,
"tag"),
171 ctxt, 8, IntegerType::SignednessSemantics::Unsigned)},
173 hw::StructType readRespType = hw::StructType::get(
175 hw::StructType::FieldInfo{
176 StringAttr::get(ctxt,
"tag"),
178 ctxt, 8, IntegerType::SignednessSemantics::Unsigned)},
179 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"data"),
182 return createReqResp(getSymNameAttr(),
"read",
"req", readReqType,
"resp",
186void HostMemServiceDeclOp::getPortList(
187 SmallVectorImpl<ServicePortInfo> &ports) {
188 ports.push_back(writePortInfo());
189 ports.push_back(readPortInfo());
192void TelemetryServiceDeclOp::getPortList(
193 SmallVectorImpl<ServicePortInfo> &ports) {
194 auto *
ctxt = getContext();
196 hw::InnerRefAttr::get(getSymNameAttr(), StringAttr::get(ctxt,
"report")),
197 ChannelBundleType::get(
199 {
BundledChannel{StringAttr::get(ctxt,
"get"), ChannelDirection::to,
200 ChannelType::get(ctxt, IntegerType::get(ctxt, 1))},
201 BundledChannel{StringAttr::get(ctxt,
"data"), ChannelDirection::from,
202 ChannelType::get(ctxt, AnyType::get(ctxt))}},
assert(baseType &&"element must be base type")
static ServicePortInfo createReqResp(StringAttr sym, Twine name, StringRef reqName, Type reqType, StringRef respName, Type respType)
Utility function to create a req/resp pair bundle service port.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Describes a service port.