This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: arm_hard_regno_mode_ok update
- From: Nick Clifton <nickc at cambridge dot redhat dot com>
- To: Richard dot Earnshaw at arm dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: 25 Jan 2002 11:42:59 +0000
- Subject: Re: arm_hard_regno_mode_ok update
- References: <200201241636.QAA24712@cam-mail2.cambridge.arm.com>
Hi Richard,
> I don't think this code can't be right in general. I really think a
> user needs to be able to name *any* reserved register in an ASM type
> statement.
True.
> Why is the check in there in the first place? We didn't need it
> before...
Because I am trying to stop IP (r12) being assigned to hold a DImode
value, since the upper half will be placed in the stack pointer
(r13), which is not good.
Anyway here is a patch which I think will do the right thing.
Cheers
Nick
2002-01-25 Nick Clifton <nickc@cambridge.redhat.com>
* config/arm/arm.c (arm_hard_regno_mode_ok): Allow any general
purpose register to hold an SImode (or smaller) value.
Index: config/arm/arm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/arm.c,v
retrieving revision 1.191
diff -c -3 -p -w -r1.191 arm.c
*** arm.c 2002/01/24 16:27:51 1.191
--- arm.c 2002/01/25 11:40:42
*************** arm_hard_regno_mode_ok (regno, mode)
*** 9139,9162 ****
return (NUM_REGS (mode) < 2) || (regno < LAST_LO_REGNUM);
if (regno <= LAST_ARM_REGNUM)
! /* If the register is a general purpose ARM register we allow
! it only if it not a special register (SP, LR, PC) and only
! if there will be enough (non-special) registers to hold the
! entire value. */
! {
! /* As a special exception we allow an SImode value to be
! "assigned" to the stack pointer. This is not intended
! to actually allow a value to be stored in the SP, but so
! that the stack pointer can be referenced from C code like
! this:
register char * stack_ptr asm ("sp");
! This expression is actually used in newlib... */
! if (mode == SImode && regno == SP_REGNUM)
! return 1;
! return regno < (SP_REGNUM - (unsigned) NUM_REGS (mode));
! }
if ( regno == FRAME_POINTER_REGNUM
|| regno == ARG_POINTER_REGNUM)
--- 9139,9158 ----
return (NUM_REGS (mode) < 2) || (regno < LAST_LO_REGNUM);
if (regno <= LAST_ARM_REGNUM)
! /* We allow an SImode or smaller value to be stored in any
! general purpose register. This does not mean, for example
! that GCC will choose to store a variable in the stack pointer
! since it is a fixed register. But it is important to allow
! access to these special registers, so that they can be
! referenced from C code via the asm assembler alias, eg:
register char * stack_ptr asm ("sp");
! For any mode requiring more than one register to hold the
! value we restrict the choice so that r13, r14, and r15
! cannot be part of the register set. */
! return (NUM_REGS (mode) <= 1)
! || (regno < (SP_REGNUM - (unsigned) NUM_REGS (mode)));
if ( regno == FRAME_POINTER_REGNUM
|| regno == ARG_POINTER_REGNUM)