use of com.dat3m.dartagnan.solver.caat.predicates.relationGraphs.base.EmptyGraph in project Dat3M by hernanponcedeleon.
the class ExecutionGraph method getOrCreateGraphFromRelation.
private RelationGraph getOrCreateGraphFromRelation(Relation rel) {
if (relationGraphMap.containsKey(rel)) {
return relationGraphMap.get(rel);
}
RelationGraph graph;
Class<?> relClass = rel.getClass();
// ===== Filter special relations ======
if (SPECIAL_RELS.contains(rel.getName())) {
switch(rel.getName()) {
case CTRL:
graph = new CtrlDepGraph();
break;
case DATA:
graph = new DataDepGraph();
break;
case ADDR:
graph = new AddrDepGraph();
break;
case CRIT:
graph = new RcuGraph();
break;
default:
throw new UnsupportedOperationException(rel.getName() + " is marked as special relation but has associated graph.");
}
} else if (relClass == RelRf.class) {
graph = new ReadFromGraph();
} else if (relClass == RelLoc.class) {
graph = new LocationGraph();
} else if (relClass == RelPo.class) {
graph = new ProgramOrderGraph();
} else if (relClass == RelCo.class) {
graph = new CoherenceGraph();
} else if (rel.isRecursiveRelation()) {
RecursiveGraph recGraph = new RecursiveGraph();
recGraph.setName(rel.getName() + "_rec");
relationGraphMap.put(rel, recGraph);
recGraph.setConcreteGraph(getOrCreateGraphFromRelation(rel.getInner()));
return recGraph;
} else if (rel.isUnaryRelation()) {
Relation innerRelation = rel.getInner();
RelationGraph innerGraph = getOrCreateGraphFromRelation(innerRelation);
// A safety check because recursion might have computed this RelationGraph already
if (relationGraphMap.containsKey(rel)) {
return relationGraphMap.get(rel);
}
if (relClass == RelInverse.class) {
graph = new InverseGraph(innerGraph);
} else if (relClass == RelTrans.class) {
graph = new TransitiveGraph(innerGraph);
} else if (relClass == RelRangeIdentity.class) {
graph = new RangeIdentityGraph(innerGraph);
} else if (relClass == RelTransRef.class) {
// FIXME: This is very, very sketchy and instead of doing this
// a WmmProcessor should run that transforms the wmm accordingly.
RelTrans relTrans = new RelTrans(innerRelation);
RelationGraph transGraph = getOrCreateGraphFromRelation(relTrans);
graph = new ReflexiveClosureGraph(transGraph);
} else {
throw new UnsupportedOperationException(relClass.toString() + " has no associated graph yet.");
}
} else if (rel.isBinaryRelation()) {
RelationGraph first = getOrCreateGraphFromRelation(rel.getFirst());
RelationGraph second = getOrCreateGraphFromRelation(rel.getSecond());
// A safety check because recursion might have computed this RelationGraph already
if (relationGraphMap.containsKey(rel)) {
return relationGraphMap.get(rel);
}
if (relClass == RelUnion.class) {
graph = new UnionGraph(first, second);
} else if (relClass == RelIntersection.class) {
graph = new IntersectionGraph(first, second);
} else if (relClass == RelComposition.class) {
graph = new CompositionGraph(first, second);
} else if (relClass == RelMinus.class) {
graph = new DifferenceGraph(first, second);
} else {
throw new UnsupportedOperationException(relClass.toString() + " has no associated graph yet.");
}
} else if (rel.isStaticRelation()) {
if (relClass == RelCartesian.class) {
RelCartesian cartRel = (RelCartesian) rel;
SetPredicate lhs = getOrCreateSetFromFilter(cartRel.getFirstFilter());
SetPredicate rhs = getOrCreateSetFromFilter(cartRel.getSecondFilter());
graph = new CartesianGraph(lhs, rhs);
} else if (relClass == RelRMW.class) {
graph = new RMWGraph();
} else if (relClass == RelExt.class) {
graph = new ExternalGraph();
} else if (relClass == RelInt.class) {
graph = new InternalGraph();
} else if (relClass == RelFencerel.class) {
graph = new FenceGraph(((RelFencerel) rel).getFenceName());
} else if (relClass == RelSetIdentity.class) {
SetPredicate set = getOrCreateSetFromFilter(((RelSetIdentity) rel).getFilter());
graph = new SetIdentityGraph(set);
} else if (relClass == RelId.class) {
graph = new IdentityGraph();
} else if (relClass == RelEmpty.class) {
graph = new EmptyGraph();
} else {
// This is a fallback for all unimplemented static graphs
graph = new StaticDefaultWMMGraph(rel);
}
} else {
throw new UnsupportedOperationException(relClass.toString() + " has no associated graph yet.");
}
graph.setName(rel.getName());
relationGraphMap.put(rel, graph);
return graph;
}
Aggregations