From fc7ec83a5e18d34bce13e38139f723d3747760f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20R=C3=BChle?= Date: Sat, 22 Aug 2015 16:58:19 +0200 Subject: [PATCH] Fix edge type after edge splitting Simplify code to preserve type of preserved edge. Document why that is a good idea. --- src/gallium/drivers/nouveau/codegen/nv50_ir_bb.cpp | 9 +++++---- src/gallium/drivers/nouveau/codegen/nv50_ir_graph.cpp | 4 +--- src/gallium/drivers/nouveau/codegen/nv50_ir_graph.h | 13 ++++++++++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_bb.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_bb.cpp index 6033068..2410b77 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_bb.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_bb.cpp @@ -514,9 +514,9 @@ Pass::splitEdge(Graph::Edge *e) BasicBlock *pn = new BasicBlock(func); // add new edge from edge source to new bb - // Note: this will modify the outgoing edges of the edge's source - // TODO: check whether TREE is always correct; shouldn't it rather copy the edge's type? - src->cfg.attach(&pn->cfg, Graph::Edge::TREE /*e->getType()*/); + // note that this edge is the only edge to the new bb and therefore on + // the spanning tree + src->cfg.attach(&pn->cfg, Graph::Edge::TREE); // modify the source's exit if necessary assert(src->getExit()->op != OP_CALL); @@ -525,7 +525,8 @@ Pass::splitEdge(Graph::Edge *e) // reuse the split edge as the outgoing edge of the new block in order // to preserve the targets incident edge order - e->moveOrigin(&pn->cfg, Graph::Edge::FORWARD); + // note that the edge type has to be preserved, too + e->moveOrigin(&pn->cfg); return pn; } diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.cpp index 21cb4d9..9536a39 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.cpp @@ -50,7 +50,7 @@ void Graph::insert(Node *node) size++; } -void Graph::Edge::moveOrigin(Node *src, Type kind) +void Graph::Edge::moveOrigin(Node *src) { assert(src); @@ -75,8 +75,6 @@ void Graph::Edge::moveOrigin(Node *src, Type kind) } origin->out = this; ++origin->outCount; - - type = kind; } void Graph::Edge::unlink() diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.h index 83dfc7b..6b49e2c 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.h +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.h @@ -59,7 +59,18 @@ public: inline Type getType() const { return type; } const char *typeStr() const; - void moveOrigin(Node *src, Type newKind); + /** + * Helper function for rewiring an edge while preserving the order of + * the target's incoming edges. + * + * Any EdgeIterator over the target's incoming edges remains valid. + * Any EdgeIterator over the outgoing edges of either the new or old + * origin becomes invalid. + * + * Note that edge type is preserved, therefore this cannot be used to + * make major changes to the graph structure. + */ + void moveOrigin(Node *src); private: Node *origin; -- 2.1.4