From 6e0af6ef491616b430a419b08ae3f2b6137a8881 Mon Sep 17 00:00:00 2001 From: Tuowen Zhao Date: Tue, 11 Oct 2016 17:49:01 -0600 Subject: fixes --- src/ir_chill.cc | 60 +++------------------------------------------------------ 1 file changed, 3 insertions(+), 57 deletions(-) (limited to 'src/ir_chill.cc') diff --git a/src/ir_chill.cc b/src/ir_chill.cc index 4e37b48..933e59c 100755 --- a/src/ir_chill.cc +++ b/src/ir_chill.cc @@ -19,21 +19,6 @@ History: #include "loop.hh" #include "chill_error.hh" -#include "clang/Frontend/FrontendActions.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - #include "code_gen/CG_chillRepr.h" #include "code_gen/CG_chillBuilder.h" #include @@ -1201,6 +1186,7 @@ void IR_clangCode::ReplaceExpression(IR_Ref *old, omega::CG_outputRepr *repr) { 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(); if (!node->isBinaryOperator()) { if (node->isUnaryOperator()) { chillAST_UnaryOperator *uop = (chillAST_UnaryOperator*)node; @@ -1225,10 +1211,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]; - // really need to be more rigorous than this hack // TODO - if (node->isImplicitCastExpr()) node = ((chillAST_ImplicitCastExpr *) node)->getSubExpr(); - if (node->isCStyleCastExpr()) node = ((chillAST_CStyleCastExpr *) node)->getSubExpr(); - if (node->isParenExpr()) node = ((chillAST_ParenExpr *) node)->getSubExpr(); + node = node->constantFold(); if (node->isIntegerLiteral() || node->isFloatingLiteral()) return IR_OP_CONSTANT; else if (node->isBinaryOperator() || node->isUnaryOperator()) { @@ -1252,39 +1235,6 @@ IR_OPERATION_TYPE IR_clangCode::QueryExpOperation(const omega::CG_outputRepr *re CHILL_ERROR("IR_clangCode::QueryExpOperation() UNHANDLED NODE TYPE %s\n", node->getTypeString()); exit(-1); } - - /* CLANG - Expr *e = static_cast(repr)->GetExpression(); - if(isa(e) || isa(e)) return IR_OP_CONSTANT; - else if(isa(e)) return IR_OP_VARIABLE; - else if(BinaryOperator *bop = dyn_cast(e)) { - switch(bop->getOpcode()) { - case BO_Assign: return IR_OP_ASSIGNMENT; - case BO_Add: return IR_OP_PLUS; - case BO_Sub: return IR_OP_MINUS; - case BO_Mul: return IR_OP_MULTIPLY; - case BO_Div: return IR_OP_DIVIDE; - default: return IR_OP_UNKNOWN; - } - } else if(UnaryOperator *uop = dyn_cast(e)) { - switch(uop->getOpcode()) { - case UO_Minus: return IR_OP_NEGATIVE; - case UO_Plus: return IR_OP_POSITIVE; - default: return IR_OP_UNKNOWN; - } - } else if(ConditionalOperator *cop = dyn_cast(e)) { - BinaryOperator *bop; - if(bop = dyn_cast(cop->getCond())) { - if(bop->getOpcode() == BO_GT) return IR_OP_MAX; - else if(bop->getOpcode() == BO_LT) return IR_OP_MIN; - } else return IR_OP_UNKNOWN; - - } - - else if(e == NULL) return IR_OP_NULL; - else return IR_OP_UNKNOWN; - } - END CLANG */ } @@ -1294,11 +1244,7 @@ std::vector IR_clangCode::QueryExpOperand(const omega::C CG_chillRepr *crepr = (CG_chillRepr *) repr; chillAST_Node *e = crepr->chillnodes[0]; // ?? - // really need to be more rigorous than this hack // TODO - if (e->isImplicitCastExpr()) e = ((chillAST_ImplicitCastExpr *) e)->getSubExpr(); - if (e->isCStyleCastExpr()) e = ((chillAST_CStyleCastExpr *) e)->getSubExpr(); - if (e->isParenExpr()) e = ((chillAST_ParenExpr *) e)->getSubExpr(); - + e = e->constantFold(); if (e->isIntegerLiteral() || e->isFloatingLiteral() || e->isDeclRefExpr()) { omega::CG_chillRepr *repr = new omega::CG_chillRepr(e); -- cgit v1.2.3-70-g09d2