Even numbered register pairs restriction on some instructions
Matthew Malcomson
matthew.malcomson@arm.com
Mon Sep 3 16:10:00 GMT 2018
> I think you can use pdp11 as an example, it does two things that are similar to what you're describing.
>
> One is that it requires SImode to go into an even regno, and indicates that it uses two registers. See TARGET_HARD_REGNO_MODE_OK and TARGET_HARD_REGNO_NREGS.
>
> The other is that it has one instruction that wants an odd (!) register: 16 bit multiply. Multiply is weird: if you give it an even destination register it produces a 32 bit result in that register pair, with an odd register number it produces a 16 bit result. So pdp11.md defines both "mulhi3" and "mulsihi3" insns. The latter has an SImode output so that uses the even numbered register, as I already described. The former uses a machine-specific constraint "d". That is defined in constraints.md to mean a register in class MUL_REGS. pdp11.h defines that name and what registers it refers to, and pdp11.h does the reverse mapping (REGNO_REG_CLASS).
>
> If you want even register numbers for some instructions but that's not tied to a specific type size (like SImode in my case), I think you'd want to use something analogous to the MUL_REGS thing I described. Say, "EVEN_REGS". REGNO_REG_CLASS would report even regnum to be in EVEN_REGS, odd in GENERAL_REGS. The bitmaps for REG_CLASS_CONTENTS would show that EVEN_REGS contains only even numbered registers while GENERAL_REGS contains both odd and even. And you'd defined a register constraint which matches EVEN_REGS. Then the instructions where you want them would use that constraint.
>
> paul
>
> Yes, it's possible. You can look at TDmode (128-bit decimal floating point)
> on powerpc64*-linux, which is only allowed in even-odd register pairs.
> It's in *all* cases though, not some of the time.
>
> Peter
>
Thanks for the suggestions,
I've had a look into these, and unfortunately it seems they have the
same problem I've been hitting before.
The use of the TARGET_HARD_REGNO_MODE_OK macro limits all uses of
registers in a given mode (so that we wouldn't be able to use register
pairs beginning with odd registers for other instructions), while using
an EVEN_REGS register class won't work in modes that span more than one
hard register (as all hard registers covered by a pseudo register must
be in the same class).
Thanks again,
Matthew
More information about the Gcc
mailing list