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

fix target/6032


Frobbing options because of profiling is silly.
Just emit rtl and everything works itself out.


r~


        * config/sparc/sparc.h (OVERRIDE_OPTIONS): Don't override -fpic
        or -fomit-frame-pointer with profiling.
        (SUBTARGET_OVERRIDE_OPTIONS): Remove.
        (FUNCTION_PROFILER): Do nothing.
        (PROFILE_HOOK): New.
        * config/sparc/sparc.c (sparc_override_options): Don't check
        code models for profiling.
        (sparc_function_profiler): Remove.
        (sparc_profile_hook): New.
        * config/sparc/sparc-protos.h: Update.

Index: config/sparc/sparc-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sparc-protos.h,v
retrieving revision 1.17.8.3
diff -c -p -d -r1.17.8.3 sparc-protos.h
*** sparc-protos.h	2002/03/29 08:22:23	1.17.8.3
--- sparc-protos.h	2002/03/30 20:55:03
*************** extern int check_pic PARAMS ((int));
*** 57,66 ****
  extern int short_branch PARAMS ((int, int));
  extern int sparc_flat_epilogue_delay_slots PARAMS ((void));
  extern unsigned long sparc_flat_compute_frame_size PARAMS ((int));
! extern void sparc_function_profiler PARAMS ((FILE *, int));
! extern void sparc_function_block_profiler PARAMS ((FILE *, int));
! extern void sparc_block_profiler PARAMS ((FILE *, int));
! extern void sparc_function_block_profiler_exit PARAMS ((FILE *));
  extern void sparc_override_options PARAMS ((void));
  extern int leaf_return_peephole_ok PARAMS ((void));
  extern void sparc_output_scratch_registers PARAMS ((FILE *));
--- 57,63 ----
  extern int short_branch PARAMS ((int, int));
  extern int sparc_flat_epilogue_delay_slots PARAMS ((void));
  extern unsigned long sparc_flat_compute_frame_size PARAMS ((int));
! extern void sparc_profile_hook PARAMS ((int));
  extern void sparc_override_options PARAMS ((void));
  extern int leaf_return_peephole_ok PARAMS ((void));
  extern void sparc_output_scratch_registers PARAMS ((FILE *));
Index: config/sparc/sparc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sparc.c,v
retrieving revision 1.185.2.8
diff -c -p -d -r1.185.2.8 sparc.c
*** sparc.c	2002/03/29 08:22:23	1.185.2.8
--- sparc.c	2002/03/30 20:55:03
*************** sparc_override_options ()
*** 432,443 ****
    /* Do various machine dependent initializations.  */
    sparc_init_modes ();
  
-   if ((profile_flag)
-       && sparc_cmodel != CM_32 && sparc_cmodel != CM_MEDLOW)
-     {
-       error ("profiling does not support code models other than medlow");
-     }
- 
    /* Register global variables with the garbage collector.  */
    sparc_add_gc_roots ();
  }
--- 432,437 ----
*************** sparc_return_peephole_ok (dest, src)
*** 8621,8662 ****
    return IN_OR_GLOBAL_P (dest);
  }
  
! /* Output assembler code to FILE to increment profiler label # LABELNO
!    for profiling a function entry.
! 
!    32 bit sparc uses %g2 as the STATIC_CHAIN_REGNUM which gets clobbered
!    during profiling so we need to save/restore it around the call to mcount.
!    We're guaranteed that a save has just been done, and we use the space
!    allocated for intreg/fpreg value passing.  */
  
  void
! sparc_function_profiler (file, labelno)
!      FILE *file;
       int labelno;
  {
    char buf[32];
!   ASM_GENERATE_INTERNAL_LABEL (buf, "LP", labelno);
! 
!   if (! TARGET_ARCH64)
!     fputs ("\tst\t%g2, [%fp-4]\n", file);
! 
!   fputs ("\tsethi\t%hi(", file);
!   assemble_name (file, buf);
!   fputs ("), %o0\n", file);
! 
!   fputs ("\tcall\t", file);
!   assemble_name (file, MCOUNT_FUNCTION);
!   putc ('\n', file);
  
!   fputs ("\t or\t%o0, %lo(", file);
!   assemble_name (file, buf);
!   fputs ("), %o0\n", file);
  
!   if (! TARGET_ARCH64)
!     fputs ("\tld\t[%fp-4], %g2\n", file);
  }
