7d24ae27b00882e36f41ee48857034443ea83ef1
[satune.git] / src / ASTTransform / analyzer.cc
1 #include "analyzer.h"
2 #include "common.h"
3 #include "order.h"
4 #include "boolean.h"
5 #include "ordergraph.h"
6 #include "ordernode.h"
7 #include "rewriter.h"
8 #include "orderedge.h"
9 #include "mutableset.h"
10 #include "ops.h"
11 #include "csolver.h"
12 #include "orderanalysis.h"
13 #include "tunable.h"
14 #include "transform.h"
15 #include "element.h"
16 #include "integerencoding.h"
17 #include "decomposeordertransform.h"
18
19 void orderAnalysis(CSolver *This) {
20         Vector<Order *> *orders = This->getOrders();
21         uint size = orders->getSize();
22         for (uint i = 0; i < size; i++) {
23                 Order *order = orders->get(i);
24                 DecomposeOrderTransform* decompose = new DecomposeOrderTransform(This, order, DECOMPOSEORDER, &onoff);
25                 if (!decompose->canExecuteTransform()){
26                         continue;
27                         delete decompose;
28                 }
29
30                 OrderGraph *graph = buildOrderGraph(order);
31                 if (order->type == PARTIAL) {
32                         //Required to do SCC analysis for partial order graphs.  It
33                         //makes sure we don't incorrectly optimize graphs with negative
34                         //polarity edges
35                         completePartialOrderGraph(graph);
36                 }
37
38
39                 bool mustReachGlobal = GETVARTUNABLE(This->getTuner(), order->type, MUSTREACHGLOBAL, &onoff);
40
41                 if (mustReachGlobal)
42                         reachMustAnalysis(This, graph, false);
43
44                 bool mustReachLocal = GETVARTUNABLE(This->getTuner(), order->type, MUSTREACHLOCAL, &onoff);
45
46                 if (mustReachLocal) {
47                         //This pair of analysis is also optional
48                         if (order->type == PARTIAL) {
49                                 localMustAnalysisPartial(This, graph);
50                         } else {
51                                 localMustAnalysisTotal(This, graph);
52                         }
53                 }
54
55                 bool mustReachPrune = GETVARTUNABLE(This->getTuner(), order->type, MUSTREACHPRUNE, &onoff);
56
57                 if (mustReachPrune)
58                         removeMustBeTrueNodes(This, graph);
59
60                 //This is needed for splitorder
61                 computeStronglyConnectedComponentGraph(graph);
62                 decompose->setOrderGraph(graph);
63                 decompose->doTransform();
64                 delete decompose;
65                 delete graph;
66
67                 /*
68                 IntegerEncodingTransform* integerEncoding = new IntegerEncodingTransform(This, order, ORDERINTEGERENCODING, &offon);
69                 if(!integerEncoding->canExecuteTransform()){
70                         continue;
71                         delete integerEncoding;
72                 }
73                 integerEncoding->doTransform();
74                 delete integerEncoding; */
75         }
76 }
77
78