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

Re: Missing functionality in arm_compute_initial_elimination_offset


Hi Richard,

: 2001-08-14  Nick Clifton  <nickc@cambridge.redhat.com>
: 
:         * config/arm/arm.c (arm_compute_initial_elimination_offset): New
:         function.
:  	...
: 
: arm_compute_initial_elimination_offset currently contains the comment
: 
:   /* FIXME: we should allow for saved floating point registers.  */
: 
: This omission will break arm/linux compilations (amongst others) which use 
: this option.

Yes you are right.  I realise what happened now - I developed the
patch on an old branch, where the saves of the FP registers was
omitted from the calculation of the stack offset, and when I moved the
patch to the mainline sources I missed the fact that this bug had been
fixed.

I will apply the patch below to fix this.

This patch also incorporates the changes that Fred Fish posted since
they are necessary in order to allow an arm-elf toolchain to build
and that is what I was using for testing.

Cheers
	Nick

2001-08-30  Nick Clifton  <nickc@cambridge.redhat.com>

	* config/arm/arm.c (arm_compute_initial_elimination_offset):
	Account for the saves of the FP registers.

	* config/arm/unknown-elf.h (TEXT_SECTION): Delete.
	(TEXT_SECTION_ASM_OP): Define.
	(INIT_SECTION_ASM_OP): Define.
	(FINI_SECTION_ASM_OP): Define.
	(SUBTARGET_EXTRA_SECTIONS): Remove trailing comma.
	(RDATA_SECTION_FUNCITON): Provide prototype.

Index: gcc/config/arm/arm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/arm.c,v
retrieving revision 1.160
diff -p -r1.160 arm.c
*** arm.c	2001/08/18 20:25:50	1.160
--- arm.c	2001/08/30 10:44:13
*************** arm_compute_initial_elimination_offset (
*** 7943,7958 ****
--- 7943,7965 ----
      {
        unsigned int reg;
  
+       /* In theory we should check all of the hard registers to
+ 	 see if they will be saved onto the stack.  In practice
+ 	 registers 11 upwards have special meanings and need to
+ 	 be check individually.  */
        for (reg = 0; reg <= 10; reg ++)
  	if (regs_ever_live[reg] && ! call_used_regs[reg])
  	  call_saved_registers += 4;
  
+       /* Determine if register 11 will be clobbered.  */
        if (! TARGET_APCS_FRAME
  	  && ! frame_pointer_needed
  	  && regs_ever_live[HARD_FRAME_POINTER_REGNUM]
  	  && ! call_used_regs[HARD_FRAME_POINTER_REGNUM])
  	call_saved_registers += 4;
  
+       /* The PIC register is fixed, so if the function will
+ 	 corrupt it, it has to be saved onto the stack.  */
        if (flag_pic && regs_ever_live[PIC_OFFSET_TABLE_REGNUM])
  	call_saved_registers += 4;
  
*************** arm_compute_initial_elimination_offset (
*** 7962,7975 ****
  	     for it here.  */
  	  && ! frame_pointer_needed)
  	call_saved_registers += 4;
      }
  
    /* The stack frame contains 4 registers - the old frame pointer,
       the old stack pointer, the return address and PC of the start
       of the function.  */
    stack_frame = frame_pointer_needed ? 16 : 0;
- 
-   /* FIXME: we should allow for saved floating point registers.  */
  
    /* OK, now we have enough information to compute the distances.
       There must be an entry in these switch tables for each pair
--- 7969,7987 ----
  	     for it here.  */
  	  && ! frame_pointer_needed)
  	call_saved_registers += 4;
+ 
+       /* If the hard floating point registers are going to be
+ 	 used then they must be saved on the stack as well.
+          Each register occupies 12 bytes of stack space.  */
+       for (reg = FIRST_ARM_FP_REGNUM; reg <= LAST_ARM_FP_REGNUM; reg ++)
+ 	if (regs_ever_live[reg] && ! call_used_regs[reg])
+ 	  call_saved_registers += 12;
      }
  
    /* The stack frame contains 4 registers - the old frame pointer,
       the old stack pointer, the return address and PC of the start
       of the function.  */
    stack_frame = frame_pointer_needed ? 16 : 0;
  
    /* OK, now we have enough information to compute the distances.
       There must be an entry in these switch tables for each pair

Index: gcc/config/arm/unknown-elf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/arm/unknown-elf.h,v
retrieving revision 1.20
diff -p -r1.20 unknown-elf.h
*** unknown-elf.h	2001/08/13 22:05:16	1.20
--- unknown-elf.h	2001/08/30 10:44:15
*************** Boston, MA 02111-1307, USA.  */
*** 37,43 ****
  #define USER_LABEL_PREFIX 	""
  #define LOCAL_LABEL_PREFIX 	"."
  
! #define TEXT_SECTION "		.text"
  
  #define INVOKE__main
  
--- 37,45 ----
  #define USER_LABEL_PREFIX 	""
  #define LOCAL_LABEL_PREFIX 	"."
  
! #define TEXT_SECTION_ASM_OP 	"\t.text"
! #define INIT_SECTION_ASM_OP	"\t.section\t.init"
! #define FINI_SECTION_ASM_OP	"\t.section\t.fini"
  
  #define INVOKE__main
  
*************** Boston, MA 02111-1307, USA.  */
*** 51,57 ****
  
  /* A list of other sections which the compiler might be "in" at any
     given time.  */
! #define SUBTARGET_EXTRA_SECTIONS in_rdata,
  
  /* A list of extra section function definitions.  */
  #define SUBTARGET_EXTRA_SECTION_FUNCTIONS	RDATA_SECTION_FUNCTION
--- 53,59 ----
  
  /* A list of other sections which the compiler might be "in" at any
     given time.  */
! #define SUBTARGET_EXTRA_SECTIONS in_rdata
  
  /* A list of extra section function definitions.  */
  #define SUBTARGET_EXTRA_SECTION_FUNCTIONS	RDATA_SECTION_FUNCTION
*************** Boston, MA 02111-1307, USA.  */
*** 59,64 ****
--- 61,68 ----
  #define RDATA_SECTION_ASM_OP	"\t.section .rodata"
  
  #define RDATA_SECTION_FUNCTION 					\
+ void rdata_section PARAMS ((void));				\
+ 								\
  void								\
  rdata_section ()						\
  {								\


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