diff options
author | Richard Henderson <rth@redhat.com> | 2003-04-11 14:15:36 -0700 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2003-04-11 14:15:36 -0700 |
commit | 52859c77e9752203d3d551275df65d4d6f223df8 (patch) | |
tree | f675f00c76e2ef9d9b6ec56014ab50bc39c69884 | |
parent | 68d28100a03d7a4bb0f5763f6478c2c84bf4e2ab (diff) | |
download | gcc-52859c77e9752203d3d551275df65d4d6f223df8.zip gcc-52859c77e9752203d3d551275df65d4d6f223df8.tar.gz gcc-52859c77e9752203d3d551275df65d4d6f223df8.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 21 | ||||
-rw-r--r-- | gcc/gengtype.c | 4 | ||||
-rw-r--r-- | gcc/optabs.c | 11 | ||||
-rw-r--r-- | gcc/output.h | 1 | ||||
-rw-r--r-- | gcc/print-rtl.c | 17 | ||||
-rw-r--r-- | gcc/rtl.def | 10 | ||||
-rw-r--r-- | gcc/rtl.h | 40 | ||||
-rw-r--r-- | gcc/target-def.h | 2 | ||||
-rw-r--r-- | gcc/varasm.c | 71 |
9 files changed, 155 insertions, 22 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 300f4e0..7baa961 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,26 @@ 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. (setbits_libfunc, gcov_flush_libfunc, gcov_init_libfunc): New. * optabs.c (init_optabs): Initialize them. diff --git a/gcc/gengtype.c b/gcc/gengtype.c index 73c9580..4a3c298 100644 --- a/gcc/gengtype.c +++ b/gcc/gengtype.c @@ -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 diff --git a/gcc/optabs.c b/gcc/optabs.c index fc00b18..59f7147 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -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 diff --git a/gcc/output.h b/gcc/output.h index 18e0b23..5f70c7a 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -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)); diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c index 26259e1..4c159f1 100644 --- a/gcc/print-rtl.c +++ b/gcc/print-rtl.c @@ -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)) { diff --git a/gcc/rtl.def b/gcc/rtl.def index b208724..97fa413 100644 --- a/gcc/rtl.def +++ b/gcc/rtl.def @@ -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. @@ -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. */ diff --git a/gcc/target-def.h b/gcc/target-def.h index 86774c1..eef6b23 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -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. */ diff --git a/gcc/varasm.c b/gcc/varasm.c index 0289a7c..04df7ae 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -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 @@ -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. */ |