Fix tabbing
[satune.git] / src / ASTAnalyses / Encoding / encodinggraph.cc
index 8029049c5a165710238b2083d96b65dd7c699546..2ac69c1de22ddbedb684e04eb44cc51cc76e61f4 100644 (file)
@@ -54,32 +54,32 @@ void EncodingGraph::buildGraph() {
 
 
 void EncodingGraph::validate() {
-       SetIteratorBooleanEdge* it= solver->getConstraints();
-       while(it->hasNext()){
+       SetIteratorBooleanEdge *it = solver->getConstraints();
+       while (it->hasNext()) {
                BooleanEdge be = it->next();
-               if(be->type == PREDICATEOP){
+               if (be->type == PREDICATEOP) {
                        BooleanPredicate *b = (BooleanPredicate *)be.getBoolean();
-                       if(b->predicate->type == OPERATORPRED){
-                               PredicateOperator* predicate = (PredicateOperator*) b->predicate;
-                               if(predicate->getOp() == SATC_EQUALS){
+                       if (b->predicate->type == OPERATORPRED) {
+                               PredicateOperator *predicate = (PredicateOperator *) b->predicate;
+                               if (predicate->getOp() == SATC_EQUALS) {
                                        ASSERT(b->inputs.getSize() == 2);
-                                       Element* e1= b->inputs.get(0);
-                                       Element* e2= b->inputs.get(1);
-                                       if(e1->type == ELEMCONST || e1->type == ELEMCONST)
+                                       Element *e1 = b->inputs.get(0);
+                                       Element *e2 = b->inputs.get(1);
+                                       if (e1->type == ELEMCONST || e1->type == ELEMCONST)
                                                continue;
                                        ElementEncoding *enc1 = e1->getElementEncoding();
                                        ElementEncoding *enc2 = e2->getElementEncoding();
                                        ASSERT(enc1->getElementEncodingType() != ELEM_UNASSIGNED);
                                        ASSERT(enc2->getElementEncodingType() != ELEM_UNASSIGNED);
-                                       if(enc1->getElementEncodingType() == enc2->getElementEncodingType() && enc1->getElementEncodingType() == BINARYINDEX && b->getFunctionEncoding()->type == CIRCUIT){
-                                               for(uint i=0; i<enc1->encArraySize; i++){
-                                                       if(enc1->isinUseElement(i)){
+                                       if (enc1->getElementEncodingType() == enc2->getElementEncodingType() && enc1->getElementEncodingType() == BINARYINDEX && b->getFunctionEncoding()->type == CIRCUIT) {
+                                               for (uint i = 0; i < enc1->encArraySize; i++) {
+                                                       if (enc1->isinUseElement(i)) {
                                                                uint64_t val1 = enc1->encodingArray[i];
-                                                               if(enc2->isinUseElement(i)){
+                                                               if (enc2->isinUseElement(i)) {
                                                                        ASSERT(val1 == enc2->encodingArray[i]);
-                                                               }else{
-                                                                       for(uint j=0; j< enc2->encArraySize; j++){
-                                                                               if(enc2->isinUseElement(j)){
+                                                               } else {
+                                                                       for (uint j = 0; j < enc2->encArraySize; j++) {
+                                                                               if (enc2->isinUseElement(j)) {
                                                                                        ASSERT(val1 != enc2->encodingArray[j]);
                                                                                }
                                                                        }
@@ -88,15 +88,15 @@ void EncodingGraph::validate() {
                                                }
                                        }
                                        //Now make sure that all the elements in the set are appeared in the encoding array!
-                                       for(uint k=0; k< b->inputs.getSize(); k++){
+                                       for (uint k = 0; k < b->inputs.getSize(); k++) {
                                                Element *e = b->inputs.get(k);
                                                ElementEncoding *enc = e->getElementEncoding();
                                                Set *s = e->getRange();
                                                for (uint i = 0; i < s->getSize(); i++) {
                                                        uint64_t value = s->getElement(i);
-                                                       bool exist=false;
-                                                       for(uint j=0; j< enc->encArraySize; j++){
-                                                               if(enc->isinUseElement(j) && enc->encodingArray[j] == value){
+                                                       bool exist = false;
+                                                       for (uint j = 0; j < enc->encArraySize; j++) {
+                                                               if (enc->isinUseElement(j) && enc->encodingArray[j] == value) {
                                                                        exist = true;
                                                                        break;
                                                                }
@@ -155,7 +155,7 @@ void EncodingGraph::encode() {
                                                ASSERT(encoding->isinUseElement(encodingIndex));
                                                encoding->encodingArray[encodingIndex] = value;
                                        }
-                               } else{
+                               } else {
                                        model_print("DAMN in encode()\n");
                                        e->print();
                                }
@@ -207,7 +207,7 @@ void EncodingGraph::mergeNodes(EncodingNode *first, EncodingNode *second) {
                first->setEncoding(BINARYINDEX);
        if (graph2 == NULL)
                second->setEncoding(BINARYINDEX);
-       
+
        if (graph1 == NULL && graph2 == NULL) {
                graph1 = new EncodingSubGraph();
                subgraphs.add(graph1);
@@ -334,14 +334,14 @@ void EncodingGraph::decideEdges() {
                        EncodingSubGraph *tmpsg = leftGraph; leftGraph = rightGraph; rightGraph = tmpsg;
                }
                //model_print("Right=%p RGraph=%p\tLeft=%p LGraph=%p\n", right, rightGraph, left, leftGraph);
-               uint leftSize = 0, rightSize = 0, newSize = 0, max=0;
+               uint leftSize = 0, rightSize = 0, newSize = 0, max = 0;
                uint64_t totalCost = 0;
                bool merge = false;
 //             model_print("**************decideEdge*************\n");
 //             model_print("LeftNode Size = %u\n", left->getSize());
 //             model_print("rightNode Size = %u\n", right->getSize());
 //             model_print("UnionSize = %u\n", left->s->getUnionSize(right->s));
-                       
+
                if (leftGraph == NULL && rightGraph == NULL) {
                        leftSize = convertSize(left->getSize());
                        rightSize = convertSize(right->getSize());
@@ -351,8 +351,8 @@ void EncodingGraph::decideEdges() {
                        totalCost = (newSize - leftSize) * left->elements.getSize() +
                                                                        (newSize - rightSize) * right->elements.getSize();
                        //model_print("leftSize=%u\trighSize=%u\tnewSize=%u\n", leftSize, rightSize, newSize);
-                       max = rightSize > leftSize? rightSize : leftSize;
-                       if(newSize == max){
+                       max = rightSize > leftSize ? rightSize : leftSize;
+                       if (newSize == max) {
                                merge = true;
                        }
                } else if (leftGraph != NULL && rightGraph == NULL) {
@@ -364,8 +364,8 @@ void EncodingGraph::decideEdges() {
                        totalCost = (newSize - leftSize) * leftGraph->numElements +
                                                                        (newSize - rightSize) * right->elements.getSize();
                        //model_print("leftSize=%u\trighSize=%u\tnewSize=%u\n", leftSize, rightSize, newSize);
-                       max = rightSize > leftSize? rightSize : leftSize;
-                       if(newSize == max){
+                       max = rightSize > leftSize ? rightSize : leftSize;
+                       if (newSize == max) {
                                merge = true;
                        }
                } else {
@@ -380,7 +380,7 @@ void EncodingGraph::decideEdges() {
 //                     model_print("LeftGraph size=%u\n", leftGraph->encodingSize);
 //                     model_print("RightGraph size=%u\n", rightGraph->encodingSize);
 //                     model_print("UnionGraph size = %u\n", leftGraph->estimateNewSize(rightGraph));
-                       if(rightSize < 64 && leftSize < 64){
+                       if (rightSize < 64 && leftSize < 64) {
                                merge = true;
                        }
                }