diff --git a/integration_test/Dialect/ESI/runtime/loopback.mlir b/integration_test/Dialect/ESI/runtime/loopback.mlir index 92dd32b7b934..e2f83daa28b0 100644 --- a/integration_test/Dialect/ESI/runtime/loopback.mlir +++ b/integration_test/Dialect/ESI/runtime/loopback.mlir @@ -145,15 +145,9 @@ hw.module @top(in %clk: !seq.clock, in %rst: i1) { // QUERY-HIER: internal_write: // QUERY-HIER: ack: !esi.channel // QUERY-HIER: req: !esi.channel> -// QUERY-HIER: func1: -// QUERY-HIER: arg: !esi.channel -// QUERY-HIER: result: !esi.channel -// QUERY-HIER: structFunc: -// QUERY-HIER: arg: !esi.channel> -// QUERY-HIER: result: !esi.channel> -// QUERY-HIER: arrayFunc: -// QUERY-HIER: arg: !esi.channel> -// QUERY-HIER: result: !esi.channel> +// QUERY-HIER: func1: function i16(i16) +// QUERY-HIER: structFunc: function !hw.struct(!hw.struct) +// QUERY-HIER: arrayFunc: function !hw.array<2xsi8>(!hw.array<1xsi8>) // QUERY-HIER: * Children: // QUERY-HIER: * Instance:loopback_inst[0] // QUERY-HIER: * Ports: diff --git a/lib/Dialect/ESI/runtime/cpp/include/esi/Services.h b/lib/Dialect/ESI/runtime/cpp/include/esi/Services.h index faa5f69b5738..c55b69f79d5f 100644 --- a/lib/Dialect/ESI/runtime/cpp/include/esi/Services.h +++ b/lib/Dialect/ESI/runtime/cpp/include/esi/Services.h @@ -35,6 +35,8 @@ class ServicePort : public BundlePort { public: using BundlePort::BundlePort; virtual ~ServicePort() = default; + // Get a description of the service port. + virtual std::optional toString() const { return std::nullopt; } }; /// Parent class of all APIs modeled as 'services'. May or may not map to a @@ -174,6 +176,14 @@ class FuncService : public Service { void connect(); std::future call(const MessageData &arg); + virtual std::optional toString() const override { + const esi::Type *argType = + dynamic_cast(arg.getType())->getInner(); + const esi::Type *resultType = + dynamic_cast(result.getType())->getInner(); + return "function " + resultType->getID() + "(" + argType->getID() + ")"; + } + private: std::mutex callMutex; WriteChannelPort &arg; diff --git a/lib/Dialect/ESI/runtime/cpp/tools/esiquery.cpp b/lib/Dialect/ESI/runtime/cpp/tools/esiquery.cpp index 450cabece943..c276300af504 100644 --- a/lib/Dialect/ESI/runtime/cpp/tools/esiquery.cpp +++ b/lib/Dialect/ESI/runtime/cpp/tools/esiquery.cpp @@ -92,11 +92,16 @@ void printInfo(std::ostream &os, AcceleratorConnection &acc) { void printPort(std::ostream &os, const BundlePort &port, std::string indent = "") { - os << indent << " " << port.getID() << ":" << std::endl; - for (const auto &[name, chan] : port.getChannels()) { + os << indent << " " << port.getID() << ":"; + if (auto svcPort = dynamic_cast(&port)) + if (auto svcPortStr = svcPort->toString()) { + os << " " << *svcPortStr << std::endl; + return; + } + os << std::endl; + for (const auto &[name, chan] : port.getChannels()) os << indent << " " << name << ": " << chan.getType()->getID() << std::endl; - } } void printInstance(std::ostream &os, const HWModule *d,