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};
40void ChannelServiceDeclOp::getPortList(
41 SmallVectorImpl<ServicePortInfo> &ports) {
42 auto *ctxt = getContext();
44 hw::InnerRefAttr::get(getSymNameAttr(), StringAttr::get(ctxt,
"to_host")),
45 ChannelBundleType::get(
47 {
BundledChannel{StringAttr::get(ctxt,
"data"), ChannelDirection::from,
48 ChannelType::get(ctxt, AnyType::get(ctxt))}},
51 hw::InnerRefAttr::get(getSymNameAttr(),
52 StringAttr::get(ctxt,
"from_host")),
53 ChannelBundleType::get(
55 {
BundledChannel{StringAttr::get(ctxt,
"data"), ChannelDirection::to,
56 ChannelType::get(ctxt, AnyType::get(ctxt))}},
61 auto *ctxt = getContext();
63 IntegerType::get(ctxt, llvm::Log2_64_Ceil(getDepth()),
64 IntegerType::SignednessSemantics::Unsigned);
67 hw::StructType writeType = hw::StructType::get(
69 {hw::StructType::FieldInfo{StringAttr::get(ctxt,
"address"), addressType},
70 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"data"),
72 return createReqResp(getSymNameAttr(),
"write",
"req", writeType,
"ack",
73 IntegerType::get(ctxt, 0));
77 auto *ctxt = getContext();
79 IntegerType::get(ctxt, llvm::Log2_64_Ceil(getDepth()),
80 IntegerType::SignednessSemantics::Unsigned);
82 return createReqResp(getSymNameAttr(),
"read",
"address", addressType,
"data",
86void RandomAccessMemoryDeclOp::getPortList(
87 SmallVectorImpl<ServicePortInfo> &ports) {
88 ports.push_back(writePortInfo());
89 ports.push_back(readPortInfo());
92void CallServiceDeclOp::getPortList(SmallVectorImpl<ServicePortInfo> &ports) {
93 auto *ctxt = getContext();
95 hw::InnerRefAttr::get(getSymNameAttr(), StringAttr::get(ctxt,
"call")),
96 ChannelBundleType::get(
98 {
BundledChannel{StringAttr::get(ctxt,
"arg"), ChannelDirection::from,
99 ChannelType::get(ctxt, AnyType::get(ctxt))},
100 BundledChannel{StringAttr::get(ctxt,
"result"), ChannelDirection::to,
101 ChannelType::get(ctxt, AnyType::get(ctxt))}},
105void FuncServiceDeclOp::getPortList(SmallVectorImpl<ServicePortInfo> &ports) {
106 auto *ctxt = getContext();
108 hw::InnerRefAttr::get(getSymNameAttr(), StringAttr::get(ctxt,
"call")),
109 ChannelBundleType::get(
111 {
BundledChannel{StringAttr::get(ctxt,
"arg"), ChannelDirection::to,
112 ChannelType::get(ctxt, AnyType::get(ctxt))},
114 ChannelDirection::from,
115 ChannelType::get(ctxt, AnyType::get(ctxt))}},
119void MMIOServiceDeclOp::getPortList(SmallVectorImpl<ServicePortInfo> &ports) {
120 auto *ctxt = getContext();
123 hw::InnerRefAttr::get(getSymNameAttr(), StringAttr::get(ctxt,
"read")),
124 ChannelBundleType::get(
127 StringAttr::get(ctxt,
"offset"), ChannelDirection::to,
131 ctxt, 32, IntegerType::SignednessSemantics::Unsigned))},
132 BundledChannel{StringAttr::get(ctxt,
"data"), ChannelDirection::from,
133 ChannelType::get(ctxt, IntegerType::get(ctxt, 64))}},
136 auto cmdType = hw::StructType::get(
138 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"write"),
139 IntegerType::get(ctxt, 1)},
140 hw::StructType::FieldInfo{
141 StringAttr::get(ctxt,
"offset"),
143 ctxt, 32, IntegerType::SignednessSemantics::Unsigned)},
144 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"data"),
145 IntegerType::get(ctxt, 64)},
148 hw::InnerRefAttr::get(getSymNameAttr(),
149 StringAttr::get(ctxt,
"read_write")),
150 ChannelBundleType::get(
152 {
BundledChannel{StringAttr::get(ctxt,
"cmd"), ChannelDirection::to,
153 ChannelType::get(ctxt, cmdType)},
154 BundledChannel{StringAttr::get(ctxt,
"data"), ChannelDirection::from,
155 ChannelType::get(ctxt, IntegerType::get(ctxt, 64))}},
160 auto *ctxt = getContext();
162 IntegerType::get(ctxt, 64, IntegerType::SignednessSemantics::Unsigned);
165 hw::StructType writeType = hw::StructType::get(
167 {hw::StructType::FieldInfo{StringAttr::get(ctxt,
"address"), addressType},
168 hw::StructType::FieldInfo{
169 StringAttr::get(ctxt,
"tag"),
170 IntegerType::get(ctxt, 8,
171 IntegerType::SignednessSemantics::Unsigned)},
172 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"data"),
173 AnyType::get(ctxt)}});
175 getSymNameAttr(),
"write",
"req", writeType,
"ackTag",
176 IntegerType::get(ctxt, 8, IntegerType::SignednessSemantics::Unsigned));
180 auto *ctxt = getContext();
182 IntegerType::get(ctxt, 64, IntegerType::SignednessSemantics::Unsigned);
184 hw::StructType readReqType = hw::StructType::get(
186 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"address"),
188 hw::StructType::FieldInfo{
189 StringAttr::get(ctxt,
"tag"),
191 ctxt, 8, IntegerType::SignednessSemantics::Unsigned)},
193 hw::StructType readRespType = hw::StructType::get(
195 hw::StructType::FieldInfo{
196 StringAttr::get(ctxt,
"tag"),
198 ctxt, 8, IntegerType::SignednessSemantics::Unsigned)},
199 hw::StructType::FieldInfo{StringAttr::get(ctxt,
"data"),
202 return createReqResp(getSymNameAttr(),
"read",
"req", readReqType,
"resp",
206void HostMemServiceDeclOp::getPortList(
207 SmallVectorImpl<ServicePortInfo> &ports) {
208 ports.push_back(writePortInfo());
209 ports.push_back(readPortInfo());
212void TelemetryServiceDeclOp::getPortList(
213 SmallVectorImpl<ServicePortInfo> &ports) {
214 auto *ctxt = getContext();
216 hw::InnerRefAttr::get(getSymNameAttr(), StringAttr::get(ctxt,
"report")),
217 ChannelBundleType::get(
219 {
BundledChannel{StringAttr::get(ctxt,
"get"), ChannelDirection::to,
220 ChannelType::get(ctxt, IntegerType::get(ctxt, 0))},
221 BundledChannel{StringAttr::get(ctxt,
"data"), ChannelDirection::from,
222 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.