From: sandeep Date: Sat, 27 Oct 2001 21:09:22 +0000 (+0000) Subject: Added new option --dumptree . This will dump the front end tree X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=b75e8929c91c765ecea2b27742958c142d645308;p=fw%2Fsdcc Added new option --dumptree . This will dump the front end tree before lowering it to iCode. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1456 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCast.c b/src/SDCCast.c index a2663573..2cc429de 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -53,6 +53,7 @@ ast *createIvalCharPtr (ast *, sym_link *, ast *); ast *optimizeRRCRLC (ast *); ast *optimizeGetHbit (ast *); ast *backPatchLabels (ast *, symbol *, symbol *); +void PA(ast *t); int inInitMode = 0; memmap *GcurMemmap=NULL; /* points to the memmap that's currently active */ FILE *codeOutFile; @@ -4177,7 +4178,8 @@ createFunction (symbol * name, ast * body) ex = newAst_VALUE (symbolVal (name)); /* create name */ ex = newNode (FUNCTION, ex, body); ex->values.args = FUNC_ARGS(name->type); - + ex->decorated=1; + if (options.dump_tree) PA(ex); if (fatalError) { werror (E_FUNC_NO_CODE, name->name); @@ -4276,6 +4278,7 @@ void ast_print (ast * tree, FILE *outfile, int indent) } if (tree->opval.op == BLOCK) { symbol *decls = tree->values.sym; + INDENT(indent+4,outfile); fprintf(outfile,"{\n"); while (decls) { INDENT(indent+4,outfile); @@ -4286,6 +4289,7 @@ void ast_print (ast * tree, FILE *outfile, int indent) decls = decls->next; } ast_print(tree->right,outfile,indent+4); + INDENT(indent+4,outfile); fprintf(outfile,"}\n"); return; } @@ -4845,18 +4849,17 @@ void ast_print (ast * tree, FILE *outfile, int indent) /* ifx Statement */ /*----------------------------*/ case IFX: - ast_print(tree->left,outfile,indent); - INDENT(indent,outfile); fprintf(outfile,"IF (%p) \n",tree); + ast_print(tree->left,outfile,indent+4); if (tree->trueLabel) { INDENT(indent,outfile); - fprintf(outfile,"NE(==) 0 goto %s\n",tree->trueLabel->name); + fprintf(outfile,"NE(!=) 0 goto %s\n",tree->trueLabel->name); } if (tree->falseLabel) { INDENT(indent,outfile); fprintf(outfile,"EQ(==) 0 goto %s\n",tree->falseLabel->name); } - ast_print(tree->right,outfile,indent); + ast_print(tree->right,outfile,indent+4); return ; /*------------------------------------------------------------------*/ /*----------------------------*/ diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h index 3df24562..9e24a3e4 100644 --- a/src/SDCCglobl.h +++ b/src/SDCCglobl.h @@ -203,6 +203,7 @@ struct options int dump_range; /* dump after live range analysis */ int dump_pack; /* dump after register packing */ int dump_rassgn; /* dump after register assignment */ + int dump_tree; /* dump front-end tree before lowering to iCode */ int cc_only; /* compile only flag */ int intlong_rent; /* integer & long support routines reentrant */ int float_rent; /* floating point routines are reentrant */ diff --git a/src/SDCCmain.c b/src/SDCCmain.c index be35a877..63d3937b 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -171,6 +171,7 @@ optionsTable[] = { { 0, "--dumpliverange", &options.dump_range, NULL }, { 0, "--dumpregpack", &options.dump_pack, NULL }, { 0, "--dumpregassign", &options.dump_rassgn, NULL }, + { 0, "--dumptree", &options.dump_tree, NULL }, { 0, OPTION_DUMP_ALL, NULL, "Dump the internal structure at all stages" }, { 0, OPTION_XRAM_LOC, NULL, " External Ram start location" }, { 0, OPTION_IRAM_SIZE, NULL, " Internal Ram size" },