#include "tunable.h"
#include "qsort.h"
#include "subgraph.h"
+#include "elementencoding.h"
EncodingGraph::EncodingGraph(CSolver * _solver) :
solver(_solver) {
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);
}
graph1->addNode(node);
graphMap.put(node, graph1);
}
+ subgraphs.remove(graph2);
delete nodeit;
delete graph2;
} else {
public:
EncodingGraph(CSolver * solver);
void buildGraph();
+ void encode();
CMEMALLOC;
private:
Vector<EncodingEdge *> edgeVector;
HashsetElement discovered;
HashtableNodeToSubGraph graphMap;
-
+ HashsetEncodingSubGraph subgraphs;
+
void decideEdges();
void mergeNodes(EncodingNode *first, EncodingNode *second);
void processElement(Element *e);
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
EncodingSubGraph::EncodingSubGraph() :
encodingSize(0),
- numElements(0) {
+ numElements(0),
+ maxEncodingVal(0) {
}
uint hashNodeValuePair(NodeValuePair *nvp) {
if (!encodingArray.get(encoding))
break;
}
+ if (encoding > maxEncodingVal)
+ maxEncodingVal = encoding;
ev->encoding = encoding;
ev->assigned = true;
}
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);
NVPMap map;
uint encodingSize;
uint numElements;
-
+ uint maxEncodingVal;
+
friend class EncodingGraph;
};