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

i386 pic label stub


Applied to new_ia32_branch.

This started off just to clean up branch merge problems
wrt pic_label_rtx and Bernd's current_function cleanups.
But in fact there's no real point in having more than
one out of line pic label stub per object file.


r~


        * i386.c (pic_label_rtx, pic_label_no): Remove.
        (pic_label_output): New.
        (asm_output_function_prefix): Output the pic stub only once.
        (load_pic_register): Use pic_label_name directly.
        (struct machine_function): Remove pic_label_rtx, pic_label_name.
        (save_386_machine_status): Don't save them.
        (restore_386_machine_status): Or restore them.
        (clear_386_stack_locals): Don't clear pic_label_name.

Index: i386.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/config/i386/i386.c,v
retrieving revision 1.81.2.16
diff -c -p -d -r1.81.2.16 i386.c
*** i386.c	1999/08/25 22:42:13	1.81.2.16
--- i386.c	1999/08/29 00:13:23
*************** ix86_can_use_return_insn_p ()
*** 1350,1358 ****
    return nregs == 0 || ! frame_pointer_needed;
  }
  
! static rtx pic_label_rtx;
! static char pic_label_name [256];
! static int pic_label_no = 0;
  
  /* This function generates code for -fpic that loads %ebx with
     the return address of the caller and then returns.  */
--- 1350,1357 ----
    return nregs == 0 || ! frame_pointer_needed;
  }
  
! static char pic_label_name[32];
! static int pic_label_output;
  
  /* This function generates code for -fpic that loads %ebx with
     the return address of the caller and then returns.  */
*************** asm_output_function_prefix (file, name)
*** 1371,1400 ****
    /* Deep branch prediction favors having a return for every call. */
    if (pic_reg_used && TARGET_DEEP_BRANCH_PREDICTION)
      {
!       tree prologue_node;
! 
!       if (pic_label_rtx == 0)
  	{
! 	  pic_label_rtx = gen_label_rtx ();
! 	  ASM_GENERATE_INTERNAL_LABEL (pic_label_name, "LPR", pic_label_no++);
! 	  LABEL_NAME (pic_label_rtx) = pic_label_name;
! 	}
! 
!       prologue_node = make_node (FUNCTION_DECL);
!       DECL_RESULT (prologue_node) = 0;
  
!       /* This used to call ASM_DECLARE_FUNCTION_NAME() but since it's an
! 	 internal (non-global) label that's being emitted, it didn't make
! 	 sense to have .type information for local labels.   This caused
! 	 the SCO OpenServer 5.0.4 ELF assembler grief (why are you giving
!   	 me debug info for a label that you're declaring non-global?) this
! 	 was changed to call ASM_OUTPUT_LABEL() instead. */
  
!       ASM_OUTPUT_LABEL (file, pic_label_name); 
  
!       xops[1] = gen_rtx_MEM (SImode, xops[1]);
!       output_asm_insn ("mov{l}\t{%1, %0|%0, %1}", xops);
!       output_asm_insn ("ret", xops);
      }
  }
  
--- 1370,1392 ----
    /* Deep branch prediction favors having a return for every call. */
    if (pic_reg_used && TARGET_DEEP_BRANCH_PREDICTION)
      {
!       if (!pic_label_output)
  	{
! 	  /* This used to call ASM_DECLARE_FUNCTION_NAME() but since it's an
! 	     internal (non-global) label that's being emitted, it didn't make
! 	     sense to have .type information for local labels.   This caused
! 	     the SCO OpenServer 5.0.4 ELF assembler grief (why are you giving
!   	     me debug info for a label that you're declaring non-global?) this
! 	     was changed to call ASM_OUTPUT_LABEL() instead. */
  
! 	  ASM_OUTPUT_LABEL (file, pic_label_name); 
  
! 	  xops[1] = gen_rtx_MEM (SImode, xops[1]);
! 	  output_asm_insn ("mov{l}\t{%1, %0|%0, %1}", xops);
! 	  output_asm_insn ("ret", xops);
  
! 	  pic_label_output = 1;
! 	}
      }
  }
  
*************** load_pic_register ()
*** 1407,1420 ****
  
    if (TARGET_DEEP_BRANCH_PREDICTION)
      {
!       if (pic_label_rtx == 0)
! 	{
! 	  pic_label_rtx = gen_label_rtx ();
! 	  ASM_GENERATE_INTERNAL_LABEL (pic_label_name, "LPR", pic_label_no++);
! 	  LABEL_NAME (pic_label_rtx) = pic_label_name;
! 	}
!       pclab = gen_rtx_MEM (QImode,
! 	gen_rtx_SYMBOL_REF (Pmode, LABEL_NAME (pic_label_rtx)));
      }
    else
      {
--- 1399,1407 ----
  
    if (TARGET_DEEP_BRANCH_PREDICTION)
      {
!       if (pic_label_name[0] == '\0')
! 	ASM_GENERATE_INTERNAL_LABEL (pic_label_name, "LPR", 0);
!       pclab = gen_rtx_MEM (QImode, gen_rtx_SYMBOL_REF (Pmode, pic_label_name));
      }
    else
      {
*************** static rtx ix86_stack_locals[(int) MAX_M
*** 4961,4968 ****
  struct machine_function
  {
    rtx ix86_stack_locals[(int) MAX_MACHINE_MODE][MAX_386_STACK_LOCALS];
-   rtx pic_label_rtx;
-   char pic_label_name[256];
  };
  
  /* Functions to save and restore ix86_stack_locals.
--- 4948,4953 ----
*************** save_386_machine_status (p)
*** 4977,4984 ****
      = (struct machine_function *) xmalloc (sizeof (struct machine_function));
    bcopy ((char *) ix86_stack_locals, (char *) p->machine->ix86_stack_locals,
  	 sizeof ix86_stack_locals);
-   p->machine->pic_label_rtx = pic_label_rtx;
-   bcopy (pic_label_name, p->machine->pic_label_name, 256);
  }
  
  void
--- 4962,4967 ----
*************** restore_386_machine_status (p)
*** 4987,4994 ****
  {
    bcopy ((char *) p->machine->ix86_stack_locals, (char *) ix86_stack_locals,
  	 sizeof ix86_stack_locals);
-   pic_label_rtx = p->machine->pic_label_rtx;
-   bcopy (p->machine->pic_label_name, pic_label_name, 256);
    free (p->machine);
    p->machine = NULL;
  }
--- 4970,4975 ----
*************** clear_386_stack_locals ()
*** 5008,5015 ****
      for (n = 0; n < MAX_386_STACK_LOCALS; n++)
        ix86_stack_locals[(int) mode][n] = NULL_RTX;
  
-   pic_label_rtx = NULL_RTX;
-   bzero (pic_label_name, 256);
    /* Arrange to save and restore ix86_stack_locals around nested functions.  */
    save_machine_status = save_386_machine_status;
    restore_machine_status = restore_386_machine_status;
--- 4989,4994 ----


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