More code
authorbdemsky <bdemsky@uci.edu>
Tue, 19 Sep 2017 21:07:30 +0000 (14:07 -0700)
committerbdemsky <bdemsky@uci.edu>
Tue, 19 Sep 2017 21:07:30 +0000 (14:07 -0700)
src/ASTAnalyses/Encoding/encodinggraph.cc
src/ASTAnalyses/Encoding/encodinggraph.h
src/ASTAnalyses/Encoding/graphstructs.h
src/ASTAnalyses/Encoding/subgraph.cc
src/ASTAnalyses/Encoding/subgraph.h

index e0cc869..08db96d 100644 (file)
@@ -8,6 +8,7 @@
 #include "tunable.h"
 #include "qsort.h"
 #include "subgraph.h"
+#include "elementencoding.h"
 
 EncodingGraph::EncodingGraph(CSolver * _solver) :
        solver(_solver) {
@@ -45,11 +46,39 @@ void EncodingGraph::buildGraph() {
        decideEdges();
 }
 
+void EncodingGraph::encode() {
+       SetIteratorEncodingSubGraph * itesg=subgraphs.iterator();
+       while(itesg->hasNext()) {
+               EncodingSubGraph *sg=itesg->next();
+               sg->encode();
+       }
+       delete itesg;
+
+       ElementIterator it(solver);
+       while(it.hasNext()) {
+               Element * e = it.next();
+               switch(e->type) {
+               case ELEMSET:
+               case ELEMFUNCRETURN: {
+                       ElementEncoding *encoding=getElementEncoding(e);
+                       if (encoding->getElementEncodingType() == ELEM_UNASSIGNED) {
+                               //Do assignment...
+                       }
+                       break;
+               }
+               default:
+                       break;
+               }
+       }
+       
+}
+
 void EncodingGraph::mergeNodes(EncodingNode *first, EncodingNode *second) {
        EncodingSubGraph *graph1=graphMap.get(first);
        EncodingSubGraph *graph2=graphMap.get(second);
        if (graph1 == NULL && graph2 == NULL) {
                graph1 = new EncodingSubGraph();
+               subgraphs.add(graph1);
                graphMap.put(first, graph1);
                graph1->addNode(first);
        }
@@ -67,6 +96,7 @@ void EncodingGraph::mergeNodes(EncodingNode *first, EncodingNode *second) {
                        graph1->addNode(node);
                        graphMap.put(node, graph1);
                }
+               subgraphs.remove(graph2);
                delete nodeit;
                delete graph2;
        } else {
index 2fd4b37..5fe6d2a 100644 (file)
@@ -8,6 +8,7 @@ class EncodingGraph {
  public:
        EncodingGraph(CSolver * solver);
        void buildGraph();
+       void encode();
        
        CMEMALLOC;
  private:
@@ -17,7 +18,8 @@ class EncodingGraph {
        Vector<EncodingEdge *> edgeVector;
        HashsetElement discovered;
        HashtableNodeToSubGraph graphMap;
-
+       HashsetEncodingSubGraph subgraphs;
+       
        void decideEdges();
        void mergeNodes(EncodingNode *first, EncodingNode *second);
        void processElement(Element *e);
index 3a54a81..89add61 100644 (file)
@@ -15,4 +15,6 @@ typedef Hashset<EncodingEdge *, uintptr_t, PTRSHIFT> HashsetEncodingEdge;
 typedef SetIterator<EncodingEdge *, uintptr_t, PTRSHIFT> SetIteratorEncodingEdge;
 
 typedef Hashtable<EncodingNode *, EncodingSubGraph *, uintptr_t, PTRSHIFT> HashtableNodeToSubGraph;
+typedef Hashset<EncodingSubGraph *, uintptr_t, PTRSHIFT> HashsetEncodingSubGraph;
+typedef SetIterator<EncodingSubGraph *, uintptr_t, PTRSHIFT> SetIteratorEncodingSubGraph;
 #endif
index 3690ea7..f75d7c8 100644 (file)
@@ -5,7 +5,8 @@
 
 EncodingSubGraph::EncodingSubGraph() :
        encodingSize(0),
-       numElements(0) {
+       numElements(0),
+       maxEncodingVal(0) {
 }
 
 uint hashNodeValuePair(NodeValuePair *nvp) {
@@ -60,6 +61,8 @@ void EncodingSubGraph::solveEquals() {
                        if (!encodingArray.get(encoding))
                                break;
                }
+               if (encoding > maxEncodingVal)
+                       maxEncodingVal = encoding;
                ev->encoding = encoding;
                ev->assigned = true;
        }
@@ -80,6 +83,8 @@ void EncodingSubGraph::solveComparisons() {
                                while(nextIt->hasNext()) {
                                        EncodingValue *nextVal=nextIt->next();
                                        if (nextVal->encoding < minVal) {
+                                               if (minVal > maxEncodingVal)
+                                                       maxEncodingVal = minVal;
                                                nextVal->encoding = minVal;
                                                discovered.add(nextVal);
                                                tovisit.push(nextVal);
index 4f19eb1..7738445 100644 (file)
@@ -60,7 +60,8 @@ class EncodingSubGraph {
        NVPMap map;
        uint encodingSize;
        uint numElements;
-
+       uint maxEncodingVal;
+       
        friend class EncodingGraph;
 };