How to check the type of gimple

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to check the type of gimple

gcc - Help mailing list
Hello,
I want to write a function in pass to check basic block is POINTER_TYPE or not.Here is my code:>unsigned int>find_pointer (function *fun)>{> basic_block bb;>  gimple_stmt_iterator gsi;
>  FOR_EACH_BB_FN(bb,cfun)>  {>    for (gsi = gsi_start_bb(bb); ! gsi_end_p(gsi); gsi_next(&gsi))>    {>      gimple *stmt = gsi_stmt (gsi);>      stmt = gsi_stmt (gsi);>     if (TREE_CODE(stmt)==POINTER_TYPE)>  >     fprintf(stderr, "find pointer\n");                    >    }>  }...
But it seems that using TREE_CODE with gimple is not correct.Can you give some advice?
Thank you
Reply | Threaded
Open this post in threaded view
|

Re: How to check the type of gimple

Prathamesh Kulkarni-2
On Wed, 24 Oct 2018 at 20:19, wang tom via gcc-help
<[hidden email]> wrote:
>
> Hello,
> I want to write a function in pass to check basic block is POINTER_TYPE or not.Here is my code:>unsigned int>find_pointer (function *fun)>{> basic_block bb;>  gimple_stmt_iterator gsi;
> >  FOR_EACH_BB_FN(bb,cfun)>  {>    for (gsi = gsi_start_bb(bb); ! gsi_end_p(gsi); gsi_next(&gsi))>    {>      gimple *stmt = gsi_stmt (gsi);>      stmt = gsi_stmt (gsi);>     if (TREE_CODE(stmt)==POINTER_TYPE)>  >     fprintf(stderr, "find pointer\n");                    >    }>  }...
> But it seems that using TREE_CODE with gimple is not correct.Can you give some advice?
You might want to check type of stmt's result.
stmt = gsi_stmt (gsi);
lhs = gimple_get_lhs (stmt);
if (lhs && POINTER_TYPE_P (TREE_TYPE (lhs)))
  fprintf (stderr, "pointer found");

Regards,
Prathamesh
> Thank you