X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=cyclegraph.cc;h=3168923a8c0f260c137755e7775f99a643ab96a5;hb=9a97c2b585705b1a1870e799e387f95ea3b7b12c;hp=1eb1add33fc255e4f53e9044b3d3850b422668dd;hpb=3519c47202090f3c4a69de0e89aaa2617b17ff75;p=c11tester.git diff --git a/cyclegraph.cc b/cyclegraph.cc index 1eb1add3..3168923a 100644 --- a/cyclegraph.cc +++ b/cyclegraph.cc @@ -31,7 +31,7 @@ CycleNode * CycleGraph::getNode(const ModelAction *action) { * @param to The edge points to this ModelAction * @param from The edge comes from this ModelAction */ -void CycleGraph::addEdge(const ModelAction *to, const ModelAction *from) { +void CycleGraph::addEdge(const ModelAction *from, const ModelAction *to) { CycleNode *fromnode=getNode(from); CycleNode *tonode=getNode(to); @@ -60,7 +60,7 @@ void CycleGraph::addEdge(const ModelAction *to, const ModelAction *from) { * can occur in between the rmw and the from action. Only one RMW * action can read from a given write. */ -void CycleGraph::addRMWEdge(const ModelAction *rmw, const ModelAction *from) { +void CycleGraph::addRMWEdge(const ModelAction *from, const ModelAction *rmw) { CycleNode *fromnode=getNode(from); CycleNode *rmwnode=getNode(rmw); @@ -81,6 +81,21 @@ void CycleGraph::addRMWEdge(const ModelAction *rmw, const ModelAction *from) { fromnode->addEdge(rmwnode); } +/** + * Checks whether one ModelAction can reach another. + * @param from The ModelAction from which to begin exploration + * @param to The ModelAction to reach + * @return True, @a from can reach @a to; otherwise, false + */ +bool CycleGraph::checkReachable(const ModelAction *from, const ModelAction *to) { + CycleNode *fromnode = actionToNode.get(from); + CycleNode *tonode = actionToNode.get(to); + + if (!fromnode || !tonode) + return false; + + return checkReachable(fromnode, tonode); +} /** * Checks whether one CycleNode can reach another.