]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rtl.def (SYMBOL_REF): Add two 0 fields.
authorRichard Henderson <rth@redhat.com>
Fri, 11 Apr 2003 21:15:36 +0000 (14:15 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Fri, 11 Apr 2003 21:15:36 +0000 (14:15 -0700)
        * rtl.def (SYMBOL_REF): Add two 0 fields.
        * gengtype.c (adjust_field_rtx_def): Handle them.
        * print-rtl.c (print_rtx): Print them.
        * rtl.h (SYMBOL_REF_DECL, SYMBOL_REF_FLAGS): New.
        (SYMBOL_FLAG_FUNCTION, SYMBOL_REF_FUNCTION_P): New.
        (SYMBOL_FLAG_LOCAL, SYMBOL_REF_LOCAL_P): New.
        (SYMBOL_FLAG_SMALL, SYMBOL_REF_SMALL_P): New.
        (SYMBOL_FLAG_TLS_SHIFT, SYMBOL_REF_TLS_MODEL): New.
        (SYMBOL_FLAG_EXTERNAL, SYMBOL_REF_EXTERNAL_P): New.
        (SYMBOL_FLAG_MACH_DEP): New.
        * optabs.c (init_one_libfunc): Zap fake SYMBOL_REF_DECL.
        * varasm.c (make_decl_rtl): Set SYMBOL_REF_DECL.
        (assemble_static_space): Set SYMBOL_REF_FLAGS.
        (assemble_trampoline_template): Likewise.
        (output_constant_def, force_const_mem): Likewise.
        (default_encode_section_info): New.
        * output.h: Declare it.
        * target-def.h (TARGET_ENCODE_SECTION_INFO): Use it.

From-SVN: r65479

gcc/ChangeLog
gcc/gengtype.c
gcc/optabs.c
gcc/output.h
gcc/print-rtl.c
gcc/rtl.def
gcc/rtl.h
gcc/target-def.h
gcc/varasm.c

index 300f4e096f1b90a8788d9585faec73fb6772fa67..7baa961fe29080ef164a1b32d9a8caf6369be112 100644 (file)
@@ -1,3 +1,24 @@
+2003-04-11  Richard Henderson  <rth@redhat.com>
+
+       * rtl.def (SYMBOL_REF): Add two 0 fields.
+       * gengtype.c (adjust_field_rtx_def): Handle them.
+       * print-rtl.c (print_rtx): Print them.
+       * rtl.h (SYMBOL_REF_DECL, SYMBOL_REF_FLAGS): New.
+       (SYMBOL_FLAG_FUNCTION, SYMBOL_REF_FUNCTION_P): New.
+       (SYMBOL_FLAG_LOCAL, SYMBOL_REF_LOCAL_P): New.
+       (SYMBOL_FLAG_SMALL, SYMBOL_REF_SMALL_P): New.
+       (SYMBOL_FLAG_TLS_SHIFT, SYMBOL_REF_TLS_MODEL): New.
+       (SYMBOL_FLAG_EXTERNAL, SYMBOL_REF_EXTERNAL_P): New.
+       (SYMBOL_FLAG_MACH_DEP): New.
+       * optabs.c (init_one_libfunc): Zap fake SYMBOL_REF_DECL.
+       * varasm.c (make_decl_rtl): Set SYMBOL_REF_DECL.
+       (assemble_static_space): Set SYMBOL_REF_FLAGS.
+       (assemble_trampoline_template): Likewise.
+       (output_constant_def, force_const_mem): Likewise.
+       (default_encode_section_info): New.
+       * output.h: Declare it.
+       * target-def.h (TARGET_ENCODE_SECTION_INFO): Use it.
+
 2003-04-11  Richard Henderson  <rth@redhat.com>
 
        * libfuncs.h (LTI_setbits, LTI_gcov_flush, LTI_gcov_init): New.
index 73c9580b655f6c1139ab19318aba3b833350afd3..4a3c29853eb7e0354ee35b6999cdfc35f32778f3 100644 (file)
@@ -544,6 +544,10 @@ adjust_field_rtx_def (t, opt)
                t = reg_attrs_tp, subname = "rtreg";
              else if (i == SCRATCH && aindex == 0)
                t = scalar_tp, subname = "rtint";
+             else if (i == SYMBOL_REF && aindex == 1)
+               t = scalar_tp, subname = "rtint";
+             else if (i == SYMBOL_REF && aindex == 2)
+               t = tree_tp, subname = "rttree";
              else if (i == BARRIER && aindex >= 3)
                t = scalar_tp, subname = "rtint";
              else
index fc00b186dee6dedf36657aaf9bb917399ece97df..59f714714e01f5966e5eb5881bf2bdbb4b6f9f9c 100644 (file)
@@ -5381,6 +5381,8 @@ rtx
 init_one_libfunc (name)
      const char *name;
 {
+  rtx symbol;
+
   /* Create a FUNCTION_DECL that can be passed to
      targetm.encode_section_info.  */
   /* ??? We don't have any type information except for this is
@@ -5391,8 +5393,13 @@ init_one_libfunc (name)
   DECL_EXTERNAL (decl) = 1;
   TREE_PUBLIC (decl) = 1;
 
-  /* Return the symbol_ref from the mem rtx.  */
-  return XEXP (DECL_RTL (decl), 0);
+  symbol = XEXP (DECL_RTL (decl), 0);
+
+  /* Zap the nonsensical SYMBOL_REF_DECL for this.  What we're left with
+     are the flags assigned by targetm.encode_section_info.  */
+  SYMBOL_REF_DECL (symbol) = 0;
+
+  return symbol;
 }
 
 /* Call this once to initialize the contents of the optabs
index 18e0b230712fe7b3e765e29016ec336a8632f2d7..5f70c7a748e47d5f703d67f1faedd2359bb0b5da 100644 (file)
@@ -519,6 +519,7 @@ extern void default_select_rtx_section PARAMS ((enum machine_mode, rtx,
                                                unsigned HOST_WIDE_INT));
 extern void default_elf_select_rtx_section PARAMS ((enum machine_mode, rtx,
                                                    unsigned HOST_WIDE_INT));
+extern void default_encode_section_info PARAMS ((tree, int));
 extern const char *default_strip_name_encoding PARAMS ((const char *));
 extern bool default_binds_local_p PARAMS ((tree));
 extern bool default_binds_local_p_1 PARAMS ((tree, int));
index 26259e157234ca19892ead89403998abbb26bf7b..4c159f123bf8e3f01c41797dffa9c2ac658cf44f 100644 (file)
@@ -239,9 +239,22 @@ print_rtx (in_rtx)
          {
            if (REGNO (in_rtx) != ORIGINAL_REGNO (in_rtx))
              fprintf (outfile, " [%d]", ORIGINAL_REGNO (in_rtx));
-           break;
          }
-       if (i == 4 && GET_CODE (in_rtx) == NOTE)
+#ifndef GENERATOR_FILE
+       else if (i == 1 && GET_CODE (in_rtx) == SYMBOL_REF)
+         {
+           int flags = SYMBOL_REF_FLAGS (in_rtx);
+           if (flags)
+             fprintf (outfile, " [flags 0x%x]", flags);
+         }
+       else if (i == 2 && GET_CODE (in_rtx) == SYMBOL_REF)
+         {
+           tree decl = SYMBOL_REF_DECL (in_rtx);
+           if (decl)
+             print_node_brief (outfile, "", decl, 0);
+         }
+#endif
+       else if (i == 4 && GET_CODE (in_rtx) == NOTE)
          {
            switch (NOTE_LINE_NUMBER (in_rtx))
              {
index b2087241e171d4daace95cf3121d826618e19d95..97fa41340996572fe20ed3ef893ebf176d3f4f15 100644 (file)
@@ -860,11 +860,11 @@ DEF_RTL_EXPR(MEM, "mem", "e0", 'o')
    LABEL_NEXTREF and CONTAINING_INSN.  */
 DEF_RTL_EXPR(LABEL_REF, "label_ref", "u00", 'o')
 
-/* Reference to a named label: the string that is the first operand,
-   with `_' added implicitly in front.
-   Exception: if the first character explicitly given is `*',
-   to give it to the assembler, remove the `*' and do not add `_'.  */
-DEF_RTL_EXPR(SYMBOL_REF, "symbol_ref", "s", 'o')
+/* Reference to a named label: 
+   Operand 0: label name
+   Operand 1: flags (see SYMBOL_FLAG_* in rtl.h)
+   Operand 2: tree decl from which this symbol is derived, or null.  */
+DEF_RTL_EXPR(SYMBOL_REF, "symbol_ref", "s00", 'o')
 
 /* The condition code register is represented, in our imagination,
    as a register holding a value that can be compared to zero.
index 9174bf71f43e252ace3d06d0fe59f3d80657bc9b..fa5ef84963c01829505892f138f9ffc816a196b2 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -1245,6 +1245,46 @@ do {                                             \
 #define SYMBOL_REF_WEAK(RTX)                                           \
   (RTL_FLAG_CHECK1("SYMBOL_REF_WEAK", (RTX), SYMBOL_REF)->integrated)
 
+/* The tree decl associated with the symbol, or null.  */
+#define SYMBOL_REF_DECL(RTX)   X0TREE ((RTX), 2)
+
+/* A set of flags on a symbol_ref that are, in some respects, redundant with
+   information derivable from the tree decl associated with this symbol.
+   Except that we build a *lot* of SYMBOL_REFs that aren't associated with a
+   decl.  In some cases this is a bug.  But beyond that, it's nice to cache
+   this information to avoid recomputing it.  Finally, this allows space for
+   the target to store more than one bit of information, as with
+   SYMBOL_REF_FLAG.  */
+#define SYMBOL_REF_FLAGS(RTX)  X0INT ((RTX), 1)
+
+/* These flags are common enough to be defined for all targets.  They
+   are computed by the default version of targetm.encode_section_info.  */
+
+/* Set if this symbol is a function.  */
+#define SYMBOL_FLAG_FUNCTION   (1 << 0)
+#define SYMBOL_REF_FUNCTION_P(RTX) \
+  ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_FUNCTION) != 0)
+/* Set if targetm.binds_local_p is true.  */
+#define SYMBOL_FLAG_LOCAL      (1 << 1)
+#define SYMBOL_REF_LOCAL_P(RTX) \
+  ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_LOCAL) != 0)
+/* Set if targetm.in_small_data_p is true.  */
+#define SYMBOL_FLAG_SMALL      (1 << 2)
+#define SYMBOL_REF_SMALL_P(RTX) \
+  ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_SMALL) != 0)
+/* The three-bit field at [5:3] is true for TLS variables; use
+   SYMBOL_REF_TLS_MODEL to extract the field as an enum tls_model.  */
+#define SYMBOL_FLAG_TLS_SHIFT  3
+#define SYMBOL_REF_TLS_MODEL(RTX) \
+  ((enum tls_model) ((SYMBOL_REF_FLAGS (RTX) >> SYMBOL_FLAG_TLS_SHIFT) & 3))
+/* Set if this symbol is not defined in this translation unit.  */
+#define SYMBOL_FLAG_EXTERNAL   (1 << 6)
+#define SYMBOL_REF_EXTERNAL_P(RTX) \
+  ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_EXTERNAL) != 0)
+
+/* Subsequent bits are available for the target to use.  */
+#define SYMBOL_FLAG_MACH_DEP   (1 << 7)
+
 /* Define a macro to look for REG_INC notes,
    but save time on machines where they never exist.  */
 
