summaryrefslogtreecommitdiff
path: root/src/transformations/loop.cc
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2016-10-12 16:10:42 -0600
committerTuowen Zhao <ztuowen@gmail.com>2016-10-12 16:10:42 -0600
commite7b23d0ca917cc80e3525352e720424f574aadb9 (patch)
tree87c503ecc5380daabd8633ce186bd0873dbd802e /src/transformations/loop.cc
parentdffb489fda5e6224970a0af6e49f07243c26541d (diff)
downloadchill-e7b23d0ca917cc80e3525352e720424f574aadb9.tar.gz
chill-e7b23d0ca917cc80e3525352e720424f574aadb9.tar.bz2
chill-e7b23d0ca917cc80e3525352e720424f574aadb9.zip
anand's init code
Diffstat (limited to 'src/transformations/loop.cc')
-rw-r--r--src/transformations/loop.cc74
1 files changed, 71 insertions, 3 deletions
diff --git a/src/transformations/loop.cc b/src/transformations/loop.cc
index faf33e6..0839705 100644
--- a/src/transformations/loop.cc
+++ b/src/transformations/loop.cc
@@ -286,9 +286,6 @@ void Loop::reduce(int stmt_num,
-
-
-
//-----------------------------------------------------------------------------
// Class Loop
//-----------------------------------------------------------------------------
@@ -319,6 +316,9 @@ void Loop::buildIS(std::vector<ir_tree_node*> &ir_tree,std::vector<int> &lexical
// Setup the IS holder
Relation r(num_dep_dim);
F_And *f_root = r.add_and();
+ // Setup inspector bounds
+ std::vector<std::string> insp_lb;
+ std::vector<std::string> insp_ub;
int current = 0;
@@ -354,6 +354,30 @@ void Loop::buildIS(std::vector<ir_tree_node*> &ir_tree,std::vector<int> &lexical
// Here is using substituted lowerbound
exp2formula(ir, r, f_and, freevar, lb,e,'s',IR_COND_EQ, false, uninterpreted_symbols[loc],uninterpreted_symbols_stringrepr[loc]);
}
+ if ((ir->QueryExpOperation(lp->lower_bound())
+ == IR_OP_ARRAY_VARIABLE)
+ && (ir->QueryExpOperation(lp->lower_bound())
+ == ir->QueryExpOperation(
+ lp->upper_bound()))) {
+ std::vector<CG_outputRepr *> v =
+ ir->QueryExpOperand(lp->lower_bound());
+ IR_ArrayRef *ref =
+ static_cast<IR_ArrayRef *>(ir->Repr2Ref(
+ v[0]));
+ std::string s0 = ref->name();
+ std::vector<CG_outputRepr *> v2 =
+ ir->QueryExpOperand(lp->upper_bound());
+ IR_ArrayRef *ref2 =
+ static_cast<IR_ArrayRef *>(ir->Repr2Ref(
+ v2[0]));
+ std::string s1 = ref2->name();
+
+ if (s0 == s1) {
+ insp_lb.push_back(s0);
+ insp_ub.push_back(s1);
+
+ }
+ }
break;
}
case IR_CONTROL_IF: {
@@ -381,6 +405,50 @@ void Loop::buildIS(std::vector<ir_tree_node*> &ir_tree,std::vector<int> &lexical
}
r.setup_names();
r.simplify();
+ // Inspector initialization
+ for (int j = 0; j < insp_lb.size(); j++) {
+
+ std::string lb = insp_lb[j] + "_";
+ std::string ub = lb + "_";
+
+ Global_Var_ID u, l;
+ bool found_ub = false;
+ bool found_lb = false;
+ for (DNF_Iterator di(copy(r).query_DNF()); di; di++)
+ for (Constraint_Iterator ci = (*di)->constraints(); ci; ci++)
+
+ for (Constr_Vars_Iter cvi(*ci); cvi; cvi++) {
+ Variable_ID v = cvi.curr_var();
+ if (v->kind() == Global_Var)
+ if (v->get_global_var()->arity() > 0) {
+
+ std::string name =
+ v->get_global_var()->base_name();
+ if (name == lb) {
+ l = v->get_global_var();
+ found_lb = true;
+ } else if (name == ub) {
+ u = v->get_global_var();
+ found_ub = true;
+ }
+ }
+
+ }
+
+ if (found_lb && found_ub) {
+ Relation known_(copy(r).n_set());
+ known_.copy_names(copy(r));
+ known_.setup_names();
+ Variable_ID index_lb = known_.get_local(l, Input_Tuple);
+ Variable_ID index_ub = known_.get_local(u, Input_Tuple);
+ F_And *fr = known_.add_and();
+ GEQ_Handle g = fr->add_GEQ();
+ g.update_coef(index_ub, 1);
+ g.update_coef(index_lb, -1);
+ g.update_const(-1);
+ addKnown(known_);
+ }
+ }
// Write back
stmt[loc].code = static_cast<IR_Block*>(ir_stmt[loc]->content)->extract();
stmt[loc].IS = r;