gimple pass

2009-07-24 Thread anandulle

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\nNumber of assignment statements::
%d\n\n",numassigns);   
  printf("\n\nTotal Number of assignment statements (including
temp vars):: %d\n\n",totalassigns);
  printf("\n\nNumber of INTEGER statements :: %d\n\n",intvar);


  if(flag_pass_gccwk09){
 fprintf(dump_file,"\n\nNumber of assignment statements::
%d\n\n",numassigns);
 fprintf(dump_file,"\n\nTotal 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.



gcc-help needed

2009-07-25 Thread anandulle

i have added my own pass and i am trying to find out the number of variable
declarations in a C program the code is attached for your reference 
http://www.nabble.com/file/p24656019/gccwk09.c gccwk09.c i am getting an
error like this whats wrong kindly help me 


mainD.1181 = 0;
return D.1181;


Number of assignment statements:: 0



Total Number of assignment statements (including temp vars):: 1



total no of increment count :: 0


/home/ulle/gcc/native/cprog/pg1.c: In function ‘main’:
/home/ulle/gcc/native/cprog/pg1.c:7: internal compiler error: Segmentation
fault

-- 
View this message in context: 
http://www.nabble.com/gcc-help-needed-tp24656019p24656019.html
Sent from the gcc - Dev mailing list archive at Nabble.com.



gcc code debug

2009-09-17 Thread anandulle

hello 

  I was traversing through the source code of GCC using GDB
and I understood some of the function the GCC toplev_main() calls but when i
came to one particular initialization  init_optimization_passes()  i was not
able to understand the statements

 if (pass->static_pass_number)
 pass->todo_flags_start |= TODO_mark_first_instance;
 *list = pass;
 pass->static_pass_number = -1;

I want to know what is the static_pass_number, what is the value inside it

thanking you


yours sincerely

Anand Raj S Ulle
Shivmurthy
-- 
View this message in context: 
http://www.nabble.com/gcc-code-debug-tp25491558p25491558.html
Sent from the gcc - Dev mailing list archive at Nabble.com.