Re: addin new pass to gimple

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 23, 2009 at 08:54, anandulle<anandulle@xxxxxxxxx> 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 thatway.  The code to detect assignments looks correct.  To see what kindof expression you have on the RHS, simply check TREE_CODE (rval)
If you just want to traverse the operands in the statement, you canuse 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 filterthat states that you're only interested in real operands.  Look up thedocumentation in the internals manual for more detail.
You're using a version earlier than 4.4, so I may be off in thedetails.  But I don't think we changed the API for this too muchrecently.

Diego.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux