This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Those pesky incomprehensible if statements
- To: gcc at gcc dot gnu dot org
- Subject: Those pesky incomprehensible if statements
- From: "Zack Weinberg" <zackw at stanford dot edu>
- Date: Mon, 19 Feb 2001 11:34:18 -0800
I was staring at one of those incomprehensible if statements this
morning. Not a horrible one, just four lines, and it is one
conceptual unit.
if (GET_CODE (SET_SRC (set)) == PLUS
&& XEXP (SET_SRC (set), 0) == stack_pointer_rtx
&& GET_CODE (XEXP (SET_SRC (set), 1)) == CONST_INT
&& SET_DEST (set) == stack_pointer_rtx)
But I still had to stare at it for, oh, thirty seconds before I could
see what it does, because it's buried under all the verbiage. And I
said to myself, what we need here is some syntactic sugar. Something
like
if (match_p (set, '(set (stack_pointer_rtx)
(plus (stack_pointer_rtx) (const_int)))))
Isn't that so much easier to read?
Of course, I have not the slightest notion how to implement such a
thing such that the minilanguage has a sensible grammar and the
implementation doesn't slow the compiler to a crawl.
zw