! 
! 
  /* Mark ARG, which is really a struct ultrasparc_pipline_state *, for
     GC.  */
  
--- 8615,8637 ----
    return IN_OR_GLOBAL_P (dest);
  }
  
! /* Output rtl to increment the profiler label LABELNO
!    for profiling a function entry.  */
  
  void
! sparc_profile_hook (labelno)
       int labelno;
  {
    char buf[32];
!   rtx lab, fun;
  
!   ASM_GENERATE_INTERNAL_LABEL (buf, "LP", labelno);
!   lab = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
!   fun = gen_rtx_SYMBOL_REF (Pmode, MCOUNT_FUNCTION);
  
!   emit_library_call (fun, 0, VOIDmode, 1, lab, Pmode);
  }
! 
  /* Mark ARG, which is really a struct ultrasparc_pipline_state *, for
     GC.  */
  
Index: config/sparc/sparc.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sparc.h,v
retrieving revision 1.161.2.7
diff -c -p -d -r1.161.2.7 sparc.h
*** sparc.h	2002/03/29 08:22:23	1.161.2.7
--- sparc.h	2002/03/30 20:55:03
*************** Unrecognized value in TARGET_CPU_DEFAULT
*** 373,401 ****
  /* Show we can debug even without a frame pointer.  */
  #define CAN_DEBUG_WITHOUT_FP
  
! /* To make profiling work with -f{pic,PIC}, we need to emit the profiling
!    code into the rtl.  Also, if we are profiling, we cannot eliminate
!    the frame pointer (because the return address will get smashed).  */
! 
! #define OVERRIDE_OPTIONS \
!   do {									\
!     if (profile_flag || profile_arc_flag)				\
!       {									\
! 	if (flag_pic)							\
! 	  {								\
! 	    const char *const pic_string = (flag_pic == 1) ? "-fpic" : "-fPIC";\
! 	    warning ("%s and profiling conflict: disabling %s",		\
! 		     pic_string, pic_string);				\
! 	    flag_pic = 0;						\
! 	  }								\
! 	flag_omit_frame_pointer = 0;					\
!       }									\
!     sparc_override_options ();						\
!     SUBTARGET_OVERRIDE_OPTIONS;						\
!   } while (0)
! 
! /* This is meant to be redefined in the host dependent files.  */
! #define SUBTARGET_OVERRIDE_OPTIONS
  
  /* Generate DBX debugging information.  */
  
--- 373,379 ----
  /* Show we can debug even without a frame pointer.  */
  #define CAN_DEBUG_WITHOUT_FP
  
! #define OVERRIDE_OPTIONS  sparc_override_options ()
  
  /* Generate DBX debugging information.  */
  
*************** do {									\
*** 1866,1879 ****
  #endif
  
  
! /* Output assembler code to FILE to increment profiler label # LABELNO
!    for profiling a function entry.  */
  
! #define FUNCTION_PROFILER(FILE, LABELNO) \
!   sparc_function_profiler(FILE, LABELNO)
  
  /* Set the name of the mcount function for the system.  */
- 
  #define MCOUNT_FUNCTION "*mcount"
  
  /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
--- 1844,1856 ----
  #endif
  
  
! /* Emit rtl for profiling.  */
! #define PROFILE_HOOK(LABEL)   sparc_profile_hook (LABEL)
  
! /* All the work done in PROFILE_HOOK, but still required.  */
! #define FUNCTION_PROFILER(FILE, LABELNO) do { } while (0)
  
  /* Set the name of the mcount function for the system.  */
  #define MCOUNT_FUNCTION "*mcount"
  
  /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,


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