146 assert(
nodeMap.count(fromNodeId) != 0);
147 assert(
nodeMap.count(toNodeId) != 0);
149 int fromNodeIdx =
nodeMap[fromNodeId];
150 Node &fromNode =
nodes[fromNodeIdx];
152 int toNodeIdx =
nodeMap[toNodeId];
153 Node &toNode =
nodes[toNodeIdx];
155 assert(fromNode.portMap.count(fromPortId) != 0);
156 assert(toNode.portMap.count(toPortId) != 0);
158 int fromPortIdx = fromNode.portMap[fromPortId];
159 Port &fromPort = fromNode.ports[fromPortIdx];
161 int toPortIdx = toNode.portMap[toPortId];
162 Port &toPort = toNode.ports[toPortIdx];
165 assert(fromBit == 0 && toBit == 0);
166 assert(fromPort.bits.size() == toPort.bits.size());
167 width = fromPort.bits.size();
170 assert(fromBit >= 0 && toBit >= 0);
171 for (
int i = 0; i < width; i++)
173 assert(fromBit + i <
int(fromPort.bits.size()));
174 assert(toBit + i <
int(toPort.bits.size()));
176 int fromEdgeIdx = fromPort.bits[fromBit + i].edgeIdx;
177 int toEdgeIdx = toPort.bits[toBit + i].edgeIdx;
179 if (fromEdgeIdx == toEdgeIdx)
183 if (
edges[toEdgeIdx].isExtern)
184 edges[fromEdgeIdx].isExtern =
true;
185 if (
edges[toEdgeIdx].constValue) {
186 assert(
edges[fromEdgeIdx].constValue == 0);
187 edges[fromEdgeIdx].constValue =
edges[toEdgeIdx].constValue;
189 for (
const auto &ref :
edges[toEdgeIdx].portBits) {
190 edges[fromEdgeIdx].portBits.insert(ref);
191 nodes[ref.nodeIdx].ports[ref.portIdx].bits[ref.bitIdx].edgeIdx = fromEdgeIdx;
195 if (toEdgeIdx+1 !=
int(
edges.size())) {
197 for (
const auto &ref :
edges[toEdgeIdx].portBits)
198 nodes[ref.nodeIdx].ports[ref.portIdx].bits[ref.bitIdx].edgeIdx = toEdgeIdx;
std::vector< Node > nodes
std::vector< Edge > edges
std::map< std::string, int > nodeMap