From 4e22699cb200c413a46f1affc38c89559a20c9e0 Mon Sep 17 00:00:00 2001 From: Tuowen Zhao Date: Tue, 11 Oct 2016 00:34:42 -0600 Subject: working if --- lib/chillcg/src/CG_chillBuilder.cc | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) (limited to 'lib/chillcg/src/CG_chillBuilder.cc') diff --git a/lib/chillcg/src/CG_chillBuilder.cc b/lib/chillcg/src/CG_chillBuilder.cc index 185372a..033e32b 100755 --- a/lib/chillcg/src/CG_chillBuilder.cc +++ b/lib/chillcg/src/CG_chillBuilder.cc @@ -60,7 +60,7 @@ namespace omega { // No op break; default: - CG_ERROR("UNHANDLED statement of type %s %s\n",n->getTypeString()); + CG_ERROR("UNHANDLED statement of type %d\n",n->getType()); exit(-1); } return r; @@ -170,7 +170,7 @@ namespace omega { CG_chillRepr *old = (CG_chillRepr *) stmt; std::vector oldnodes = old->getChillCode(); - for (int j=0; jclone(), "=", rAST->clone()); // clone?? - delete lhs; delete rhs; return new CG_chillRepr(bop); } @@ -224,7 +223,6 @@ namespace omega { chillAST_BinaryOperator *bop = new chillAST_BinaryOperator(lAST->clone(), "+=", rAST->clone()); // clone?? - delete lhs; delete rhs; return new CG_chillRepr(bop); } @@ -336,7 +334,6 @@ namespace omega { //fprintf(stderr, "CG_chillBuilder::CreateIf()\n"); if (true_stmtList == NULL && false_stmtList == NULL) { - delete guardList; return NULL; } else if (guardList == NULL) { // this seems odd @@ -368,10 +365,6 @@ namespace omega { chillAST_IfStmt *if_stmt = new chillAST_IfStmt( conditional, then_part, else_part); - delete guardList; - delete true_stmtList; - delete false_stmtList; - return new CG_chillRepr( if_stmt ); } @@ -511,7 +504,6 @@ namespace omega { //fprintf(stderr, "CG_chillBuilder::CreateLoop( indent %d)\n", indent); if (stmtList == NULL) { - delete control; return NULL; } else if (control == NULL) { @@ -533,7 +525,6 @@ namespace omega { forstmt->setBody(cs); - delete stmtList; return control; } @@ -635,17 +626,15 @@ namespace omega { CG_chillRepr *crop = (CG_chillRepr *) rop; if(clop == NULL) { + chillAST_Node *lAST = new chillAST_IntegerLiteral(0); chillAST_Node *rAST = crop->chillnodes[0]; - chillAST_UnaryOperator *ins = new chillAST_UnaryOperator("-", true, rAST->clone()); - delete crop; + chillAST_BinaryOperator *ins = new chillAST_BinaryOperator(lAST,"-" , rAST->clone()); return new CG_chillRepr(ins); } else { chillAST_Node *lAST = clop->chillnodes[0]; chillAST_Node *rAST = crop->chillnodes[0]; chillAST_BinaryOperator *bop = new chillAST_BinaryOperator(lAST->clone(), "-", rAST->clone()); - - delete clop; delete crop; return new CG_chillRepr(bop); } } @@ -663,7 +652,7 @@ namespace omega { if (lop != NULL) { lop->clear(); delete lop; - } + } return NULL; } @@ -674,7 +663,6 @@ namespace omega { chillAST_Node *rAST = crop->chillnodes[0]; chillAST_BinaryOperator *binop = new chillAST_BinaryOperator( lAST, "*", rAST); - delete lop; delete rop; return new CG_chillRepr( binop ); } @@ -706,7 +694,6 @@ namespace omega { chillAST_Node *rAST = crop->chillnodes[0]; chillAST_BinaryOperator *binop = new chillAST_BinaryOperator( lAST, "/", rAST); - delete lop; delete rop; // ?? return new CG_chillRepr( binop ); } @@ -772,7 +759,6 @@ namespace omega { chillAST_Node *rAST = crop->chillnodes[0]; chillAST_BinaryOperator *binop = new chillAST_BinaryOperator( lAST, "<=", rAST); - delete lop; delete rop; // ?? return new CG_chillRepr( binop ); } @@ -798,7 +784,6 @@ namespace omega { //fprintf(stderr, " ??\n"); chillAST_BinaryOperator *binop = new chillAST_BinaryOperator( lAST, "==", rAST); - delete lop; delete rop; // ?? return new CG_chillRepr( binop ); } @@ -825,7 +810,6 @@ namespace omega { //fprintf(stderr, " ??\n"); chillAST_BinaryOperator *binop = new chillAST_BinaryOperator( lAST, "!=", rAST); - delete lop; delete rop; // ?? return new CG_chillRepr( binop ); } @@ -873,7 +857,6 @@ namespace omega { chillAST_MemberExpr *memexpr = new chillAST_MemberExpr( DRE, rvd->varname, NULL, CHILLAST_MEMBER_EXP_DOT ); - //delete lop; delete rop; // ?? return new CG_chillRepr( memexpr ); } @@ -928,7 +911,6 @@ namespace omega { } //fprintf(stderr, "after %d nodes\n", cr1->chillnodes.size() ); - delete list2; return list1; } -- cgit v1.2.3-70-g09d2