This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [tuples] Accessors for RHS of assignments
- From: Zdenek Dvorak <rakdver at kam dot mff dot cuni dot cz>
- To: Diego Novillo <dnovillo at google dot com>
- Cc: Aldy Hernandez <aldyh at redhat dot com>, Christopher Matthews <chrismatthews at google dot com>, Andrew Macleod <amacleod at redhat dot com>, gcc at gcc dot gnu dot org
- Date: Thu, 21 Jun 2007 01:13:06 +0200
- Subject: Re: [tuples] Accessors for RHS of assignments
- References: <46796F96.1080407@google.com>
Hello,
> So, I think I am still not convinced which way we want to access the RHS
> of a GS_ASSIGN.
>
> Since GS_ASSIGN can have various types of RHS, we originally had:
>
> gs_assign_unary_rhs (gs) <- Access the only operand on RHS
> gs_assign_binary_rhs1 (gs) <- Access the 1st RHS operand
> gs_assign_binary_rhs2 (gs) <- Access the 2nd RHS operand
>
> And the corresponding _set functions.
>
> I then managed to half convince myself that it'd be better to have a
> single gs_assign_rhs() accessor with a 'which' parameter. After
> implementing that, I think I hate it. Particularly since this 'which'
> parameter is just a number (0 or 1). It could be a mnemonic, but it
> would still be annoying.
>
> So, I'm thinking of going back to the way it was before, but it is not
> optimal. Do people feel strongly over one or the other?
I may be missing something, but surely having the accessors uniform
would be better? So that I can write things like
/* Process all operands. */
for (i = 0; i < n_operands (gs); i++)
process (gs_assign_rhs (gs, i));
rather than
if (is_unary (gs))
process (gs_assign_unary_rhs (gs));
else if (is_binary (gs))
{
process (gs_assign_binary_rhs1 (gs));
process (gs_assign_binary_rhs2 (gs));
}
else if (is_ternary (gs))
...
Anyway, you can always
#define gs_assign_unary_rhs(X) gs_assign_rhs(X, 0)
#define gs_assign_binary_rhs1(X) gs_assign_rhs(X, 0)
#define gs_assign_binary_rhs2(X) gs_assign_rhs(X, 1)
as well, and use these in cases where you know with which arity you are
working.
Zdenek