Re: Use conditional casting with symtab_node

2012-10-14 Thread Diego Novillo
On Fri, Oct 12, 2012 at 4:22 AM, Richard Biener wrote: > I also think that instead of > >>> if (cgraph_node *q = p->cast_to ()) > > we want > > if ((q = cast_to (p)) > > I see absolutely no good reason to make cast_to a member, given > that the language has static_cast, const_cast and stuff

Re: Use conditional casting with symtab_node

2012-10-13 Thread Gabriel Dos Reis
On Sat, Oct 13, 2012 at 12:44 PM, Lawrence Crowl wrote: >> Thus, please re-use or follow existing concepts. > > Both are existing concepts. What I proposed is a common technique > for avoiding the cost of dynamic_cast when down casting in a class > hierarchy. Both concepts will work. I propose

Re: Use conditional casting with symtab_node

2012-10-13 Thread Lawrence Crowl
On 10/12/12, Richard Biener wrote: > On Oct 11, 2012 Xinliang David Li wrote: >> On Oct 11, 2012 Lawrence Crowl wrote: >>> On 10/10/12, Xinliang David Li wrote: In a different thread, I proposed the following alternative to 'try_xxx': template T* symbol::cast_to(symbol* p) {

Re: Use conditional casting with symtab_node

2012-10-12 Thread Xinliang David Li
On Fri, Oct 12, 2012 at 1:22 AM, Richard Biener wrote: > On Thu, Oct 11, 2012 at 10:39 PM, Xinliang David Li > wrote: >> On Thu, Oct 11, 2012 at 1:23 PM, Lawrence Crowl wrote: >>> On 10/10/12, Xinliang David Li wrote: In a different thread, I proposed the following alternative to 'try_xxx

Re: Use conditional casting with symtab_node

2012-10-12 Thread Richard Biener
On Thu, Oct 11, 2012 at 10:39 PM, Xinliang David Li wrote: > On Thu, Oct 11, 2012 at 1:23 PM, Lawrence Crowl wrote: >> On 10/10/12, Xinliang David Li wrote: >>> In a different thread, I proposed the following alternative to 'try_xxx': >>> >>> template T* symbol::cast_to(symbol* p) { >>>if (p

Re: Use conditional casting with symtab_node

2012-10-11 Thread Xinliang David Li
On Thu, Oct 11, 2012 at 1:23 PM, Lawrence Crowl wrote: > On 10/10/12, Xinliang David Li wrote: >> In a different thread, I proposed the following alternative to 'try_xxx': >> >> template T* symbol::cast_to(symbol* p) { >>if (p->is()) >> return static_cast(p); >>return 0; >> } >> >>

Re: Use conditional casting with symtab_node

2012-10-11 Thread Lawrence Crowl
On 10/10/12, Xinliang David Li wrote: > In a different thread, I proposed the following alternative to 'try_xxx': > > template T* symbol::cast_to(symbol* p) { >if (p->is()) > return static_cast(p); >return 0; > } > > cast: > > template T& symbol:as(symbol* p) { >assert(p->is())

Re: Use conditional casting with symtab_node

2012-10-11 Thread Richard Biener
On Thu, Oct 11, 2012 at 7:31 AM, Xinliang David Li wrote: > On Fri, Oct 5, 2012 at 1:49 AM, Richard Guenther > wrote: >> On Thu, Oct 4, 2012 at 8:16 PM, Diego Novillo wrote: >>> On Thu, Oct 4, 2012 at 2:14 PM, Lawrence Crowl wrote: >>> So, Jan Hubicka requested and approved the current spe

Re: Use conditional casting with symtab_node

2012-10-10 Thread Xinliang David Li
On Fri, Oct 5, 2012 at 1:49 AM, Richard Guenther wrote: > On Thu, Oct 4, 2012 at 8:16 PM, Diego Novillo wrote: >> On Thu, Oct 4, 2012 at 2:14 PM, Lawrence Crowl wrote: >> >>> So, Jan Hubicka requested and approved the current spelling. >>> What now? >> >> I don't think we should hold this up. T

Re: Use conditional casting with symtab_node

2012-10-10 Thread Xinliang David Li
On Wed, Sep 19, 2012 at 11:39 AM, Lawrence Crowl wrote: > On 9/19/12, Gabriel Dos Reis wrote: >> On Sep 19, 2012 Richard Guenther wrote: >> > Indeed. Btw, can we not provide a specialization for >> > dynamic_cast <>? This ->try_... looks awkward to me compared >> > to the more familiar >> > >>

Re: Use conditional casting with symtab_node

2012-10-10 Thread Xinliang David Li
In a different thread, I proposed the following alternative to 'try_xxx': template T* symbol::cast_to(symbol* p) { if (p->is()) return static_cast(p); return 0; } cast: template T& symbol:as(symbol* p) { assert(p->is()) return static_cast(*p); } David On Wed, Sep 19, 2012

Re: Use conditional casting with symtab_node

2012-10-10 Thread Diego Novillo
On Tue, Oct 9, 2012 at 8:03 PM, Lawrence Crowl wrote: > I would like some clarity. Can I commit this patch? I'm thinking, yes. I will be making the gengtype changes in time for stage 1, so further renames can continue after those patches are in. Jan, Richard? Any strong objections? Diego.

Re: Use conditional casting with symtab_node

2012-10-09 Thread Lawrence Crowl
On 10/5/12, Jan Hubicka wrote: >> On Thu, Oct 4, 2012 at 8:16 PM, Diego Novillo wrote: >> > On Thu, Oct 4, 2012 at 2:14 PM, Lawrence Crowl wrote: >> > >> >> So, Jan Hubicka requested and approved the current spelling. >> >> What now? >> > >> > I don't think we should hold this up. The names Jan

Re: Use conditional casting with symtab_node

2012-10-05 Thread Steven Bosscher
On Fri, Oct 5, 2012 at 11:50 PM, Lawrence Crowl wrote: > If no one cares about these time reports, then I will gladly stop > spending the effort to make them. It's not that no-one cases, I think, but the mathematics don't have to be so complicated. Just showing or saying there's no significant co

Re: Use conditional casting with symtab_node

2012-10-05 Thread Lawrence Crowl
On 10/5/12, Diego Novillo wrote: > On Oct 5, 2012 Richard Guenther wrote: > > Sorry, that wasn't intended. I question these numbers because > > unless you bootstrap say 100 times the noise in bootstrap > > speed is way too high to make such claims. Of course critical > > information is missing:

Re: Use conditional casting with symtab_node

2012-10-05 Thread Steven Bosscher
On Fri, Oct 5, 2012 at 2:43 PM, Diego Novillo wrote: > Because (...) there has been so much > negative pressure on our work, that we sometimes try to find some > benefit when reality may provide neutral results. When people say "your work sucks", they probably don't mean to apply negative pressure

Re: Use conditional casting with symtab_node

2012-10-05 Thread Steven Bosscher
On Fri, Oct 5, 2012 at 2:43 PM, Diego Novillo wrote: > Because (...) there has been so much > negative pressure on our work, that we sometimes try to find some > benefit when reality may provide neutral results. When people say "your work sucks", they probably don't mean to apply negative pressure

Re: Use conditional casting with symtab_node

2012-10-05 Thread Diego Novillo
On Fri, Oct 5, 2012 at 7:05 AM, Richard Guenther wrote: > Sorry, that wasn't intended. I question these numbers because > unless you bootstrap say 100 times the noise in bootstrap speed > is way too high to make such claims. Of course critical information > is missing: I agree with Nathan. Yo

Re: Use conditional casting with symtab_node

2012-10-05 Thread Richard Guenther
On Fri, Oct 5, 2012 at 12:50 PM, Nathan Froyd wrote: > - Original Message - >> I see all these patches with mixed feeling - it puts breaks on all >> developers >> because they need to learn the new interface which does not bring any >> immediate benefit. So I think _your_ development time

Re: Use conditional casting with symtab_node

2012-10-05 Thread Nathan Froyd
- Original Message - > I see all these patches with mixed feeling - it puts breaks on all > developers > because they need to learn the new interface which does not bring any > immediate benefit. So I think _your_ development time would be > better > spent by fixing open bugs or by tacklin

Re: Use conditional casting with symtab_node

2012-10-05 Thread Jan Hubicka
> On Thu, Oct 4, 2012 at 8:16 PM, Diego Novillo wrote: > > On Thu, Oct 4, 2012 at 2:14 PM, Lawrence Crowl wrote: > > > >> So, Jan Hubicka requested and approved the current spelling. > >> What now? > > > > I don't think we should hold this up. The names Jan requested seem > > reasonable enough.

Re: Use conditional casting with symtab_node

2012-10-05 Thread Richard Guenther
On Thu, Oct 4, 2012 at 8:16 PM, Diego Novillo wrote: > On Thu, Oct 4, 2012 at 2:14 PM, Lawrence Crowl wrote: > >> So, Jan Hubicka requested and approved the current spelling. >> What now? > > I don't think we should hold this up. The names Jan requested seem > reasonable enough. We seem to be r

Re: Use conditional casting with symtab_node

2012-10-04 Thread Diego Novillo
On Thu, Oct 4, 2012 at 2:14 PM, Lawrence Crowl wrote: > So, Jan Hubicka requested and approved the current spelling. > What now? I don't think we should hold this up. The names Jan requested seem reasonable enough. We seem to be running in circles here. Diego.

Re: Use conditional casting with symtab_node

2012-10-02 Thread Lawrence Crowl
Updated Patch Add functions symtab_node_def::try_function and symtab_node_def::try_variable. These function return a pointer to the more specific type (e.g. cgraph_node*) if and only if the general type (symtab_node aka symtab_node_def*) is an instance of the specific type. These functions are es

Re: Use conditional casting with symtab_node

2012-09-21 Thread Lawrence Crowl
Add functions symtab_node_def::try_function and symtab_node_def::try_variable. These function return a pointer to the more specific type (e.g. cgraph_node*) if and only if the general type (symtab_node aka symtab_node_def*) is an instance of the specific type. These functions are essentially check

Re: Use conditional casting with symtab_node

2012-09-20 Thread Lawrence Crowl
On 9/20/12, Gabriel Dos Reis wrote: > On Sep 20, 2012 Lawrence Crowl wrote: > > > > Why do you think cascading ifs is a bad idea? > > > > > > Precedent. Confusion in case of dangling else (requiring > > > more {}, and hence even more indentation). Ugly. > > > > I generally take ugly as an indic

Re: Use conditional casting with symtab_node

2012-09-20 Thread Gabriel Dos Reis
On Thu, Sep 20, 2012 at 1:53 PM, Lawrence Crowl wrote: >> > Why do you think cascading ifs is a bad idea? >> >> Precedent. Confusion in case of dangling else (requiring more {}, >> and hence even more indentation). Ugly. > > I generally take ugly as an indication that the function needs > refac

Re: Use conditional casting with symtab_node

2012-09-20 Thread Lawrence Crowl
On 9/20/12, Michael Matz wrote: > On Wed, 19 Sep 2012, Lawrence Crowl wrote: > > On 9/19/12, Eric Botcazou wrote: > > > > The language syntax would bind the conditional into the > > > > intializer, as in > > > > > > > > if (varpool_node *vnode = (node->try_variable () > > > >

Re: Use conditional casting with symtab_node

2012-09-20 Thread Michael Matz
Hi, On Wed, 19 Sep 2012, Lawrence Crowl wrote: > On 9/19/12, Eric Botcazou wrote: > > > The language syntax would bind the conditional into the > > > intializer, as in > > > > > > if (varpool_node *vnode = (node->try_variable () > > > && vnode->finalized)) > > >

Re: Use conditional casting with symtab_node

2012-09-20 Thread Michael Matz
Hi, On Wed, 19 Sep 2012, Richard Guenther wrote: > > Just write: > > > > varpool_node *vnode; > > > > if ((vnode = node->try_variable ()) && vnode->finalized) > > varpool_analyze_node (vnode); > > > > This has been the standard style for the past 2 decades and trading it for > > cascading

Re: Use conditional casting with symtab_node

2012-09-19 Thread Lawrence Crowl
On 9/19/12, Gabriel Dos Reis wrote: > On Wed, Sep 19, 2012 at 1:39 PM, Lawrence Crowl wrote: >> On 9/19/12, Gabriel Dos Reis wrote: >>> On Sep 19, 2012 Richard Guenther wrote: >>> > Indeed. Btw, can we not provide a specialization for >>> > dynamic_cast <>? This ->try_... looks awkward to me

Re: Use conditional casting with symtab_node

2012-09-19 Thread Gabriel Dos Reis
On Wed, Sep 19, 2012 at 1:39 PM, Lawrence Crowl wrote: > On 9/19/12, Gabriel Dos Reis wrote: >> On Sep 19, 2012 Richard Guenther wrote: >> > Indeed. Btw, can we not provide a specialization for >> > dynamic_cast <>? This ->try_... looks awkward to me compared >> > to the more familiar >> > >>

Re: Use conditional casting with symtab_node

2012-09-19 Thread Lawrence Crowl
On 9/19/12, Gabriel Dos Reis wrote: > On Sep 19, 2012 Richard Guenther wrote: > > Indeed. Btw, can we not provide a specialization for > > dynamic_cast <>? This ->try_... looks awkward to me compared > > to the more familiar > > > > vnode = dynamic_cast (node) > > > > but yeah - dynamic_cast i

Re: Use conditional casting with symtab_node

2012-09-19 Thread Lawrence Crowl
On 9/19/12, Eric Botcazou wrote: > > The language syntax would bind the conditional into the > > intializer, as in > > > > if (varpool_node *vnode = (node->try_variable () > > && vnode->finalized)) > > varpool_analyze_node (vnode); > > > > which does not type-mat

Re: Use conditional casting with symtab_node

2012-09-19 Thread Gabriel Dos Reis
On Wed, Sep 19, 2012 at 4:17 AM, Richard Guenther wrote: > On Wed, Sep 19, 2012 at 9:29 AM, Eric Botcazou wrote: >>> >>> The language syntax would bind the conditional into the intializer, as in >>> >>> if (varpool_node *vnode = (node->try_variable () >>> && vnode->

Re: Use conditional casting with symtab_node

2012-09-19 Thread Richard Guenther
On Wed, Sep 19, 2012 at 9:29 AM, Eric Botcazou wrote: >> >> The language syntax would bind the conditional into the intializer, as in >> >> if (varpool_node *vnode = (node->try_variable () >> && vnode->finalized)) >> varpool_analyze_node (vnode); >> >> which does

Re: Use conditional casting with symtab_node

2012-09-19 Thread Eric Botcazou
> > The language syntax would bind the conditional into the intializer, as in > > if (varpool_node *vnode = (node->try_variable () > && vnode->finalized)) > varpool_analyze_node (vnode); > > which does not type-match. > > So, if you want the type saftey and pe

Re: Use conditional casting with symtab_node

2012-09-18 Thread Lawrence Crowl
On 9/18/12, Richard Guenther wrote: > On Sep 18, 2012 Lawrence Crowl wrote: > > * cgraph.h (varpool_node): Rename to varpool_node_for_tree. > > Sure it should be varpool_node_for_decl, if any. > Or varpool_node_from_decl (grep for what is more common) Grep says _for_decl wins over _from_decl by

Re: Use conditional casting with symtab_node

2012-09-18 Thread Lawrence Crowl
On 9/18/12, Eric Botcazou wrote: >> When, the property test is embedded within a larger condition, a little >> restructuring is required to pull out the secondary conditions. For >> example, >> >> if (symtab_variable_p (node) >> && varpool (node)->finalized) >> varpool_analyze_node (v

Re: Use conditional casting with symtab_node

2012-09-18 Thread Eric Botcazou
> When, the property test is embedded within a larger condition, a little > restructuring is required to pull out the secondary conditions. For > example, > > if (symtab_variable_p (node) > && varpool (node)->finalized) > varpool_analyze_node (varpool (node)); > > becomes > > if (