use of cx2x.xcodeml.transformation.Transformation in project claw-compiler by C2SM-RCM.
the class ClawXcodeMlTranslator method reorderTransformations.
private void reorderTransformations() {
if (_transformer.getGroups().containsKey(ParallelizeForward.class)) {
TransformationGroup tg = _transformer.getGroups().get(ParallelizeForward.class);
if (tg.count() <= 1) {
return;
}
DirectedGraph<Transformation> dg = new DirectedGraph<>();
Map<String, List<Transformation>> fctMap = new HashMap<>();
for (Transformation t : tg.getTransformations()) {
ParallelizeForward p = (ParallelizeForward) t;
dg.addNode(p);
if (fctMap.containsKey(p.getCallingFctName())) {
List<Transformation> tList = fctMap.get(p.getCallingFctName());
tList.add(p);
} else {
List<Transformation> tList = new ArrayList<>();
tList.add(p);
fctMap.put(p.getCallingFctName(), tList);
}
}
for (Transformation t : tg.getTransformations()) {
ParallelizeForward p = (ParallelizeForward) t;
if (p.getCalledFctName() != null) {
if (fctMap.containsKey(p.getCalledFctName())) {
List<Transformation> tList = fctMap.get(p.getCalledFctName());
for (Transformation end : tList) {
dg.addEdge(p, end);
}
}
}
}
List<Transformation> ordered = TopologicalSort.sort(TopologicalSort.reverseGraph(dg));
tg.setTransformations(ordered);
}
}
Aggregations