public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <richard.guenther@gmail.com>
To: Xinliang David Li <davidxl@google.com>
Cc: Bernd Schmidt <bernds@codesourcery.com>,
		Gabriel Dos Reis <gdr@integrable-solutions.net>,
	David Edelsohn <dje.gcc@gmail.com>,
		Diego Novillo <dnovillo@google.com>, gcc <gcc@gcc.gnu.org>
Subject: Re: Switching to C++ by default in 4.8
Date: Tue, 10 Apr 2012 11:14:00 -0000	[thread overview]
Message-ID: <CAFiYyc0utRXo2Jcy+LZ+dC8yccU62L6DWLwJ3USD04MC3f9A_Q@mail.gmail.com> (raw)
In-Reply-To: <CAAkRFZ+4RfHszKh50DW1wKSis0wo3516Hy8626FNpYwgGWdABQ@mail.gmail.com>

On Tue, Apr 10, 2012 at 1:34 AM, Xinliang David Li <davidxl@google.com> wrote:
> On Wed, Apr 4, 2012 at 5:04 AM, Richard Guenther
> <richard.guenther@gmail.com> wrote:
>> On Wed, Apr 4, 2012 at 1:50 PM, Bernd Schmidt <bernds@codesourcery.com> wrote:
>>> On 04/04/2012 11:06 AM, Richard Guenther wrote:
>>>> So - I'll veto the switch unless I see 1) and 2).  1) and 2) can be combined
>>>> by transitioning vec.h to a C++ template class, with proper GC support.
>>>> (not sure that I can veto anything - heh)
>>>
>>> I don't think I can veto anything, but I'll go on the record again
>>> saying that I don't think this entire plan is a good idea. Write a new
>>> project in C++? Absolutely. Convert a large existing one to a different
>>> language? A huge waste of time that will distract us for years from
>>> actual user-visible changes.
>>
>> I agree for the idea of converting all of GCC to C++ (whatever that means).
>> I disagree for the part making the internal infrastructure easier to use,
>> understand and maintain.  Which means targeting mostly isolated sub-systems,
>> like vec.h (and other various containers), double-int.[ch] (and other various
>> way of representing and working with constants).  Making tree or gimple a
>> C++ class with inheritance and whatever is indeed a huge waste of time
>> and existing developer ressources (that, if only because they have to adapt
>> and maintain two completely different code-bases over some time).
>>
>> I expect the GCC core to maintain written in C, compiled by C++.
>
>
> GCC's current C programming APIs (both browsing APIs and
> creator/factory APIs) are somewhat primitive and too low level. I
> expect switching to C++ can significantly make GCC more modern
> looking. It can greatly improve readability and productivity (for
> simplifying transformation and instrumentation development). C++
> features should not be be abused (e.g., MI, VI etc), but we should not
> miss on basic C++ features.
>
> Class hierarchy is one such feature that is useful. Assuming we have
> two hierarchies for gcc: one for values rooted at ValExp, and one for
> gimple stmts rooted at GimpInst.
>
> 1) For IR browsing,
>   *) all the macro accessors can be eliminated -- a big plus for debugging;
>   *) gcc implementation has lots of hard coded TREE_OPERAND (exp, nn)
>
>     e.g.
>            exp->as_component_ref().get_field() ..
>            exp->as_mem_access().get_base() ...
>            exp->as_mem_acesss().get_address() --> produces the
> address expression for memory access
>            exp->as_mem_access().get_alias_handle ()
>
>            gimple_inst->serialize (&fixup_list) --> a virtual
> function overriden by actual instruction types that knows its byte
> code format.
>
> For experienced GCC developers, current APIs won't a problem at all --
> but it does become a big minus for newbies and in the long run will
> hurt gcc community.
>
> 2) IR manipulation APIs -- the problem seems more serious. It seems
> GCC prefers low level APIs so that incremental update of derived data
> (control flow, SSA) can be easier -- but that does not have to be the
> case -- high level APIs can hide most of the update from the
> programmer.
>
>  Example:   Create a a simple assignment instruction from a load (this
> example comes from Asan implementation in gcc by Kostya)
>
>  t = build1 (INDIRECT_REF, some_type,
>               build1 (VIEW_CONVERT_EXPR, some_type, addr));
>   t = force_gimple_operand (t, &stmts, false, NULL_TREE);
>   gimple_seq_add_seq (&seq, stmts);
>   the_value = make_rename_temp (shadow_type, "__var_name");
>   g = gimple_build_assign (the_value, t);
>  nm = make_ssa_name (the_value, g);
>  gimple_assign_set_lhs (g, nm);
>
>
> This can be as simple as (by hiding the gimplification, ssa name creation etc)
>
>   new_assign_insn = gimple::new_load_insn (INDIRECT_REF, some_type, addr_exp);
>   new_assign_insn->get_lhs()->as_ssa_name()->get_val_decl()->setname("...");
>
> The creator interface can also take a form that accepts the addr_insn
> that produces the address.
>
> Another example:
>
> Instrument a BB1 so that it is guarded:
>
> if (counts > sampling_rate) // BB0
>  {
>      counts = 0;
>      ORIGINAL BB1 code
>  } // BB2
>
>
> It can be as simple as the following:
>
> basic_block bb0, bb1;
>
> gimple_br_inst = gimple::new_cond_br (value:new_cmp_exp (....),
>                                                                  bb1,
> /* taken branch* /
>
> &bb2, /* fall through */
>
> &bb2, /* merge point */
>
> &bb0 /* New predecessor */);
> reset_count = gimple:new_store_insn (..., bb1, insert_before);
>
>
> If the current APIs are used to do the coding, it will take how X
> times more API calls which is non-readable for human beings.

