/** * Copy Constructor for LoopVertex. * * @param that the source object for copying */ public LoopVertex(final LoopVertex that) { super(that); this.compositeTransformFullName = new String(that.compositeTransformFullName); // Copy all elements to the clone final DAG<IRVertex, IREdge> dagToCopy = that.getDAG(); dagToCopy.topologicalDo(v -> { this.getBuilder().addVertex(v, dagToCopy); dagToCopy.getIncomingEdgesOf(v).forEach(this.getBuilder()::connectVertices); }); that.dagIncomingEdges.forEach(((v, es) -> es.forEach(this::addDagIncomingEdge))); that.iterativeIncomingEdges.forEach((v, es) -> es.forEach(this::addIterativeIncomingEdge)); that.nonIterativeIncomingEdges.forEach((v, es) -> es.forEach(this::addNonIterativeIncomingEdge)); that.dagOutgoingEdges.forEach(((v, es) -> es.forEach(this::addDagOutgoingEdge))); that.edgeWithLoopToEdgeWithInternalVertex.forEach((eLoop, eInternal) -> this.mapEdgeWithLoop(eLoop, eInternal)); this.maxNumberOfIterations = that.maxNumberOfIterations; this.terminationCondition = that.terminationCondition; }
/** * Copy Constructor for LoopVertex. * * @param that the source object for copying */ public LoopVertex(final LoopVertex that) { super(that); this.compositeTransformFullName = new String(that.compositeTransformFullName); // Copy all elements to the clone final DAG<IRVertex, IREdge> dagToCopy = that.getDAG(); dagToCopy.topologicalDo(v -> { this.getBuilder().addVertex(v, dagToCopy); dagToCopy.getIncomingEdgesOf(v).forEach(this.getBuilder()::connectVertices); }); that.dagIncomingEdges.forEach(((v, es) -> es.forEach(this::addDagIncomingEdge))); that.iterativeIncomingEdges.forEach((v, es) -> es.forEach(this::addIterativeIncomingEdge)); that.nonIterativeIncomingEdges.forEach((v, es) -> es.forEach(this::addNonIterativeIncomingEdge)); that.dagOutgoingEdges.forEach(((v, es) -> es.forEach(this::addDagOutgoingEdge))); that.edgeWithLoopToEdgeWithInternalVertex.forEach((eLoop, eInternal) -> this.mapEdgeWithLoop(eLoop, eInternal)); this.maxNumberOfIterations = that.maxNumberOfIterations; this.terminationCondition = that.terminationCondition; }
/** * Merge the list of loopVertices into a single LoopVertex. * @param loopVertices list of LoopVertices to merge. * @return the merged single LoopVertex. */ private LoopVertex mergeLoopVertices(final Set<LoopVertex> loopVertices) { final String newName = String.join("+", loopVertices.stream().map(LoopVertex::getName).collect(Collectors.toList())); final LoopVertex mergedLoopVertex = new LoopVertex(newName); loopVertices.forEach(loopVertex -> { final DAG<IRVertex, IREdge> dagToCopy = loopVertex.getDAG(); dagToCopy.topologicalDo(v -> { mergedLoopVertex.getBuilder().addVertex(v); dagToCopy.getIncomingEdgesOf(v).forEach(mergedLoopVertex.getBuilder()::connectVertices); }); loopVertex.getDagIncomingEdges().forEach((v, es) -> es.forEach(mergedLoopVertex::addDagIncomingEdge)); loopVertex.getIterativeIncomingEdges().forEach((v, es) -> es.forEach(mergedLoopVertex::addIterativeIncomingEdge)); loopVertex.getNonIterativeIncomingEdges().forEach((v, es) -> es.forEach(mergedLoopVertex::addNonIterativeIncomingEdge)); loopVertex.getDagOutgoingEdges().forEach((v, es) -> es.forEach(mergedLoopVertex::addDagOutgoingEdge)); }); return mergedLoopVertex; } }
/** * Merge the list of loopVertices into a single LoopVertex. * @param loopVertices list of LoopVertices to merge. * @return the merged single LoopVertex. */ private LoopVertex mergeLoopVertices(final Set<LoopVertex> loopVertices) { final String newName = String.join("+", loopVertices.stream().map(LoopVertex::getName).collect(Collectors.toList())); final LoopVertex mergedLoopVertex = new LoopVertex(newName); loopVertices.forEach(loopVertex -> { final DAG<IRVertex, IREdge> dagToCopy = loopVertex.getDAG(); dagToCopy.topologicalDo(v -> { mergedLoopVertex.getBuilder().addVertex(v); dagToCopy.getIncomingEdgesOf(v).forEach(mergedLoopVertex.getBuilder()::connectVertices); }); loopVertex.getDagIncomingEdges().forEach((v, es) -> es.forEach(mergedLoopVertex::addDagIncomingEdge)); loopVertex.getIterativeIncomingEdges().forEach((v, es) -> es.forEach(mergedLoopVertex::addIterativeIncomingEdge)); loopVertex.getNonIterativeIncomingEdges().forEach((v, es) -> es.forEach(mergedLoopVertex::addNonIterativeIncomingEdge)); loopVertex.getDagOutgoingEdges().forEach((v, es) -> es.forEach(mergedLoopVertex::addDagOutgoingEdge)); }); return mergedLoopVertex; }
listToModify.addAll(edgesToAdd); loopVertex.getBuilder().removeVertex(candidate.getKey()); loopVertex.getDagIncomingEdges().remove(candidate.getKey()); loopVertex.getNonIterativeIncomingEdges().remove(candidate.getKey());
listToModify.addAll(edgesToAdd); loopVertex.getBuilder().removeVertex(candidate.getKey()); loopVertex.getDagIncomingEdges().remove(candidate.getKey()); loopVertex.getNonIterativeIncomingEdges().remove(candidate.getKey());
assignedLoopVertex.getBuilder().addVertex(dstVertex, dag); final LoopVertex srcLoopVertex = dag.getAssignedLoopVertexOf(irEdge.getSrc()); if (srcLoopVertex.equals(assignedLoopVertex)) { // connecting within the composite loop DAG. assignedLoopVertex.getBuilder().connectVertices(irEdge); } else { // loop -> loop connection assignedLoopVertex.addDagIncomingEdge(irEdge);
assignedLoopVertex.getBuilder().addVertex(dstVertex, dag); final LoopVertex srcLoopVertex = dag.getAssignedLoopVertexOf(irEdge.getSrc()); if (srcLoopVertex.equals(assignedLoopVertex)) { // connecting within the composite loop DAG. assignedLoopVertex.getBuilder().connectVertices(irEdge); } else { // loop -> loop connection assignedLoopVertex.addDagIncomingEdge(irEdge);