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]

x86 dwarf patch


rth wrote a version of this patch a while back to simplify the dwarf
debugging info generated for -fpic compiles.  My last patch allows
this to be much simpler.

2000-01-24  Richard Henderson  <rth@cygnus.com>

	* i386.c (i386_dwarf_output_addr_const): New.
	* i386.h (ASM_OUTPUT_DWARF_ADDR_CONST): New.

	* dwarf2out.c (mem_loc_descriptor): Call ASM_SIMPLIFY_DWARF_ADDR
	if defined.
	* dwarfout.c (output_mem_loc_descriptor): Likewise.
	* i386.c (i386_simplify_dwarf_addr): New.
	* i386.h (ASM_SIMPLIFY_DWARF_ADDR): New.

Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/dwarf2out.c,v
retrieving revision 1.142
diff -c -p -r1.142 dwarf2out.c
*** dwarf2out.c	2000/01/14 00:46:57	1.142
--- dwarf2out.c	2000/01/25 05:00:04
*************** mem_loc_descriptor (rtl, mode)
*** 6433,6438 ****
--- 6296,6305 ----
       actually within the array.  That's *not* necessarily the same as the
       zeroth element of the array.  */
  
+ #ifdef ASM_SIMPLIFY_DWARF_ADDR
+   rtl = ASM_SIMPLIFY_DWARF_ADDR (rtl);
+ #endif
+ 
    switch (GET_CODE (rtl))
      {
      case POST_INC:
Index: dwarfout.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/dwarfout.c,v
retrieving revision 1.50
diff -c -p -r1.50 dwarfout.c
*** dwarfout.c	2000/01/14 00:46:57	1.50
--- dwarfout.c	2000/01/25 02:36:01
*************** output_mem_loc_descriptor (rtl)
*** 1715,1720 ****
--- 1715,1724 ----
       which is actually within the array.  That's *not* necessarily the
       same as the zeroth element of the array.  */
  
+ #ifdef ASM_SIMPLIFY_DWARF_ADDR
+   rtl = ASM_SIMPLIFY_DWARF_ADDR (rtl);
+ #endif
+ 
    switch (GET_CODE (rtl))
      {
        case SUBREG:
Index: config/i386/i386-protos.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386-protos.h,v
retrieving revision 1.9
diff -c -p -r1.9 i386-protos.h
*** config/i386/i386-protos.h	2000/01/20 00:05:32	1.9
--- config/i386/i386-protos.h	2000/01/25 02:36:08
*************** extern const char *output_387_binary_op 
*** 81,86 ****
--- 81,89 ----
  extern const char *output_fix_trunc PARAMS ((rtx, rtx*));
  extern const char *output_fp_compare PARAMS ((rtx, rtx*, int, int));
  
+ extern void i386_dwarf_output_addr_const PARAMS ((FILE*, rtx));
+ extern rtx i386_simplify_dwarf_addr PARAMS ((rtx));
+ 
  extern void ix86_expand_move PARAMS ((enum machine_mode, rtx[]));
  extern void ix86_expand_binary_operator PARAMS ((enum rtx_code,
  					       enum machine_mode, rtx[]));
Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.c,v
retrieving revision 1.125
diff -c -p -r1.125 i386.c
*** config/i386/i386.c	2000/01/20 00:05:32	1.125
--- config/i386/i386.c	2000/01/25 02:36:11
*************** ix86_initial_elimination_offset (from, t
*** 1599,1605 ****
     desired stack alignment which is to be maintained.  Also determine
     the number of registers saved below the local storage.  */
  
! HOST_WIDE_INT
  ix86_compute_frame_size (size, nregs_on_stack)
       HOST_WIDE_INT size;
       int *nregs_on_stack;
--- 1599,1605 ----
     desired stack alignment which is to be maintained.  Also determine
     the number of registers saved below the local storage.  */
  
! static HOST_WIDE_INT
  ix86_compute_frame_size (size, nregs_on_stack)
       HOST_WIDE_INT size;
       int *nregs_on_stack;
*************** output_pic_addr_const (file, x, code)
*** 2660,2665 ****
--- 2660,2710 ----
      default:
        output_operand_lossage ("invalid expression as operand");
      }
+ }
+ 
+ /* This is called from dwarfout.c via ASM_OUTPUT_DWARF_ADDR_CONST.  
+    We need to handle our special PIC relocations.  */
+ 
+ void 
+ i386_dwarf_output_addr_const (file, x)
+      FILE *file;
+      rtx x;
+ {
+   fprintf (file, "\t%s\t", INT_ASM_OP);
+   if (flag_pic)
+     output_pic_addr_const (file, x, '\0');
+   else
+     output_addr_const (file, x);
+   fputc ('\n', file);
+ }
+ 
+ /* In the name of slightly smaller debug output, and to cater to
+    general assembler losage, recognize PIC+GOTOFF and turn it back
+    into a direct symbol reference.  */
+ 
+ rtx
+ i386_simplify_dwarf_addr (orig_x)
+      rtx orig_x;
+ {
+   rtx x = orig_x;
+ 
+   if (GET_CODE (x) != PLUS
+       || GET_CODE (XEXP (x, 0)) != REG
+       || GET_CODE (XEXP (x, 1)) != CONST)
+     return orig_x;
+ 
+   x = XEXP (XEXP (x, 1), 0);
+   if (GET_CODE (x) == UNSPEC
+       && XINT (x, 1) == 7)
+     return XVECEXP (x, 0, 0);
+ 
+   if (GET_CODE (x) == PLUS
+       && GET_CODE (XEXP (x, 0)) == UNSPEC
+       && GET_CODE (XEXP (x, 1)) == CONST_INT
+       && XINT (XEXP (x, 0), 1) == 7)
+     return gen_rtx_PLUS (VOIDmode, XVECEXP (XEXP (x, 0), 0, 0), XEXP (x, 1));
+ 
+   return orig_x;
  }
  
  static void
Index: config/i386/i386.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/i386/i386.h,v
retrieving revision 1.92
diff -c -p -r1.92 i386.h
*** config/i386/i386.h	2000/01/20 00:05:32	1.92
--- config/i386/i386.h	2000/01/25 02:36:13
*************** config/i386/i386.h						\
*** 2303,2308 ****
--- 2303,2319 ----
  #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
    fprintf (FILE, "\t%s\t%s%d-%s%d\n",ASM_LONG, LPREFIX, VALUE, LPREFIX, REL)
  
+ /* A C statement that outputs an address constant appropriate to 
+    for DWARF debugging.  */
+ 
+ #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,X) \
+   i386_dwarf_output_addr_const((FILE),(X))
+ 
+ /* Either simplify a location expression, or return the original.  */
+ 
+ #define ASM_SIMPLIFY_DWARF_ADDR(X) \
+   i386_simplify_dwarf_addr(X)
+ 
  /* Define the parentheses used to group arithmetic operations
     in assembler code.  */
  

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