index 86774c1d59ea8f220ee394fdf426cf036c7b6aa8..eef6b23e750c7c4fc2d7435aa544d2b3e0a38f03 100644 (file)
@@ -280,7 +280,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #endif
 
 #ifndef TARGET_ENCODE_SECTION_INFO
-#define TARGET_ENCODE_SECTION_INFO hook_void_tree_int
+#define TARGET_ENCODE_SECTION_INFO default_encode_section_info
 #endif
 
 /* The whole shebang.  */
index 0289a7c9fca241fd9038424fadf6a2b5a3af1c1f..04df7ae02b48d008403aad95f2a9e04237ede58c 100644 (file)
@@ -920,8 +920,11 @@ make_decl_rtl (decl, asmspec)
       name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
     }
 
-  x = gen_rtx_MEM (DECL_MODE (decl), gen_rtx_SYMBOL_REF (Pmode, name));
-  SYMBOL_REF_WEAK (XEXP (x, 0)) = DECL_WEAK (decl);
+  x = gen_rtx_SYMBOL_REF (Pmode, name);
+  SYMBOL_REF_WEAK (x) = DECL_WEAK (decl);
+  SYMBOL_REF_DECL (x) = decl;
+  
+  x = gen_rtx_MEM (DECL_MODE (decl), x);
   if (TREE_CODE (decl) != FUNCTION_DECL)
     set_mem_attributes (x, decl, 1);
   SET_DECL_RTL (decl, x);
@@ -1765,6 +1768,7 @@ assemble_static_space (size)
   namestring = ggc_strdup (name);
 
   x = gen_rtx_SYMBOL_REF (Pmode, namestring);
+  SYMBOL_REF_FLAGS (x) = SYMBOL_FLAG_LOCAL;
 
 #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
   ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, NULL_TREE, name, size,
@@ -1799,6 +1803,7 @@ assemble_trampoline_template ()
   char label[256];
   const char *name;
   int align;
+  rtx symbol;
 
   /* By default, put trampoline templates in read-only data section.  */
 
@@ -1821,7 +1826,10 @@ assemble_trampoline_template ()
   /* Record the rtl to refer to it.  */
   ASM_GENERATE_INTERNAL_LABEL (label, "LTRAMP", 0);
   name = ggc_strdup (label);
-  return gen_rtx_SYMBOL_REF (Pmode, name);
+  symbol = gen_rtx_SYMBOL_REF (Pmode, name);
+  SYMBOL_REF_FLAGS (symbol) = SYMBOL_FLAG_LOCAL;
+
+  return symbol;
 }
 #endif
 \f
@@ -2650,6 +2658,8 @@ output_constant_def (exp, defer)
 
   if (desc == 0)
     {
+      rtx symbol;
+
       /* No constant equal to EXP is known to have been output.
         Make a constant descriptor to enter EXP in the hash table.
         Assign the label number and record it in the descriptor for
@@ -2666,9 +2676,10 @@ output_constant_def (exp, defer)
       const_hash_table[hash] = desc;
 
       /* We have a symbol name; construct the SYMBOL_REF and the MEM.  */
-      rtl = desc->rtl
-       = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)),
-                      gen_rtx_SYMBOL_REF (Pmode, desc->label));
+      symbol = gen_rtx_SYMBOL_REF (Pmode, desc->label);
+      SYMBOL_REF_FLAGS (symbol) = SYMBOL_FLAG_LOCAL;
+
+      rtl = desc->rtl = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)), symbol);
 
       set_mem_attributes (rtl, exp, 1);
       set_mem_alias_set (rtl, 0);
