cyclegraph: add edgeCreatesCycle() function
[c11tester.git] / cyclegraph.h
index 6b3d93e5e45ec661d3acd4db987796b9b1adaea6..5d9c976b5a1c21ae22459ec9380ce3164f529ddd 100644 (file)
@@ -42,7 +42,7 @@ class CycleGraph {
  private:
        void putNode(const ModelAction *act, CycleNode *node);
        CycleNode * getNode(const ModelAction *);
-       HashTable<CycleNode *, CycleNode *, uintptr_t, 4, model_malloc, model_calloc, model_free> *discovered;
+       HashTable<const CycleNode *, const CycleNode *, uintptr_t, 4, model_malloc, model_calloc, model_free> *discovered;
 
        /** @brief A table for mapping ModelActions to CycleNodes */
        HashTable<const ModelAction *, CycleNode *, uintptr_t, 4> actionToNode;
@@ -50,7 +50,9 @@ class CycleGraph {
        std::vector<CycleNode *> nodeList;
 #endif
 
-       bool checkReachable(CycleNode *from, CycleNode *to) const;
+       bool checkReachable(const CycleNode *from, const CycleNode *to) const;
+
+       bool edgeCreatesCycle(const CycleNode *from, const CycleNode *to) const;
 
        /** @brief A flag: true if this graph contains cycles */
        bool hasCycles;
@@ -70,6 +72,8 @@ class CycleNode {
        bool addEdge(CycleNode *node);
        CycleNode * getEdge(unsigned int i) const;
        unsigned int getNumEdges() const;
+       CycleNode * getBackEdge(unsigned int i) const;
+       unsigned int getNumBackEdges() const;
        bool setRMW(CycleNode *);
        CycleNode * getRMW() const;
        const ModelAction * getAction() const { return action; }
@@ -89,6 +93,9 @@ class CycleNode {
        /** @brief The edges leading out from this node */
        std::vector< CycleNode *, SnapshotAlloc<CycleNode *> > edges;
 
+       /** @brief The edges leading into this node */
+       std::vector< CycleNode *, SnapshotAlloc<CycleNode *> > back_edges;
+
        /** Pointer to a RMW node that reads from this node, or NULL, if none
         * exists */
        CycleNode *hasRMW;