diff options
-rwxr-xr-x | src/ir_chill.cc | 19 | ||||
-rw-r--r-- | src/transformations/loop.cc | 3 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/ir_chill.cc b/src/ir_chill.cc index 933e59c..54c9b3b 100755 --- a/src/ir_chill.cc +++ b/src/ir_chill.cc @@ -1180,13 +1180,21 @@ void IR_clangCode::ReplaceExpression(IR_Ref *old, omega::CG_outputRepr *repr) { delete old; } +// TODO move it somewhere else +chillAST_Node *mild_unwrap(chillAST_Node* n) { + if (n->isParenExpr()) + return (static_cast<chillAST_ParenExpr*>(n))->getSubExpr(); + if (n->isCStyleCastExpr()) + return (static_cast<chillAST_CStyleCastExpr*>(n))->getSubExpr(); + if (n->isImplicitCastExpr()) + return (static_cast<chillAST_ImplicitCastExpr*>(n))->getSubExpr(); + return n; +} - -// TODO IR_CONDITION_TYPE IR_clangCode::QueryBooleanExpOperation(const omega::CG_outputRepr *repr) const { CG_chillRepr *crepr = (CG_chillRepr *)repr; chillAST_Node *node = crepr->chillnodes[0]; - node = node->constantFold(); + node = mild_unwrap(node); if (!node->isBinaryOperator()) { if (node->isUnaryOperator()) { chillAST_UnaryOperator *uop = (chillAST_UnaryOperator*)node; @@ -1211,8 +1219,7 @@ IR_CONDITION_TYPE IR_clangCode::QueryBooleanExpOperation(const omega::CG_outputR IR_OPERATION_TYPE IR_clangCode::QueryExpOperation(const omega::CG_outputRepr *repr) const { CG_chillRepr *crepr = (CG_chillRepr *) repr; chillAST_Node *node = crepr->chillnodes[0]; - node = node->constantFold(); - + node = mild_unwrap(node); if (node->isIntegerLiteral() || node->isFloatingLiteral()) return IR_OP_CONSTANT; else if (node->isBinaryOperator() || node->isUnaryOperator()) { char *opstring; @@ -1244,7 +1251,7 @@ std::vector<omega::CG_outputRepr *> IR_clangCode::QueryExpOperand(const omega::C CG_chillRepr *crepr = (CG_chillRepr *) repr; chillAST_Node *e = crepr->chillnodes[0]; // ?? - e = e->constantFold(); + e = mild_unwrap(e); if (e->isIntegerLiteral() || e->isFloatingLiteral() || e->isDeclRefExpr()) { omega::CG_chillRepr *repr = new omega::CG_chillRepr(e); diff --git a/src/transformations/loop.cc b/src/transformations/loop.cc index 95f2c05..b3539a6 100644 --- a/src/transformations/loop.cc +++ b/src/transformations/loop.cc @@ -487,6 +487,9 @@ void Loop::align_loops(std::vector<ir_tree_node*> &ir_tree, std::vector<std::str clp->chilllowerbound = ocg->CreateMinus(NULL, clp->chilllowerbound); clp->chillupperbound = ocg->CreateMinus(NULL, clp->chillupperbound); clp->step_size_ = -clp->step_size_; + CG_outputRepr *inv = ocg->CreateMinus(NULL,ivar); + vars_to_be_replaced.push_back(iname); + vars_replacement.push_back(inv); } // Ready to recurse align_loops(ir_tree[i]->children,vars_to_be_replaced,vars_replacement,level+1); |