edits
authorbdemsky <bdemsky@uci.edu>
Tue, 19 Sep 2017 23:43:40 +0000 (16:43 -0700)
committerbdemsky <bdemsky@uci.edu>
Tue, 19 Sep 2017 23:43:40 +0000 (16:43 -0700)
src/ASTAnalyses/Encoding/encodinggraph.cc
src/ASTAnalyses/Encoding/encodinggraph.h
src/ASTAnalyses/Encoding/subgraph.cc
src/ASTAnalyses/Encoding/subgraph.h

index 08db96d..3bcf68e 100644 (file)
@@ -62,7 +62,26 @@ void EncodingGraph::encode() {
                case ELEMFUNCRETURN: {
                        ElementEncoding *encoding=getElementEncoding(e);
                        if (encoding->getElementEncodingType() == ELEM_UNASSIGNED) {
                case ELEMFUNCRETURN: {
                        ElementEncoding *encoding=getElementEncoding(e);
                        if (encoding->getElementEncodingType() == ELEM_UNASSIGNED) {
-                               //Do assignment...
+                               EncodingNode *n = getNode(e);
+                               ASSERT(n != NULL);
+                               ElementEncodingType encodetype=n->getEncoding();
+                               encoding->setElementEncodingType(encodetype);
+                               if (encodetype == UNARY || encodetype == ONEHOT) {
+                                       encoding->encodingArrayInitialization();
+                               } else if (encodetype == BINARYINDEX) {
+                                       EncodingSubGraph * subgraph = graphMap.get(n);
+                                       uint encodingSize = subgraph->getEncodingSize(n);
+                                       uint paddedSize = encoding->getSizeEncodingArray(encodingSize);
+                                       encoding->allocInUseArrayElement(paddedSize);
+                                       encoding->allocEncodingArrayElement(paddedSize);
+                                       Set * s=e->getRange();
+                                       for(uint i=0;i<s->getSize();i++) {
+                                               uint64_t value=s->getElement(i);
+                                               uint encodingIndex=subgraph->getEncoding(n, value);
+                                               encoding->setInUseElement(encodingIndex);
+                                               encoding->encodingArray[encodingIndex] = value;
+                                       }
+                               }
                        }
                        break;
                }
                        }
                        break;
                }
@@ -292,6 +311,14 @@ EncodingNode * EncodingGraph::createNode(Element *e) {
        return n;
 }
 
        return n;
 }
 
+EncodingNode * EncodingGraph::getNode(Element *e) {
+       if (e->type == ELEMCONST)
+               return NULL;
+       Set *s = e->getRange();
+       EncodingNode *n = encodingMap.get(s);
+       return n;
+}
+
 void EncodingNode::addElement(Element *e) {
        elements.add(e);
 }
 void EncodingNode::addElement(Element *e) {
        elements.add(e);
 }
index 5fe6d2a..0c94c38 100644 (file)
@@ -26,6 +26,7 @@ class EncodingGraph {
        void processFunction(ElementFunction *f);
        void processPredicate(BooleanPredicate *b);
        EncodingNode * createNode(Element *e);
        void processFunction(ElementFunction *f);
        void processPredicate(BooleanPredicate *b);
        EncodingNode * createNode(Element *e);
+       EncodingNode * getNode(Element *e);
        EncodingEdge * getEdge(EncodingNode *left, EncodingNode *right, EncodingNode *dst);
 };
 
        EncodingEdge * getEdge(EncodingNode *left, EncodingNode *right, EncodingNode *dst);
 };
 
@@ -36,7 +37,7 @@ class EncodingNode {
        uint getSize() const;
        VarType getType() const;
        void setEncoding(ElementEncodingType e) {encoding=e;}
        uint getSize() const;
        VarType getType() const;
        void setEncoding(ElementEncodingType e) {encoding=e;}
-       
+       ElementEncodingType getEncoding() {return encoding;}
        CMEMALLOC;
  private:
        Set *s;
        CMEMALLOC;
  private:
        Set *s;
index f75d7c8..50cc2d0 100644 (file)
@@ -30,6 +30,12 @@ int sortEncodingValue(const void *p1, const void *p2) {
                return 1;
 }
 
                return 1;
 }
 
+uint EncodingSubGraph::getEncoding(EncodingNode *n, uint64_t val) {
+       NodeValuePair nvp(n, val);
+       EncodingValue *ev = map.get(&nvp);
+       return ev->encoding;
+}
+
 void EncodingSubGraph::solveEquals() {
        Vector<EncodingValue *> toEncode;
        Vector<bool> encodingArray;
 void EncodingSubGraph::solveEquals() {
        Vector<EncodingValue *> toEncode;
        Vector<bool> encodingArray;
index 7738445..1f90e91 100644 (file)
@@ -40,6 +40,8 @@ class EncodingSubGraph {
        void addNode(EncodingNode *n);
        SetIteratorEncodingNode * nodeIterator();
        void encode();
        void addNode(EncodingNode *n);
        SetIteratorEncodingNode * nodeIterator();
        void encode();
+       uint getEncoding(EncodingNode *n, uint64_t val);
+       uint getEncodingSize(EncodingNode *n) { return maxEncodingVal;}
        
        CMEMALLOC;
  private:
        
        CMEMALLOC;
  private: