[patch] Associate a name with a CODE_LABEL

Catherine Moore clm@cygnus.com
Wed Nov 3 13:23:00 GMT 1999


I think I addressed all of the issues.  How does this version look?

ChangeLog:

	* defaults.h (ASM_OUTPUT_ALTERNATE_LABEL_NAME): Provide default.
	* emit-rtl.c (gen_label_rtx): Support LABEL_ALTERNATE_NAME.
	* final.c (final_scan_insn): Emit LABEL_ALTERNATE_NAME.
	* ggc-common.c (ggc_mark_rtx_children): Mark LABEL_ALTERNATE_NAME.
	* jump.c (delete_unreferenced_labels): Don't delete if
	LABEL_ALTERNATE_NAME is set.
	* print-rtl.c (print_rtx): Dump alternate name.
	* rtl.def (CODE_LABEL): Change format to "iuuis00s".
	* rtl.h (LABEL_ALTERNATE_NAME): Define.
	* rtl.texi (LABEL_ALTERNATE_NAME): Document.
	* tm.texi (ASM_OUTPUT_ALTERNATE_LABEL_NAME): Document.

Index: defaults.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/defaults.h,v
retrieving revision 1.12
diff -p -r1.12 defaults.h
*** defaults.h	1999/09/09 21:36:19	1.12
--- defaults.h	1999/11/03 20:53:47
*************** do { fprintf (FILE, "\t%s\t", ASM_LONG);
*** 54,59 ****
--- 54,65 ----
     } while (0)
  #endif
  
+ /* Provide default for ASM_OUTPUT_ALTERNATE_LABEL_NAME.  */
+ #ifndef ASM_OUTPUT_ALTERNATE_LABEL_NAME
+ #define ASM_OUTPUT_ALTERNATE_LABEL_NAME(FILE,INSN) \
+   fprintf (FILE, "%s:\n", LABEL_ALTERNATE_NAME (INSN))
+ #endif
+ 
  /* choose a reasonable default for ASM_OUTPUT_ASCII.  */
  
  #ifndef ASM_OUTPUT_ASCII
Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/emit-rtl.c,v
retrieving revision 1.94
diff -p -r1.94 emit-rtl.c
*** emit-rtl.c	1999/10/27 01:25:12	1.94
--- emit-rtl.c	1999/11/03 20:54:01
*************** gen_label_rtx ()
*** 1523,1531 ****
    register rtx label;
  
    label = gen_rtx_CODE_LABEL (VOIDmode, 0, NULL_RTX,
! 			      NULL_RTX, label_num++, NULL_PTR);
  
    LABEL_NUSES (label) = 0;
    return label;
  }
  
--- 1523,1532 ----
    register rtx label;
  
    label = gen_rtx_CODE_LABEL (VOIDmode, 0, NULL_RTX,
! 			      NULL_RTX, label_num++, NULL_PTR, NULL_PTR);
  
    LABEL_NUSES (label) = 0;
+   LABEL_ALTERNATE_NAME (label) = NULL;
    return label;
  }
  
Index: final.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/final.c,v
retrieving revision 1.102
diff -p -r1.102 final.c
*** final.c	1999/10/24 19:23:11	1.102
--- final.c	1999/11/03 20:54:18
*************** final_scan_insn (insn, file, optimize, p
*** 2418,2431 ****
  	      ASM_OUTPUT_CASE_LABEL (file, "L", CODE_LABEL_NUMBER (insn),
  				     NEXT_INSN (insn));
  #else
! 	      ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (insn));
  #endif
  #endif
  	      break;
  	    }
  	}
! 
!       ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (insn));
        break;
  
      default:
--- 2418,2436 ----
  	      ASM_OUTPUT_CASE_LABEL (file, "L", CODE_LABEL_NUMBER (insn),
  				     NEXT_INSN (insn));
  #else
!               if (LABEL_ALTERNATE_NAME (insn))
!                 ASM_OUTPUT_ALTERNATE_LABEL_NAME (file, insn);
!               else
! 	        ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (insn));
  #endif
  #endif
  	      break;
  	    }
  	}
!       if (LABEL_ALTERNATE_NAME (insn))
!         ASM_OUTPUT_ALTERNATE_LABEL_NAME (file, insn);
!       else
!         ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (insn));
        break;
  
      default:
Index: ggc-common.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/ggc-common.c,v
retrieving revision 1.14
diff -p -r1.14 ggc-common.c
*** ggc-common.c	1999/11/01 01:11:20	1.14
--- ggc-common.c	1999/11/03 20:54:22
*************** ggc_mark_rtx_children (r)
*** 252,257 ****
--- 252,258 ----
        break;
      case CODE_LABEL:
        ggc_mark_rtx (LABEL_REFS (r));
+       ggc_mark_string (LABEL_ALTERNATE_NAME (r));
        break;
      case LABEL_REF:
        ggc_mark_rtx (LABEL_NEXTREF (r));
