public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* addin new pass to gimple
@ 2009-07-23 12:54 anandulle
  2009-07-23 13:09 ` Diego Novillo
  0 siblings, 1 reply; 4+ messages in thread
From: anandulle @ 2009-07-23 12:54 UTC (permalink / raw)
  To: gcc-help


hi 

i am trying to add new pass to gimple , my task is to find out how many
Arithmetic operators are there in a given program.

1) i know that i have to create a struct tree_opt_pass  i have done that
also, 
2) i have added the following line s to tree-pass.h  
extern struct tree_opt_pass 
3) included next pass in passes.c 
4) i have got the function to print the assigiment statements but i have
doubts in that kindly help me 


the code is ------------------

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;
			default :
				break;	
		}    		
}

Now i want to know what is VAR_DECL and where can i search for that , if I
have to change my code to print Arithmetic statements what other than
VAR_DECL can I use kindly any body know abut gimple optimization help me in
this regard
-- 
View this message in context: http://www.nabble.com/addin-new-pass-to-gimple-tp24625142p24625142.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: addin new pass to gimple
  2009-07-23 12:54 addin new pass to gimple anandulle
@ 2009-07-23 13:09 ` Diego Novillo
  0 siblings, 0 replies; 4+ messages in thread
From: Diego Novillo @ 2009-07-23 13:09 UTC (permalink / raw)
  To: anandulle; +Cc: gcc-help

On Thu, Jul 23, 2009 at 08:54, anandulle<anandulle@gmail.com> wrote:

> 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;
>                        default :
>                                break;
>                }
> }
>
> Now i want to know what is VAR_DECL and where can i search for that , if I
> have to change my code to print Arithmetic statements what other than
> VAR_DECL can I use kindly any body know abut gimple optimization help me in
> this regard

You don't really need to parse the structure of the statement that
way.  The code to detect assignments looks correct.  To see what kind
of expression you have on the RHS, simply check TREE_CODE (rval)

If you just want to traverse the operands in the statement, you can
use FOR_EACH_SSA_TREE_OPERAND.  Something like:

ssa_op_iter i;
tree op;
tree stmt;
FOR_EACH_SSA_TREE_OPERAND (op, stmt, i, SSA_OP_USE)
   ....

'op' will be one of the operands at each iteration of the loop.
'stmt' is the statement you're looking at.  SSA_OP_USE is a filter
that states that you're only interested in real operands.  Look up the
documentation in the internals manual for more detail.

You're using a version earlier than 4.4, so I may be off in the
details.  But I don't think we changed the API for this too much
recently.


Diego.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* addin new pass to gimple
@ 2009-07-28 12:30 anandulle
  0 siblings, 0 replies; 4+ messages in thread
From: anandulle @ 2009-07-28 12:30 UTC (permalink / raw)
  To: gcc-help


hello 

              I am ameture and i want to learn gcc -gimple IR , gimple pass;
where do i get the information or if you could show me an example let say
counting the number of var declaration stmts in a given program it will be
helpful .

Help needed badly please help me
-- 
View this message in context: http://www.nabble.com/addin-new-pass-to-gimple-tp24698035p24698035.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* addin new pass to gimple
@ 2009-07-28 12:28 anandulle
  0 siblings, 0 replies; 4+ messages in thread
From: anandulle @ 2009-07-28 12:28 UTC (permalink / raw)
  To: gcc-help


hello 

              I am ameture and i want to learn gcc -gimple IR , gimple pass;
where do i get the information or if you could show me an example let say
counting the number of var declaration stmts in a given program it will be
helpful .

Help needed badly please help me
-- 
View this message in context: http://www.nabble.com/addin-new-pass-to-gimple-tp24698032p24698032.html
Sent from the gcc - Help mailing list archive at Nabble.com.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-07-28 12:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-23 12:54 addin new pass to gimple anandulle
2009-07-23 13:09 ` Diego Novillo
2009-07-28 12:28 anandulle
2009-07-28 12:30 anandulle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).