This is the mail archive of the gcc@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]

Those pesky incomprehensible if statements


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


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