This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Use predicates for RTL objects
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Arvind Sankar <nivedita at alum dot mit dot edu>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 7 Aug 2019 12:33:53 -0500
- Subject: Re: Use predicates for RTL objects
- References: <20190807161528.GA3326377@rani.riverdale.lan>
On Wed, Aug 07, 2019 at 12:15:29PM -0400, Arvind Sankar wrote:
> I would also like to get some comments on the following idea to make the
> code checks more readable: I am thinking of adding
> bool rtx_def::is_a (enum rtx_code) const
> This would allow us to make all the rtx_code comparisons more readable
> without having to define individual macros for each.
> i.e.,
> REG_P (x) => x->is_a (REG)
> GET_CODE (x) == PLUS => x->is_a (PLUS)
> GET_CODE (PATTERN (x)) == SEQUENCE => PATTERN (x)->is_a (SEQUENCE)
That makes things much worse. Not only is it less readable (IMO), but
the "is_a" idiom is used to check if something is of a certain class,
which is not the case here.
In "GET_CODE (x) == PLUS" it is clear that what the resulting machine
code does is cheap. With "x->is_a (PLUS)", who knows what is happening
below the covers!
(And "REG_P" and similar are much shorter code to type).
Segher