Commit 52859c77 by Richard Henderson Committed by Richard Henderson

rtl.def (SYMBOL_REF): Add two 0 fields.

        * 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
parent 68d28100
2003-04-11 Richard Henderson <rth@redhat.com> 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. * libfuncs.h (LTI_setbits, LTI_gcov_flush, LTI_gcov_init): New.
(setbits_libfunc, gcov_flush_libfunc, gcov_init_libfunc): New. (setbits_libfunc, gcov_flush_libfunc, gcov_init_libfunc): New.
* optabs.c (init_optabs): Initialize them. * optabs.c (init_optabs): Initialize them.
......
...@@ -544,6 +544,10 @@ adjust_field_rtx_def (t, opt) ...@@ -544,6 +544,10 @@ adjust_field_rtx_def (t, opt)
t = reg_attrs_tp, subname = "rtreg"; t = reg_attrs_tp, subname = "rtreg";
else if (i == SCRATCH && aindex == 0) else if (i == SCRATCH && aindex == 0)
t = scalar_tp, subname = "rtint"; 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) else if (i == BARRIER && aindex >= 3)
t = scalar_tp, subname = "rtint"; t = scalar_tp, subname = "rtint";
else else
......
...@@ -5381,6 +5381,8 @@ rtx ...@@ -5381,6 +5381,8 @@ rtx
init_one_libfunc (name) init_one_libfunc (name)
const char *name; const char *name;
{ {
rtx symbol;
/* Create a FUNCTION_DECL that can be passed to /* Create a FUNCTION_DECL that can be passed to
targetm.encode_section_info. */ targetm.encode_section_info. */
/* ??? We don't have any type information except for this is /* ??? We don't have any type information except for this is
...@@ -5391,8 +5393,13 @@ init_one_libfunc (name) ...@@ -5391,8 +5393,13 @@ init_one_libfunc (name)
DECL_EXTERNAL (decl) = 1; DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 1; TREE_PUBLIC (decl) = 1;
/* Return the symbol_ref from the mem rtx. */ symbol = XEXP (DECL_RTL (decl), 0);
return 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 /* Call this once to initialize the contents of the optabs
......
...@@ -519,6 +519,7 @@ extern void default_select_rtx_section PARAMS ((enum machine_mode, rtx, ...@@ -519,6 +519,7 @@ extern void default_select_rtx_section PARAMS ((enum machine_mode, rtx,
unsigned HOST_WIDE_INT)); unsigned HOST_WIDE_INT));
extern void default_elf_select_rtx_section PARAMS ((enum machine_mode, rtx, extern void default_elf_select_rtx_section PARAMS ((enum machine_mode, rtx,
unsigned HOST_WIDE_INT)); unsigned HOST_WIDE_INT));
extern void default_encode_section_info PARAMS ((tree, int));
extern const char *default_strip_name_encoding PARAMS ((const char *)); extern const char *default_strip_name_encoding PARAMS ((const char *));
extern bool default_binds_local_p PARAMS ((tree)); extern bool default_binds_local_p PARAMS ((tree));
extern bool default_binds_local_p_1 PARAMS ((tree, int)); extern bool default_binds_local_p_1 PARAMS ((tree, int));
......
...@@ -239,9 +239,22 @@ print_rtx (in_rtx) ...@@ -239,9 +239,22 @@ print_rtx (in_rtx)
{ {
if (REGNO (in_rtx) != ORIGINAL_REGNO (in_rtx)) if (REGNO (in_rtx) != ORIGINAL_REGNO (in_rtx))
fprintf (outfile, " [%d]", 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)) switch (NOTE_LINE_NUMBER (in_rtx))
{ {
......
...@@ -860,11 +860,11 @@ DEF_RTL_EXPR(MEM, "mem", "e0", 'o') ...@@ -860,11 +860,11 @@ DEF_RTL_EXPR(MEM, "mem", "e0", 'o')
LABEL_NEXTREF and CONTAINING_INSN. */ LABEL_NEXTREF and CONTAINING_INSN. */
DEF_RTL_EXPR(LABEL_REF, "label_ref", "u00", 'o') DEF_RTL_EXPR(LABEL_REF, "label_ref", "u00", 'o')
/* Reference to a named label: the string that is the first operand, /* Reference to a named label:
with `_' added implicitly in front. Operand 0: label name
Exception: if the first character explicitly given is `*', Operand 1: flags (see SYMBOL_FLAG_* in rtl.h)
to give it to the assembler, remove the `*' and do not add `_'. */ Operand 2: tree decl from which this symbol is derived, or null. */
DEF_RTL_EXPR(SYMBOL_REF, "symbol_ref", "s", 'o') DEF_RTL_EXPR(SYMBOL_REF, "symbol_ref", "s00", 'o')
/* The condition code register is represented, in our imagination, /* The condition code register is represented, in our imagination,
as a register holding a value that can be compared to zero. as a register holding a value that can be compared to zero.
......
...@@ -1245,6 +1245,46 @@ do { \ ...@@ -1245,6 +1245,46 @@ do { \
#define SYMBOL_REF_WEAK(RTX) \ #define SYMBOL_REF_WEAK(RTX) \
(RTL_FLAG_CHECK1("SYMBOL_REF_WEAK", (RTX), SYMBOL_REF)->integrated) (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, /* Define a macro to look for REG_INC notes,
but save time on machines where they never exist. */ but save time on machines where they never exist. */
......
...@@ -280,7 +280,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -280,7 +280,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif #endif
#ifndef TARGET_ENCODE_SECTION_INFO #ifndef TARGET_ENCODE_SECTION_INFO
#define TARGET_ENCODE_SECTION_INFO hook_void_tree_int #define TARGET_ENCODE_SECTION_INFO default_encode_section_info
#endif #endif
/* The whole shebang. */ /* The whole shebang. */
......
...@@ -920,8 +920,11 @@ make_decl_rtl (decl, asmspec) ...@@ -920,8 +920,11 @@ make_decl_rtl (decl, asmspec)
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
} }
x = gen_rtx_MEM (DECL_MODE (decl), gen_rtx_SYMBOL_REF (Pmode, name)); x = gen_rtx_SYMBOL_REF (Pmode, name);
SYMBOL_REF_WEAK (XEXP (x, 0)) = DECL_WEAK (decl); 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) if (TREE_CODE (decl) != FUNCTION_DECL)
set_mem_attributes (x, decl, 1); set_mem_attributes (x, decl, 1);
SET_DECL_RTL (decl, x); SET_DECL_RTL (decl, x);
...@@ -1765,6 +1768,7 @@ assemble_static_space (size) ...@@ -1765,6 +1768,7 @@ assemble_static_space (size)
namestring = ggc_strdup (name); namestring = ggc_strdup (name);
x = gen_rtx_SYMBOL_REF (Pmode, namestring); x = gen_rtx_SYMBOL_REF (Pmode, namestring);
SYMBOL_REF_FLAGS (x) = SYMBOL_FLAG_LOCAL;
#ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL #ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, NULL_TREE, name, size, ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, NULL_TREE, name, size,
...@@ -1799,6 +1803,7 @@ assemble_trampoline_template () ...@@ -1799,6 +1803,7 @@ assemble_trampoline_template ()
char label[256]; char label[256];
const char *name; const char *name;
int align; int align;
rtx symbol;
/* By default, put trampoline templates in read-only data section. */ /* By default, put trampoline templates in read-only data section. */
...@@ -1821,7 +1826,10 @@ assemble_trampoline_template () ...@@ -1821,7 +1826,10 @@ assemble_trampoline_template ()
/* Record the rtl to refer to it. */ /* Record the rtl to refer to it. */
ASM_GENERATE_INTERNAL_LABEL (label, "LTRAMP", 0); ASM_GENERATE_INTERNAL_LABEL (label, "LTRAMP", 0);
name = ggc_strdup (label); 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 #endif
...@@ -2650,6 +2658,8 @@ output_constant_def (exp, defer) ...@@ -2650,6 +2658,8 @@ output_constant_def (exp, defer)
if (desc == 0) if (desc == 0)
{ {
rtx symbol;
/* No constant equal to EXP is known to have been output. /* No constant equal to EXP is known to have been output.
Make a constant descriptor to enter EXP in the hash table. Make a constant descriptor to enter EXP in the hash table.
Assign the label number and record it in the descriptor for Assign the label number and record it in the descriptor for
...@@ -2666,9 +2676,10 @@ output_constant_def (exp, defer) ...@@ -2666,9 +2676,10 @@ output_constant_def (exp, defer)
const_hash_table[hash] = desc; const_hash_table[hash] = desc;
/* We have a symbol name; construct the SYMBOL_REF and the MEM. */ /* We have a symbol name; construct the SYMBOL_REF and the MEM. */
rtl = desc->rtl symbol = gen_rtx_SYMBOL_REF (Pmode, desc->label);
= gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)), SYMBOL_REF_FLAGS (symbol) = SYMBOL_FLAG_LOCAL;
gen_rtx_SYMBOL_REF (Pmode, desc->label));
rtl = desc->rtl = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)), symbol);
set_mem_attributes (rtl, exp, 1); set_mem_attributes (rtl, exp, 1);
set_mem_alias_set (rtl, 0); set_mem_alias_set (rtl, 0);
...@@ -3173,7 +3184,7 @@ force_const_mem (mode, x) ...@@ -3173,7 +3184,7 @@ force_const_mem (mode, x)
int hash; int hash;
struct constant_descriptor_rtx *desc; struct constant_descriptor_rtx *desc;
char label[256]; char label[256];
rtx def; rtx def, symbol;
struct pool_constant *pool; struct pool_constant *pool;
unsigned int align; unsigned int align;
...@@ -3234,19 +3245,21 @@ force_const_mem (mode, x) ...@@ -3234,19 +3245,21 @@ force_const_mem (mode, x)
/* Construct the SYMBOL_REF and the MEM. */ /* Construct the SYMBOL_REF and the MEM. */
pool->desc->rtl = def symbol = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (label));
= gen_rtx_MEM (mode, gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (label))); SYMBOL_REF_FLAGS (symbol) = SYMBOL_FLAG_LOCAL;
set_mem_alias_set (def, const_alias_set);
pool->desc->rtl = def = gen_rtx_MEM (mode, symbol);
set_mem_attributes (def, (*lang_hooks.types.type_for_mode) (mode, 0), 1); set_mem_attributes (def, (*lang_hooks.types.type_for_mode) (mode, 0), 1);
RTX_UNCHANGING_P (def) = 1; RTX_UNCHANGING_P (def) = 1;
/* Add label to symbol hash table. */ /* 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]; pool->next_sym = const_rtx_sym_hash_table[hash];
const_rtx_sym_hash_table[hash] = pool; const_rtx_sym_hash_table[hash] = pool;
/* Mark the symbol_ref as belonging to this constants 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; current_function_uses_const_pool = 1;
return def; return def;
...@@ -5370,6 +5383,40 @@ default_elf_select_rtx_section (mode, x, align) ...@@ -5370,6 +5383,40 @@ default_elf_select_rtx_section (mode, x, align)
mergeable_constant_section (mode, align, 0); 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 /* By default, we do nothing for encode_section_info, so we need not
do anything but discard the '*' marker. */ do anything but discard the '*' marker. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment