From fa81ebb1262328d72f2810b71bacf5b6e1256f3d Mon Sep 17 00:00:00 2001 From: Lucas Ramirez Date: Mon, 18 Sep 2023 22:24:47 +0200 Subject: [PATCH] [export-dot] Missing DOTPrinter.h in previous commit --- include/dynamatic/Support/DOTPrinter.h | 45 +++++++++----------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/include/dynamatic/Support/DOTPrinter.h b/include/dynamatic/Support/DOTPrinter.h index b1a92cb02..4d13be2cb 100644 --- a/include/dynamatic/Support/DOTPrinter.h +++ b/include/dynamatic/Support/DOTPrinter.h @@ -31,20 +31,26 @@ struct EdgeInfo; /// mode, the resulting DOT can be used with legacy Dynamatic. class DOTPrinter { public: + /// Printing mode, dictating the structure and content of the printed DOTs. + enum class Mode { VISUAL, LEGACY, LEGACY_BUFFERS }; + /// Style in which to render edges in the printed DOTs. + enum class EdgeStyle { SPLINE, ORTHO }; + /// Constructs a DOTPrinter whose printing behavior is controlled by a couple /// flags, plus a pointer to a timing database that must be valid in legacy /// mode (when building Dynamatic++ in debug mode, the constructor will assert /// if the `legacy` flag is true and the timing database is nullptr). - DOTPrinter(bool legacy, bool debug, TimingDatabase *timingDB = nullptr); + DOTPrinter(Mode mode, EdgeStyle edgeStyle, + TimingDatabase *timingDB = nullptr); /// Prints Handshake-level IR to standard output. LogicalResult printDOT(mlir::ModuleOp mod); private: - /// Whether to export a legacy-compatible DOT. - bool legacy; - /// Whether to pretty-print the exported DOT (pretty-print if false). - bool debug; + /// Printing mode (e.g., compatible with legacy tools or not). + Mode mode; + /// Style of edges in the resulting DOTs. + EdgeStyle edgeStyle; /// Timing models for dataflow components (required in legacy mode, can safely /// be nullptr when not in legacy mode). TimingDatabase *timingDB; @@ -129,31 +135,10 @@ class DOTPrinter { /// Closes a subgraph in the DOT file. void closeSubgraph(); - /// In legacy mode, registers inputs and outputs of a node for later DOT - /// verification. Input and output ports can be skipped (useful for function - /// arguments and end node) using their respective flags. Each registered node - /// is named using the node name passed as argument as a prefix. As a - /// consequence, a specific node name must never be used in more than one call - /// to the method. Fails if a port with the same name as an existing port is - /// generated. - LogicalResult legacyRegisterPorts(NodeInfo &info, std::string &nodeName, - bool skipInputs = false, - bool skipOutputs = false); - - /// In legacy mode, registers a channel between two ports for later DOT - /// verification. The edge is named using the source and destination node - /// names passed as arguments. Fails if a channel with the same name as an - /// existing channel is generated. - LogicalResult legacyRegisterChannel(EdgeInfo &info, std::string &srcName, - std::string &dstName); - - /// In legacy mode, verifies that all registered ports are part of a unique - /// registered channel and that no port is undriven. Additionally, if the flag - /// is set, verifies that ports linked by a channel have the same bitwidth - /// (which is not true in general in DOTs produced by legacy Dynamatic). Fails - /// if one of the above DOT invariants is broken. - LogicalResult verifyDOT(handshake::FuncOp funcOp, - bool failOnWidthMismatch = false); + /// Returns whether the DOT printer was setup in a legacy-compatible mode. + inline bool inLegacyMode() { + return mode == Mode::LEGACY || mode == Mode::LEGACY_BUFFERS; + } }; /// Holds information about data attributes for a DOT node.