From c185c79706795682a35d3b15df2ff3b7e1f2138b Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 25 Jan 2006 09:10:56 +0000 Subject: rtl.texi (SYMBOL_REF_CONSTANT, [...]): Document. * doc/rtl.texi (SYMBOL_REF_CONSTANT, SYMBOL_REF_DATA): Document. * gengtype.c (adjust_field_rtx_def): Garbage-collect field 2 of a SYMBOL_REF as either a tree or a constant_descriptor_rtx, depending on the value of CONSTANT_POOL_ADDRESS_P. * optabs.c (init_one_libfunc): Nullify SYMBOL_REF_DATA rather than SYMBOL_REF_DECL. * varasm.c (make_decl_rtl, build_constant_desc): Set SYMBOL_REF_DATA rather than SYMBOL_REF_DECL. (rtx_constant_pool): Remove const_rtx_sym_htab. (const_desc_rtx_sym_hash, const_desc_rtx_sym_eq): Delete. (init_varasm_status): Don't initialize const_rtx_sym_htab. (force_const_mem): Point SYMBOL_REF_DATA to the constant pool entry. Remove handling of const_rtx_sym_htab. (find_pool_constant): Delete. (get_pool_constant, get_pool_constant_mark): Use SYMBOL_REF_CONSTANT rather than find_pool_constant. (get_pool_constant_for_function): Delete. (get_pool_mode, mark_constant): Use SYMBOL_REF_CONSTANT rather than find_pool_constant. * rtl.h (rtunion_def): Add rt_constant and rt_ptr fields. (X0CONSTANT, X0PTR, SYMBOL_REF_DATA): New macros. (SYMBOL_REF_DECL): Return NULL if CONSTANT_POOL_ADDRESS_P. (SYMBOL_REF_CONSTANT): New macro. (get_pool_constant_for_function): Delete. * config/i386/winnt.c (i386_pe_mark_dllexport): Set SYMBOL_REF_DATA rather than SYMBOL_REF_DECL. (i386_pe_mark_dllimport): Likewise. * config/rs6000/rs6000.c (rs6000_emit_move): Copy SYMBOL_REF_DATA rather than SYMBOL_REF_DECL. * config/darwin.c (machopic_indirect_data_reference): Likewise. (machopic_indirect_call_target): Likewise. From-SVN: r110210 --- gcc/config/darwin.c | 5 ++-- gcc/config/i386/winnt.c | 4 ++-- gcc/config/rs6000/rs6000.c | 2 +- gcc/doc/rtl.texi | 10 ++++++++ gcc/gengtype.c | 21 +++++++++++++++-- gcc/optabs.c | 2 +- gcc/rtl.h | 16 +++++++++++-- gcc/varasm.c | 57 ++++++---------------------------------------- 8 files changed, 56 insertions(+), 61 deletions(-) diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 8920d62..05de707 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -559,7 +559,7 @@ machopic_indirect_data_reference (rtx orig, rtx reg) (Pmode, machopic_indirection_name (orig, /*stub_p=*/false))); - SYMBOL_REF_DECL (ptr_ref) = SYMBOL_REF_DECL (orig); + SYMBOL_REF_DATA (ptr_ref) = SYMBOL_REF_DATA (orig); ptr_ref = gen_const_mem (Pmode, ptr_ref); machopic_define_symbol (ptr_ref); @@ -642,10 +642,9 @@ machopic_indirect_call_target (rtx target) const char *stub_name = machopic_indirection_name (sym_ref, /*stub_p=*/true); enum machine_mode mode = GET_MODE (sym_ref); - tree decl = SYMBOL_REF_DECL (sym_ref); XEXP (target, 0) = gen_rtx_SYMBOL_REF (mode, stub_name); - SYMBOL_REF_DECL (XEXP (target, 0)) = decl; + SYMBOL_REF_DATA (XEXP (target, 0)) = SYMBOL_REF_DATA (sym_ref); MEM_READONLY_P (target) = 1; MEM_NOTRAP_P (target) = 1; } diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c index d80db9e..711766c 100644 --- a/gcc/config/i386/winnt.c +++ b/gcc/config/i386/winnt.c @@ -229,7 +229,7 @@ i386_pe_mark_dllexport (tree decl) idp = get_identifier (newname); symref = gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER (idp)); - SYMBOL_REF_DECL (symref) = decl; + SYMBOL_REF_DATA (symref) = decl; XEXP (DECL_RTL (decl), 0) = symref; } @@ -274,7 +274,7 @@ i386_pe_mark_dllimport (tree decl) idp = get_identifier (newname); symref = gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER (idp)); - SYMBOL_REF_DECL (symref) = decl; + SYMBOL_REF_DATA (symref) = decl; newrtl = gen_rtx_MEM (Pmode,symref); XEXP (DECL_RTL (decl), 0) = newrtl; diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 204bb51..cba6cb7 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -4002,7 +4002,7 @@ rs6000_emit_move (rtx dest, rtx source, enum machine_mode mode) = CONSTANT_POOL_ADDRESS_P (operands[1]); SYMBOL_REF_FLAGS (new_ref) = SYMBOL_REF_FLAGS (operands[1]); SYMBOL_REF_USED (new_ref) = SYMBOL_REF_USED (operands[1]); - SYMBOL_REF_DECL (new_ref) = SYMBOL_REF_DECL (operands[1]); + SYMBOL_REF_DATA (new_ref) = SYMBOL_REF_DATA (operands[1]); operands[1] = new_ref; } diff --git a/gcc/doc/rtl.texi b/gcc/doc/rtl.texi index acd99c9..6102616 100644 --- a/gcc/doc/rtl.texi +++ b/gcc/doc/rtl.texi @@ -455,6 +455,16 @@ that is, some sort of constant. In this case, the @code{symbol_ref} is an entry in the per-file constant pool; again, there is no associated front end symbol table entry. +@findex SYMBOL_REF_CONSTANT +@item SYMBOL_REF_CONSTANT (@var{x}) +If @samp{CONSTANT_POOL_ADDRESS_P (@var{x})} is true, this is the constant +pool entry for @var{x}. It is null otherwise. + +@findex SYMBOL_REF_DATA +@item SYMBOL_REF_DATA (@var{x}) +A @samp{void *} pointer used to store @code{SYMBOL_REF_DECL} or +@code{SYMBOL_REF_CONSTANT}. + @findex SYMBOL_REF_FLAGS @item SYMBOL_REF_FLAGS (@var{x}) In a @code{symbol_ref}, this is used to communicate various predicates diff --git a/gcc/gengtype.c b/gcc/gengtype.c index 0a91523..06c965ee 100644 --- a/gcc/gengtype.c +++ b/gcc/gengtype.c @@ -454,7 +454,7 @@ adjust_field_rtx_def (type_p t, options_p ARG_UNUSED (opt)) options_p nodot; int i; type_p rtx_tp, rtvec_tp, tree_tp, mem_attrs_tp, note_union_tp, scalar_tp; - type_p bitmap_tp, basic_block_tp, reg_attrs_tp; + type_p bitmap_tp, basic_block_tp, reg_attrs_tp, constant_tp, symbol_union_tp; if (t->kind != TYPE_UNION) { @@ -472,6 +472,7 @@ adjust_field_rtx_def (type_p t, options_p ARG_UNUSED (opt)) reg_attrs_tp = create_pointer (find_structure ("reg_attrs", 0)); bitmap_tp = create_pointer (find_structure ("bitmap_element_def", 0)); basic_block_tp = create_pointer (find_structure ("basic_block_def", 0)); + constant_tp = create_pointer (find_structure ("constant_descriptor_rtx", 0)); scalar_tp = create_scalar_type ("rtunion scalar", 14); { @@ -510,6 +511,19 @@ adjust_field_rtx_def (type_p t, options_p ARG_UNUSED (opt)) note_union_tp = new_structure ("rtx_def_note_subunion", 1, &lexer_line, note_flds, NULL); } + /* Create a type to represent the various forms of SYMBOL_REF_DATA. */ + { + pair_p sym_flds; + + sym_flds = create_field (NULL, tree_tp, "rt_tree"); + sym_flds->opt = create_option (nodot, "default", ""); + + sym_flds = create_field (sym_flds, constant_tp, "rt_constant"); + sym_flds->opt = create_option (nodot, "tag", "1"); + + symbol_union_tp = new_structure ("rtx_def_symbol_subunion", 1, + &lexer_line, sym_flds, NULL); + } for (i = 0; i < NUM_RTX_CODE; i++) { pair_p subfields = NULL; @@ -562,7 +576,7 @@ adjust_field_rtx_def (type_p t, options_p ARG_UNUSED (opt)) else if (i == SYMBOL_REF && aindex == 1) t = scalar_tp, subname = "rt_int"; else if (i == SYMBOL_REF && aindex == 2) - t = tree_tp, subname = "rt_tree"; + t = symbol_union_tp, subname = ""; else if (i == BARRIER && aindex >= 3) t = scalar_tp, subname = "rt_int"; else @@ -627,6 +641,9 @@ adjust_field_rtx_def (type_p t, options_p ARG_UNUSED (opt)) if (t == note_union_tp) subfields->opt = create_option (subfields->opt, "desc", "NOTE_LINE_NUMBER (&%0)"); + if (t == symbol_union_tp) + subfields->opt = create_option (subfields->opt, "desc", + "CONSTANT_POOL_ADDRESS_P (&%0)"); } sname = xasprintf ("rtx_def_%s", rtx_name[i]); diff --git a/gcc/optabs.c b/gcc/optabs.c index 75d6894..972339c 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -5133,7 +5133,7 @@ init_one_libfunc (const char *name) /* 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; + SYMBOL_REF_DATA (symbol) = 0; return symbol; } diff --git a/gcc/rtl.h b/gcc/rtl.h index f61d777..03cfcb6 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -171,6 +171,8 @@ union rtunion_def struct basic_block_def *rt_bb; mem_attrs *rt_mem; reg_attrs *rt_reg; + struct constant_descriptor_rtx *rt_constant; + void *rt_ptr; }; typedef union rtunion_def rtunion; @@ -630,6 +632,8 @@ extern void rtl_check_failed_flag (const char *, rtx, const char *, #define X0CSELIB(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_cselib) #define X0MEMATTR(RTX, N) (RTL_CHECKC1 (RTX, N, MEM).rt_mem) #define X0REGATTR(RTX, N) (RTL_CHECKC1 (RTX, N, REG).rt_reg) +#define X0CONSTANT(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_constant) +#define X0PTR(RTX, N) (RTL_CHECK1 (RTX, N, '0').rt_ptr) /* Access a '0' field with any type. */ #define X0ANY(RTX, N) RTL_CHECK1 (RTX, N, '0') @@ -1193,8 +1197,17 @@ do { \ #define SYMBOL_REF_WEAK(RTX) \ (RTL_FLAG_CHECK1("SYMBOL_REF_WEAK", (RTX), SYMBOL_REF)->return_val) +/* A pointer attached to the SYMBOL_REF; either SYMBOL_REF_DECL or + SYMBOL_REF_CONSTANT. */ +#define SYMBOL_REF_DATA(RTX) X0PTR ((RTX), 2) + /* The tree (decl or constant) associated with the symbol, or null. */ -#define SYMBOL_REF_DECL(RTX) X0TREE ((RTX), 2) +#define SYMBOL_REF_DECL(RTX) \ + (CONSTANT_POOL_ADDRESS_P (RTX) ? NULL : X0TREE ((RTX), 2)) + +/* The rtx constant pool entry for a symbol, or null. */ +#define SYMBOL_REF_CONSTANT(RTX) \ + (CONSTANT_POOL_ADDRESS_P (RTX) ? X0CONSTANT ((RTX), 2) : NULL) /* 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. @@ -1417,7 +1430,6 @@ struct function; extern rtx get_pool_constant (rtx); extern rtx get_pool_constant_mark (rtx, bool *); extern enum machine_mode get_pool_mode (rtx); -extern rtx get_pool_constant_for_function (struct function *, rtx); extern rtx simplify_subtraction (rtx); /* In function.c */ diff --git a/gcc/varasm.c b/gcc/varasm.c index 5ca43f6..1a29d27 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -845,7 +845,7 @@ make_decl_rtl (tree decl) x = gen_rtx_SYMBOL_REF (Pmode, name); SYMBOL_REF_WEAK (x) = DECL_WEAK (decl); - SYMBOL_REF_DECL (x) = decl; + SYMBOL_REF_DATA (x) = decl; x = gen_rtx_MEM (DECL_MODE (decl), x); if (TREE_CODE (decl) != FUNCTION_DECL) @@ -2573,7 +2573,7 @@ build_constant_desc (tree exp) /* We have a symbol name; construct the SYMBOL_REF and the MEM. */ symbol = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (label)); SYMBOL_REF_FLAGS (symbol) = SYMBOL_FLAG_LOCAL; - SYMBOL_REF_DECL (symbol) = desc->value; + SYMBOL_REF_DATA (symbol) = desc->value; TREE_CONSTANT_POOL_ADDRESS_P (symbol) = 1; rtl = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)), symbol); @@ -2751,7 +2751,6 @@ struct rtx_constant_pool GTY(()) constant addresses are restricted so that such constants must be stored in memory. */ htab_t GTY((param_is (struct constant_descriptor_rtx))) const_rtx_htab; - htab_t GTY((param_is (struct constant_descriptor_rtx))) const_rtx_sym_htab; /* Current offset in constant pool (does not include any machine-specific header). */ @@ -2792,23 +2791,6 @@ const_desc_rtx_eq (const void *a, const void *b) return rtx_equal_p (x->constant, y->constant); } -/* Hash and compare functions for const_rtx_sym_htab. */ - -static hashval_t -const_desc_rtx_sym_hash (const void *ptr) -{ - const struct constant_descriptor_rtx *desc = ptr; - return htab_hash_string (XSTR (desc->sym, 0)); -} - -static int -const_desc_rtx_sym_eq (const void *a, const void *b) -{ - const struct constant_descriptor_rtx *x = a; - const struct constant_descriptor_rtx *y = b; - return XSTR (x->sym, 0) == XSTR (y->sym, 0); -} - /* This is the worker function for const_rtx_hash, called via for_each_rtx. */ static int @@ -2912,8 +2894,6 @@ init_varasm_status (struct function *f) pool->const_rtx_htab = htab_create_ggc (31, const_desc_rtx_hash, const_desc_rtx_eq, NULL); - pool->const_rtx_sym_htab = htab_create_ggc (31, const_desc_rtx_sym_hash, - const_desc_rtx_sym_eq, NULL); pool->first = pool->last = NULL; pool->offset = 0; } @@ -2998,14 +2978,10 @@ force_const_mem (enum machine_mode mode, rtx x) the constants pool. */ desc->sym = symbol = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (label)); SYMBOL_REF_FLAGS (symbol) = SYMBOL_FLAG_LOCAL; + SYMBOL_REF_DATA (symbol) = desc; CONSTANT_POOL_ADDRESS_P (symbol) = 1; current_function_uses_const_pool = 1; - /* Insert the descriptor into the symbol cross-reference table too. */ - slot = htab_find_slot (pool->const_rtx_sym_htab, desc, INSERT); - gcc_assert (!*slot); - *slot = desc; - /* Construct the MEM. */ desc->mem = def = gen_const_mem (mode, symbol); set_mem_attributes (def, lang_hooks.types.type_for_mode (mode, 0), 1); @@ -3019,23 +2995,12 @@ force_const_mem (enum machine_mode mode, rtx x) return copy_rtx (def); } -/* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to - the corresponding constant_descriptor_rtx structure. */ - -static struct constant_descriptor_rtx * -find_pool_constant (struct rtx_constant_pool *pool, rtx sym) -{ - struct constant_descriptor_rtx tmp; - tmp.sym = sym; - return htab_find (pool->const_rtx_sym_htab, &tmp); -} - /* Given a constant pool SYMBOL_REF, return the corresponding constant. */ rtx get_pool_constant (rtx addr) { - return find_pool_constant (cfun->varasm->pool, addr)->constant; + return SYMBOL_REF_CONSTANT (addr)->constant; } /* Given a constant pool SYMBOL_REF, return the corresponding constant @@ -3046,25 +3011,17 @@ get_pool_constant_mark (rtx addr, bool *pmarked) { struct constant_descriptor_rtx *desc; - desc = find_pool_constant (cfun->varasm->pool, addr); + desc = SYMBOL_REF_CONSTANT (addr); *pmarked = (desc->mark != 0); return desc->constant; } -/* Likewise, but for the constant pool of a specific function. */ - -rtx -get_pool_constant_for_function (struct function *f, rtx addr) -{ - return find_pool_constant (f->varasm->pool, addr)->constant; -} - /* Similar, return the mode. */ enum machine_mode get_pool_mode (rtx addr) { - return find_pool_constant (cfun->varasm->pool, addr)->mode; + return SYMBOL_REF_CONSTANT (addr)->mode; } /* Return the size of the constant pool. */ @@ -3208,7 +3165,7 @@ mark_constant (rtx *current_rtx, void *data) if (CONSTANT_POOL_ADDRESS_P (x)) { - struct constant_descriptor_rtx *desc = find_pool_constant (pool, x); + struct constant_descriptor_rtx *desc = SYMBOL_REF_CONSTANT (x); if (desc->mark == 0) { desc->mark = 1; -- cgit v1.1