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]
Other format: [Raw text]

discouraging register use


Ok, I'm working on this chip that has a small number of cheap
registers, and a large number of expensive ones (they exist in memory
but the chip treats them like registers).  What is the preferred (aka
"right") way of telling gcc to prefer the cheap registers?

Let's say we have register constraints "c" (cheap) and "m" (memory).
addsi, for example, can do c+c, c+m, m+c, and m+m, and sees them all
equal.  Since the "m" class is bigger than the "c" class, gcc strongly
prefers the "m" class, regardless of register move cost.

I've tried using insns like this:

  [(set (match_operand:SI 0 "" "c,?cm")
        (plus:SI (match_operand:SI 1 "" "0,0")
		 (match_operand:SI 1 "" "c,cm")))]

But that doesn't do it.  I tried adding a plethora of register class
supersets, but that just leads to reload problems (for this chip, I
think not in general) because it wasn't able to "fall back" to using
the expensive registers once it got the idea to use the cheap ones.

Do I have to do something like this?  If so, I'm going to have some
*really* long lines in my md file (for this chip).  Or is there some
other way of changing gcc's register preferences, without precluding
the registers completely?

  [(set (match_operand:SI 0 "" "c,c,?m,?m")
        (plus:SI (match_operand:SI 1 "" "0,0,0,0")
		 (match_operand:SI 1 "" "c,?m,c,?m")))]


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