The above is non-readable to me neither.  That we miss a helper
to do the split-the-cfg-here-with-a-conditional-branch-and-bbs-for-true-false
does not mean that such helper has to use whatever fancy C++ interface.
What's wrong with a C helper for the above?  Why is it easier in C++ at all?

And you want to contribute the 10+ man years to consistently(!) transition
GCC to such API?

Sorry, but you cannot magically transform GCC to something more modern.
Thus it will be isolated "leaf" modules that will see conversion.  I don't hold
my breath for even converting the gimple bits, not to even think about trees
(or RTL).

Sorry.

Richard.

>
> thanks,
>
> David
>
>>
>>> I also find debugging C++ in gdb somewhat more annoying than debugging
>>> plain C, and at the moment I always go back to a stage1 compiler.
>>
>> Indeed - I'd be worried if my debugging efficiency decreases by more than 5%.
>>
>> Richard.

  parent reply	other threads:[~2012-04-10 11:14 UTC|newest]

Thread overview: 182+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-03 17:38 Diego Novillo
2012-04-03 19:39 ` Paweł Sikora
2012-04-03 20:52   ` Ian Lance Taylor
2012-04-03 21:34     ` Paweł Sikora
2012-04-20 20:14       ` Joseph S. Myers
2012-04-04  5:19     ` Basile Starynkevitch
2012-04-04  1:13 ` David Edelsohn
2012-04-04  4:00   ` Ian Lance Taylor
2012-04-04  4:42     ` Miles Bader
2012-04-04  8:32   ` Gabriel Dos Reis
2012-04-04  9:06     ` Richard Guenther
2012-04-04  9:10       ` Gabriel Dos Reis
2012-04-04  9:15       ` Gabriel Dos Reis
2012-04-04  9:59         ` Richard Guenther
2012-04-04 10:02           ` Richard Guenther
2012-04-04 11:20       ` Diego Novillo
2012-04-04 11:38         ` Richard Guenther
2012-04-04 14:12           ` Tom Tromey
2012-04-04 14:45             ` Richard Guenther
2012-04-04 14:48               ` Richard Guenther
2012-04-14  1:35           ` Chiheng Xu
2012-04-14  9:09             ` Robert Dewar
2012-04-14 10:03               ` Chiheng Xu
2012-04-14 11:13                 ` Robert Dewar
2012-04-14 11:41                 ` Jonathan Wakely
2012-04-14 10:39               ` Gabriel Dos Reis
2012-04-14 11:08                 ` Robert Dewar
2012-04-16  9:37                   ` Chiheng Xu
2012-04-16  9:38                     ` Jonathan Wakely
2012-04-17  9:11                     ` Robert Dewar
2012-04-05 12:40         ` Pedro Lamarão
2012-04-05 13:05           ` Richard Guenther
2012-04-05 14:21             ` Diego Novillo
2012-04-05 14:24               ` Richard Guenther
2012-04-05 14:36                 ` Diego Novillo
2012-04-05 20:17                   ` David Edelsohn
2012-04-05 20:36                     ` Gabriel Dos Reis
2012-04-06  0:11                       ` David Edelsohn
2012-04-09 10:37                         ` Richard Guenther
2012-04-09 15:07                           ` David Edelsohn
2012-04-10 22:04               ` Pedro Lamarão
2012-04-10 22:56                 ` Diego Novillo
2012-04-04 11:53       ` Bernd Schmidt
2012-04-04 12:04         ` Richard Guenther
2012-04-04 14:59           ` Diego Novillo
2012-04-04 17:54           ` Lawrence Crowl
2012-04-05  9:18             ` Richard Guenther
2012-04-05 20:07               ` Lawrence Crowl
2012-04-09 10:40                 ` Richard Guenther
2012-04-09 17:56                   ` Lawrence Crowl
2012-04-09 18:22                     ` Jakub Jelinek
2012-04-09 18:52                       ` Lawrence Crowl
2012-04-09 18:54                         ` Jakub Jelinek
2012-04-09 21:15                           ` Lawrence Crowl
2012-04-10 11:09                         ` Richard Guenther
2012-04-11  1:36                           ` Lawrence Crowl
2012-04-11  6:55                             ` Jakub Jelinek
2012-04-13 23:26                               ` Dave Korn
2012-04-11  9:32                             ` Richard Guenther
2012-04-14  3:07                       ` Chiheng Xu
2012-04-14  3:04                   ` Chiheng Xu
2012-04-14 21:25                     ` Lawrence Crowl
2012-04-09 23:34           ` Xinliang David Li
2012-04-10  8:46             ` Jakub Jelinek
2012-04-10 12:26               ` Michael Matz
2012-04-10 15:51                 ` David Edelsohn
2012-04-10 16:05                   ` Gabriel Dos Reis
2012-04-10 16:13                     ` Diego Novillo
2012-04-11  9:17                       ` Richard Guenther
2012-04-11 16:35                         ` Xinliang David Li
2012-04-10 16:12                 ` Xinliang David Li
2012-04-10 16:24                   ` Michael Matz
2012-04-10 17:08                     ` Xinliang David Li
2012-04-10 17:29                     ` Torvald Riegel
2012-04-10 18:00                       ` Eric Botcazou
2012-04-10 19:56                         ` Torvald Riegel
2012-04-10 21:13                           ` Eric Botcazou
2012-04-10 21:29                             ` Torvald Riegel
2012-04-10 23:15                               ` Eric Botcazou
2012-04-11 20:57                                 ` Torvald Riegel
2012-04-11 21:15                                   ` Eric Botcazou
2012-04-11 21:43                                     ` Torvald Riegel
2012-04-13 23:33                                     ` Dave Korn
2012-04-11  9:24                       ` Richard Guenther
2012-04-11 12:58                         ` Torvald Riegel
2012-04-11 13:13                           ` Richard Guenther
2012-04-11 13:23                             ` Gabriel Dos Reis
2012-04-11 14:19                             ` Torvald Riegel
2012-04-11 17:24                             ` Xinliang David Li
2012-04-11 18:17                               ` Andrew Pinski
2012-04-11 20:02                                 ` Xinliang David Li
2012-04-12  5:08                                 ` Ian Lance Taylor
2012-04-12  6:12                                   ` Miles Bader
2012-04-12  6:22                                     ` James Dennett
2012-04-11 18:26                               ` Jonathan Wakely
2012-04-11 18:41                                 ` Pedro Alves
2012-04-11 20:00                                 ` Xinliang David Li
2012-04-11 20:05                                   ` Jonathan Wakely
2012-04-12  5:10                                     ` Ian Lance Taylor
     [not found]                           ` <12130397.ZsTVnyYbKR@pawels>
2012-04-11 13:14                             ` Richard Guenther
2012-04-11 13:24                           ` Bernd Schmidt
2012-04-11 17:31                             ` Xinliang David Li
2012-04-11 18:37                               ` Basile Starynkevitch
2012-04-11 18:52                                 ` Gabriel Dos Reis
2012-04-11 20:14                                 ` Xinliang David Li
2012-04-12 15:51                                 ` Ludovic Courtès
2012-04-13 23:45                             ` Dave Korn
2012-04-11 14:41                           ` Jonathan Wakely
2012-04-11 17:13                           ` Xinliang David Li
2012-04-11 19:30                           ` Tobias Burnus
2012-04-11 20:44                             ` Torvald Riegel
2012-04-13 23:48                             ` Dave Korn
2012-04-13 23:37                           ` Dave Korn
2012-04-10 17:48                     ` DJ Delorie
2012-04-10 19:21                     ` Dave Korn
2012-04-10 16:23               ` Xinliang David Li
2012-04-10 16:39                 ` Jakub Jelinek
2012-04-10 16:43                   ` Gabriel Dos Reis
2012-04-10 16:47                     ` Diego Novillo
2012-04-12 19:40                       ` Tom Tromey
2012-04-12 19:42                         ` Diego Novillo
2012-04-12 19:51                           ` Tom Tromey
2012-04-10 17:37                   ` Torvald Riegel
2012-04-10 21:39                     ` Miles Bader
2012-04-10 22:32                       ` Bernd Schmidt
2012-04-10 23:28                         ` Eric Botcazou
2012-04-10 23:35                           ` Gabriel Dos Reis
2012-04-11  7:49                             ` Eric Botcazou
2012-04-11  7:55                               ` Gabriel Dos Reis
2012-04-11  8:11                                 ` Eric Botcazou
2012-04-11 11:41                                   ` Jeff Law
2012-04-11  7:02                           ` Jakub Jelinek
2012-04-11  7:46                             ` Gabriel Dos Reis
2012-04-11  7:51                               ` Jakub Jelinek
2012-04-11 12:37                               ` Bernd Schmidt
2012-04-11 12:47                                 ` Richard Guenther
2012-04-11 17:10                                   ` Xinliang David Li
2012-04-11 13:20                                 ` Gabriel Dos Reis
2012-04-11 13:29                                   ` Jakub Jelinek
2012-04-11 13:44                                     ` Gabriel Dos Reis
2012-04-11 14:45                                     ` David Edelsohn
2012-04-11 17:41                                       ` Xinliang David Li
2012-04-11 17:08                                 ` Xinliang David Li
2012-04-11  8:07                             ` Eric Botcazou
2012-04-11  9:45                               ` Richard Guenther
2012-04-10 17:54                   ` Xinliang David Li
2012-04-11 12:44                     ` Marek Polacek
2012-04-11 16:49                       ` Xinliang David Li
2012-04-11  2:24                   ` Lawrence Crowl
2012-04-11  9:43                     ` Richard Guenther
2012-04-11 16:47                       ` Xinliang David Li
2012-04-11 20:48                       ` Paweł Sikora
2012-04-11 22:34                       ` Lawrence Crowl
2012-04-12  9:28                     ` Chiheng Xu
2012-04-12 10:30                       ` Richard Guenther
2012-04-14  1:15                         ` Chiheng Xu
2012-04-14  6:30                           ` Chiheng Xu
2012-04-14  9:08                           ` Robert Dewar
2012-04-14 10:38                             ` Chiheng Xu
2012-04-14 11:06                               ` Robert Dewar
2012-04-10 16:42               ` Paweł Sikora
2012-04-10 19:23                 ` Dave Korn
2012-04-10 20:39                   ` Andrew Pinski
2012-04-11  9:27                   ` Richard Guenther
2012-04-11  1:01               ` Lawrence Crowl
2012-04-14  3:40               ` Chiheng Xu
2012-04-14  3:48               ` Chiheng Xu
2012-04-15 20:11                 ` Chiheng Xu
2012-04-16  7:48                   ` Duncan Sands
2012-04-16  9:23                     ` Chiheng Xu
2012-04-16 18:53                   ` Oleg Endo
2012-04-17 22:03                     ` Chiheng Xu
2012-04-18  0:15                       ` Oleg Endo
2012-04-10 11:14             ` Richard Guenther [this message]
2012-04-10 16:33               ` Xinliang David Li
2012-04-14  2:41           ` Chiheng Xu
2012-04-04 11:22   ` Diego Novillo
2012-04-04  7:07 ` Tristan Gingold
2012-04-04 13:13   ` Ian Lance Taylor
2012-04-04 13:32     ` Tristan Gingold
2012-04-04 14:37       ` Gabriel Dos Reis
2012-04-04 14:52         ` Tristan Gingold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFiYyc0utRXo2Jcy+LZ+dC8yccU62L6DWLwJ3USD04MC3f9A_Q@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=bernds@codesourcery.com \
    --cc=davidxl@google.com \
    --cc=dje.gcc@gmail.com \
    --cc=dnovillo@google.com \
    --cc=gcc@gcc.gnu.org \
    --cc=gdr@integrable-solutions.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).