rtl.def (CODE_LABEL): Remove slot 8.
authorZack Weinberg <zack@codesourcery.com>
Fri, 19 Jul 2002 23:11:19 +0000 (23:11 +0000)
committerZack Weinberg <zack@gcc.gnu.org>
Fri, 19 Jul 2002 23:11:19 +0000 (23:11 +0000)
* rtl.def (CODE_LABEL): Remove slot 8.
* rtl.h (struct rtx_def): Document new uses of jump and call fields.
(LABEL_ALTERNATE_NAME): Delete.
(LABEL_KIND, SET_LABEL_KIND, LABEL_ALT_ENTRY_P): New.
* defaults.h: Remove default for ASM_OUTPUT_ALTERNATE_LABEL_NAME.

* final.c (output_alternate_entry_point): New.
(final_scan_insn): Use it instead of
ASM_OUTPUT_ALTERNATE_LABEL_NAME.  Do not consider possibility
of a case label being an alternate entry point.

* cfgbuild.c (make_edges, find_bb_boundaries): Use LABEL_ALT_ENTRY_P.
* emit-rtl.c (gen_label_rtx): Adjust call to gen_rtx_CODE_LABEL.
Do not clear LABEL_NUSES (unnecessary) or LABEL_ALTERNATE_NAME
(field deleted).
* print-rtl.c, ra-debug.c: Update code to output CODE_LABELs.

* doc/rtl.texi: Document LABEL_KIND, SET_LABEL_KIND, and
LABEL_ALT_ENTRY_P; not LABEL_ALTERNATE_NAME.
* doc/tm.texi: Delete documentation of
ASM_OUTPUT_ALTERNATE_LABEL_NAME.

From-SVN: r55597

gcc/ChangeLog
gcc/cfgbuild.c
gcc/defaults.h
gcc/doc/rtl.texi
gcc/doc/tm.texi
gcc/emit-rtl.c
gcc/final.c
gcc/print-rtl.c
gcc/ra-debug.c
gcc/rtl.def
gcc/rtl.h

index 2e8b734631eb2d3c640f96ecd10d87bd8c7ef9de..69403e0b4db6729081d718e9018a0363047cee98 100644 (file)
@@ -1,3 +1,27 @@
+2002-07-19  Zack Weinberg  <zack@codesourcery.com>
+
+       * rtl.def (CODE_LABEL): Remove slot 8.
+       * rtl.h (struct rtx_def): Document new uses of jump and call fields.
+       (LABEL_ALTERNATE_NAME): Delete.
+       (LABEL_KIND, SET_LABEL_KIND, LABEL_ALT_ENTRY_P): New.
+       * defaults.h: Remove default for ASM_OUTPUT_ALTERNATE_LABEL_NAME.
+
+       * final.c (output_alternate_entry_point): New.
+       (final_scan_insn): Use it instead of
+       ASM_OUTPUT_ALTERNATE_LABEL_NAME.  Do not consider possibility
+       of a case label being an alternate entry point.
+
+       * cfgbuild.c (make_edges, find_bb_boundaries): Use LABEL_ALT_ENTRY_P.
+       * emit-rtl.c (gen_label_rtx): Adjust call to gen_rtx_CODE_LABEL.
+       Do not clear LABEL_NUSES (unnecessary) or LABEL_ALTERNATE_NAME
+       (field deleted).
+       * print-rtl.c, ra-debug.c: Update code to output CODE_LABELs.
+
+       * doc/rtl.texi: Document LABEL_KIND, SET_LABEL_KIND, and
+       LABEL_ALT_ENTRY_P; not LABEL_ALTERNATE_NAME.
+       * doc/tm.texi: Delete documentation of
+       ASM_OUTPUT_ALTERNATE_LABEL_NAME.
+
 2002-07-19  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
 
        * config/mips/iris5gas.h (DWARF2_DEBUGGING_INFO): Define.
index 8b7b705893135e581b3393ed5c1a07464f4b6bd2..12dd200a60fe46e2a1d1637222a67ea5078a8ce3 100644 (file)
@@ -321,7 +321,7 @@ make_edges (label_value_list, min, max, update_p)
       enum rtx_code code;
       int force_fallthru = 0;
 
-      if (GET_CODE (bb->head) == CODE_LABEL && LABEL_ALTERNATE_NAME (bb->head))
+      if (GET_CODE (bb->head) == CODE_LABEL && LABEL_ALT_ENTRY_P (bb->head))
        cached_make_edge (NULL, ENTRY_BLOCK_PTR, bb, 0);
 
       /* Examine the last instruction of the block, and discover the
@@ -699,7 +699,7 @@ find_bb_boundaries (bb)
          bb = fallthru->dest;
          remove_edge (fallthru);
          flow_transfer_insn = NULL_RTX;
-         if (LABEL_ALTERNATE_NAME (insn))
+         if (LABEL_ALT_ENTRY_P (insn))
            make_edge (ENTRY_BLOCK_PTR, bb, 0);
        }
 
index 3bbf231c2f07d94d7bb531003327bb6183d9563c..5b88ac2d880befd5f3b67800de4e91d9beb2f61d 100644 (file)
@@ -80,12 +80,6 @@ do { fputs (integer_asm_op (POINTER_SIZE / UNITS_PER_WORD, TRUE), FILE); \
    } 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) \
-do { ASM_OUTPUT_LABEL(FILE,LABEL_ALTERNATE_NAME (INSN)); } while (0)
-#endif
-
 /* choose a reasonable default for ASM_OUTPUT_ASCII.  */
 
 #ifndef ASM_OUTPUT_ASCII
index 5894910d30be883339bc8210de2d3113d4559419..427637450ba59fc94057dba0b77c7a6434323030 100644 (file)
@@ -2830,13 +2830,32 @@ Besides as a @code{code_label}, a label can also be represented as a
 
 @findex LABEL_NUSES
 The field @code{LABEL_NUSES} is only defined once the jump optimization
-phase is completed and contains the number of times this label is
+phase is completed.  It 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 LABEL_KIND
+@findex SET_LABEL_KIND
+@findex LABEL_ALT_ENTRY_P
+@cindex alternate entry points
+The field @code{LABEL_KIND} differentiates four different types of
+labels: @code{LABEL_NORMAL}, @code{LABEL_STATIC_ENTRY},
+@code{LABEL_GLOBAL_ENTRY}, and @code{LABEL_WEAK_ENTRY}.  The only labels
+that do not have type @code{LABEL_NORMAL} are @dfn{alternate entry
+points} to the current function.  These may be static (visible only in
+the containing translation unit), global (exposed to all translation
+units), or weak (global, but can be overriden by another symbol with the
+same name).
+
+Much of the compiler treats all four kinds of label identically.  Some
+of it needs to know whether or not a label is an alternate entry point;
+for this purpose, the macro @code{LABEL_ALT_ENTRY_P} is provided.  It is
+equivalent to testing whether @samp{LABEL_KIND (label) == LABEL_NORMAL}.
+The only place that cares about the distinction between static, global,
+and weak alternate entry points, besides the front-end code that creates
+them, is the function @code{output_alternate_entry_point}, in
+@file{final.c}.
+
+To set the kind of a label, use the @code{SET_LABEL_KIND} macro.
 
 @findex barrier
 @item barrier
index 17d0d138aef20dad84d4116cc3d9e254250cf606..0892a05d627c0c092592cbd254b315600d322d7c 100644 (file)
@@ -6597,17 +6597,6 @@ bundles.
 If this macro is not defined, then @code{ASM_OUTPUT_INTERNAL_LABEL} will be
 used.
 
-@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
index eedea4a4e4a8d9b700e7c39b86b1ebbb82ef59dc..af537d257f075edff9cfc19502c1e62e2203c7de 100644 (file)
@@ -2185,14 +2185,8 @@ widen_memory_access (memref, mode, offset)
 rtx
 gen_label_rtx ()
 {
-  rtx label;
-
-  label = gen_rtx_CODE_LABEL (VOIDmode, 0, NULL_RTX, NULL_RTX,
-                             NULL, label_num++, NULL, NULL);
-
-  LABEL_NUSES (label) = 0;
-  LABEL_ALTERNATE_NAME (label) = NULL;
-  return label;
+  return gen_rtx_CODE_LABEL (VOIDmode, 0, NULL_RTX, NULL_RTX,
+                            NULL, label_num++, NULL);
 }
 \f
 /* For procedure integration.  */
index 3b3dfcd68b26115099ba57f5e98b0e82ef673b20..e0b38601dbfb6b3e1dd6a69edee69bbcb715f3db 100644 (file)
@@ -222,6 +222,7 @@ static void profile_after_prologue PARAMS ((FILE *));
 static void notice_source_line PARAMS ((rtx));
 static rtx walk_alter_subreg   PARAMS ((rtx *));
 static void output_asm_name    PARAMS ((void));
+static void output_alternate_entry_point PARAMS ((FILE *, rtx));
 static tree get_mem_expr_from_op       PARAMS ((rtx, int *));
 static void output_asm_operand_names PARAMS ((rtx *, int *, int));
 static void output_operand     PARAMS ((rtx, int));
@@ -1952,6 +1953,37 @@ get_insn_template (code, insn)
     }
 }
 
+/* Emit the appropriate declaration for an alternate-entry-point
+   symbol represented by INSN, to FILE.  INSN is a CODE_LABEL with
+   LABEL_KIND != LABEL_NORMAL.
+
+   The case fall-through in this function is intentional.  */
+static void
+output_alternate_entry_point (file, insn)
+     FILE *file;
+     rtx insn;
+{
+  const char *name = LABEL_NAME (insn);
+
+  switch (LABEL_KIND (insn))
+    {
+    case LABEL_WEAK_ENTRY:
+#ifdef ASM_WEAKEN_LABEL
+      ASM_WEAKEN_LABEL (file, name);
+#endif
+    case LABEL_GLOBAL_ENTRY:
+      ASM_GLOBALIZE_LABEL (file, name);
+    case LABEL_STATIC_ENTRY:
+      /* FIXME output a .type directive here if appropriate.  */
+      ASM_OUTPUT_LABEL (file, name);
+      break;
+
+    case LABEL_NORMAL:
+    default:
+      abort ();
+    }
+}
+
 /* The final scan for one insn, INSN.
    Args are same as in `final', except that INSN
    is the insn being scanned.
@@ -2242,17 +2274,14 @@ final_scan_insn (insn, file, optimize, prescan, nopeepholes)
              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));
+             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);
+      if (LABEL_ALT_ENTRY_P (insn))
+       output_alternate_entry_point (file, insn);
       else
        ASM_OUTPUT_INTERNAL_LABEL (file, "L", CODE_LABEL_NUMBER (insn));
       break;
index a6fedf6d3a6c946948a40ea9b732c8dc387becb4..15538052c1828ea1d5058bdba4330383d37fcd28 100644 (file)
@@ -526,9 +526,14 @@ print_rtx (in_rtx)
 
     case CODE_LABEL:
       fprintf (outfile, " [%d uses]", LABEL_NUSES (in_rtx));
-      if (LABEL_ALTERNATE_NAME (in_rtx))
-       fprintf (outfile, " [alternate name: %s]",
-                LABEL_ALTERNATE_NAME (in_rtx));
+      switch (LABEL_KIND (in_rtx))
+       {
+         case LABEL_NORMAL: break;
+         case LABEL_STATIC_ENTRY: fputs (" [entry]", outfile); break;
+         case LABEL_GLOBAL_ENTRY: fputs (" [global entry]", outfile); break;
+         case LABEL_WEAK_ENTRY: fputs (" [weak entry]", outfile); break;
+         default: abort();
+       }
       break;
 
     case CALL_PLACEHOLDER:
index 239778a240b4c1e571cb693983bb886b85264d9f..fd8c8d4bb5b61386516e71ba5b3c199819e5153d 100644 (file)
@@ -381,8 +381,14 @@ ra_print_rtx (file, x, with_pn)
          fprintf (file, "L%d:\t; ", CODE_LABEL_NUMBER (x));
          if (LABEL_NAME (x))
            fprintf (file, "(%s) ", LABEL_NAME (x));
-         if (LABEL_ALTERNATE_NAME (x))
-           fprintf (file, "(alternate: %s) ", LABEL_ALTERNATE_NAME (x));
+         switch (LABEL_KIND (x))
+           {
+           case LABEL_NORMAL: break;
+           case LABEL_STATIC_ENTRY: fputs (" (entry)", file); break;
+           case LABEL_GLOBAL_ENTRY: fputs (" (global entry)", file); break;
+           case LABEL_WEAK_ENTRY: fputs (" (weak entry)", file); break;
+           default: abort();
+           }
          fprintf (file, " [%d uses] uid=(", LABEL_NUSES (x));
        }
       fprintf (file, "%d", INSN_UID (x));
index 1acbf983589ae9dab2f26cf4d785134b8e13e55f..2934188c70b255fabf05c8e4b9afcb67a036f1e5 100644 (file)
@@ -573,10 +573,9 @@ DEF_RTL_EXPR(BARRIER, "barrier", "iuu", 'x')
    4: is used in jump.c for the use-count of the label.
    5: is used in flow.c to point to the chain of label_ref's to this label.
    6: is a number that is unique in the entire compilation.
-   7: is the user-given name of the label, if any.
-   8: is the alternate label name.  */
-DEF_RTL_EXPR(CODE_LABEL, "code_label", "iuuB00iss", 'x')
-     
+   7: is the user-given name of the label, if any.  */
+DEF_RTL_EXPR(CODE_LABEL, "code_label", "iuuB00is", 'x')
+
 /* Say where in the code a source line starts, for symbol table's sake.
    Operand:
    4: filename, if line number > 0, note-specific data otherwise.
index 31032b6e2177f2b2ad49105ae45abe827bf993c9..9490dd7fb8b6ff35da1b59dd6c7d2b2214c921db 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -130,9 +130,10 @@ struct rtx_def
   /* 1 in a MEM if we should keep the alias set for this mem unchanged
      when we access a component.
      1 in a CALL_INSN if it is a sibling call.
-     1 in a SET that is for a return.  */
+     1 in a SET that is for a return.
+     In a CODE_LABEL, part of the two-bit alternate entry field.  */
   unsigned int jump : 1;
