This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][RFC] Automatized pattern matching
- From: Geoff Keating <geoffk at geoffk dot org>
- To: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: 13 Jan 2004 12:32:21 -0800
- Subject: Re: [PATCH][RFC] Automatized pattern matching
- References: <20030606220326.GA7464@atrey.karlin.mff.cuni.cz>
Hi Zdenek,
> as someone mentioned on gcc summit, quite a lot of big conditions in gcc
> is in fact a pattern matching on rtl expressions, that probably cannot
> be expressed in a more clear way in c directly.
>
> What we could however do is to use a language more suited to this task
> to describe the patterns and to translate them into c automatically.
> The patch below shows a simple implementation of this idea (for
> technical details see comments in pattern.c); it for example allows you
> to write
>
> if (MATCH_RTX ("(const (plus $base const_int@1))", addr))
> offset = INTVAL (_match1);
You didn't seem to get any comments on this, and at the time I was too
busy, but now that I look at it this seems like a really good idea.
I'm particularly thinking of code like this example in rs6000.c:
/* We must recognize output that we have already generated ourselves. */
if (GET_CODE (x) == PLUS
&& GET_CODE (XEXP (x, 0)) == PLUS
&& GET_CODE (XEXP (XEXP (x, 0), 0)) == REG
&& GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
&& GET_CODE (XEXP (x, 1)) == CONST_INT)
{
push_reload (XEXP (x, 0), NULL_RTX, &XEXP (x, 0), NULL,
BASE_REG_CLASS, GET_MODE (x), VOIDmode, 0, 0,
opnum, (enum reload_type)type);
*win = 1;
return x;
}
which ought to be much more readable using a MATCH_RTX-like
functionality. So, I'd encourage to update your patch, fix the few
details (like allowing line breaks) and I'll review it.
--
- Geoffrey Keating <geoffk@geoffk.org>