public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Where can I get the output of the front-end.
@ 2003-04-03 17:36 Matthieu Moy
  2003-04-03 18:01 ` Steven Bosscher
  2003-04-03 18:50 ` Pop Sébastian
  0 siblings, 2 replies; 5+ messages in thread
From: Matthieu Moy @ 2003-04-03 17:36 UTC (permalink / raw)
  To: gcc

Hi,

I'm  still trying  to re-use  the  front-end of  GCC to  do some  code
analysis. (I'm using the tree-ssa branch)

I begin  to understand how the  data structures are made,  but I don't
understand *where*, in the programm, they are generated. 

What I would like to do is

C++ source -----> SSA tree ---(standard way)----> RTL
                             \
                              `---(my add-on)---> ...

So, I thought of  hacking the ssa -> rtl code, but  I can't find which
function is doing so in gcc ! 

Any help appreciated, thanks,

-- 
Matthieu

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

* Re: Where can I get the output of the front-end.
  2003-04-03 17:36 Where can I get the output of the front-end Matthieu Moy
@ 2003-04-03 18:01 ` Steven Bosscher
  2003-04-04 18:12   ` Matthieu Moy
  2003-04-03 18:50 ` Pop Sébastian
  1 sibling, 1 reply; 5+ messages in thread
From: Steven Bosscher @ 2003-04-03 18:01 UTC (permalink / raw)
  To: Matthieu Moy; +Cc: gcc

Op do 03-04-2003, om 18:09 schreef Matthieu Moy:
> Hi,
> 
> I'm  still trying  to re-use  the  front-end of  GCC to  do some  code
> analysis. (I'm using the tree-ssa branch)
> 
> I begin  to understand how the  data structures are made,  but I don't
> understand *where*, in the programm, they are generated. 
> 
> What I would like to do is
> 
> C++ source -----> SSA tree ---(standard way)----> RTL
>                              \
>                               `---(my add-on)---> ...
> 
> So, I thought of  hacking the ssa -> rtl code, but  I can't find which
> function is doing so in gcc ! 
> 
> Any help appreciated, thanks,

Look at tree-optimize.c, or if you want to hook in after the SSA
optimizers are done, grep for TV_EXPAND in c-decl.c.

Greetz
Steven


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

* Re: Where can I get the output of the front-end.
  2003-04-03 17:36 Where can I get the output of the front-end Matthieu Moy
  2003-04-03 18:01 ` Steven Bosscher
@ 2003-04-03 18:50 ` Pop Sébastian
  1 sibling, 0 replies; 5+ messages in thread
From: Pop Sébastian @ 2003-04-03 18:50 UTC (permalink / raw)
  To: gcc

On Thu, Apr 03, 2003 at 06:09:35PM +0200, Matthieu Moy wrote:
> What I would like to do is
> 
> C++ source -----> SSA tree ---(standard way)----> RTL
>                              \
>                               `---(my add-on)---> ...
> 
> So, I thought of  hacking the ssa -> rtl code, but  I can't find which
> function is doing so in gcc ! 
> 

The rtl is generated by the "emit_*" functions from expr.c
and "genrtl_*" functions from stmt.c

http://gcc.gnu.org/ml/gcc/2002-09/msg01051.html

But I think that what you're looking for is tree-optimize.c where 
you have the tree in the SSA representation: 


  /* Build the flowgraph.  */
  init_flow ();
  build_tree_cfg (fnbody);

  /* Begin analysis and optimization passes.  */
  if (n_basic_blocks > 0 && ! (errorcount || sorrycount))
    {
      /* Rewrite the function into SSA form.  */
      rewrite_into_ssa (fndecl);
      
      if (flag_tree_pre)
	tree_perform_ssapre (fndecl);

      if (flag_tree_ccp)
	tree_ssa_ccp (fndecl);
      
      if (flag_tree_copyprop)
	tree_ssa_copyprop (fndecl);

      if (flag_tree_dce)
	tree_ssa_dce (fndecl);
    }

  if (n_basic_blocks > 0 && ! (errorcount || sorrycount))
    {
      /* Rewrite the function out of SSA form.  */
      rewrite_out_of_ssa (fndecl);
    }


This code is reachable if you compile with -O2.

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

* Re: Where can I get the output of the front-end.
  2003-04-03 18:01 ` Steven Bosscher
@ 2003-04-04 18:12   ` Matthieu Moy
  2003-04-04 19:07     ` Pop Sébastian
  0 siblings, 1 reply; 5+ messages in thread
From: Matthieu Moy @ 2003-04-04 18:12 UTC (permalink / raw)
  To: Steven Bosscher; +Cc: gcc

Steven Bosscher <s.bosscher@student.tudelft.nl> writes:

> Op do 03-04-2003, om 18:09 schreef Matthieu Moy:
>> Hi,
>> 
>> I'm  still trying  to re-use  the  front-end of  GCC to  do some  code
>> analysis. (I'm using the tree-ssa branch)

[...]

> Look at  tree-optimize.c, or if  you want to  hook in after  the SSA

OK, I could do it. 

I still have 2 questions :

* I  plugged myself  just  after  the ssa  optimizations  by adding  a
  function  call.  What  I  don't  manage  to  do  is  to  remove  the
  backend ... (My modified code still generates RTL and assembler)

* I can see the functions one by one, but is there a moment during the
  compilation  at which we  can see  the whole  program in  one single
  tree ? (A kind of list of functions and declarations)

Thanks,

-- 
Matthieu

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

* Re: Where can I get the output of the front-end.
  2003-04-04 18:12   ` Matthieu Moy
@ 2003-04-04 19:07     ` Pop Sébastian
  0 siblings, 0 replies; 5+ messages in thread
From: Pop Sébastian @ 2003-04-04 19:07 UTC (permalink / raw)
  To: Steven Bosscher, gcc, Matthieu.Moy

> * I can see the functions one by one, but is there a moment during the
>   compilation  at which we  can see  the whole  program in  one single
>   tree ? (A kind of list of functions and declarations)
> 

From cgraphunit.c:

/* Analyze the whole compilation unit once it is parsed completely.  */

void
cgraph_finalize_compilation_unit ()


>  
> * I  plugged myself  just  after  the ssa  optimizations  by adding  a 
>   function  call.  What  I  don't  manage  to  do  is  to  remove  the 
>   backend ... (My modified code still generates RTL and assembler) 
>  

Define a global variable, say "rest_of_compilation_needed", that will
control the access to the back_end:

Index: c-decl.c
===================================================================
RCS file: /home/pop/cvsroot/gcc-cvs/gcc/gcc/c-decl.c,v
retrieving revision 1.334.2.41
diff -u -3 -p -c -r1.334.2.41 c-decl.c
*** c-decl.c	13 Mar 2003 22:24:24 -0000	1.334.2.41
--- c-decl.c	4 Apr 2003 18:50:04 -0000
*************** c_expand_body_1 (fndecl, nested_p)
*** 6630,6637 ****
    input_filename = saved_input_filename;
    lineno = saved_lineno;
  
!   /* Run the optimizers and output the assembler code for this function.  */
!   rest_of_compilation (fndecl);
  
    /* Undo the GC context switch.  */
    if (nested_p)
--- 6630,6638 ----
    input_filename = saved_input_filename;
    lineno = saved_lineno;
  
!   if (rest_of_compilation_needed)
!     /* Run the optimizers and output the assembler code for this function.  */
!     rest_of_compilation (fndecl);
  
    /* Undo the GC context switch.  */
    if (nested_p)

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

end of thread, other threads:[~2003-04-04 18:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-03 17:36 Where can I get the output of the front-end Matthieu Moy
2003-04-03 18:01 ` Steven Bosscher
2003-04-04 18:12   ` Matthieu Moy
2003-04-04 19:07     ` Pop Sébastian
2003-04-03 18:50 ` Pop Sébastian

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).