edits
[satune.git] / src / ASTAnalyses / Encoding / subgraph.h
index bc7fdbf5bb8164ed64261ec3398e9fa31f75f881..1f90e917fd053b34755bc2e6f40a265362785f37 100644 (file)
@@ -11,20 +11,28 @@ class NodeValuePair {
        uint64_t value;
 };
 
+class EncodingValue;
+
+typedef Hashset<EncodingValue *, uintptr_t, PTRSHIFT> HashsetEncodingValue;
+typedef SetIterator<EncodingValue *, uintptr_t, PTRSHIFT> SetIteratorEncodingValue;
+
 class EncodingValue {
  public:
- EncodingValue(uint64_t _val) : value(_val), inComparison(false) {}
+ EncodingValue(uint64_t _val) : value(_val), encoding(0), inComparison(false), assigned(false) {}
        void merge(EncodingValue *value);
        uint64_t value;
+       uint encoding;
        bool inComparison;
+       bool assigned;
        HashsetEncodingNode nodes;
-       Vector<EncodingValue *> larger;
+       HashsetEncodingValue larger;
+       HashsetEncodingValue notequals;
 };
 
 uint hashNodeValuePair(NodeValuePair *nvp);
 bool equalsNodeValuePair(NodeValuePair *nvp1, NodeValuePair *nvp2);
 
-typedef Hashtable<NodeValuePair *, EncodingValue *, uintptr_t, 4, hashNodeValuePair, equalsNodeValuePair> NVPMap;
+typedef Hashtable<NodeValuePair *, EncodingValue *, uintptr_t, 0, hashNodeValuePair, equalsNodeValuePair> NVPMap;
 
 class EncodingSubGraph {
  public:
@@ -32,6 +40,8 @@ class EncodingSubGraph {
        void addNode(EncodingNode *n);
        SetIteratorEncodingNode * nodeIterator();
        void encode();
+       uint getEncoding(EncodingNode *n, uint64_t val);
+       uint getEncodingSize(EncodingNode *n) { return maxEncodingVal;}
        
        CMEMALLOC;
  private:
@@ -39,14 +49,21 @@ class EncodingSubGraph {
        uint estimateNewSize(EncodingSubGraph *sg);
        void traverseValue(EncodingNode *node, uint64_t value);
        void computeEncodingValue();
-       void computeInequalities();
+       void computeComparisons();
+       void computeEqualities();
+       void solveComparisons();
+       void solveEquals();
        void generateComparison(EncodingNode *left, EncodingNode *right);
+       void generateEquals(EncodingNode *left, EncodingNode *right);
+       void orderEV(EncodingValue *smaller, EncodingValue *larger);
 
+       HashsetEncodingValue values;
        HashsetEncodingNode nodes;
        NVPMap map;
        uint encodingSize;
        uint numElements;
-
+       uint maxEncodingVal;
+       
        friend class EncodingGraph;
 };