X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fnv50%2Fcodegen%2Fnv50_ir_graph.h;h=cfa73c3dd1a6f829fcb62148122404047e630ce6;hb=15ce0f76e2e014374a292550505f58da88333fb7;hp=640f518500f18b483066ef0f89d5b213d84e6d28;hpb=d2d19ea51fa3575a8d014a69a9b835c335728817;p=mesa.git diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_graph.h b/src/gallium/drivers/nv50/codegen/nv50_ir_graph.h index 640f518500f..cfa73c3dd1a 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir_graph.h +++ b/src/gallium/drivers/nv50/codegen/nv50_ir_graph.h @@ -36,12 +36,6 @@ class Graph public: class Node; - class GraphIterator : public Iterator - { - public: - virtual ~GraphIterator() { }; - }; - class Edge { public: @@ -80,10 +74,18 @@ public: class EdgeIterator : public Iterator { public: - EdgeIterator() : e(0), t(0), d(0) { } - EdgeIterator(Graph::Edge *first, int dir) : e(first), t(first), d(dir) { } + EdgeIterator() : e(0), t(0), d(0), rev(false) { } + EdgeIterator(Graph::Edge *first, int dir, bool reverse) + : d(dir), rev(reverse) + { + t = e = ((rev && first) ? first->prev[d] : first); + } - virtual void next() { e = (e->next[d] == t) ? 0 : e->next[d]; } + virtual void next() + { + Graph::Edge *n = (rev ? e->prev[d] : e->next[d]); + e = (n == t ? NULL : n); + } virtual bool end() const { return !e; } virtual void *get() const { return e; } @@ -96,6 +98,7 @@ public: Graph::Edge *e; Graph::Edge *t; int d; + bool rev; }; class Node @@ -108,8 +111,8 @@ public: bool detach(Node *); void cut(); - inline EdgeIterator outgoing() const; - inline EdgeIterator incident() const; + inline EdgeIterator outgoing(bool reverse = false) const; + inline EdgeIterator incident(bool reverse = false) const; inline Node *parent() const; // returns NULL if count(incident edges) != 1 @@ -153,14 +156,12 @@ public: void insert(Node *node); // attach to or set as root - GraphIterator *iteratorDFS(bool preorder = true); - GraphIterator *iteratorCFG(); + IteratorRef iteratorDFS(bool preorder = true); + IteratorRef iteratorCFG(); // safe iterators are unaffected by changes to the *edges* of the graph - GraphIterator *safeIteratorDFS(bool preorder = true); - GraphIterator *safeIteratorCFG(); - - inline void putIterator(Iterator *); // should be GraphIterator * + IteratorRef safeIteratorDFS(bool preorder = true); + IteratorRef safeIteratorCFG(); void classifyEdges(); @@ -199,19 +200,14 @@ int Graph::Node::getSequence() const return visited; } -void Graph::putIterator(Iterator *iter) -{ - delete reinterpret_cast(iter); -} - -Graph::EdgeIterator Graph::Node::outgoing() const +Graph::EdgeIterator Graph::Node::outgoing(bool reverse) const { - return EdgeIterator(out, 0); + return EdgeIterator(out, 0, reverse); } -Graph::EdgeIterator Graph::Node::incident() const +Graph::EdgeIterator Graph::Node::incident(bool reverse) const { - return EdgeIterator(in, 1); + return EdgeIterator(in, 1, reverse); } int Graph::Node::incidentCountFwd() const