-  /* This flag is currently unused.  */
+  /* In a CODE_LABEL, part of the two-bit alternate entry field.  */
   unsigned int call : 1;
   /* 1 in a REG, MEM, or CONCAT if the value is set at most once, anywhere.
      1 in a SUBREG if it references an unsigned object whose mode has been
@@ -876,8 +877,55 @@ extern const char * const note_insn_name[NOTE_INSN_MAX - NOTE_INSN_BIAS];
    of LABEL_REFs that point at it, so unused labels can be deleted.  */
 #define LABEL_NUSES(RTX) XCINT (RTX, 4, CODE_LABEL)
 
-/* Associate a name with a CODE_LABEL.  */
-#define LABEL_ALTERNATE_NAME(RTX) XCSTR (RTX, 8, CODE_LABEL)
+/* Labels carry a two-bit field composed of the ->jump and ->call
+   bits.  This field indicates whether the label is an alternate
+   entry point, and if so, what kind.  */
+enum label_kind
+{
+  LABEL_NORMAL = 0,    /* ordinary label */
+  LABEL_STATIC_ENTRY,  /* alternate entry point, not exported */
+  LABEL_GLOBAL_ENTRY,  /* alternate entry point, exported */
+  LABEL_WEAK_ENTRY     /* alternate entry point, exported as weak symbol */
+};
+
+#if defined ENABLE_RTL_FLAG_CHECKING && (GCC_VERSION > 2007)
+
+/* Retrieve the kind of LABEL.  */
+#define LABEL_KIND(LABEL) __extension__                                        \
+({ rtx const _label = (LABEL);                                         \
+   if (GET_CODE (_label) != CODE_LABEL)                                        \
+     rtl_check_failed_flag ("LABEL_KIND", _label, __FILE__, __LINE__,  \
+                           __FUNCTION__);                              \
+   (enum label_kind) ((_label->jump << 1) | _label->call); })
+
+/* Set the kind of LABEL.  */
+#define SET_LABEL_KIND(LABEL, KIND) do {                               \
+   rtx _label = (LABEL);                                               \
+   unsigned int _kind = (KIND);                                                \
+   if (GET_CODE (_label) != CODE_LABEL)                                        \
+     rtl_check_failed_flag ("SET_LABEL_KIND", _label, __FILE__, __LINE__, \
+                           __FUNCTION__);                              \
+   _label->jump = ((_kind >> 1) & 1);                                  \
+   _label->call = (_kind & 1);                                         \
+} while (0)
+
+#else
+
+/* Retrieve the kind of LABEL.  */
+#define LABEL_KIND(LABEL) \
+   ((enum label_kind) (((LABEL)->jump << 1) | (LABEL)->call))
+
+/* Set the kind of LABEL.  */
+#define SET_LABEL_KIND(LABEL, KIND) do {                               \
+   rtx _label = (LABEL);                                               \
+   unsigned int _kind = (KIND);                                                \
+   _label->jump = ((_kind >> 1) & 1);                                  \
+   _label->call = (_kind & 1);                                         \
+} while (0)
+
+#endif /* rtl flag checking */
+
+#define LABEL_ALT_ENTRY_P(LABEL) (LABEL_KIND (LABEL) != LABEL_NORMAL)
 
 /* The original regno this ADDRESSOF was built for.  */
 #define ADDRESSOF_REGNO(RTX) XCUINT (RTX, 1, ADDRESSOF)