Hello We want to know what are TREE_CODES and TREE_TYPES;we were trying to do the assignment in gimple pass, we got a code which checks the number of assignment statements but now we want to check the deceleration statements we browsed through the tree.def , tree.h and tree.c files and came to know about the TREE_CODES, what we have understood is that the TREE_CODE(stmt) is a function and it takes the current statements from the c program and tries to find out the lval and rval, now if TREE_CODE of lval== VAR_DECL then incr the assignments statements. We understood this code but how to check the other constructs like (arithmetic expression), logical expre, etc i have attached the code for your reference, can we add a new case statements like this, sir kindly tell us what wrong we have done we are not able to get the count
#include "config.h" #include "system.h" #include "coretypes.h" #include "tm.h" #include "tree.h" #include "rtl.h" #include "tm_p.h" #include "hard-reg-set.h" #include "basic-block.h" #include "output.h" #include "flags.h" #include "function.h" #include "expr.h" #include "ggc.h" #include "langhooks.h" #include "diagnostic.h" #include "tree-flow.h" #include "timevar.h" #include "tree-dump.h" #include "tree-pass.h" #include "toplev.h" #include "except.h" #include "cfgloop.h" #include "cfglayout.h" #include "tree-ssa-propagate.h" #include "value-prof.h" #include "pointer-set.h" #include "tree-inline.h" /* global declarations */ extern FILE * dump_file; int numassigns,totalassigns,intvar; void initialize_stats(void) { numassigns=0; totalassigns=0; intvar=0; } void printstatistics(void) { printf("\n\n************Number of assignment statements:: %d\n\n",numassigns); printf("\n\n************Total Number of assignment statements (including temp vars):: %d\n\n",totalassigns); printf("\n\n************Number of INTEGER statements :: %d\n\n",intvar); if(flag_pass_gccwk09){ fprintf(dump_file,"\n\n************Number of assignment statements:: %d\n\n",numassigns); fprintf(dump_file,"\n\n************Total Number of assignment statements (including temp vars):: %d\n\n",totalassigns); } } void process_statement(tree stmt) { tree lval,rval; switch (TREE_CODE(stmt)){ case GIMPLE_MODIFY_STMT: lval=GIMPLE_STMT_OPERAND(stmt,0); rval=GIMPLE_STMT_OPERAND(stmt,1); if(TREE_CODE(lval) == VAR_DECL) { if(!DECL_ARTIFICIAL(lval)){ //print_generic_stmt(stderr,stmt,0); numassigns++; } totalassigns++; } break; case DECL: if(TREE_CODE(TREE_TYPE(stmt)) == INTEGER_TYPE) { intvar++; } default : break; } } /* Note the return type of the below function */ static unsigned int gccwk09_main(void) { basic_block bb; block_stmt_iterator si; initialize_stats(); FOR_EACH_BB (bb) { for (si=bsi_start(bb); !bsi_end_p(si) ; bsi_next(&si) ) { tree stmt = bsi_stmt(si); print_generic_stmt(stderr,stmt,0); process_statement(stmt); } } printstatistics(); return 0; } struct tree_opt_pass pass_gccwk09 = { "gccwk09", NULL, gccwk09_main, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0 }; waiting for your reply thanking you Anand Raj S Ulle , Shivmurthy PM -- View this message in context: http://www.nabble.com/gimple-pass-tp24648076p24648076.html Sent from the gcc - Dev mailing list archive at Nabble.com.