This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] make LABEL_DECL has its own rtx field for its associated CODE_LABEL


On Thu, Apr 21, 2011 at 05:54:28PM +0200, Michael Matz wrote:
> > > In particular, FIELD_DECLs have a size, but they have no RTL associated
> > > with them. ?And LABEL_DECLs have RTL, but no size.
> 
> Blaeh.  So far about nice clean ideas :)  One hacky idea: change my 
> proposal to this:
> 
>  decl_common {} ?# no size, no rtl, no align, no pt_uid
>  decl_with_rtl_or_size : decl_common {
>  ? # add align, pt_uid
>    union {
>      rtx rtl;
>      tree size;
>    } u;
>  }
>  decl_with_size : decl_with_rtl_or_size {
>  ? # add size, size_unit
>  }
> 
> Use the rtl_or_size struct primarily for the current _with_rtl things that 
> don't naturally have a size, but use it also for FIELD_DECLs via the 
> union.

I'm not sure I follow this wrt FIELD_DECLs.  Before you have:

  ...lots of decl fields..
  tree size;
  tree size_unit;

After you have:

  ...lots of decl fields...
  union { rtx rtl; tree size; } u;
  tree size;
  tree size_unit;

Or did you mean something like:

  /* As above.  */
  decl_with_rtl_or_size
  /* Add a size_unit field.  */
  decl_with_size_unit : decl_with_rtl_or_size /* FIELD_DECL */
  /* Add a size field for DECLs that do have RTL.  */
  decl_with_rtl_and_size : decl_with_size_unit /* VAR_DECL, PARM_DECL, etc.  */

which looks just awful. :)

> Alternatively I could also envision making a new tree_ struct for just 
> field_decls, that would contain the size and other fields that currently 
> are in decl_common just for fields (in particular the off_align) member.
> The various accessors like DECL_SIZE would then need to dispatch based on 
> tree code.

You could also do something like:

struct tree_decl_size {
  tree size;
  tree size_unit;
  ...
};

struct tree_field_decl {
  ...
  struct tree_decl_size size;
};

struct tree_var_decl {
  ...
  struct tree_decl_size size;
};

static inline tree *
decl_size_1 (tree node)
{
  switch (TREE_CODE (node))
    {
    case FIELD_DECL: return &node->field_decl.size.size;
    case VAR_DECL: return &node->var_decl.size.size;
    ...
    default: gcc_unreachable ();
    }
}

/* Might also need a HAS_DECL_SIZE_P predicate or similar.  */
#define DECL_SIZE(NODE) (*decl_size_1 (NODE))
...

which would make it somewhat more obvious when things have sizes, as
well as letting you remove DECL_SIZE{,_UNIT} from FUNCTION_DECL.
Slimming CONST_DECL and LABEL_DECL like this is useful mostly for code
cleanliness, but eliminating such fields from FUNCTION_DECL would have a
much more noticeable memory size impact.

-Nathan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]