Index: jump.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/jump.c,v
retrieving revision 1.89
diff -p -r1.89 jump.c
*** jump.c	1999/11/02 16:37:22	1.89
--- jump.c	1999/11/03 20:54:44
*************** delete_unreferenced_labels (f)
*** 2433,2439 ****
  
    for (insn = f; insn; )
      {
!       if (GET_CODE (insn) == CODE_LABEL && LABEL_NUSES (insn) == 0)
  	insn = delete_insn (insn);
        else
  	{
--- 2433,2441 ----
  
    for (insn = f; insn; )
      {
!       if (GET_CODE (insn) == CODE_LABEL
!           && LABEL_NUSES (insn) == 0
!           && LABEL_ALTERNATE_NAME (insn) == NULL)
  	insn = delete_insn (insn);
        else
  	{
Index: print-rtl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/print-rtl.c,v
retrieving revision 1.39
diff -p -r1.39 print-rtl.c
*** print-rtl.c	1999/10/15 21:26:33	1.39
--- print-rtl.c	1999/11/03 20:54:46
*************** print_rtx (in_rtx)
*** 354,360 ****
  #endif
  
    if (GET_CODE (in_rtx) == CODE_LABEL)
!     fprintf (outfile, " [num uses: %d]", LABEL_NUSES (in_rtx));
    
    if (dump_for_graph
        && (is_insn || GET_CODE (in_rtx) == NOTE
--- 354,364 ----
  #endif
  
    if (GET_CODE (in_rtx) == CODE_LABEL)
!     {
!       fprintf (outfile, " [num uses: %d]", LABEL_NUSES (in_rtx));
!       if (LABEL_ALTERNATE_NAME (in_rtx))
!         fprintf (outfile, " [alternate name: %s]", LABEL_ALTERNATE_NAME (in_rtx));
!     }
    
    if (dump_for_graph
        && (is_insn || GET_CODE (in_rtx) == NOTE
Index: rtl.def
===================================================================
RCS file: /cvs/gcc/egcs/gcc/rtl.def,v
retrieving revision 1.25
diff -p -r1.25 rtl.def
*** rtl.def	1999/10/10 11:52:53	1.25
--- rtl.def	1999/11/03 20:54:52
*************** DEF_RTL_EXPR(BARRIER, "barrier", "iuu", 
*** 376,383 ****
     3: is a number that is unique in the entire compilation.
     4: is the user-given name of the label, if any.
     5: is used in jump.c for the use-count of the label.
!    6: is used in flow.c to point to the chain of label_ref's to this label.  */
! DEF_RTL_EXPR(CODE_LABEL, "code_label", "iuuis00", 'x')
       
  /* Say where in the code a source line starts, for symbol table's sake.
     Contains a filename and a line number.  Line numbers <= 0 are special:
--- 376,384 ----
     3: is a number that is unique in the entire compilation.
     4: is the user-given name of the label, if any.
     5: is used in jump.c for the use-count of the label.
!    6: is used in flow.c to point to the chain of label_ref's to this label.
!    7: is the alternate label name.  */
! DEF_RTL_EXPR(CODE_LABEL, "code_label", "iuuis00s", 'x')
       
  /* Say where in the code a source line starts, for symbol table's sake.
     Contains a filename and a line number.  Line numbers <= 0 are special:
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/rtl.h,v
retrieving revision 1.151
diff -p -r1.151 rtl.h
*** rtl.h	1999/11/02 15:48:26	1.151
--- rtl.h	1999/11/03 20:55:04
*************** extern const char * const note_insn_name
*** 597,602 ****
--- 597,605 ----
     of LABEL_REFs that point at it, so unused labels can be deleted.  */
  #define LABEL_NUSES(RTX) XCINT(RTX, 5, CODE_LABEL)
  
+ /* Associate a name with a CODE_LABEL.  */
+ #define LABEL_ALTERNATE_NAME(RTX) XCSTR(RTX, 7, CODE_LABEL)
+ 
  /* The original regno this ADDRESSOF was built for.  */
  #define ADDRESSOF_REGNO(RTX) XCINT(RTX, 1, ADDRESSOF)
  
Index: rtl.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/rtl.texi,v
retrieving revision 1.22
diff -p -r1.22 rtl.texi
*** rtl.texi	1999/10/28 10:36:01	1.22
--- rtl.texi	1999/11/03 20:55:23
*************** The field @code{LABEL_NUSES} is only def
*** 2384,2389 ****
--- 2384,2394 ----
  phase is completed and contains the number of times this label is
  referenced in the current function.
  
+ @findex LABEL_ALTERNATE_NAME
+ The field @code{LABEL_ALTERNATE_NAME} is used to associate a name with
+ a @code{code_label}.  If this field is defined, the alternate name will
+ be emitted instead of an internally generated label name.
+ 
  @findex barrier
  @item barrier
  Barriers are placed in the instruction stream when control cannot flow
Index: tm.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tm.texi,v
retrieving revision 1.97
diff -p -r1.97 tm.texi
*** tm.texi	1999/10/28 09:34:40	1.97
--- tm.texi	1999/11/03 20:56:09
*************** The usual definition of this macro is as
*** 5736,5741 ****
--- 5736,5752 ----
  fprintf (@var{stream}, "L%s%d:\n", @var{prefix}, @var{num})
  @end example
  
+ @findex ASM_OUTPUT_ALTERNATE_LABEL_NAME
+ @item ASM_OUTPUT_ALTERNATE_LABEL_NAME (@var{stream}, @var{string})
+ A C statement to output to the stdio stream @var{stream} the string
+ @var{string}.
+ 
+ The default definition of this macro is as follows:
+ 
+ @example
+ fprintf (@var{stream}, "%s:\n", LABEL_ALTERNATE_NAME (INSN))
+ @end example
+ 
  @findex ASM_GENERATE_INTERNAL_LABEL
  @item ASM_GENERATE_INTERNAL_LABEL (@var{string}, @var{prefix}, @var{num})
  A C statement to store into the string @var{string} a label whose name


More information about the Gcc-patches mailing list