diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2016-09-22 15:12:54 -0600 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2016-09-22 15:12:54 -0600 |
commit | 1929ac1a60615ee86779790c46e04e53de75462f (patch) | |
tree | 35566b4f04184a9aed98fdc9dda74507075a7890 /src | |
parent | f27e01a039195c379fd6716c4870858789941365 (diff) | |
download | chill-1929ac1a60615ee86779790c46e04e53de75462f.tar.gz chill-1929ac1a60615ee86779790c46e04e53de75462f.tar.bz2 chill-1929ac1a60615ee86779790c46e04e53de75462f.zip |
add CHILL_DEBUG_PRINT & CHILL_DEBUG_BEGIN & CHILL_DEBUG_END
Diffstat (limited to 'src')
-rw-r--r-- | src/chillASTs.cc (renamed from src/chill_ast.cc) | 39 | ||||
-rwxr-xr-x | src/ir_clang.cc | 168 | ||||
-rw-r--r-- | src/irtools.cc | 78 | ||||
-rw-r--r-- | src/omegatools.cc | 2 | ||||
-rw-r--r-- | src/transformations/loop.cc (renamed from src/loop.cc) | 86 | ||||
-rw-r--r-- | src/transformations/loop_basic.cc (renamed from src/loop_basic.cc) | 0 | ||||
-rw-r--r-- | src/transformations/loop_datacopy.cc (renamed from src/loop_datacopy.cc) | 0 | ||||
-rw-r--r-- | src/transformations/loop_extra.cc (renamed from src/loop_extra.cc) | 0 | ||||
-rw-r--r-- | src/transformations/loop_tile.cc (renamed from src/loop_tile.cc) | 0 | ||||
-rw-r--r-- | src/transformations/loop_unroll.cc (renamed from src/loop_unroll.cc) | 0 |
10 files changed, 187 insertions, 186 deletions
diff --git a/src/chill_ast.cc b/src/chillASTs.cc index 978e303..ebb811c 100644 --- a/src/chill_ast.cc +++ b/src/chillASTs.cc @@ -1,7 +1,8 @@ -#include "chill_ast.hh" +#include <chilldebug.h> +#include "chillAST.h" using namespace std; @@ -882,7 +883,7 @@ chillAST_FunctionDecl::chillAST_FunctionDecl(const char *rt, const char *fname, chillAST_FunctionDecl::chillAST_FunctionDecl(const char *rt, const char *fname, chillAST_node *par, void *unique) { - fprintf(stderr, "chillAST_FunctionDecl::chillAST_FunctionDecl with unique %p\n", unique); + CHILL_DEBUG_PRINT("chillAST_FunctionDecl::chillAST_FunctionDecl with unique %p\n", unique); returnType = strdup(rt); functionName = strdup(fname); this->setFunctionCPU(); @@ -903,17 +904,17 @@ chillAST_FunctionDecl::chillAST_FunctionDecl(const char *rt, const char *fname, void chillAST_FunctionDecl::addParameter( chillAST_VarDecl *p) { - fprintf(stderr, "%s chillAST_FunctionDecl::addParameter( 0x%x param %s) total of %d parameters\n", functionName, p, p->varname, 1+parameters.size()); + CHILL_DEBUG_PRINT("%s chillAST_FunctionDecl::addParameter( 0x%x param %s) total of %d parameters\n", functionName, p, p->varname, 1+parameters.size()); if (symbolTableHasVariableNamed( ¶meters, p->varname)) { // NOT recursive. just in FunctionDecl - fprintf(stderr, "chillAST_FunctionDecl::addParameter( %s ), parameter already exists?\n", p->varname); + CHILL_DEBUG_PRINT("chillAST_FunctionDecl::addParameter( %s ), parameter already exists?\n", p->varname); // exit(-1); // ?? return; // error? } parameters.push_back(p); //addSymbolToTable( parameters, p ); - fprintf(stderr, "setting %s isAParameter\n", p->varname); + CHILL_DEBUG_PRINT("setting %s isAParameter\n", p->varname); p->isAParameter = true; p->setParent( this ); // ?? unclear TODO @@ -923,7 +924,7 @@ void chillAST_FunctionDecl::addParameter( chillAST_VarDecl *p) { void chillAST_FunctionDecl::addDecl( chillAST_VarDecl *vd) { // to symbol table ONLY - fprintf(stderr, "chillAST_FunctionDecl::addDecl( %s )\n", vd->varname); + CHILL_DEBUG_PRINT("chillAST_FunctionDecl::addDecl( %s )\n", vd->varname); if (!body) { //fprintf(stderr, "had no body\n"); body = new chillAST_CompoundStmt(); @@ -977,11 +978,11 @@ chillAST_VarDecl *chillAST_FunctionDecl::funcHasVariableNamed( const char *name //fprintf(stderr, "comparing '%s' to '%s'\n", name, vd->varname); if (!strcmp(name, vd->varname)) { //fprintf(stderr, "yep, it's variable %d\n", i); - fprintf(stderr, "%s was already defined in the function body\n", vd->varname); + CHILL_DEBUG_PRINT("%s was already defined in the function body\n", vd->varname); return vd; // need to check type? } } - fprintf(stderr, "not a parameter or variable named %s\n", name); + CHILL_DEBUG_PRINT("not a parameter or variable named %s\n", name); return NULL; } @@ -1021,10 +1022,12 @@ void chillAST_FunctionDecl::insertChild(int i, chillAST_node* node) { } void chillAST_FunctionDecl::addChild(chillAST_node* node) { - fprintf(stderr, "chillAST_FunctionDecl::addChild( ) "); node->print(0,stderr); fprintf(stderr, "\n\n"); + CHILL_DEBUG_BEGIN + node->print(0,stderr); fprintf(stderr, "\n\n"); + CHILL_DEBUG_END if (node->isVarDecl()) { chillAST_VarDecl *vd = ((chillAST_VarDecl *) node); - fprintf(stderr, "functiondecl %s adding a VarDecl named %s\n", functionName, vd->varname); + CHILL_DEBUG_PRINT("functiondecl %s adding a VarDecl named %s\n", functionName, vd->varname); } body->addChild( node ); @@ -2138,7 +2141,7 @@ void chillAST_ForStmt::loseLoopWithLoopVar( char *var ) { chillAST_BinaryOperator::chillAST_BinaryOperator() { //fprintf(stderr, "chillAST_BinaryOperator::chillAST_BinaryOperator() %p no parent\n", this); - fprintf(stderr, "chillAST_BinaryOperator::chillAST_BinaryOperator() no parent\n"); + CHILL_DEBUG_PRINT("chillAST_BinaryOperator::chillAST_BinaryOperator() no parent\n"); lhs = rhs = NULL; op = NULL; asttype = CHILLAST_NODETYPE_BINARYOPERATOR; @@ -2149,7 +2152,7 @@ chillAST_BinaryOperator::chillAST_BinaryOperator() { chillAST_BinaryOperator::chillAST_BinaryOperator(chillAST_node *l, const char *oper, chillAST_node *r, chillAST_node *par) { //fprintf(stderr, "chillAST_BinaryOperator::chillAST_BinaryOperator( l %p %s r %p, parent %p) this %p\n", l, oper, r, par, this); - fprintf(stderr, "chillAST_BinaryOperator::chillAST_BinaryOperator( l %s r )\n", oper); + CHILL_DEBUG_PRINT("chillAST_BinaryOperator::chillAST_BinaryOperator( l %s r )\n", oper); //if (l && r ) { // fprintf(stderr, "("); l->print(0,stderr); fprintf(stderr, ") %s (", oper); r->print(0,stderr); fprintf(stderr, ")\n\n"); @@ -3872,10 +3875,7 @@ chillAST_node* chillAST_VarDecl::clone() { void chillAST_VarDecl::splitarraypart() { - fprintf(stderr, "chillAST_VarDecl::splitarraypart() "); - //fprintf(stderr, "%p ", arraypart); - if (arraypart) fprintf(stderr, "%s", arraypart); - fprintf(stderr, "\n"); + if (arraypart) CHILL_DEBUG_PRINT("%s\n", arraypart); // split arraypart into (leading??) asterisks and known sizes [1][2][3] if (!arraypart || // NULL @@ -3895,7 +3895,7 @@ void chillAST_VarDecl::splitarraypart() { for ( int i=0; i<strlen(arraypart); i++) { if (arraypart[i] == '*') { if (fixedcount) { - fprintf(stderr, "illegal vardecl arraypart: '%s'\n", arraypart); + CHILL_ERROR("illegal vardecl arraypart: '%s'\n", arraypart); segfault(); exit(-1); } @@ -5311,8 +5311,7 @@ chillAST_VarDecl::chillAST_VarDecl( chillAST_TypedefDecl *tdd, const char *n, c chillAST_VarDecl::chillAST_VarDecl( const char *t, const char *n, const char *a, void *ptr, chillAST_node *par) { - fprintf(stderr, "2chillAST_VarDecl::chillAST_VarDecl( type %s, name %s, arraypart '%s' ) %p\n", t, n, a, this); - //fprintf(stderr, "2chillAST_VarDecl::chillAST_VarDecl( type %s, name %s, arraypart %s, ptr 0x%x, parent 0x%x )\n", t, n, a, ptr, par); + CHILL_DEBUG_PRINT("chillAST_VarDecl::chillAST_VarDecl( type %s, name %s, arraypart '%s' ) %p\n", t, n, a, this); vartype = strdup(t); @@ -5453,7 +5452,7 @@ chillAST_VarDecl::chillAST_VarDecl( const char *t, const char *n, const char *a isFromSourceFile = true; // default filename = NULL; - fprintf(stderr, "2chillAST_VarDecl::chillAST_VarDecl LEAVING\n"); + CHILL_DEBUG_PRINT("LEAVING\n"); //parent->print(); fprintf(stderr, "\n\n"); diff --git a/src/ir_clang.cc b/src/ir_clang.cc index 16deff3..0c56cf0 100755 --- a/src/ir_clang.cc +++ b/src/ir_clang.cc @@ -43,7 +43,7 @@ History: #include <vector> #include <chilldebug.h> -#include "chill_ast.hh" +#include "chillAST.h" // TODO move to ir_clang.hh // fwd declarations @@ -833,7 +833,7 @@ chillAST_node * ConvertDeclStmt( DeclStmt *clangDS, chillAST_node *p ) { // TODO if (V->hasInit()) { - fprintf(stderr, " ConvertDeclStmt() UNHANDLED initialization\n"); + CHILL_ERROR(" ConvertDeclStmt() UNHANDLED initialization\n"); exit(-1); } } @@ -886,13 +886,12 @@ chillAST_node * ConvertFunctionDecl( FunctionDecl *D, chillAST_node *p ) { int numparams = D->getNumParams(); - //fprintf(stderr, "\nand %d parameters\n", numparams); + CHILL_DEBUG_PRINT( " %d parameters\n", numparams); for (int i=0; i<numparams; i++) { - if (i) fprintf(stderr, ", "); VarDecl *clangvardecl = D->getParamDecl(i); // the ith parameter (CLANG) ParmVarDecl *pvd = D->getParamDecl(i); QualType T = pvd->getOriginalType(); - fprintf(stderr, "OTYPE %s\n", T.getAsString().c_str()); + CHILL_DEBUG_PRINT("OTYPE %s\n", T.getAsString().c_str()); chillAST_VarDecl *chillPVD = (chillAST_VarDecl *)ConvertVarDecl( clangvardecl, chillFD ) ; //chillPVD->print(); fflush(stdout); @@ -901,14 +900,14 @@ chillAST_node * ConvertFunctionDecl( FunctionDecl *D, chillAST_node *p ) { VariableDeclarations.push_back(chillPVD); chillFD->addParameter(chillPVD); - fprintf(stderr, "chillAST ParmVarDecl for %s from chill location 0x%x\n",chillPVD->varname, clangvardecl); + CHILL_DEBUG_PRINT("chillAST ParmVarDecl for %s from chill location 0x%x\n",chillPVD->varname, clangvardecl); } // for each parameter //fprintf(stderr, ")\n{\n"); // beginning of function body //if (D->isExternC()) { chillFD->setExtern(); fprintf(stderr, "%s is extern\n", FuncName.c_str()); }; - if (D->getBuiltinID()) { chillFD->setExtern(); fprintf(stderr, "%s is builtin (extern)\n", FuncName.c_str()); }; + if (D->getBuiltinID()) { chillFD->setExtern(); CHILL_DEBUG_PRINT("%s is builtin (extern)\n", FuncName.c_str()); }; Stmt *clangbody = D->getBody(); if (clangbody) { // may just be fwd decl or external, without an actual body @@ -1670,12 +1669,14 @@ IR_Ref *IR_chillArrayRef::clone() const { // ---------------------------------------------------------------------------- // Class: IR_chillLoop // ---------------------------------------------------------------------------- -IR_chillLoop::IR_chillLoop(const IR_Code *ir, clang::ForStmt *tf) { fprintf(stderr, "IR_chillLoop::IR_chillLoop() you lose\n"); exit(-1); }; +IR_chillLoop::IR_chillLoop(const IR_Code *ir, clang::ForStmt *tf) { CHILL_ERROR("IR_chillLoop::IR_chillLoop() you lose\n"); exit(-1); }; -IR_chillLoop::IR_chillLoop(const IR_Code *ir, chillAST_ForStmt *achillforstmt) { - fprintf(stderr, "IR_xxxxLoop::IR_xxxxLoop()\n"); - fprintf(stderr, "loop is:\n"); - achillforstmt->print(); +IR_chillLoop::IR_chillLoop(const IR_Code *ir, chillAST_ForStmt *achillforstmt) { + CHILL_DEBUG_BEGIN + fprintf(stderr, "IR_xxxxLoop::IR_xxxxLoop()\n"); + fprintf(stderr, "loop is:\n"); + achillforstmt->print(); + CHILL_DEBUG_END ir_ = ir; chillforstmt = achillforstmt; @@ -1684,7 +1685,7 @@ IR_chillLoop::IR_chillLoop(const IR_Code *ir, chillAST_ForStmt *achillforstmt) { chillAST_BinaryOperator *cond = (chillAST_BinaryOperator *)chillforstmt->getCond(); // check to be sure (assert) if (!init->isAssignmentOp() || !cond->isComparisonOp() ) { - fprintf(stderr, "ir_clang.cc, malformed loop init or cond:\n"); + CHILL_ERROR("malformed loop init or cond:\n"); achillforstmt->print(); exit(-1); } @@ -1738,21 +1739,21 @@ IR_chillLoop::IR_chillLoop(const IR_Code *ir, chillAST_ForStmt *achillforstmt) { else beets = true; if (beets) { - fprintf(stderr, "malformed loop increment (or more likely unhandled case)\n"); - inc->print(); - exit(-1); + CHILL_ERROR("malformed loop increment (or more likely unhandled case)\n"); + inc->print(); + exit(-1); } } // binary operator - else { - fprintf(stderr, "IR_chillLoop constructor, unhandled loop increment\n"); - inc->print(); - exit(-1); + else { + CHILL_ERROR("IR_chillLoop constructor, unhandled loop increment\n"); + inc->print(); + exit(-1); } //inc->print(0, stderr);fprintf(stderr, "\n"); chillAST_DeclRefExpr *dre = (chillAST_DeclRefExpr *)init->getLHS(); if (!dre->isDeclRefExpr()) { - fprintf(stderr, "malformed loop init.\n"); + CHILL_DEBUG_PRINT("malformed loop init.\n"); init->print(); } @@ -1767,22 +1768,22 @@ IR_chillLoop::IR_chillLoop(const IR_Code *ir, chillAST_ForStmt *achillforstmt) { chillbody = achillforstmt->getBody(); - fprintf(stderr, "IR_xxxxLoop::IR_xxxxLoop() DONE\n"); + CHILL_DEBUG_PRINT("IR_xxxxLoop::IR_xxxxLoop() DONE\n"); } omega::CG_outputRepr *IR_chillLoop::lower_bound() const { - fprintf(stderr, "IR_xxxxLoop::lower_bound()\n"); + CHILL_DEBUG_PRINT("IR_xxxxLoop::lower_bound()\n"); return new omega::CG_chillRepr(chilllowerbound); } omega::CG_outputRepr *IR_chillLoop::upper_bound() const { - fprintf(stderr, "IR_xxxxLoop::upper_bound()\n"); + CHILL_DEBUG_PRINT("IR_xxxxLoop::upper_bound()\n"); return new omega::CG_chillRepr(chillupperbound); } IR_Block *IR_chillLoop::body() const { - fprintf(stderr, "IR_xxxxLoop::body()\n"); + CHILL_DEBUG_PRINT("IR_xxxxLoop::body()\n"); //assert(isa<CompoundStmt>(tf_->getBody())); //fprintf(stderr, "returning a clangBLOCK corresponding to the body of the loop\n"); //fprintf(stderr, "body type %s\n", chillbody->getTypeString()); @@ -1790,25 +1791,26 @@ IR_Block *IR_chillLoop::body() const { } IR_Control *IR_chillLoop::clone() const { - fprintf(stderr, "IR_xxxxLoop::clone()\n"); + CHILL_DEBUG_PRINT("IR_xxxxLoop::clone()\n"); //chillforstmt->print(); fflush(stdout); return new IR_chillLoop(ir_, chillforstmt); } IR_CONDITION_TYPE IR_chillLoop::stop_cond() const { chillAST_BinaryOperator *loopcondition = (chillAST_BinaryOperator*) chillupperbound; - fprintf(stderr, "IR_xxxxLoop::stop_cond()\n"); + CHILL_DEBUG_PRINT("IR_xxxxLoop::stop_cond()\n"); return conditionoperator; } IR_Block *IR_chillLoop::convert() { // convert the loop to a block - fprintf(stderr, "IR_xxxxLoop::convert() maybe \n"); + CHILL_DEBUG_PRINT("IR_xxxxLoop::convert() maybe \n"); return new IR_chillBlock( ir_, chillbody ); // ?? return NULL; } void IR_chillLoop::dump() const { - fprintf(stderr, "TODO: IR_chillLoop::dump()\n"); exit(-1); + CHILL_ERROR("TODO: IR_chillLoop::dump()\n"); + exit(-1); } @@ -1816,8 +1818,8 @@ void IR_chillLoop::dump() const { // Class: IR_chillBlock // ---------------------------------------------------------------------------- omega::CG_outputRepr *IR_chillBlock::original() const { - fprintf(stderr, "IR_xxxxBlock::original() TODO \n"); - exit(-1); + CHILL_ERROR("IR_xxxxBlock::original() TODO \n"); + exit(-1); return NULL; } @@ -1851,7 +1853,7 @@ omega::CG_outputRepr *IR_chillBlock::extract() const { } IR_Control *IR_chillBlock::clone() const { - fprintf(stderr, "IR_xxxxBlock::clone()\n"); + CHILL_DEBUG_PRINT("IR_xxxxBlock::clone()\n"); //fprintf(stderr, "IR_xxxxBlock::clone() %d statements\n", statements.size()); return new IR_chillBlock( this ); // shallow copy ? } @@ -1945,15 +1947,12 @@ IR_clangCode_Global_Init *IR_clangCode_Global_Init::pinstance = 0; IR_clangCode_Global_Init *IR_clangCode_Global_Init::Instance(char **argv) { - fprintf(stderr, "in IR_clangCode_Global_Init::Instance(), "); - if (pinstance == 0) { - //fprintf(stderr, "\n\n*** making the one and only instance ***\n\n\n"); + if (pinstance == 0) { // this is the only way to create an IR_clangCode_Global_Init pinstance = new IR_clangCode_Global_Init; pinstance->ClangCompiler = new aClangCompiler( argv[1] ); } - //fprintf(stderr, "leaving IR_clangCode_Global_Init::Instance()\n"); return pinstance; } @@ -2053,7 +2052,7 @@ aClangCompiler::aClangCompiler( char *filename ) { NULLASTConsumer TheConsumer; // must pass a consumer in to ParseAST(). This one does nothing //fprintf(stderr, "ready? Parse.\n"); - fprintf(stderr, "actually parsing file %s using clang\n", filename); + CHILL_DEBUG_PRINT("actually parsing file %s using clang\n", filename); ParseAST( Clang->getPreprocessor(), &TheConsumer, Clang->getASTContext()); @@ -2062,7 +2061,7 @@ aClangCompiler::aClangCompiler( char *filename ) { // TUD->dump(); // print it out // create another AST, very similar to the clang AST but not written by idiots - fprintf(stderr, "converting entire clang AST into chill AST (ir_clang.cc)\n"); + CHILL_DEBUG_PRINT("converting entire clang AST into chill AST (ir_clang.cc)\n"); chillAST_node * wholefile = ConvertTranslationUnit( TUD, filename); fflush(stdout); @@ -2136,17 +2135,17 @@ chillAST_FunctionDecl* aClangCompiler::findprocedurebyname( char *procname ) { //fprintf(stderr, "procs has %d members\n", procs.size()); if ( procs.size() == 0 ) { - fprintf(stderr, "could not find function named '%s' in AST from file %s\n", procname, SourceFileName); + CHILL_ERROR("could not find function named '%s' in AST from file %s\n", procname, SourceFileName); exit(-1); } if ( procs.size() > 1 ) { - fprintf(stderr, "oddly, found %d functions named '%s' in AST from file %s\n", procs.size(), procname, SourceFileName); - fprintf(stderr, "I am unsure what to do\n"); + CHILL_ERROR("oddly, found %d functions named '%s' in AST from file %s\n", procs.size(), procname, SourceFileName); + CHILL_ERROR("I am unsure what to do\n"); exit(-1); } - fprintf(stderr, "found the procedure named %s\n", procname); + CHILL_DEBUG_PRINT("found the procedure named %s\n", procname); return (chillAST_FunctionDecl *)procs[0]; } @@ -2226,7 +2225,7 @@ IR_clangCode_Global_Init::~IR_clangCode_Global_Init() // ---------------------------------------------------------------------------- IR_clangCode::IR_clangCode(const char *fname, const char *proc_name): IR_Code() { - fprintf(stderr, "\nIR_xxxxCode::IR_xxxxCode()\n\n"); + CHILL_DEBUG_PRINT("IR_xxxxCode::IR_xxxxCode()\n"); //fprintf(stderr, "IR_clangCode::IR_clangCode( filename %s, procedure %s )\n", filename, proc_name); filename = strdup(fname); // filename is internal to IR_clangCode @@ -2260,15 +2259,14 @@ IR_clangCode::IR_clangCode(const char *fname, const char *proc_name): IR_Code() pInstance->setCurrentFunction( localFD ); chillAST_node *b = localFD->getBody(); // we do this just because it will get done next - fprintf(stderr, "in IR_xxxxCode::IR_xxxxCode(), new CG_xxxxBuilder\n"); - fprintf(stderr, "ir_clang.cc calling new CG_chillBuilder() umwut?\n"); + CHILL_DEBUG_PRINT("calling new CG_chillBuilder() umwut?\n"); ocg_ = new omega::CG_chillBuilder(); // ocg == omega code gen chillfunc = localFD; } - fprintf(stderr, "IR_xxxxCode::IR_xxxxCode() returning after reading source file and finding function\n\n"); + CHILL_DEBUG_PRINT("returning after reading source file and finding function\n\n"); //chillfunc->dump( 0, stderr); @@ -2277,7 +2275,7 @@ IR_clangCode::IR_clangCode(const char *fname, const char *proc_name): IR_Code() IR_clangCode::~IR_clangCode() { //func_->print(llvm::outs(), 4); // printing as part of the destructor !! - fprintf(stderr, "IR_xxxxCode::~IR_xxxxCode()\noutput happening as part of the destructor !!\n"); + CHILL_DEBUG_PRINT("\n\toutput happening as part of the destructor !!\n"); //chillfunc->dump(); //chillfunc->print(); @@ -2578,7 +2576,7 @@ std::vector<IR_ArrayRef *> IR_clangCode::FindArrayRef(const omega::CG_outputRepr std::vector<IR_Control *> IR_clangCode::FindOneLevelControlStructure(const IR_Block *block) const { - fprintf(stderr, "IR_xxxxCode::FindOneLevelControlStructure()\n"); + CHILL_DEBUG_PRINT("IR_xxxxCode::FindOneLevelControlStructure()\n"); const IR_chillBlock *CB = (const IR_chillBlock *) block; //fprintf(stderr, "block 0x%x\n", block); @@ -2588,14 +2586,14 @@ std::vector<IR_Control *> IR_clangCode::FindOneLevelControlStructure(const IR_Bl //fprintf(stderr, "blockast 0x%x\n", blockast); if (blockast == NULL) { int numstmts = CB->statements.size(); - fprintf(stderr, "%d statements\n", numstmts); + CHILL_DEBUG_PRINT("%d statements\n", numstmts); if (numstmts == 0) return controls; else if (numstmts == 1) blockast = CB->statements[0]; // a single statement else { - fprintf(stderr, "IR_xxxBlock is dumb, with multiple ways to hold statements\n"); + CHILL_ERROR( "IR_xxxBlock is dumb, with multiple ways to hold statements\n"); exit(-1); // TODO FIX } } @@ -2615,11 +2613,14 @@ std::vector<IR_Control *> IR_clangCode::FindOneLevelControlStructure(const IR_Bl std::vector<chillAST_node *> children; - if (blockast->asttype == CHILLAST_NODETYPE_FORSTMT) { fflush(stdout); - fprintf(stderr, "found a top level For statement (Loop)\n"); - fprintf(stderr, "For Stmt (loop) is:\n"); - blockast->print(); - fprintf(stderr, "pushing the loop at TOP\n"); + if (blockast->asttype == CHILLAST_NODETYPE_FORSTMT) { + CHILL_DEBUG_BEGIN + fflush(stdout); + fprintf(stderr, "found a top level For statement (Loop)\n"); + fprintf(stderr, "For Stmt (loop) is:\n"); + blockast->print(); + fprintf(stderr, "pushing the loop at TOP\n"); + CHILL_DEBUG_END controls.push_back( new IR_chillLoop( this, (chillAST_ForStmt *)blockast)); } @@ -2663,16 +2664,16 @@ std::vector<IR_Control *> IR_clangCode::FindOneLevelControlStructure(const IR_Bl CHILL_ASTNODE_TYPE typ = children[i]->asttype; if (typ == CHILLAST_NODETYPE_LOOP) { if (numchildren == 1) { - fprintf(stderr, "found a For statement (Loop)\n"); + CHILL_DEBUG_PRINT("found a For statement (Loop)\n"); } else { - fprintf(stderr, "found a For statement (Loop) at %d within a Basic Block\n", i); + CHILL_DEBUG_PRINT("found a For statement (Loop) at %d within a Basic Block\n", i); } //children[i]->print(); printf("\n"); fflush(stdout); ns = basicblock->numstatements(); if (ns) { - fprintf(stderr, "pushing a run of statements %d to %d as a block\n", i-ns, i-1); + CHILL_DEBUG_PRINT("pushing a run of statements %d to %d as a block\n", i-ns, i-1); controls.push_back( basicblock ); basicblock = new IR_chillBlock(this); // start a new one } @@ -2704,17 +2705,17 @@ std::vector<IR_Control *> IR_clangCode::FindOneLevelControlStructure(const IR_Bl } else { - fprintf(stderr, "IR_clangCode::FindOneLevelControlStructure(), block is a %s???\n", blockast->getTypeString()); + CHILL_ERROR("IR_clangCode::FindOneLevelControlStructure(), block is a %s???\n", blockast->getTypeString()); exit(-1); } - fprintf(stderr, "returning vector of %d controls\n", controls.size() ); + CHILL_DEBUG_PRINT("returning vector of %d controls\n", controls.size() ); return controls; } IR_Block *IR_clangCode::MergeNeighboringControlStructures(const std::vector<IR_Control *> &controls) const { - fprintf(stderr, "IR_xxxxCode::MergeNeighboringControlStructures %d controls\n", controls.size()); + CHILL_DEBUG_PRINT("IR_xxxxCode::MergeNeighboringControlStructures %d controls\n", controls.size()); if (controls.size() == 0) return NULL; @@ -2726,7 +2727,7 @@ IR_Block *IR_clangCode::MergeNeighboringControlStructures(const std::vector<IR_C for (int i = 0; i < controls.size(); i++) { switch (controls[i]->type()) { case IR_CONTROL_LOOP: { - fprintf(stderr, "control %d is IR_CONTROL_LOOP\n", i); + CHILL_DEBUG_PRINT("control %d is IR_CONTROL_LOOP\n", i); chillAST_ForStmt *loop = static_cast<IR_chillLoop *>(controls[i])->chillforstmt; if (parent == NULL) { parent = loop->parent; @@ -2739,7 +2740,7 @@ IR_Block *IR_clangCode::MergeNeighboringControlStructures(const std::vector<IR_C break; } case IR_CONTROL_BLOCK: { - fprintf(stderr, "control %d is IR_CONTROL_BLOCK\n", i); + CHILL_DEBUG_PRINT("control %d is IR_CONTROL_BLOCK\n", i); IR_chillBlock *CB = static_cast<IR_chillBlock*>(controls[i]); std::vector<chillAST_node*> blockstmts = CB->statements; if (statements.size() != 0) { @@ -2758,8 +2759,7 @@ IR_Block *IR_clangCode::MergeNeighboringControlStructures(const std::vector<IR_C else { if (CB->chillAST) CBlock->addStatement(CBlock->chillAST); // if this is a block, add theblock's statements? else { // should never happen - fprintf(stderr, "WARNING: ir_clang.cc IR_clangCode::MergeNeighboringControlStructures"); - fprintf(stderr, " empty IR_CONTROL_BLOCK \n"); + CHILL_DEBUG_PRINT("WARNING: empty IR_CONTROL_BLOCK \n"); } } break; @@ -2923,9 +2923,8 @@ void IR_clangCode::ReplaceCode(IR_Control *old, omega::CG_outputRepr *repr) { } break; case IR_CONTROL_BLOCK: - fprintf(stderr, "old is IR_CONTROL_BLOCK\n"); - fprintf(stderr, "IR_clangCode::ReplaceCode() stubbed out\n"); - exit(-1); + CHILL_ERROR("old is IR_CONTROL_BLOCK\n"); + exit(-1); //tf_old = static_cast<IR_chillBlock *>(old)->getStmtList()[0]; break; default: @@ -2935,17 +2934,18 @@ void IR_clangCode::ReplaceCode(IR_Control *old, omega::CG_outputRepr *repr) { fflush(stdout); //fprintf(stderr, "\nafter inserting %d statements into the Clang IR,", numnew); - fprintf(stderr, "\nnew parent2 is\n\n{\n"); - std::vector<chillAST_node*> newparentcode = par->getChildren(); - for (int i=0; i<newparentcode.size(); i++) { - fflush(stdout); - //fprintf(stderr, "%d ", i); - newparentcode[i]->print(); printf(";\n"); fflush(stdout); - } - + CHILL_DEBUG_BEGIN + fprintf(stderr, "new parent2 is\n\n{\n"); + std::vector<chillAST_node*> newparentcode = par->getChildren(); + for (int i=0; i<newparentcode.size(); i++) { + fflush(stdout); + //fprintf(stderr, "%d ", i); + newparentcode[i]->print(); printf(";\n"); fflush(stdout); + } + fprintf(stderr, "}\n"); + CHILL_DEBUG_END - fprintf(stderr, "}\n"); } @@ -3045,14 +3045,14 @@ IR_OPERATION_TYPE IR_clangCode::QueryExpOperation(const omega::CG_outputRepr *re if (!strcmp(opstring, "/")) return IR_OP_DIVIDE; if (!strcmp(opstring, "=")) return IR_OP_ASSIGNMENT; - fprintf(stderr, "ir_clang.cc IR_clangCode::QueryExpOperation() UNHANDLED Binary(or Unary)Operator op type (%s)\n", opstring); + CHILL_ERROR("UNHANDLED Binary(or Unary)Operator op type (%s)\n", opstring); exit(-1); } else if (node->isDeclRefExpr() ) return IR_OP_VARIABLE; // ?? //else if (node->is ) return something; else { - fprintf(stderr, "IR_clangCode::QueryExpOperation() UNHANDLED NODE TYPE %s\n", node->getTypeString()); - exit(-1); + CHILL_ERROR("IR_clangCode::QueryExpOperation() UNHANDLED NODE TYPE %s\n", node->getTypeString()); + exit(-1); } /* CLANG @@ -3123,7 +3123,7 @@ std::vector<omega::CG_outputRepr *> IR_clangCode::QueryExpOperand(const omega::C v.push_back(new omega::CG_chillRepr( bop->rhs )); } else { - fprintf(stderr, "ir_clang.cc IR_clangCode::QueryExpOperand() Binary Operator UNHANDLED op (%s)\n", op); + CHILL_ERROR("Binary Operator UNHANDLED op (%s)\n", op); exit(-1); } } // BinaryOperator @@ -3135,13 +3135,13 @@ std::vector<omega::CG_outputRepr *> IR_clangCode::QueryExpOperand(const omega::C v.push_back( new omega::CG_chillRepr( uop->subexpr )); } else { - fprintf(stderr, "ir_clang.cc IR_clangCode::QueryExpOperand() Unary Operator UNHANDLED op (%s)\n", op); + CHILL_ERROR("ir_clang.cc IR_clangCode::QueryExpOperand() Unary Operator UNHANDLED op (%s)\n", op); exit(-1); } } // unaryoperator else { - fprintf(stderr, "ir_clang.cc IR_clangCode::QueryExpOperand() UNHANDLED node type %s\n", e->getTypeString()); - exit(-1); + CHILL_ERROR("UNHANDLED node type %s\n", e->getTypeString()); + exit(-1); } diff --git a/src/irtools.cc b/src/irtools.cc index 16c4f7c..d8d234f 100644 --- a/src/irtools.cc +++ b/src/irtools.cc @@ -13,6 +13,7 @@ #include <iostream> #include <code_gen/CG_outputBuilder.h> +#include <chilldebug.h> #include "irtools.hh" #include "omegatools.hh" #include "chill_error.hh" @@ -26,18 +27,18 @@ std::vector<ir_tree_node *> build_ir_tree(IR_Control *control, ir_tree_node *parent) { std::vector<ir_tree_node *> result; - fprintf(stderr, "irtools.cc, build_ir_tree( control, parent) building a CHILL IR tree \n"); + CHILL_DEBUG_PRINT("building a CHILL IR tree \n"); switch (control->type()) { case IR_CONTROL_BLOCK: { - fprintf(stderr, "irtools.cc L31 case IR_CONTROL_BLOCK\n"); + CHILL_DEBUG_PRINT("case IR_CONTROL_BLOCK\n"); IR_Block *IRCB = static_cast<IR_Block *>(control); std::vector<IR_Control *> controls = control->ir_->FindOneLevelControlStructure(IRCB); - fprintf(stderr, "irtools.cc BACK FROM FindOneLevelControlStructure() %d controls\n", controls.size()); + CHILL_DEBUG_PRINT( "BACK FROM FindOneLevelControlStructure() %d controls\n", controls.size()); if (controls.size() == 0) { - fprintf(stderr, "controls.size() == 0\n"); + CHILL_DEBUG_PRINT("controls.size() == 0\n"); ir_tree_node *node = new ir_tree_node; node->content = control; @@ -46,19 +47,19 @@ std::vector<ir_tree_node *> build_ir_tree(IR_Control *control, result.push_back(node); } else { - fprintf(stderr, "controls.size() == %d (NONZERO)\n", controls.size()); + CHILL_DEBUG_PRINT("controls.size() == %d (NONZERO)\n", controls.size()); delete control; for (int i = 0; i < controls.size(); i++) switch (controls[i]->type()) { case IR_CONTROL_BLOCK: { - fprintf(stderr, "controls[%d] is IR_CONTROL_BLOCK\n", i); + CHILL_DEBUG_PRINT("controls[%d] is IR_CONTROL_BLOCK\n", i); std::vector<ir_tree_node *> t = build_ir_tree(controls[i], parent); result.insert(result.end(), t.begin(), t.end()); break; } case IR_CONTROL_LOOP: { - fprintf(stderr, "controls[%d] is IR_CONTROL_LOOP\n", i); + CHILL_DEBUG_PRINT("controls[%d] is IR_CONTROL_LOOP\n", i); ir_tree_node *node = new ir_tree_node; node->content = controls[i]; node->parent = parent; @@ -68,7 +69,7 @@ std::vector<ir_tree_node *> build_ir_tree(IR_Control *control, break; } case IR_CONTROL_IF: { - fprintf(stderr, "controls[%d] is IR_CONTROL_IF\n", i); + CHILL_DEBUG_PRINT("controls[%d] is IR_CONTROL_IF\n", i); static int unique_if_identifier = 0; IR_If* theif = static_cast<IR_If *>(controls[i]); @@ -85,7 +86,7 @@ std::vector<ir_tree_node *> build_ir_tree(IR_Control *control, block = theif->else_body(); if (block != NULL) { - fprintf(stderr, "IF_CONTROL has an else\n"); + CHILL_DEBUG_PRINT("IF_CONTROL has an else\n"); ir_tree_node *node = new ir_tree_node; node->content = controls[i]->clone(); node->parent = parent; @@ -108,16 +109,16 @@ std::vector<ir_tree_node *> build_ir_tree(IR_Control *control, break; } case IR_CONTROL_LOOP: { - fprintf(stderr, "case IR_CONTROL_LOOP\n"); + CHILL_DEBUG_PRINT("case IR_CONTROL_LOOP\n"); ir_tree_node *node = new ir_tree_node; node->content = control; node->parent = parent; - fprintf(stderr, "recursing. build_ir_tree() of CONTROL_LOOP creating children L122\n"); + CHILL_DEBUG_PRINT("recursing. build_ir_tree() of CONTROL_LOOP creating children L122\n"); node->children = build_ir_tree( static_cast<const IR_Loop *>(control)->body(), node); node->payload = -1; result.push_back(node); - fprintf(stderr, "recursing. build_ir_tree() of CONTROL_LOOP creating children DONE\n"); + CHILL_DEBUG_PRINT("recursing. build_ir_tree() of CONTROL_LOOP creating children DONE\n"); break; } default: @@ -129,7 +130,7 @@ std::vector<ir_tree_node *> build_ir_tree(IR_Control *control, break; } - fprintf(stderr, "build_ir_tree() vector result has %ld parts\n", result.size()); + CHILL_DEBUG_PRINT("build_ir_tree() vector result has %ld parts\n", result.size()); return result; } @@ -138,18 +139,18 @@ std::vector<ir_tree_node *> build_ir_tree(IR_Control *control, // lexical order in the source code. std::vector<ir_tree_node *> extract_ir_stmts(const std::vector<ir_tree_node *> &ir_tree) { - fprintf(stderr, "extract_ir_stmts() ir_tree.size() %d\n", ir_tree.size()); + CHILL_DEBUG_PRINT("extract_ir_stmts() ir_tree.size() %d\n", ir_tree.size()); std::vector<ir_tree_node *> result; for (int i = 0; i < ir_tree.size(); i++) switch (ir_tree[i]->content->type()) { case IR_CONTROL_BLOCK: - fprintf(stderr, "IR_CONTROL_BLOCK\n"); + CHILL_DEBUG_PRINT("IR_CONTROL_BLOCK\n"); result.push_back(ir_tree[i]); break; case IR_CONTROL_LOOP: { - fprintf(stderr, "IR_CONTROL_LOOP( recursing )\n"); + CHILL_DEBUG_PRINT("IR_CONTROL_LOOP( recursing )\n"); // clear loop payload from previous unsuccessful initialization process ir_tree[i]->payload = -1; @@ -159,7 +160,7 @@ std::vector<ir_tree_node *> extract_ir_stmts(const std::vector<ir_tree_node *> & break; } case IR_CONTROL_IF: { - fprintf(stderr, "IR_CONTROL_IF( recursing )\n"); + CHILL_DEBUG_PRINT("IR_CONTROL_IF( recursing )\n"); std::vector<ir_tree_node *> t = extract_ir_stmts(ir_tree[i]->children); result.insert(result.end(), t.begin(), t.end()); break; @@ -176,7 +177,7 @@ std::string chill_ir_control_type_string( IR_CONTROL_TYPE type ) { case IR_CONTROL_BLOCK: return std::string( "IR_CONTROL_BLOCK"); case IR_CONTROL_LOOP: return std::string( "IR_CONTROL_LOOP" ); case IR_CONTROL_IF: return std::string( "IR_CONTROL_IF" ); - case IR_CONTROL_WHILE: return std::string( "IR_CONTROL_WHLIE"); break; + case IR_CONTROL_WHILE: return std::string( "IR_CONTROL_WHLIE"); default: return std::string( "UNKNOWN_IR_NODE_TYPE" ); } } @@ -282,15 +283,15 @@ test_data_dependences(IR_Code *ir, int nestLevelj, std::map<std::string, std::vector<omega::CG_outputRepr * > > &uninterpreted_symbols, std::map<std::string, std::vector<omega::CG_outputRepr * > > &uninterpreted_symbols_stringrepr) { + CHILL_DEBUG_BEGIN + fprintf(stderr, "\nirtools.cc test_data_dependences() %d freevars\n", freevar.size()); + fprintf(stderr, "\nrepr1 %p ", repr1); repr1->dump(); fflush(stdout); + fprintf(stderr, "\nrepr2 %p ", repr2); repr2->dump(); fflush(stdout); - fprintf(stderr, "\nirtools.cc test_data_dependences() %d freevars\n", freevar.size()); - fprintf(stderr, "\nrepr1 %p ", repr1); repr1->dump(); fflush(stdout); - fprintf(stderr, "\nrepr2 %p ", repr2); repr2->dump(); fflush(stdout); - - for (int i=0; i<index.size(); i++) fprintf(stderr, "index %d %s\n", i, index[i].c_str()); - Relation *helper = new Relation(IS1); fprintf(stderr, "IS1 "); helper->print(); fflush(stdout); - helper = new Relation(IS2); fprintf(stderr, "IS2 "); helper->print(); fflush(stdout); - + for (int i=0; i<index.size(); i++) fprintf(stderr, "index %d %s\n", i, index[i].c_str()); + Relation *helper = new Relation(IS1); fprintf(stderr, "IS1 "); helper->print(); fflush(stdout); + helper = new Relation(IS2); fprintf(stderr, "IS2 "); helper->print(); fflush(stdout); + CHILL_DEBUG_END //for (int i=0; i<freevar.size(); i++) { // std::string shit = (const std::string)(freevar[i]->base_name()); @@ -301,23 +302,25 @@ test_data_dependences(IR_Code *ir, std::pair<std::vector<DependenceVector>, std::vector<DependenceVector> > result; if (repr1 == repr2) { - fprintf(stderr, "repr1 == repr2\nrepr1->dump()\n"); - repr1->dump(); + CHILL_DEBUG_BEGIN + fprintf(stderr, "repr1 == repr2\nrepr1->dump()\n"); + repr1->dump(); + CHILL_DEBUG_END fflush(stdout); std::vector<IR_ArrayRef *> access = ir->FindArrayRef(repr1); - fprintf(stderr, "access of size %d\n", access.size()); + CHILL_DEBUG_PRINT("access of size %d\n", access.size()); for (int i = 0; i < access.size(); i++) { IR_ArrayRef *a = access[i]; if (a->is_write()) { - fprintf(stderr, "WRITE array access %d = %s\n", i, a->name().c_str()); + CHILL_DEBUG_PRINT("WRITE array access %d = %s\n", i, a->name().c_str()); } else { - fprintf(stderr, " array access %d = %s\n", i, a->name().c_str()); + CHILL_DEBUG_PRINT(" array access %d = %s\n", i, a->name().c_str()); } } - fprintf(stderr, "that was the list\n\n"); + CHILL_DEBUG_PRINT("that was the list\n\n"); // Manu:: variables/structures added to identify dependence vectors related to reduction operation tempResultMap trMap; @@ -335,9 +338,9 @@ test_data_dependences(IR_Code *ir, // Manu -- changes for identifying possible reduction operation // The below loop nest is used to classify array references into different statements - fprintf(stderr, "\nbefore mapRefstoStatements()\n"); + CHILL_DEBUG_PRINT("\nbefore mapRefstoStatements()\n"); mapRefstoStatements(ir,access,ref2Stmt,rMap,tnrStmts,nrStmts); - fprintf(stderr, "after mapRefstoStatements()\n\n"); + CHILL_DEBUG_PRINT("after mapRefstoStatements()\n\n"); //------------------------------------------------------------- omega::coef_t lbound[3], ubound[3]; // for each kind of dependence. We can potentially have reduction only if all @@ -368,10 +371,11 @@ test_data_dependences(IR_Code *ir, else fprintf(stderr, "%d b->is_NOT_write()\n", j); if (*sym_a == *sym_b && (a->is_write() || b->is_write())) { - fprintf(stderr, "\nirtools.cc ij %d %d SYMBOL A == SYMBOL B and one is a write\n", i, j); Relation r = arrays2relation(ir, freevar, a, IS1, b, IS2,uninterpreted_symbols,uninterpreted_symbols_stringrepr); - helper = new Relation(r); fprintf(stderr, "r "); helper->print(); fflush(stdout); - + CHILL_DEBUG_BEGIN + fprintf(stderr, "\nirtools.cc ij %d %d SYMBOL A == SYMBOL B and one is a write\n", i, j); + Relation *helper = new Relation(r); fprintf(stderr, "r "); helper->print(); fflush(stdout); + CHILL_DEBUG_END fprintf(stderr, "1\n"); std::pair<std::vector<DependenceVector>, diff --git a/src/omegatools.cc b/src/omegatools.cc index 0322182..7ebe726 100644 --- a/src/omegatools.cc +++ b/src/omegatools.cc @@ -19,7 +19,7 @@ #include "ir_code.hh" #include "chill_error.hh" -#include "chill_ast.hh" +#include "chillAST/chillASTs.hh" #include "code_gen/CG_chillRepr.h" #include <code_gen/CG_utils.h> diff --git a/src/loop.cc b/src/transformations/loop.cc index 5f863f2..570bc90 100644 --- a/src/loop.cc +++ b/src/transformations/loop.cc @@ -37,6 +37,7 @@ #include "chill_error.hh" #include <string.h> #include <list> +#include <chilldebug.h> // TODO #define _DEBUG_ true @@ -51,19 +52,19 @@ const std::string Loop::overflow_var_name_prefix = std::string("over"); void echocontroltype( const IR_Control *control ) { switch(control->type()) { case IR_CONTROL_BLOCK: { - fprintf(stderr, "IR_CONTROL_BLOCK\n"); + CHILL_DEBUG_PRINT("IR_CONTROL_BLOCK\n"); break; } case IR_CONTROL_LOOP: { - fprintf(stderr, "IR_CONTROL_LOOP\n"); + CHILL_DEBUG_PRINT("IR_CONTROL_LOOP\n"); break; } case IR_CONTROL_IF: { - fprintf(stderr, "IR_CONTROL_IF\n"); + CHILL_DEBUG_PRINT("IR_CONTROL_IF\n"); break; } default: - fprintf(stderr, "just a bunch of statements?\n"); + CHILL_DEBUG_PRINT("just a bunch of statements?\n"); } // switch } @@ -107,10 +108,10 @@ void Loop::reduce(int stmt_num, //ir->printStmt(stmt[stmt_num].code); if (stmt[stmt_num].reduction != 1) { - std::cout << "loop.cc Cannot reduce this statement\n"; + CHILL_DEBUG_PRINT("Cannot reduce this statement\n"); return; } - fprintf(stderr, "loop.cc CAN reduce this statment?\n"); + CHILL_DEBUG_PRINT("CAN reduce this statment?\n"); /*for (int i = 0; i < level.size(); i++) if (stmt[stmt_num].loop_level[level[i] - 1].segreducible != true) { @@ -303,19 +304,17 @@ bool Loop::isInitialized() const { bool Loop::init_loop(std::vector<ir_tree_node *> &ir_tree, std::vector<ir_tree_node *> &ir_stmt) { - fprintf(stderr, "\n Loop::init_loop()\n"); - - fprintf(stderr, "extract_ir_stmts()\n"); - fprintf(stderr, "ir_tree has %d statements\n", ir_tree.size()); + CHILL_DEBUG_PRINT("extract_ir_stmts()\n"); + CHILL_DEBUG_PRINT("ir_tree has %d statements\n", ir_tree.size()); ir_stmt = extract_ir_stmts(ir_tree); - fprintf(stderr,"nesting level stmt size = %d\n", (int)ir_stmt.size()); + CHILL_DEBUG_PRINT("nesting level stmt size = %d\n", (int)ir_stmt.size()); stmt_nesting_level_.resize(ir_stmt.size()); std::vector<int> stmt_nesting_level(ir_stmt.size()); - fprintf(stderr, "%d statements?\n", (int)ir_stmt.size()); + CHILL_DEBUG_PRINT("%d statements?\n", (int)ir_stmt.size()); // find out how deeply nested each statement is. (how can these be different?) for (int i = 0; i < ir_stmt.size(); i++) { @@ -330,14 +329,14 @@ bool Loop::init_loop(std::vector<ir_tree_node *> &ir_tree, } stmt_nesting_level_[i] = t; stmt_nesting_level[i] = t; - fprintf(stderr, "stmt_nesting_level[%d] = %d\n", i, t); + CHILL_DEBUG_PRINT("stmt_nesting_level[%d] = %d\n", i, t); } if (actual_code.size() == 0) actual_code = std::vector<CG_outputRepr*>(ir_stmt.size()); stmt = std::vector<Statement>(ir_stmt.size()); - fprintf(stderr, "in init_loop, made %d stmts\n", (int)ir_stmt.size()); + CHILL_DEBUG_PRINT("in init_loop, made %d stmts\n", (int)ir_stmt.size()); uninterpreted_symbols = std::vector<std::map<std::string, std::vector<omega::CG_outputRepr * > > >(ir_stmt.size()); uninterpreted_symbols_stringrepr = std::vector<std::map<std::string, std::vector<omega::CG_outputRepr * > > >(ir_stmt.size()); @@ -357,34 +356,34 @@ bool Loop::init_loop(std::vector<ir_tree_node *> &ir_tree, } } - fprintf(stderr, "max nesting level %d at location %d\n", max_nesting_level, loc); + CHILL_DEBUG_PRINT("max nesting level %d at location %d\n", max_nesting_level, loc); // most deeply nested statement acting as a reference point if (n_dim == -1) { - fprintf(stderr, "loop.cc L356 n_dim now max_nesting_level %d\n", max_nesting_level); + CHILL_DEBUG_PRINT("n_dim now max_nesting_level %d\n", max_nesting_level); n_dim = max_nesting_level; max_loc = loc; index = std::vector<std::string>(n_dim); ir_tree_node *itn = ir_stmt[loc]; - fprintf(stderr, "itn = stmt[%d]\n", loc); + CHILL_DEBUG_PRINT("itn = stmt[%d]\n", loc); int cur_dim = n_dim - 1; while (itn->parent != NULL) { - fprintf(stderr, "parent\n"); + CHILL_DEBUG_PRINT("parent\n"); itn = itn->parent; if (itn->content->type() == IR_CONTROL_LOOP) { - fprintf(stderr, "IR_CONTROL_LOOP cur_dim %d\n", cur_dim); + CHILL_DEBUG_PRINT("IR_CONTROL_LOOP cur_dim %d\n", cur_dim); IR_Loop *IRL = static_cast<IR_Loop *>(itn->content); index[cur_dim] = IRL->index()->name(); - fprintf(stderr, "index[%d] = '%s'\n", cur_dim, index[cur_dim].c_str()); + CHILL_DEBUG_PRINT("index[%d] = '%s'\n", cur_dim, index[cur_dim].c_str()); itn->payload = cur_dim--; } } } - fprintf(stderr, "align loops by names,\n"); + CHILL_DEBUG_PRINT("align loops by names,\n"); // align loops by names, temporary solution ir_tree_node *itn = ir_stmt[loc]; // defined outside loops?? int depth = stmt_nesting_level_[loc] - 1; @@ -422,13 +421,13 @@ bool Loop::init_loop(std::vector<ir_tree_node *> &ir_tree, } } - fprintf(stderr, "\nset relation variable names ****\n"); + CHILL_DEBUG_PRINT("set relation variable names ****\n"); // set relation variable names // this finds the loop variables for loops enclosing this statement and puts // them in an Omega Relation (just their names, which could fail) - fprintf(stderr, "Relation r(%d)\n", n_dim); + CHILL_DEBUG_PRINT("Relation r(%d)\n", n_dim); Relation r(n_dim); F_And *f_root = r.add_and(); itn = ir_stmt[loc]; @@ -828,18 +827,17 @@ bool Loop::init_loop(std::vector<ir_tree_node *> &ir_tree, Loop::Loop(const IR_Control *control) { - fprintf(stderr, "\nLoop::Loop(const IR_Control *control)\n"); - fprintf(stderr, "control type is %d ", control->type()); + CHILL_DEBUG_PRINT("control type is %d ", control->type()); echocontroltype(control); - + + CHILL_DEBUG_PRINT("2set last_compute_cg_ = NULL; \n"); last_compute_cgr_ = NULL; last_compute_cg_ = NULL; - fprintf(stderr, "2set last_compute_cg_ = NULL; \n"); ir = const_cast<IR_Code *>(control->ir_); // point to the CHILL IR that this loop came from if (ir == 0) { - fprintf(stderr, "ir gotten from control = 0x%x\n", (long)ir); - fprintf(stderr, "loop.cc GONNA DIE SOON *******************************\n\n"); + CHILL_DEBUG_PRINT("ir gotten from control = 0x%x\n", (long)ir); + CHILL_DEBUG_PRINT("loop.cc GONNA DIE SOON *******************************\n\n"); } init_code = NULL; @@ -848,8 +846,8 @@ Loop::Loop(const IR_Control *control) { overflow_var_name_counter = 1; known = Relation::True(0); - fprintf(stderr, "in Loop::Loop, calling build_ir_tree()\n"); - fprintf(stderr, "\nloop.cc, Loop::Loop() about to clone control\n"); + CHILL_DEBUG_PRINT("calling build_ir_tree()\n"); + CHILL_DEBUG_PRINT("about to clone control\n"); ir_tree = build_ir_tree(control->clone(), NULL); //fprintf(stderr,"in Loop::Loop. ir_tree has %ld parts\n", ir_tree.size()); @@ -4008,11 +4006,11 @@ std::pair<Relation, Relation> construct_reduced_IS_And_XFORM(IR_Code *ir, } */ - if (_DEBUG_) { + CHILL_DEBUG_BEGIN std::cout << "relation debug" << std::endl; IS.print(); - } - + CHILL_DEBUG_END + F_And *f_root = XFORM.add_and(); count_ = 1; @@ -4031,12 +4029,12 @@ std::pair<Relation, Relation> construct_reduced_IS_And_XFORM(IR_Code *ir, omega::EQ_Handle h = f_root->add_EQ(); h.update_coef(XFORM.output_var((loops.size()) * 2 + 1), 1); h.update_const(-lex_order[xform.n_out() - 1]); - - if (_DEBUG_) { + + CHILL_DEBUG_BEGIN std::cout << "relation debug" << std::endl; IS.print(); XFORM.print(); - } + CHILL_DEBUG_END return std::pair<Relation, Relation>(IS, XFORM); @@ -4299,23 +4297,23 @@ std::map<std::string, std::vector<std::string> > recurse_on_exp_for_arrays( std::vector<CG_outputRepr *> find_guards(IR_Code *ir, IR_Control *code) { - fprintf(stderr, "find_guards()\n"); + CHILL_DEBUG_PRINT("find_guards()\n"); std::vector<CG_outputRepr *> guards; switch (code->type()) { case IR_CONTROL_IF: { - fprintf(stderr, "find_guards() it's an if\n"); + CHILL_DEBUG_PRINT("find_guards() it's an if\n"); CG_outputRepr *cond = dynamic_cast<IR_If*>(code)->condition(); std::vector<CG_outputRepr *> then_body; std::vector<CG_outputRepr *> else_body; IR_Block *ORTB = dynamic_cast<IR_If*>(code)->then_body(); if (ORTB != NULL) { - fprintf(stderr, "recursing on then\n"); + CHILL_DEBUG_PRINT("recursing on then\n"); then_body = find_guards(ir, ORTB); //dynamic_cast<IR_If*>(code)->then_body()); } if (dynamic_cast<IR_If*>(code)->else_body() != NULL) { - fprintf(stderr, "recursing on then\n"); + CHILL_DEBUG_PRINT("recursing on then\n"); else_body = find_guards(ir, dynamic_cast<IR_If*>(code)->else_body()); } @@ -4330,9 +4328,9 @@ std::vector<CG_outputRepr *> find_guards(IR_Code *ir, IR_Control *code) { break; } case IR_CONTROL_BLOCK: { - fprintf(stderr, "find_guards() it's a control block\n"); + CHILL_DEBUG_PRINT("it's a control block\n"); IR_Block* IRCB = dynamic_cast<IR_Block*>(code); - fprintf(stderr, "find_guards() calling ir->FindOneLevelControlStructure(IRCB);\n"); + CHILL_DEBUG_PRINT("calling ir->FindOneLevelControlStructure(IRCB);\n"); std::vector<IR_Control *> stmts = ir->FindOneLevelControlStructure(IRCB); for (int i = 0; i < stmts.size(); i++) { @@ -4343,7 +4341,7 @@ std::vector<CG_outputRepr *> find_guards(IR_Code *ir, IR_Control *code) { break; } case IR_CONTROL_LOOP: { - fprintf(stderr, "find_guards() it's a control loop\n"); + CHILL_DEBUG_PRINT("it's a control loop\n"); std::vector<CG_outputRepr *> body = find_guards(ir, dynamic_cast<IR_Loop*>(code)->body()); if (body.size() > 0) diff --git a/src/loop_basic.cc b/src/transformations/loop_basic.cc index a058598..a058598 100644 --- a/src/loop_basic.cc +++ b/src/transformations/loop_basic.cc diff --git a/src/loop_datacopy.cc b/src/transformations/loop_datacopy.cc index 12d74fd..12d74fd 100644 --- a/src/loop_datacopy.cc +++ b/src/transformations/loop_datacopy.cc diff --git a/src/loop_extra.cc b/src/transformations/loop_extra.cc index dac05bf..dac05bf 100644 --- a/src/loop_extra.cc +++ b/src/transformations/loop_extra.cc diff --git a/src/loop_tile.cc b/src/transformations/loop_tile.cc index 41c3e7f..41c3e7f 100644 --- a/src/loop_tile.cc +++ b/src/transformations/loop_tile.cc diff --git a/src/loop_unroll.cc b/src/transformations/loop_unroll.cc index 86ffd84..86ffd84 100644 --- a/src/loop_unroll.cc +++ b/src/transformations/loop_unroll.cc |