summaryrefslogtreecommitdiff
path: root/lib/codegen
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2016-10-06 23:41:15 -0600
committerTuowen Zhao <ztuowen@gmail.com>2016-10-06 23:41:15 -0600
commit7414769da6aaff79887b5ba53406f442df9da33f (patch)
tree949765e0a6884d25c044cc2bf6313321ada5890c /lib/codegen
parentf329ee2b4cfdde656d2fe30f2a2789d8a3774203 (diff)
downloadchill-7414769da6aaff79887b5ba53406f442df9da33f.tar.gz
chill-7414769da6aaff79887b5ba53406f442df9da33f.tar.bz2
chill-7414769da6aaff79887b5ba53406f442df9da33f.zip
further cleanup
Diffstat (limited to 'lib/codegen')
-rwxr-xr-xlib/codegen/src/CG.cc205
-rwxr-xr-xlib/codegen/src/CG_utils.cc99
2 files changed, 43 insertions, 261 deletions
diff --git a/lib/codegen/src/CG.cc b/lib/codegen/src/CG.cc
index 5d903c4..3b46c72 100755
--- a/lib/codegen/src/CG.cc
+++ b/lib/codegen/src/CG.cc
@@ -34,6 +34,7 @@
#include <code_gen/codegen_error.h>
#include <stack>
#include <string.h>
+#include <code_gen/CGdebug.h>
namespace omega {
@@ -55,7 +56,6 @@ namespace omega {
const std::vector<CG_outputRepr *> &stmts,
std::vector<std::map<std::string, std::vector<CG_outputRepr *> > > uninterpreted_symbols,
bool printString) const {
- fprintf(stderr, "\nCG_result::printRepr(ocg, stmts) \n");
//Anand: making a tweak to allocate twice the original number of dynamically allocated variables
//for use with Uninterpreted function symbols
@@ -67,7 +67,7 @@ namespace omega {
int num_unin = uninterpreted_symbols.size();
int num_active = active_.size();
if (num_unin < num_active) {
- fprintf(stderr, "CG.cc CG_result::printRepr(), not enough uninterpreted symbols (%d) for active statements (5d)\n", num_unin, num_active);
+ CG_ERROR("not enough uninterpreted symbols (%d) for active statements (%d)\n", num_unin, num_active);
exit(-1);
}
@@ -80,7 +80,6 @@ namespace omega {
int num_levels = num_level();
for (int s = 0; s < active_.size(); s++) {
- fprintf(stderr, "\ns %d\n", s);
std::vector<std::string> loop_vars;
if (active_.get(s)) {
@@ -166,8 +165,6 @@ namespace omega {
//--end
#endif
-
- fprintf(stderr, "\n\n\n\nprintRepr recursing ??? return printRepr( ... )\n");
return printRepr(1, ocg, stmts, aotf, uninterpreted_symbols, printString);
}
@@ -176,11 +173,9 @@ namespace omega {
std::string CG_result::printString(
std::vector<std::map<std::string, std::vector<CG_outputRepr *> > > uninterpreted_symbols) const {
- fprintf(stderr, "CG.cc line 164, CG_result::printString()\n");
CG_stringBuilder ocg;
std::vector<CG_outputRepr *> stmts(codegen_->xforms_.size());
- fprintf(stderr, "stmts.size() %d\n", stmts.size());
for (int i = 0; i < stmts.size(); i++)
stmts[i] = new CG_stringRepr("s" + to_string(i));
@@ -194,7 +189,6 @@ namespace omega {
if (repr != NULL) {
std::string s = repr->GetString();
- //fprintf(stderr, "\nCG.cc L197 repr->GetString() = '%s'\n\n\n", s.c_str());
delete repr;
return s;
} else
@@ -313,7 +307,7 @@ namespace omega {
std::vector<std::map<std::string, std::vector<CG_outputRepr *> > > unin,
bool printString) const {
- fprintf(stderr, "CG_split::printRepr()\n");
+ CG_DEBUG_PRINT("CG_split::printRepr()\n");
int numfly = assigned_on_the_fly.size();
//fprintf(stderr, "assigned on the fly %d\n", numfly );
//for (int i=0; i<numfly; i++) {
@@ -377,7 +371,6 @@ namespace omega {
}
CG_result *CG_split::clone() const {
- //fprintf(stderr, "CG_split::clone()\n");
std::vector<CG_result *> clauses(clauses_.size());
for (int i = 0; i < clauses_.size(); i++)
clauses[i] = clauses_[i]->clone();
@@ -478,7 +471,7 @@ namespace omega {
}
// loop iterates more than once, extract bounds now
else {
- fprintf(stderr, "loop iterates more than once, extract bounds now\n");
+ CG_DEBUG_PRINT("loop iterates more than once, extract bounds now\n");
needLoop_ = true;
bounds_ = Relation(hull.n_set());
@@ -1100,8 +1093,6 @@ namespace omega {
const std::vector<CG_outputRepr *> &stmts,
const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,
std::vector<std::map<std::string, std::vector<CG_outputRepr *> > > unin, bool printString) const {
-
- fprintf(stderr, "CG_loop::printRepr() w assigned_on_the_fly gonna call printRepr with more arguments\n");
//int numfly = assigned_on_the_fly.size();
//fprintf(stderr, "assigned on the fly %d\n", numfly );
//for (int i=0; i<numfly; i++) {
@@ -1112,7 +1103,6 @@ namespace omega {
// int val = p.second;
// //fprintf(stderr, "0x%x %d\n", tr, val);
//}
-
return printRepr(true, indent, ocg, stmts, assigned_on_the_fly, unin, printString);
}
@@ -1125,19 +1115,12 @@ namespace omega {
CG_outputBuilder *ocg, const std::vector<CG_outputRepr *> &stmts,
const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,
std::vector<std::map<std::string, std::vector<CG_outputRepr *> > > unin, bool printString) const {
- fprintf(stderr, "\n*** CG.cc CG_loop printrepr with more arguments\n");
-
-
- // debugging output
- int numfly = assigned_on_the_fly.size();
- fprintf(stderr, "assigned on the fly %d\n", numfly ); // Anand makes twice as many
- for (int i=0; i<numfly; i++) {
- //fprintf(stderr, "i %d\n", i);
+ int numfly = assigned_on_the_fly.size(); // Anand makes twice as many
+ for (int i=0; i<numfly; i++) {
std::pair<CG_outputRepr *, int>p = assigned_on_the_fly[i];
CG_outputRepr *tr = NULL;
if (p.first != NULL) tr = p.first->clone();
int val = p.second;
- //fprintf(stderr, "0x%x %d\n", tr, val);
}
//Anand: adding support for Replacing substituted variables within
@@ -1157,36 +1140,24 @@ namespace omega {
else
guardRepr = NULL;
- fprintf(stderr, "after guard assigned on the fly %d\n", numfly );
- for (int i=0; i<numfly; i++) {
- //fprintf(stderr, "i %d\n", i);
+ for (int i=0; i<numfly; i++) {
std::pair<CG_outputRepr *, int>p = assigned_on_the_fly[i];
CG_outputRepr *tr = NULL;
if (p.first != NULL) tr = p.first->clone();
int val = p.second;
- //fprintf(stderr, "0x%x %d\n", tr, val);
}
- fprintf(stderr, "done flying\n");
Relation cur_known = Intersection(copy(known_), copy(guard_));
cur_known.simplify();
- fprintf(stderr, "checking needloop\n");
if (needLoop_) {
- fprintf(stderr, "needLoop_\n");
-
if (checkLoopLevel)
if (level_ == checkLoopLevel)
if (active_.get(stmtForLoopCheck))
fillInBounds = true;
-
- fprintf(stderr, "ctrlRepr = output_loop()\n");
CG_outputRepr *ctrlRepr = output_loop(ocg, bounds_, level_, cur_known,
aotf, unin[stmt_num]);
-
fillInBounds = false;
-
- fprintf(stderr, "in needLoop_ bodyrepr = \n");
int ind = (guardRepr == NULL) ? indent + 1 : indent + 2;
CG_outputRepr *bodyRepr = body_->printRepr(ind,
ocg,
@@ -1203,7 +1174,6 @@ namespace omega {
if (!smtNonSplitLevels.empty()) {
- fprintf(stderr, "!smtNonSplitLevels.empty()\n");
bool blockLoop = false;
bool threadLoop = false;
bool sync = false;
@@ -1231,24 +1201,24 @@ namespace omega {
}
}
if (blockLoop && threadLoop) {
- fprintf(stderr,
- "Warning, have %d level more than once in smtNonSplitLevels\n",
- level_);
+ CG_DEBUG_PRINT("Warning, have %d level more than once in smtNonSplitLevels\n", level_);
threadLoop = false;
}
std::string preferredIdx;
- fprintf(stderr, "loopIdxNames.size() %d\n", loopIdxNames.size());
- for (int i=0; i<loopIdxNames.size(); i++) {
- fprintf(stderr, "\n");
- for (int j=0; j<loopIdxNames[i].size(); j++) {
- fprintf(stderr, "i %d j %d %s\n", i, j,loopIdxNames[i][j].c_str() );
+ CG_DEBUG_BEGIN
+ fprintf(stderr, "loopIdxNames.size() %d\n", loopIdxNames.size());
+ for (int i=0; i<loopIdxNames.size(); i++) {
+ fprintf(stderr, "\n");
+ for (int j=0; j<loopIdxNames[i].size(); j++) {
+ fprintf(stderr, "i %d j %d %s\n", i, j,loopIdxNames[i][j].c_str() );
+ }
}
- }
- fprintf(stderr, "firstActiveStmt %d\n", firstActiveStmt);
- fprintf(stderr, "loopIdxNames[firstActiveStmt].size() %d\n", loopIdxNames[firstActiveStmt].size());
- fprintf(stderr, "level_ %d /2 %d\n", level_, level_/2);
+ fprintf(stderr, "firstActiveStmt %d\n", firstActiveStmt);
+ fprintf(stderr, "loopIdxNames[firstActiveStmt].size() %d\n", loopIdxNames[firstActiveStmt].size());
+ fprintf(stderr, "level_ %d /2 %d\n", level_, level_/2);
+ CG_DEBUG_END
if (loopIdxNames.size()
&& (level_ / 2) - 1 < loopIdxNames[firstActiveStmt].size()) {
@@ -1306,40 +1276,23 @@ namespace omega {
return ocg->CreateIf(indent, guardRepr, loopRepr, NULL);
}
else {
- fprintf(stderr, "NOT needloop_\n");
-
+ CG_DEBUG_PRINT("NOT needloop_\n");
std::pair<CG_outputRepr *, std::pair<CG_outputRepr *, int> > result =
output_assignment(ocg, bounds_, level_, cur_known, aotf, unin[stmt_num]);
-
- //fprintf(stderr, "RESULT 0x%x 0x%x %d\n", result.first, result.second.first, result.second.second );
-
-
guardRepr = ocg->CreateAnd(guardRepr, result.first);
- //fprintf(stderr, "RESULT 0x%x 0x%x %d\n", result.first, result.second.first, result.second.second );
-
- //fprintf(stderr, "after guardRepr assigned on the fly %d\n", numfly );
- for (int i=0; i<numfly; i++) {
- //fprintf(stderr, "i %d\n", i);
+ for (int i=0; i<numfly; i++) {
std::pair<CG_outputRepr *, int>p = assigned_on_the_fly[i];
CG_outputRepr *tr = NULL;
if (p.first != NULL) tr = p.first->clone();
int val = p.second;
- //fprintf(stderr, "0x%x %d\n", tr, val);
- }
-
-
+ }
if (result.second.second < CodeGen::var_substitution_threshold) {
- //fprintf(stderr, "var_substitution_threshold %d < %d level_ = %d\n", result.second.second, CodeGen::var_substitution_threshold, level_);
std::vector<std::pair<CG_outputRepr *, int> > aotf =
assigned_on_the_fly;
aotf[level_ - 1] = result.second;
- //fprintf(stderr, "RESULT 0x%x second 0x%x %d\n", result.first, result.second.first, result.second.second );
-
if(!printString) {
for (std::map<std::string, std::vector<CG_outputRepr *> >::iterator i =
unin[stmt_num].begin(); i != unin[stmt_num].end(); i++) {
-
-
std::vector<CG_outputRepr *> to_push;
for (int j = 0; j < i->second.size(); j++) {
std::string index =
@@ -1356,18 +1309,13 @@ namespace omega {
} // for
} // if
- //fprintf(stderr, "aotf !!\n");
- for (int i=0; i<numfly; i++) {
- //fprintf(stderr, "i %d\n", i);
+ for (int i=0; i<numfly; i++) {
std::pair<CG_outputRepr *, int>p = aotf[i];
CG_outputRepr *tr = NULL;
if (p.first != NULL) { tr = p.first->clone(); }
int val = p.second;
}
-
- //fprintf(stderr, "\nbodyRepr =\n");
- //body_->dump(); // this dies
- int ind = (guardRepr == NULL) ? indent : indent + 1;
+ int ind = (guardRepr == NULL) ? indent : indent + 1;
CG_outputRepr *bodyRepr = body_->printRepr(ind, ocg, stmts, aotf, unin,
printString);
@@ -1377,7 +1325,6 @@ namespace omega {
else
return ocg->CreateIf(indent, guardRepr, bodyRepr, NULL);
} else {
- //fprintf(stderr, "NOT var_substitution_threshold gonna call output_ident()\n");
int ind = (guardRepr == NULL) ? indent : indent + 1;
CG_outputRepr *assignRepr = ocg->CreateAssignment(
ind,
@@ -1394,102 +1341,6 @@ namespace omega {
else
return ocg->CreateIf(indent, guardRepr,
ocg->StmtListAppend(assignRepr, bodyRepr), NULL);
-
- /* DEAD CODE
- std::pair<EQ_Handle, int> result_ = find_simplest_assignment(
- copy(bounds_), copy(bounds_).set_var(level_),
- assigned_on_the_fly);
- bool found_func = false;
- Variable_ID v2;
- int arity;
- for (Constr_Vars_Iter cvi(result_.first); cvi; cvi++)
- if (cvi.curr_var()->kind() == Global_Var) {
- Global_Var_ID g = cvi.curr_var()->get_global_var();
- if ((g->arity() > 0)) {
-
- found_func = true;
- arity = g->arity();
- //copy(R).print();
- v2 = copy(bounds_).get_local(g,
- cvi.curr_var()->function_of());
-
- break;
- }
- }
-
- bool is_array = false;
- if (found_func) {
-
- is_array = ocg->QueryInspectorType(
- v2->get_global_var()->base_name());
-
- }
- if (!found_func || !is_array) {
-
- CG_outputRepr *assignRepr = ocg->CreateAssignment(
- (guardRepr == NULL) ? indent : indent + 1,
- output_ident(ocg, bounds_,
- const_cast<CG_loop *>(this)->bounds_.set_var(
- level_), assigned_on_the_fly),
- result.second.first);
-
- CG_outputRepr *bodyRepr = body_->printRepr(
- (guardRepr == NULL) ? indent : indent + 1, ocg, stmts,
- assigned_on_the_fly);
- if (guardRepr == NULL)
- return ocg->StmtListAppend(assignRepr, bodyRepr);
- else
- return ocg->CreateIf(indent, guardRepr,
- ocg->StmtListAppend(assignRepr, bodyRepr), NULL);
-
- } else {
-
- std::vector<CG_outputRepr *> index_expr;
-
- CG_outputRepr* lb = ocg->CreateArrayRefExpression(
- v2->get_global_var()->base_name(),
- output_ident(ocg, bounds_,
- const_cast<CG_loop *>(this)->bounds_.set_var(2),
- assigned_on_the_fly));
-
- for (int i = arity; i > 1; i--) {
-
- index_expr.push_back(
- ocg->CreateArrayRefExpression(
- v2->get_global_var()->base_name(),
- output_ident(ocg, bounds_,
- const_cast<CG_loop *>(this)->bounds_.set_var(
- 2 * i),
- assigned_on_the_fly)));
-
- //}
-
- }
-
- CG_outputRepr *ub;
- if (index_expr.size() > 1)
- ub = ocg->CreateInvoke("max", index_expr);
- else
- ub = index_expr[0];
- CG_outputRepr *le = ocg->CreateMinus(ub, ocg->CreateInt(1));
- CG_outputRepr *inductive = ocg->CreateInductive(
- output_ident(ocg, bounds_,
- const_cast<CG_loop *>(this)->bounds_.set_var(
- level_), assigned_on_the_fly), lb, le,
- NULL);
-
- CG_outputRepr *bodyRepr = body_->printRepr(
- (guardRepr == NULL) ? indent : indent + 1, ocg, stmts,
- assigned_on_the_fly);
-
- if (guardRepr == NULL) {
- return ocg->CreateLoop(indent, inductive, bodyRepr);
- } else
- return ocg->CreateIf(indent, guardRepr,
- ocg->CreateLoop(indent + 1, inductive, bodyRepr),
- NULL);
- }
- */
}
}
}
@@ -1531,7 +1382,6 @@ namespace omega {
CG_result *CG_loop::clone() const {
- //fprintf(stderr, "CG_loop::clone()\n");
return new CG_loop(codegen_, active_, level_, body_->clone());
}
@@ -1658,16 +1508,12 @@ namespace omega {
const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,
std::vector<std::map<std::string, std::vector<CG_outputRepr *> > > unin,
bool printString) const {
- fprintf(stderr, "CG_leaf::printRepr()\n");
int numfly = assigned_on_the_fly.size();
- //fprintf(stderr, "assigned on the fly %d\n", numfly );
- for (int i=0; i<numfly; i++) {
- //fprintf(stderr, "i %d\n", i);
+ for (int i=0; i<numfly; i++) {
std::pair<CG_outputRepr *, int>p = assigned_on_the_fly[i];
CG_outputRepr *tr = NULL;
if (p.first != NULL) tr = p.first->clone();
int val = p.second;
- //fprintf(stderr, "0x%x %d\n", tr, val);
}
return leaf_print_repr(active_, guards_, NULL, known_, indent, ocg,
@@ -1678,7 +1524,6 @@ namespace omega {
CG_result *CG_leaf::clone() const {
- //fprintf(stderr, "CG_leaf::clone()\n");
return new CG_leaf(codegen_, active_);
}
diff --git a/lib/codegen/src/CG_utils.cc b/lib/codegen/src/CG_utils.cc
index 19bb6c9..95f94ec 100755
--- a/lib/codegen/src/CG_utils.cc
+++ b/lib/codegen/src/CG_utils.cc
@@ -22,6 +22,7 @@
#include <code_gen/codegen_error.h>
#include <math.h>
#include <stack>
+#include <code_gen/CGdebug.h>
namespace omega {
@@ -274,36 +275,29 @@ namespace omega {
Variable_ID v,
const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,
std::map<std::string, std::vector<CG_outputRepr *> > unin) {
- fprintf(stderr, "output_ident( %s )\n", v->name().c_str());
+ CG_DEBUG_PRINT("output_ident( %s )\n", v->name().c_str());
const_cast<Relation &>(R).setup_names(); // hack
if (v->kind() == Input_Var) {
int pos = v->get_position();
if (assigned_on_the_fly[pos - 1].first != NULL) {
- //fprintf(stderr, "on the fly pos=%d\n", pos);
CG_outputRepr *tmp = assigned_on_the_fly[pos-1].first->clone();
- //fprintf(stderr, "tmp on the fly (0x%x)\n", tmp);
return tmp;
}
else {
- //fprintf(stderr, "creating Ident for %s\n", v->name().c_str());
CG_outputRepr *tmp = ocg->CreateIdent(v->name());
- //fprintf(stderr, "ident created for %s\n", v->name().c_str());
return tmp;
}
}
else if (v->kind() == Global_Var) {
- //fprintf(stderr, "CG_utils.cc output_ident() Global_Var\n");
if (v->get_global_var()->arity() == 0) {
- //fprintf(stderr, "arity 0\n");
return ocg->CreateIdent(v->name());
}
else {
/* This should be improved to take into account the possible elimination
of the set variables. */
int arity = v->get_global_var()->arity();
- //fprintf(stderr, "arity %dn", arity );
std::vector<CG_outputRepr *> argList;
if (unin.find(v->get_global_var()->base_name()) != unin.end()) {
@@ -363,19 +357,14 @@ namespace omega {
const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,
std::map<std::string, std::vector<CG_outputRepr *> > unin) {
- //fprintf(stderr, "output_assignment( )\n");
int numfly = assigned_on_the_fly.size();
- //fprintf(stderr, "assigned on the fly %d\n", numfly );
- for (int i=0; i<numfly; i++) {
- //fprintf(stderr, "i %d\n", i);
+ for (int i=0; i<numfly; i++) {
std::pair<CG_outputRepr *, int>p = assigned_on_the_fly[i];
CG_outputRepr *tr = NULL;
if (p.first != NULL) tr = p.first->clone();
int val = p.second;
- //fprintf(stderr, "0x%x %d\n", tr, val);
}
-
-
+
Variable_ID v = const_cast<Relation &>(R).set_var(level);
Conjunct *c = const_cast<Relation &>(R).single_conjunct();
@@ -650,9 +639,6 @@ namespace omega {
const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,
std::map<std::string, std::vector<CG_outputRepr *> > unin) {
std::vector<CG_outputRepr *> subs;
-
- fprintf(stderr, "CG_utils.cc output_substitutions()\n");
-
for (int i = 1; i <= R.n_out(); i++) {
Relation mapping(R.n_out(), 1);
F_And *f_root = mapping.add_and();
@@ -665,16 +651,13 @@ namespace omega {
Variable_ID v = r.output_var(1);
CG_outputRepr *repr = NULL;
- fprintf(stderr, "v %s\n", v->char_name());
std::pair<EQ_Handle, int> result = find_simplest_assignment(r, v, assigned_on_the_fly);
if (result.second < INT_MAX) {
- //fprintf(stderr, "output_substitutions() calling output_substitution_repr()\n");
- repr = output_substitution_repr(ocg, result.first, v, true, r,
+ repr = output_substitution_repr(ocg, result.first, v, true, r,
assigned_on_the_fly, unin);
- if (repr == NULL) fprintf(stderr, "IN IF, repr for %s assigned NULL\n", v->char_name());
+ if (repr == NULL) CG_ERROR("IN IF, repr for %s assigned NULL\n", v->char_name());
}
else {
- //fprintf(stderr, "else\n");
std::pair<bool, GEQ_Handle> result = find_floor_definition(R, v);
if (result.first)
try {
@@ -685,7 +668,7 @@ namespace omega {
}
}
- if (repr == NULL) fprintf(stderr, "repr NULL\n");
+ if (repr == NULL) CG_ERROR("repr NULL\n");
if (repr != NULL) {
subs.push_back(repr);
}
@@ -699,7 +682,7 @@ namespace omega {
//h.update_coef(mapping1.input_var(i), -1);
//Relation r = Composition(mapping1, copy(mapping));
//r.simplify();
-
+
Relation r = copy(R);
Variable_ID v = r.output_var(k);
@@ -718,7 +701,7 @@ namespace omega {
Variable_ID v1 = cvi.curr_var();
if (v1->kind() == Input_Var)
variables.push_back(v1);
-
+
}
*/
repr_ = output_substitution_repr(ocg, result.first, v, true,
@@ -839,8 +822,6 @@ namespace omega {
} // for int k
}
}
-
- fprintf(stderr, "CG_utils.cc output_substitutions() DONE\n\n");
return subs;
}
@@ -1195,7 +1176,6 @@ namespace omega {
const Relation &R,
const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,
std::map<std::string, std::vector<CG_outputRepr *> > unin) {
- fprintf(stderr, "output_guard()\n");
assert(R.n_out()==0);
CG_outputRepr *result = NULL;
@@ -1204,7 +1184,6 @@ namespace omega {
// e.g. 4i=5*j
for (EQ_Iterator e = c->EQs(); e; e++)
if (!(*e).has_wildcards()) {
- //fprintf(stderr, "EQ\n");
CG_outputRepr *lhs = NULL;
CG_outputRepr *rhs = NULL;
for (Constr_Vars_Iter cvi(*e); cvi; cvi++) {
@@ -1509,8 +1488,6 @@ namespace omega {
const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,
std::map<std::string, std::vector<CG_outputRepr *> > unin,
std::set<Variable_ID> excluded_floor_vars) {
- fprintf(stderr, "output_inequality_repr() v %s\n", v->name().c_str());
-
const_cast<Relation &>(R).setup_names(); // hack
coef_t a = inequality.get_coef(v);
@@ -1527,12 +1504,9 @@ namespace omega {
cvi.curr_var(),
excluded_floor_vars);
if (!result.first) {
- fprintf(stderr, "\n\n*** heading into NEW CODE\n");
-
coef_t coef_ = cvi.curr_coef();
result2 = find_floor_definition_temp(R, cvi.curr_var(),
excluded_floor_vars);
-
for (Constr_Vars_Iter cvi_(
result2[result2.size() - 1].second); cvi_; cvi_++) {
if (cvi_.curr_var()->kind() != Wildcard_Var
@@ -1545,8 +1519,6 @@ namespace omega {
ocg->CreateInt(-coef_));
repr = ocg->CreateTimes(ocg->CreateInt(-coef_),
repr);
-
- fprintf(stderr, "returning a TIMES\n");
return repr;
}
@@ -1667,8 +1639,6 @@ namespace omega {
const Relation &known,
const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,
std::map<std::string, std::vector<CG_outputRepr *> > unin) {
-
- fprintf(stderr, "output_lower_bound_repr()\n");
assert(inequality.get_coef(v) > 0);
CG_outputRepr* zero_;
if (wc == NULL
@@ -1772,11 +1742,7 @@ namespace omega {
const Relation &known,
const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,
std::map<std::string, std::vector<CG_outputRepr *> > unin) {
-
- fprintf(stderr, "CG_utils.cc output_loop()\n");
std::pair<EQ_Handle, Variable_ID> result = find_simplest_stride(R, const_cast<Relation &>(R).set_var(level));
- fprintf(stderr, "found stride\n");
-
if (result.second != NULL)
assert(abs(result.first.get_coef(const_cast<Relation &>(R).set_var(level))) == 1);
@@ -1788,19 +1754,14 @@ namespace omega {
for (GEQ_Iterator e(const_cast<Relation &>(R).single_conjunct()->GEQs());
e;
e++) {
- fprintf(stderr, "new e\n");
coef_t coef = (*e).get_coef(const_cast<Relation &>(R).set_var(level));
-
- fprintf(stderr, "coef %d\n", coef);
if (coef > 0) {
CG_outputRepr *repr = output_lower_bound_repr(ocg, *e, const_cast<Relation &>(R).set_var(level), result.first, result.second, R, known, assigned_on_the_fly, unin);
- fprintf(stderr, "got a repr\n");
- if (repr == NULL) fprintf(stderr, "repr NULL\n");
-
- if (repr == NULL)
+ if (repr == NULL) {
+ CG_ERROR("NULL lowerbound, assumed zero\n");
repr = ocg->CreateInt(0);
+ }
lbList.push_back(repr);
-
if ((*e).is_const(const_cast<Relation &>(R).set_var(level))){
if(!result.second) {
@@ -2604,10 +2565,6 @@ namespace omega {
const std::vector<std::pair<CG_outputRepr *, int> > &assigned_on_the_fly,
std::vector<std::map<std::string, std::vector<CG_outputRepr *> > > unin) {
- fprintf(stderr, "loop_print_repr() guard_repr ");
- if (guard_repr == NULL) fprintf(stderr, "NULL\n");
- else fprintf(stderr, "NOT NULL\n");
-
if (start >= end)
return NULL;
@@ -2628,9 +2585,7 @@ namespace omega {
stmts,
assigned_on_the_fly,
unin));
-
- fprintf(stderr,"CG_utils.cc loop_print_repr recursive\n");
- stmt_list = ocg->StmtListAppend(stmt_list,
+ stmt_list = ocg->StmtListAppend(stmt_list,
loop_print_repr(active,
loops,
i,
@@ -2644,12 +2599,9 @@ namespace omega {
stmts,
assigned_on_the_fly,
unin));
-
- //fprintf(stderr, "guard_repr 0x%x\n", guard_repr);
if (guard_repr == NULL)
return stmt_list;
else {
- fprintf(stderr, "CG_utils.cc loop_print_repr() CreateIf()\n");
return ocg->CreateIf(indent, guard_repr, stmt_list, NULL);
}
}
@@ -2682,8 +2634,7 @@ namespace omega {
guard_repr = ocg->CreateAnd(guard_repr, new_guard_repr);
Relation new_guard = Intersection(copy(guard), copy(then_cond));
new_guard.simplify();
- fprintf(stderr,"CG_utils.cc loop_print_repr recursive 2\n");
- return loop_print_repr(active, loops, start, end, new_guard, guard_repr,
+ return loop_print_repr(active, loops, start, end, new_guard, guard_repr,
indent, remap, xforms, ocg, stmts, aotf, unin);
}
else if (j == i && end > j) {
@@ -2694,9 +2645,7 @@ namespace omega {
new_guard.simplify();
new_guard.print(stderr);
new_guard.print_with_subs(stderr);
-
- fprintf(stderr,"CG_utils.cc loop_print_repr recursive 3\n");
- CG_outputRepr *stmt_list = loop_print_repr(active,
+ CG_outputRepr *stmt_list = loop_print_repr(active,
loops,
start,
i,
@@ -2709,9 +2658,7 @@ namespace omega {
stmts,
aotf,
unin);
-
- fprintf(stderr,"CG_utils.cc loop_print_repr recursive 4\n");
- stmt_list = ocg->StmtListAppend(stmt_list,
+ stmt_list = ocg->StmtListAppend(stmt_list,
loop_print_repr(active,
loops,
j,
@@ -2729,7 +2676,6 @@ namespace omega {
if (guard_repr == NULL)
return stmt_list;
else {
- fprintf(stderr, "CG_utils.cc loop_print_repr() CreateIf() 2\n");
return ocg->CreateIf(indent, guard_repr, stmt_list, NULL);
}
}
@@ -2737,8 +2683,6 @@ namespace omega {
int new_indent = (guard_repr==NULL)?indent:indent+1;
Relation then_new_guard = Intersection(copy(guard), copy(then_cond));
then_new_guard.simplify();
-
- fprintf(stderr,"CG_utils.cc loop_print_repr recursive 5\n");
CG_outputRepr *then_stmt_list = loop_print_repr(active,
loops,
start,
@@ -2755,8 +2699,6 @@ namespace omega {
Relation else_new_guard = Intersection(copy(guard), copy(else_cond));
else_new_guard.simplify();
-
- fprintf(stderr,"CG_utils.cc loop_print_repr recursive 6\n");
CG_outputRepr *else_stmt_list = loop_print_repr(active,
loops,
i,
@@ -2770,15 +2712,11 @@ namespace omega {
stmts,
aotf,
unin);
-
- fprintf(stderr, "CG_utils.cc loop_print_repr() CreateIf() 3\n");
- CG_outputRepr *stmt_list = ocg->CreateIf(new_indent,
+ CG_outputRepr *stmt_list = ocg->CreateIf(new_indent,
new_guard_repr,
then_stmt_list,
else_stmt_list);
-
- fprintf(stderr,"CG_utils.cc loop_print_repr recursive 7\n");
- stmt_list = ocg->StmtListAppend(stmt_list,
+ stmt_list = ocg->StmtListAppend(stmt_list,
loop_print_repr(active,
loops,
j,
@@ -2797,7 +2735,6 @@ namespace omega {
if (guard_repr == NULL)
return stmt_list;
else {
- fprintf(stderr, "CG_utils.cc loop_print_repr() CreateIf() 4\n");
return ocg->CreateIf(indent, guard_repr, stmt_list, NULL);
}
}