Merging with Tuner branch
[satune.git] / src / ASTAnalyses / Encoding / subgraph.h
index 77384456fa5e402b1aa6729013dabe9e2662aa55..00264a6c6371f4ba455cf47b4408675fa07d6d79 100644 (file)
@@ -5,10 +5,11 @@
 #include "graphstructs.h"
 
 class NodeValuePair {
- public:
- NodeValuePair(EncodingNode *n, uint64_t val) : node(n), value(val) {}
+public:
      NodeValuePair(EncodingNode *n, uint64_t val) : node(n), value(val) {}
        EncodingNode *node;
        uint64_t value;
+       CMEMALLOC;
 };
 
 class EncodingValue;
@@ -17,8 +18,8 @@ typedef Hashset<EncodingValue *, uintptr_t, PTRSHIFT> HashsetEncodingValue;
 typedef SetIterator<EncodingValue *, uintptr_t, PTRSHIFT> SetIteratorEncodingValue;
 
 class EncodingValue {
- public:
- EncodingValue(uint64_t _val) : value(_val), encoding(0), inComparison(false), assigned(false) {}
+public:
      EncodingValue(uint64_t _val) : value(_val), encoding(0), inComparison(false), assigned(false) {}
        void merge(EncodingValue *value);
        uint64_t value;
        uint encoding;
@@ -27,6 +28,7 @@ class EncodingValue {
        HashsetEncodingNode nodes;
        HashsetEncodingValue larger;
        HashsetEncodingValue notequals;
+       CMEMALLOC;
 };
 
 uint hashNodeValuePair(NodeValuePair *nvp);
@@ -35,14 +37,19 @@ bool equalsNodeValuePair(NodeValuePair *nvp1, NodeValuePair *nvp2);
 typedef Hashtable<NodeValuePair *, EncodingValue *, uintptr_t, 0, hashNodeValuePair, equalsNodeValuePair> NVPMap;
 
 class EncodingSubGraph {
- public:
+public:
        EncodingSubGraph();
+       ~EncodingSubGraph();
        void addNode(EncodingNode *n);
-       SetIteratorEncodingNode * nodeIterator();
+       SetIteratorEncodingNode *nodeIterator();
        void encode();
-       
+       uint getEncoding(EncodingNode *n, uint64_t val);
+       uint getEncodingMaxVal(EncodingNode *n) { return maxEncodingVal;}
+       double measureSimilarity(EncodingNode *n);
+       double measureSimilarity(EncodingSubGraph *sg);
+       uint numValues();
        CMEMALLOC;
- private:
+private:
        uint estimateNewSize(EncodingNode *n);
        uint estimateNewSize(EncodingSubGraph *sg);
        void traverseValue(EncodingNode *node, uint64_t value);
@@ -58,10 +65,8 @@ class EncodingSubGraph {
        HashsetEncodingValue values;
        HashsetEncodingNode nodes;
        NVPMap map;
-       uint encodingSize;
-       uint numElements;
        uint maxEncodingVal;
-       
+       Hashset64Int allValues;
        friend class EncodingGraph;
 };