@@ -3173,7 +3184,7 @@ force_const_mem (mode, x)
   int hash;
   struct constant_descriptor_rtx *desc;
   char label[256];
-  rtx def;
+  rtx def, symbol;
   struct pool_constant *pool;
   unsigned int align;
 
@@ -3234,19 +3245,21 @@ force_const_mem (mode, x)
 
   /* Construct the SYMBOL_REF and the MEM.  */
 
-  pool->desc->rtl = def
-    = gen_rtx_MEM (mode, gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (label)));
-  set_mem_alias_set (def, const_alias_set);
+  symbol = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (label));
+  SYMBOL_REF_FLAGS (symbol) = SYMBOL_FLAG_LOCAL;
+
+  pool->desc->rtl = def = gen_rtx_MEM (mode, symbol);
   set_mem_attributes (def, (*lang_hooks.types.type_for_mode) (mode, 0), 1);
   RTX_UNCHANGING_P (def) = 1;
 
   /* Add label to symbol hash table.  */
-  hash = SYMHASH (XSTR (XEXP (def, 0), 0));
+  hash = SYMHASH (XSTR (symbol, 0));
   pool->next_sym = const_rtx_sym_hash_table[hash];
   const_rtx_sym_hash_table[hash] = pool;
 
   /* Mark the symbol_ref as belonging to this constants pool.  */
-  CONSTANT_POOL_ADDRESS_P (XEXP (def, 0)) = 1;
+  CONSTANT_POOL_ADDRESS_P (symbol) = 1;
+  SYMBOL_REF_FLAGS (symbol) = SYMBOL_FLAG_LOCAL;
   current_function_uses_const_pool = 1;
 
   return def;
@@ -5370,6 +5383,40 @@ default_elf_select_rtx_section (mode, x, align)
   mergeable_constant_section (mode, align, 0);
 }
 
+/* Set the generally applicable flags on the SYMBOL_REF for EXP.  */
+
+void
+default_encode_section_info (decl, first)
+     tree decl;
+     int first ATTRIBUTE_UNUSED;
+{
+  rtx rtl, symbol;
+  int flags;
+
+  rtl = DECL_P (decl) ? DECL_RTL (decl) : TREE_CST_RTL (decl);
+
+  /* Careful not to prod global register variables.  */
+  if (GET_CODE (rtl) != MEM)
+    return;
+  symbol = XEXP (rtl, 0);
+  if (GET_CODE (symbol) != SYMBOL_REF)
+    return;
+
+  flags = 0;
+  if (TREE_CODE (decl) == FUNCTION_DECL)
+    flags |= SYMBOL_FLAG_FUNCTION;
+  if ((*targetm.binds_local_p) (decl))
+    flags |= SYMBOL_FLAG_LOCAL;
+  if ((*targetm.in_small_data_p) (decl))
+    flags |= SYMBOL_FLAG_SMALL;
+  if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL (decl))
+    flags |= decl_tls_model (decl) << SYMBOL_FLAG_TLS_SHIFT;
+  if (DECL_P (decl) && DECL_EXTERNAL (decl))
+    flags |= SYMBOL_FLAG_EXTERNAL;
+
+  SYMBOL_REF_FLAGS (symbol) = flags;
+}
+
 /* By default, we do nothing for encode_section_info, so we need not
    do anything but discard the '*' marker.  */