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 e0cc869bd19cc5ffc781b88698c063f9c2d1c5c2..08db96d7b55cc47e02c7be0e394ae1135270ce5a 100644 (file)
@@ -8,6 +8,7 @@
 #include "tunable.h"
 #include "qsort.h"
 #include "subgraph.h"
 #include "tunable.h"
 #include "qsort.h"
 #include "subgraph.h"
+#include "elementencoding.h"
 
 EncodingGraph::EncodingGraph(CSolver * _solver) :
        solver(_solver) {
 
 EncodingGraph::EncodingGraph(CSolver * _solver) :
        solver(_solver) {
@@ -45,11 +46,39 @@ void EncodingGraph::buildGraph() {
        decideEdges();
 }
 
        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();
 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);
        }
                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);
                }
                        graph1->addNode(node);
                        graphMap.put(node, graph1);
                }
+               subgraphs.remove(graph2);
                delete nodeit;
                delete graph2;
        } else {
                delete nodeit;
                delete graph2;
        } else {
index 2fd4b3748896f11ca44bfb1e92ee0aeb2ba50326..5fe6d2ad023ee53c93ffc98f289dd88dbaaffa1c 100644 (file)
@@ -8,6 +8,7 @@ class EncodingGraph {
  public:
        EncodingGraph(CSolver * solver);
        void buildGraph();
  public:
        EncodingGraph(CSolver * solver);
        void buildGraph();
+       void encode();
        
        CMEMALLOC;
  private:
        
        CMEMALLOC;
  private:
@@ -17,7 +18,8 @@ class EncodingGraph {
        Vector<EncodingEdge *> edgeVector;
        HashsetElement discovered;
        HashtableNodeToSubGraph graphMap;
        Vector<EncodingEdge *> edgeVector;
        HashsetElement discovered;
        HashtableNodeToSubGraph graphMap;
-
+       HashsetEncodingSubGraph subgraphs;
+       
        void decideEdges();
        void mergeNodes(EncodingNode *first, EncodingNode *second);
        void processElement(Element *e);
        void decideEdges();
        void mergeNodes(EncodingNode *first, EncodingNode *second);
        void processElement(Element *e);
index 3a54a818519bece41e9814fc9037c661a96bea38..89add611429f6ae602374e7154da46a4b178b733 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 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
 #endif
index 3690ea79b5cf61786b1c84dbffacf5325f24da49..f75d7c8136f15211df833f0af3790f1c8a11dbf2 100644 (file)
@@ -5,7 +5,8 @@
 
 EncodingSubGraph::EncodingSubGraph() :
        encodingSize(0),
 
 EncodingSubGraph::EncodingSubGraph() :
        encodingSize(0),
-       numElements(0) {
+       numElements(0),
+       maxEncodingVal(0) {
 }
 
 uint hashNodeValuePair(NodeValuePair *nvp) {
 }
 
 uint hashNodeValuePair(NodeValuePair *nvp) {
@@ -60,6 +61,8 @@ void EncodingSubGraph::solveEquals() {
                        if (!encodingArray.get(encoding))
                                break;
                }
                        if (!encodingArray.get(encoding))
                                break;
                }
+               if (encoding > maxEncodingVal)
+                       maxEncodingVal = encoding;
                ev->encoding = encoding;
                ev->assigned = true;
        }
                ev->encoding = encoding;
                ev->assigned = true;
        }
@@ -80,6 +83,8 @@ void EncodingSubGraph::solveComparisons() {
                                while(nextIt->hasNext()) {
                                        EncodingValue *nextVal=nextIt->next();
                                        if (nextVal->encoding < minVal) {
                                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);
                                                nextVal->encoding = minVal;
                                                discovered.add(nextVal);
                                                tovisit.push(nextVal);
index 4f19eb147bbccaa6ec4903080231a8f069139c3f..77384456fa5e402b1aa6729013dabe9e2662aa55 100644 (file)
@@ -60,7 +60,8 @@ class EncodingSubGraph {
        NVPMap map;
        uint encodingSize;
        uint numElements;
        NVPMap map;
        uint encodingSize;
        uint numElements;
-
+       uint maxEncodingVal;
+       
        friend class EncodingGraph;
 };
 
        friend class EncodingGraph;
 };