diff options
54 files changed, 431 insertions, 405 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a8f2230f003..7994a01ae5b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,51 @@ +2002-05-19 Richard Henderson <rth@redhat.com> + + * system.h (STRIP_NAME_ENCODING): Poison it. + * output.h (STRIP_NAME_ENCODING): Remove. + (default_strip_name_encoding): Declare. + * target-def.h (TARGET_STRIP_NAME_ENCODING): New. + * target.h (strip_name_encoding): New. + * varasm.c (default_strip_name_encoding): New. + + * dwarf2asm.c, varasm.c, config/darwin.c, config/darwin.h, + config/alpha/alpha.c, config/arm/pe.c, config/avr/avr.c, + config/cris/cris.c, config/i386/cygwin.h, config/i386/interix.c, + config/i386/winnt.c, config/m32r/m32r.h, config/mcore/mcore-elf.h, + config/mcore/mcore-pe.h, config/mcore/mcore.c, config/mcore/mcore.h, + config/mips/mips.c, config/mn10200/mn10200.h, config/mn10300/mn10300.h, + config/pa/pa.c, config/pa/pa.h, config/pa/som.h, + config/rs6000/rs6000.c, config/rs6000/sysv4.h, config/rs6000/xcoff.h, + config/v850/v850.h: Use the hook, not the macro. + + * config/darwin-protos.h, config/darwin.c, config/darwin.h, + config/alpha/alpha.c, config/alpha/alpha.h, config/h8300/h8300.c, + config/h8300/h8300.h, config/i386/cygwin.h, config/i386/i386-interix.h, + config/i386/i386-protos.h, config/i386/win32.h, config/i386/winnt.c, + config/ia64/ia64.c, config/ia64/ia64.h, config/m32r/m32r.c, + config/m32r/m32r.h, config/mcore/mcore.c, config/mcore/mcore.h, + config/pa/pa.c, config/rs6000/rs6000.c, config/rs6000/sysv4.h, + config/rs6000/xcoff.h, config/sh/sh.c, config/sh/sh.h, + config/v850/v850.c, config/v850/v850.h: + Move STRIP_NAME_ENCODING to out-of-line function and add + TARGET_STRIP_NAME_ENCODING. + + * config/arm/arm.c, config/arm/arm.h, config/mmix/mmix-protos.h, + config/mmix/mmix.c, config/mmix/mmix.h: Replace STRIP_NAME_ENCODING + with TARGET_STRIP_NAME_ENCODING referencing existing function; + make function static. + + * xcoffout.c: Include target.h + * Makefile.in (xcoffout.o): Update. + + * config/avr/avr.c (avr_encode_section_info): Correct prototype. + * config/avr/avr.h (STRIP_NAME_ENCODING): Remove. + * config/rs6000/rs6000.c (rs6000_xcoff_unique_section): Mark + reloc argument unused. + * config/sh/sh.c (TARGET_ENCODE_SECTION_INFO): New. + + * doc/tm.texi (TARGET_STRIP_NAME_ENCODING): Update from previous + STRIP_NAME_ENCODING docs. + 2002-05-19 Andreas Jaeger <aj@suse.de> * gengenrtl.c: Add prototype for excluded_rtx. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 7c3f961dbf5..1a49dfb8902 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1440,7 +1440,7 @@ dwarf2asm.o : dwarf2asm.c $(CONFIG_H) $(SYSTEM_H) flags.h $(RTL_H) $(TREE_H) \ vmsdbgout.o : vmsdbgout.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) flags.h \ output.h vmsdbg.h debug.h langhooks.h xcoffout.o : xcoffout.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) xcoffout.h \ - flags.h toplev.h output.h dbxout.h $(GGC_H) + flags.h toplev.h output.h dbxout.h $(GGC_H) $(TARGET_H) emit-rtl.o : emit-rtl.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h \ function.h $(REGS_H) insn-config.h $(RECOG_H) real.h $(GGC_H) \ $(EXPR_H) $(srcdir)/../include/obstack.h hard-reg-set.h bitmap.h toplev.h \ diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 837ec6d9088..d0b41f71320 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -119,6 +119,8 @@ static bool alpha_in_small_data_p PARAMS ((tree)); static void alpha_encode_section_info PARAMS ((tree, int)); +static const char *alpha_strip_name_encoding + PARAMS ((const char *)); static int some_small_symbolic_operand_1 PARAMS ((rtx *, void *)); static int split_small_symbolic_operand_1 @@ -212,6 +214,8 @@ static void vms_asm_out_destructor PARAMS ((rtx, int)); #define TARGET_IN_SMALL_DATA_P alpha_in_small_data_p #undef TARGET_ENCODE_SECTION_INFO #define TARGET_ENCODE_SECTION_INFO alpha_encode_section_info +#undef TARGET_STRIP_NAME_ENCODING +#define TARGET_STRIP_NAME_ENCODING alpha_strip_name_encoding #if TARGET_ABI_UNICOSMK static void unicosmk_asm_named_section PARAMS ((const char *, unsigned int)); @@ -1708,6 +1712,19 @@ alpha_encode_section_info (decl, first) } } +/* Undo the effects of the above. */ + +static const char * +alpha_strip_name_encoding (str) + const char *str; +{ + if (str[0] == '@') + str += 2; + if (str[0] == '*') + str++; + return str; +} + /* legitimate_address_p recognizes an RTL expression that is a valid memory address for an instruction. The MODE argument is the machine mode for the MEM expression that wants to use this address. @@ -8599,7 +8616,7 @@ unicosmk_unique_section (decl, reloc) abort (); name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); - STRIP_NAME_ENCODING (name, name); + name = alpha_strip_name_encoding (name); len = strlen (name); if (TREE_CODE (decl) == FUNCTION_DECL) @@ -8830,8 +8847,7 @@ unicosmk_ssib_name () x = XEXP (x, 0); if (GET_CODE (x) != SYMBOL_REF) abort (); - fnname = XSTR (x, 0); - STRIP_NAME_ENCODING (fnname, fnname); + fnname = alpha_strip_name_encoding (XSTR (x, 0)); len = strlen (fnname); if (len + SSIB_PREFIX_LEN > 255) @@ -9006,7 +9022,7 @@ unicosmk_output_externs (file) /* We have to strip the encoding and possibly remove user_label_prefix from the identifier in order to handle -fleading-underscore and explicit asm names correctly (cf. gcc.dg/asm-names-1.c). */ - STRIP_NAME_ENCODING (real_name, p->name); + real_name = alpha_strip_name_encoding (p->name); if (len && p->name[0] == '*' && !memcmp (real_name, user_label_prefix, len)) real_name += len; diff --git a/gcc/config/alpha/alpha.h b/gcc/config/alpha/alpha.h index 260e641805a..7c1a912f27d 100644 --- a/gcc/config/alpha/alpha.h +++ b/gcc/config/alpha/alpha.h @@ -1724,15 +1724,6 @@ do { \ #define DATA_SECTION_ASM_OP "\t.data" -#define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \ -do { \ - (VAR) = (SYMBOL_NAME); \ - if ((VAR)[0] == '@') \ - (VAR) += 2; \ - if ((VAR)[0] == '*') \ - (VAR)++; \ -} while (0) - /* How to refer to registers in assembler output. This sequence is indexed by compiler's hard-register-number (see above). */ diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index cbcd1a14dca..111884d234b 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -180,6 +180,9 @@ static void arm_encode_section_info PARAMS ((tree, int)); #define TARGET_ENCODE_SECTION_INFO arm_encode_section_info #endif +#undef TARGET_STRIP_NAME_ENCODING +#define TARGET_STRIP_NAME_ENCODING arm_strip_name_encoding + struct gcc_target targetm = TARGET_INITIALIZER; /* Obstack for minipool constant handling. */ diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index c3946d64c56..e4ee55acfae 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -1848,12 +1848,6 @@ typedef struct case '*': return 1; \ SUBTARGET_NAME_ENCODING_LENGTHS -/* This has to be handled by a function because more than part of the - ARM backend uses function name prefixes to encode attributes. */ -#undef STRIP_NAME_ENCODING -#define STRIP_NAME_ENCODING(VAR, SYMBOL_NAME) \ - (VAR) = arm_strip_name_encoding (SYMBOL_NAME) - /* This is how to output a reference to a user-level label named NAME. `assemble_name' uses this. */ #undef ASM_OUTPUT_LABELREF diff --git a/gcc/config/arm/pe.c b/gcc/config/arm/pe.c index de745586dc2..c86e23124b6 100644 --- a/gcc/config/arm/pe.c +++ b/gcc/config/arm/pe.c @@ -257,8 +257,7 @@ arm_pe_unique_section (decl, reloc) const char * prefix; name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); - /* Strip off any encoding in fnname. */ - STRIP_NAME_ENCODING (name, name); + name = arm_strip_name_encoding (name); /* The object is put in, for example, section .text$foo. The linker will then ultimately place them in .text diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index 262ed6323c4..ea2a19354d1 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -65,7 +65,7 @@ static bool avr_assemble_integer PARAMS ((rtx, unsigned int, int)); static void avr_output_function_prologue PARAMS ((FILE *, HOST_WIDE_INT)); static void avr_output_function_epilogue PARAMS ((FILE *, HOST_WIDE_INT)); static void avr_unique_section PARAMS ((tree, int)); -extern void avr_encode_section_info PARAMS ((tree, int)); +static void avr_encode_section_info PARAMS ((tree, int)); /* Allocate registers from r25 to r8 for parameters for function calls */ #define FIRST_CUM_REG 26 @@ -4517,9 +4517,9 @@ avr_unique_section (decl, reloc) int len; const char *name, *prefix; char *string; + name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); - /* Strip off any encoding in name. */ - STRIP_NAME_ENCODING (name, name); + name = (* targetm.strip_name_encoding) (name); if (TREE_CODE (decl) == FUNCTION_DECL) { @@ -4770,7 +4770,7 @@ avr_encode_section_info (decl, first) DECL_SECTION_NAME (decl) = build_string (strlen (dsec), dsec); TREE_READONLY (decl) = 1; } -} +} /* Outputs to the stdio stream FILE some appropriate text to go at the start of an assembler file. */ diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h index c227241ff74..ecbc1e5fda9 100644 --- a/gcc/config/avr/avr.h +++ b/gcc/config/avr/avr.h @@ -1742,12 +1742,6 @@ progmem_section (void) \ This macro is irrelevant if there is no separate readonly data section. */ -#define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \ - (VAR) = (SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*' || (SYMBOL_NAME)[0] == '@'); -/* `STRIP_NAME_ENCODING (VAR, SYM_NAME)' - Decode SYM_NAME and store the real name part in VAR, sans the - characters that encode section info. */ - #define ASM_FILE_START(STREAM) asm_file_start (STREAM) /* A C expression which outputs to the stdio stream STREAM some appropriate text to go at the start of an assembler file. diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c index e9a323257d8..f54f39e74d4 100644 --- a/gcc/config/cris/cris.c +++ b/gcc/config/cris/cris.c @@ -2591,7 +2591,7 @@ cris_asm_output_mi_thunk (stream, thunkdecl, delta, funcdecl) { const char *name = XSTR (XEXP (DECL_RTL (funcdecl), 0), 0); - STRIP_NAME_ENCODING (name, name); + name = (* targetm.strip_name_encoding) (name); fprintf (stream, "add.d "); assemble_name (stream, name); fprintf (stream, "%s,$pc\n", CRIS_PLT_PCOFFSET_SUFFIX); @@ -2889,7 +2889,7 @@ restart: const char *origstr = XSTR (x, 0); const char *str; - STRIP_NAME_ENCODING (str, origstr); + str = (* targetm.strip_name_encoding) (origstr); if (is_plt) { diff --git a/gcc/config/darwin-protos.h b/gcc/config/darwin-protos.h index c72b0dd1b3a..14077298629 100644 --- a/gcc/config/darwin-protos.h +++ b/gcc/config/darwin-protos.h @@ -59,6 +59,7 @@ extern void machopic_define_name PARAMS ((const char*)); extern int machopic_name_defined_p PARAMS ((const char*)); extern int machopic_ident_defined_p PARAMS ((tree)); extern void darwin_encode_section_info PARAMS ((tree, int)); +extern const char *darwin_strip_name_encoding PARAMS ((const char *)); #endif /* TREE_CODE */ diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index e6fe4204c06..3b9ee8c3cbc 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -278,7 +278,7 @@ machopic_non_lazy_ptr_name (name) return IDENTIFIER_POINTER (TREE_PURPOSE (temp)); } - STRIP_NAME_ENCODING (name, name); + name = darwin_strip_name_encoding (name); /* Try again, but comparing names this time. */ for (temp = machopic_non_lazy_pointers; @@ -288,7 +288,7 @@ machopic_non_lazy_ptr_name (name) if (TREE_VALUE (temp)) { temp_name = IDENTIFIER_POINTER (TREE_VALUE (temp)); - STRIP_NAME_ENCODING (temp_name, temp_name); + temp_name = darwin_strip_name_encoding (temp_name); if (strcmp (name, temp_name) == 0) return IDENTIFIER_POINTER (TREE_PURPOSE (temp)); } @@ -360,7 +360,7 @@ machopic_stub_name (name) return IDENTIFIER_POINTER (TREE_PURPOSE (temp)); } - STRIP_NAME_ENCODING (name, name); + name = darwin_strip_name_encoding (name); { char *buffer; @@ -414,7 +414,8 @@ machopic_validate_stub_or_non_lazy_ptr (name, validate_stub) TREE_USED (temp) = 1; if (TREE_CODE (TREE_VALUE (temp)) == IDENTIFIER_NODE) TREE_SYMBOL_REFERENCED (TREE_VALUE (temp)) = 1; - STRIP_NAME_ENCODING (real_name, IDENTIFIER_POINTER (TREE_VALUE (temp))); + real_name = IDENTIFIER_POINTER (TREE_VALUE (temp)); + real_name = darwin_strip_name_encoding (real_name); id2 = maybe_get_identifier (real_name); if (id2) TREE_SYMBOL_REFERENCED (id2) = 1; @@ -846,7 +847,7 @@ machopic_finish (asm_out_file) if (sym_name[0] == '!' && sym_name[1] == 'T') continue; - STRIP_NAME_ENCODING (sym_name, sym_name); + sym_name = darwin_strip_name_encoding (sym_name); sym = alloca (strlen (sym_name) + 2); if (sym_name[0] == '*' || sym_name[0] == '&') @@ -1015,6 +1016,15 @@ darwin_encode_section_info (decl, first) update_stubs (XSTR (sym_ref, 0)); } +/* Undo the effects of the above. */ + +const char * +darwin_strip_name_encoding (str) + const char *str; +{ + return str[0] == '!' ? str + 4 : str; +} + /* Scan the list of non-lazy pointers and update any recorded names whose stripped name matches the argument. */ @@ -1025,7 +1035,7 @@ update_non_lazy_ptrs (name) const char *name1, *name2; tree temp; - STRIP_NAME_ENCODING (name1, name); + name1 = darwin_strip_name_encoding (name); for (temp = machopic_non_lazy_pointers; temp != NULL_TREE; @@ -1035,7 +1045,7 @@ update_non_lazy_ptrs (name) if (*sym_name == '!') { - STRIP_NAME_ENCODING (name2, sym_name); + name2 = darwin_strip_name_encoding (sym_name); if (strcmp (name1, name2) == 0) { IDENTIFIER_POINTER (TREE_VALUE (temp)) = name; @@ -1089,7 +1099,7 @@ update_stubs (name) const char *name1, *name2; tree temp; - STRIP_NAME_ENCODING (name1, name); + name1 = darwin_strip_name_encoding (name); for (temp = machopic_stubs; temp != NULL_TREE; @@ -1099,7 +1109,7 @@ update_stubs (name) if (*sym_name == '!') { - STRIP_NAME_ENCODING (name2, sym_name); + name2 = darwin_strip_name_encoding (sym_name); if (strcmp (name1, name2) == 0) { IDENTIFIER_POINTER (TREE_VALUE (temp)) = name; diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 14ab0ff98b7..0de241467d3 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -235,28 +235,28 @@ do { text_section (); \ Make Objective-C internal symbols local. */ #undef ASM_OUTPUT_LABELREF -#define ASM_OUTPUT_LABELREF(FILE,NAME) \ - do { \ - STRIP_NAME_ENCODING (NAME, NAME); \ - if (NAME[0] == '&' || NAME[0] == '*') \ - { \ - int len = strlen (NAME); \ - if (len > 6 && !strcmp ("$stub", NAME + len - 5)) \ - machopic_validate_stub_or_non_lazy_ptr (NAME, 1); \ - else if (len > 7 && !strcmp ("$stub\"", NAME + len - 6)) \ - machopic_validate_stub_or_non_lazy_ptr (NAME, 1); \ - else if (len > 14 && !strcmp ("$non_lazy_ptr", NAME + len - 13)) \ - machopic_validate_stub_or_non_lazy_ptr (NAME, 0); \ - fputs (&NAME[1], FILE); \ - } \ - else if (NAME[0] == '+' || NAME[0] == '-') \ - fprintf (FILE, "\"%s\"", NAME); \ - else if (!strncmp (NAME, "_OBJC_", 6)) \ - fprintf (FILE, "L%s", NAME); \ - else if (!strncmp (NAME, ".objc_class_name_", 17)) \ - fprintf (FILE, "%s", NAME); \ - else \ - fprintf (FILE, "_%s", NAME); \ +#define ASM_OUTPUT_LABELREF(FILE,NAME) \ + do { \ + const char *xname = darwin_strip_name_encoding (NAME); \ + if (xname[0] == '&' || xname[0] == '*') \ + { \ + int len = strlen (xname); \ + if (len > 6 && !strcmp ("$stub", xname + len - 5)) \ + machopic_validate_stub_or_non_lazy_ptr (xname, 1); \ + else if (len > 7 && !strcmp ("$stub\"", xname + len - 6)) \ + machopic_validate_stub_or_non_lazy_ptr (xname, 1); \ + else if (len > 14 && !strcmp ("$non_lazy_ptr", xname + len - 13)) \ + machopic_validate_stub_or_non_lazy_ptr (xname, 0); \ + fputs (&xname[1], FILE); \ + } \ + else if (xname[0] == '+' || xname[0] == '-') \ + fprintf (FILE, "\"%s\"", xname); \ + else if (!strncmp (xname, "_OBJC_", 6)) \ + fprintf (FILE, "L%s", xname); \ + else if (!strncmp (xname, ".objc_class_name_", 17)) \ + fprintf (FILE, "%s", xname); \ + else \ + fprintf (FILE, "_%s", xname); \ } while (0) #undef ALIGN_ASM_OP @@ -553,9 +553,7 @@ enum machopic_addr_class { #define MACHOPIC_PURE (flag_pic == 2) #define TARGET_ENCODE_SECTION_INFO darwin_encode_section_info - -#define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \ - ((VAR) = ((SYMBOL_NAME[0] == '!') ? (SYMBOL_NAME) + 4 : (SYMBOL_NAME))) +#define TARGET_STRIP_NAME_ENCODING darwin_strip_name_encoding #define GEN_BINDER_NAME_FOR_STUB(BUF,STUB,STUB_LENGTH) \ do { \ @@ -591,12 +589,11 @@ enum machopic_addr_class { #define GEN_LAZY_PTR_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \ do { \ - const char *symbol_ = (SYMBOL); \ + const char *symbol_ = darwin_strip_name_encoding (SYMBOL); \ char *buffer_ = (BUF); \ - STRIP_NAME_ENCODING (symbol_, symbol_); \ if (symbol_[0] == '"') \ { \ - strcpy (buffer_, "\"L"); \ + strcpy (buffer_, "\"L"); \ strcpy (buffer_ + 2, symbol_ + 1); \ strcpy (buffer_ + (SYMBOL_LENGTH), "$lazy_ptr\""); \ } \ diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c index 64d4e85f237..bb78d4bb34f 100644 --- a/gcc/config/h8300/h8300.c +++ b/gcc/config/h8300/h8300.c @@ -66,6 +66,7 @@ static void h8300_asm_named_section PARAMS ((const char *, unsigned int)); #endif static void h8300_encode_label PARAMS ((tree)); static void h8300_encode_section_info PARAMS ((tree, int)); +static const char *h8300_strip_name_encoding PARAMS ((const char *)); /* CPU_TYPE, says what cpu we're compiling for. */ int cpu_type; @@ -115,6 +116,8 @@ const char *h8_push_op, *h8_pop_op, *h8_mov_op; #define TARGET_ASM_FUNCTION_EPILOGUE h8300_output_function_epilogue #undef TARGET_ENCODE_SECTION_INFO #define TARGET_ENCODE_SECTION_INFO h8300_encode_section_info +#undef TARGET_STRIP_NAME_ENCODING +#define TARGET_STRIP_NAME_ENCODING h8300_strip_name_encoding struct gcc_target targetm = TARGET_INITIALIZER; @@ -3477,6 +3480,15 @@ h8300_encode_section_info (decl, first) } } +/* Undo the effects of the above. */ + +static const char * +h8300_strip_name_encoding (str) + const char *str; +{ + return str + (*str == '*' || *str == '@' || *str == '&'); +} + const char * output_simode_bld (bild, operands) int bild; diff --git a/gcc/config/h8300/h8300.h b/gcc/config/h8300/h8300.h index 1baa95901c0..6a888a95ff9 100644 --- a/gcc/config/h8300/h8300.h +++ b/gcc/config/h8300/h8300.h @@ -1096,13 +1096,6 @@ struct cum_arg #define TINY_DATA_NAME_P(NAME) (*(NAME) == '&') -/* Store the user-specified part of SYMBOL_NAME in VAR. - This is sort of inverse to targetm.encode_section_info. */ -#define STRIP_NAME_ENCODING(VAR, SYMBOL_NAME) \ - (VAR) = (SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*' \ - || (SYMBOL_NAME)[0] == '@' \ - || (SYMBOL_NAME)[0] == '&'); - /* How to refer to registers in assembler output. This sequence is indexed by compiler's hard-register-number (see above). */ diff --git a/gcc/config/i386/cygwin.h b/gcc/config/i386/cygwin.h index 7098066adc1..0caf3c34057 100644 --- a/gcc/config/i386/cygwin.h +++ b/gcc/config/i386/cygwin.h @@ -255,45 +255,16 @@ do { \ section and we need to set DECL_SECTION_NAME so we do that here. Note that we can be called twice on the same decl. */ -extern void i386_pe_encode_section_info PARAMS ((TREE, int)); - #undef TARGET_ENCODE_SECTION_INFO #define TARGET_ENCODE_SECTION_INFO i386_pe_encode_section_info - -/* Utility used only in this file. */ -#define I386_PE_STRIP_ENCODING(SYM_NAME) \ - ((SYM_NAME) + ((SYM_NAME)[0] == '@' \ - ? ((SYM_NAME)[3] == '*' ? 4 : 3) : 0) \ - + ((SYM_NAME)[0] == '*' ? 1 : 0)) - -/* This macro gets just the user-specified name - out of the string in a SYMBOL_REF. Discard - trailing @[NUM] encoded by targetm.encode_section_info. */ -#undef STRIP_NAME_ENCODING -#define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \ -do { \ - const char *_p; \ - const char *_name = I386_PE_STRIP_ENCODING (SYMBOL_NAME); \ - for (_p = _name; *_p && *_p != '@'; ++_p) \ - ; \ - if (*_p == '@') \ - { \ - int _len = _p - _name; \ - char *_new_name = (char *) alloca (_len + 1); \ - strncpy (_new_name, _name, _len); \ - _new_name[_len] = '\0'; \ - (VAR) = _new_name; \ - } \ - else \ - (VAR) = _name; \ -} while (0) - +#undef TARGET_STRIP_NAME_ENCODING +#define TARGET_STRIP_NAME_ENCODING i386_pe_strip_name_encoding_full /* Output a reference to a label. */ #undef ASM_OUTPUT_LABELREF #define ASM_OUTPUT_LABELREF(STREAM, NAME) \ fprintf (STREAM, "%s%s", USER_LABEL_PREFIX, \ - I386_PE_STRIP_ENCODING (NAME)) \ + i386_pe_strip_name_encoding (NAME)) \ /* Output a common block. */ #undef ASM_OUTPUT_COMMON diff --git a/gcc/config/i386/i386-interix.h b/gcc/config/i386/i386-interix.h index fb0a9a9d87c..630a7b9b746 100644 --- a/gcc/config/i386/i386-interix.h +++ b/gcc/config/i386/i386-interix.h @@ -299,40 +299,13 @@ while (0) /* Define this macro if references to a symbol must be treated differently depending on something about the variable or - function named by the symbol (such as what section it is in). - - Apply stddef, handle (as yet unimplemented) pic. - - stddef renaming does NOT apply to Alpha. */ - -const char *gen_stdcall_suffix PARAMS ((tree)); -void i386_interix_encode_section_info PARAMS ((tree, int)); + function named by the symbol (such as what section it is in). */ #undef TARGET_ENCODE_SECTION_INFO -#define TARGET_ENCODE_SECTION_INFO i386_interix_encode_section_info - -/* This macro gets just the user-specified name - out of the string in a SYMBOL_REF. Discard - trailing @[NUM] encoded by targetm.encode_section_info. */ -#undef STRIP_NAME_ENCODING -#define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \ -do { \ - const char *_p; \ - const char *_name = SYMBOL_NAME; \ - for (_p = _name; *_p && *_p != '@'; ++_p) \ - ; \ - if (*_p == '@') \ - { \ - int _len = _p - _name; \ - char *_new_name = (char *) alloca (_len + 1); \ - strncpy (_new_name, _name, _len); \ - _new_name[_len] = '\0'; \ - (VAR) = _new_name; \ - } \ - else \ - (VAR) = _name; \ -} while (0) - +#define TARGET_ENCODE_SECTION_INFO i386_pe_encode_section_info +#undef TARGET_STRIP_NAME_ENCODING +#define TARGET_STRIP_NAME_ENCODING i386_pe_strip_name_encoding_full + #if 0 /* Turn this back on when the linker is updated to handle grouped .data$ sections correctly. See corresponding note in i386/interix.c. diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index b3b16884579..4222bba2ba6 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -199,3 +199,8 @@ extern unsigned int i386_pe_section_type_flags PARAMS ((tree, const char *, extern void i386_pe_asm_named_section PARAMS ((const char *, unsigned int)); extern void x86_output_mi_thunk PARAMS ((FILE *, int, tree)); #endif + +/* In winnt.c */ +extern void i386_pe_encode_section_info PARAMS ((tree, int)); +extern const char *i386_pe_strip_name_encoding PARAMS ((const char *)); +extern const char *i386_pe_strip_name_encoding_full PARAMS ((const char *)); diff --git a/gcc/config/i386/interix.c b/gcc/config/i386/interix.c index dc9c3d6e422..58a19ab5de6 100644 --- a/gcc/config/i386/interix.c +++ b/gcc/config/i386/interix.c @@ -102,8 +102,7 @@ i386_pe_unique_section (decl, reloc) char *string,*prefix; name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); - /* Strip off any encoding in fnname. */ - STRIP_NAME_ENCODING (name, name); + name = (* targetm.strip_name_encoding) (name); /* The object is put in, for example, section .text$foo. The linker will then ultimately place them in .text diff --git a/gcc/config/i386/win32.h b/gcc/config/i386/win32.h index 03ed4957775..a9a8b2db6b1 100644 --- a/gcc/config/i386/win32.h +++ b/gcc/config/i386/win32.h @@ -104,30 +104,8 @@ Boston, MA 02111-1307, USA. */ #undef TARGET_ENCODE_SECTION_INFO #define TARGET_ENCODE_SECTION_INFO i386_pe_encode_section_info - -/* This macro gets just the user-specified name - out of the string in a SYMBOL_REF. Discard - trailing @[NUM] encoded by targetm.encode_section_info. - Do we need the stripping of leading '*'? */ -#undef STRIP_NAME_ENCODING -#define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \ -do { \ - const char *_p; \ - const char *const _name = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*'));\ - for (_p = _name; *_p && *_p != '@'; ++_p) \ - ; \ - if (*_p == '@') \ - { \ - int _len = _p - _name; \ - char *_new_name = (char *) alloca (_len + 1); \ - strncpy (_new_name, _name, _len); \ - _new_name[_len] = '\0'; \ - (VAR) = _new_name; \ - } \ - else \ - (VAR) = _name; \ -} while (0) - +#undef TARGET_STRIP_NAME_ENCODING +#define TARGET_STRIP_NAME_ENCODING i386_pe_strip_name_encoding_full /* Emit code to check the stack when allocating more that 4000 bytes in one go. */ diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c index d88e7dbce73..d6f0a7a81aa 100644 --- a/gcc/config/i386/winnt.c +++ b/gcc/config/i386/winnt.c @@ -31,6 +31,7 @@ Boston, MA 02111-1307, USA. */ #include "tm_p.h" #include "toplev.h" #include "hashtab.h" +#include "ggc.h" /* i386/PE specific attribute support. @@ -422,6 +423,35 @@ i386_pe_encode_section_info (decl, first) } } +/* Strip only the leading encoding, leaving the stdcall suffix. */ + +const char * +i386_pe_strip_name_encoding (str) + const char *str; +{ + if (*str == '@') + str += 3; + if (*str == '*') + str += 1; + return str; +} + +/* Also strip the stdcall suffix. */ + +const char * +i386_pe_strip_name_encoding_full (str) + const char *str; +{ + const char *p; + const char *name = i386_pe_strip_name_encoding (str); + + p = strchr (name, '@'); + if (p) + return ggc_alloc_string (name, p - name); + + return name; +} + void i386_pe_unique_section (decl, reloc) tree decl; @@ -432,8 +462,7 @@ i386_pe_unique_section (decl, reloc) char *string; name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); - /* Strip off any encoding in fnname. */ - STRIP_NAME_ENCODING (name, name); + name = i386_pe_strip_name_encoding_full (name); /* The object is put in, for example, section .text$foo. The linker will then ultimately place them in .text @@ -663,7 +692,7 @@ i386_pe_asm_file_end (file) for (q = export_head; q != NULL; q = q->next) { fprintf (file, "\t.ascii \" -export:%s%s\"\n", - I386_PE_STRIP_ENCODING (q->name), + i386_pe_strip_name_encoding (q->name), (q->is_data) ? ",data" : ""); } } diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index f62f92a2735..2d01810a956 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -127,6 +127,7 @@ static void emit_all_insn_group_barriers PARAMS ((FILE *, rtx)); static void emit_predicate_relation_info PARAMS ((void)); static bool ia64_in_small_data_p PARAMS ((tree)); static void ia64_encode_section_info PARAMS ((tree, int)); +static const char *ia64_strip_name_encoding PARAMS ((const char *)); static void process_epilogue PARAMS ((void)); static int process_set PARAMS ((FILE *, rtx)); @@ -211,6 +212,8 @@ static const struct attribute_spec ia64_attribute_table[] = #define TARGET_IN_SMALL_DATA_P ia64_in_small_data_p #undef TARGET_ENCODE_SECTION_INFO #define TARGET_ENCODE_SECTION_INFO ia64_encode_section_info +#undef TARGET_STRIP_NAME_ENCODING +#define TARGET_STRIP_NAME_ENCODING ia64_strip_name_encoding #undef TARGET_SCHED_ADJUST_COST #define TARGET_SCHED_ADJUST_COST ia64_adjust_cost @@ -6981,6 +6984,17 @@ ia64_encode_section_info (decl, first) else if (symbol_str[0] == SDATA_NAME_FLAG_CHAR) XSTR (symbol, 0) = ggc_strdup (symbol_str + 1); } + +static const char * +ia64_strip_name_encoding (str) + const char *str; +{ + if (str[0] == SDATA_NAME_FLAG_CHAR) + str++; + if (str[0] == '*') + str++; + return str; +} /* Output assembly directives for prologue regions. */ diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h index eaa1a7d1c59..0d3d362830d 100644 --- a/gcc/config/ia64/ia64.h +++ b/gcc/config/ia64/ia64.h @@ -1777,18 +1777,6 @@ do { \ #define SDATA_NAME_FLAG_CHAR '@' #define IA64_DEFAULT_GVALUE 8 - -/* Decode SYM_NAME and store the real name part in VAR, sans the characters - that encode section info. */ - -#define STRIP_NAME_ENCODING(VAR, SYMBOL_NAME) \ -do { \ - (VAR) = (SYMBOL_NAME); \ - if ((VAR)[0] == SDATA_NAME_FLAG_CHAR) \ - (VAR)++; \ - if ((VAR)[0] == '*') \ - (VAR)++; \ -} while (0) /* Position Independent Code. */ diff --git a/gcc/config/m32r/m32r.c b/gcc/config/m32r/m32r.c index 6140d0ff10a..b7ebaf35f02 100644 --- a/gcc/config/m32r/m32r.c +++ b/gcc/config/m32r/m32r.c @@ -76,7 +76,7 @@ static int m32r_issue_rate PARAMS ((void)); static void m32r_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT)); static void m32r_encode_section_info PARAMS ((tree, int)); - +static const char *m32r_strip_name_encoding PARAMS ((const char *)); /* Initialize the GCC target structure. */ #undef TARGET_ATTRIBUTE_TABLE @@ -107,6 +107,8 @@ static void m32r_encode_section_info PARAMS ((tree, int)); #undef TARGET_ENCODE_SECTION_INFO #define TARGET_ENCODE_SECTION_INFO m32r_encode_section_info +#undef TARGET_STRIP_NAME_ENCODING +#define TARGET_STRIP_NAME_ENCODING m32r_strip_name_encoding struct gcc_target targetm = TARGET_INITIALIZER; @@ -486,6 +488,17 @@ m32r_encode_section_info (decl, first) } } +/* Undo the effects of the above. */ + +static const char * +m32r_strip_name_encoding (str) + const char *str; +{ + str += ENCODED_NAME_P (str); + str += *str == '*'; + return str; +} + /* Do anything needed before RTL is emitted for each function. */ void diff --git a/gcc/config/m32r/m32r.h b/gcc/config/m32r/m32r.h index 2d2b637e236..d055deba20d 100644 --- a/gcc/config/m32r/m32r.h +++ b/gcc/config/m32r/m32r.h @@ -1611,15 +1611,6 @@ sbss_section () \ /*|| SMALL_NAME_P (SYMBOL_NAME)*/ \ || MEDIUM_NAME_P (SYMBOL_NAME) \ || LARGE_NAME_P (SYMBOL_NAME)) - -/* Decode SYM_NAME and store the real name part in VAR, sans - the characters that encode section info. */ -/* Note that we have to handle symbols like "%*start". */ -#define STRIP_NAME_ENCODING(VAR, SYMBOL_NAME) \ -do { \ - (VAR) = (SYMBOL_NAME) + ENCODED_NAME_P (SYMBOL_NAME); \ - (VAR) += *(VAR) == '*'; \ -} while (0) /* PIC */ @@ -1707,14 +1698,8 @@ do { \ /* This is how to output a reference to a user-level label named NAME. `assemble_name' uses this. */ #undef ASM_OUTPUT_LABELREF -#define ASM_OUTPUT_LABELREF(FILE, NAME) \ - do \ - { \ - const char * real_name; \ - STRIP_NAME_ENCODING (real_name, (NAME)); \ - asm_fprintf (FILE, "%U%s", real_name); \ - } \ - while (0) +#define ASM_OUTPUT_LABELREF(FILE, NAME) \ + asm_fprintf (FILE, "%U%s", (*targetm.strip_name_encoding) (NAME)) /* If -Os, don't force line number labels to begin at the beginning of the word; we still want the assembler to try to put things in parallel, diff --git a/gcc/config/mcore/mcore-elf.h b/gcc/config/mcore/mcore-elf.h index 2cdbae01063..ced4886231a 100644 --- a/gcc/config/mcore/mcore-elf.h +++ b/gcc/config/mcore/mcore-elf.h @@ -67,7 +67,7 @@ exports_section () \ { \ exports_section (); \ fprintf (STREAM, "\t.ascii \" -export:%s\"\n", \ - MCORE_STRIP_NAME_ENCODING (NAME)); \ + (* targetm.strip_name_encoding) (NAME)); \ } \ while (0); diff --git a/gcc/config/mcore/mcore-pe.h b/gcc/config/mcore/mcore-pe.h index 651f3384b27..6668574458d 100644 --- a/gcc/config/mcore/mcore-pe.h +++ b/gcc/config/mcore/mcore-pe.h @@ -69,7 +69,7 @@ drectve_section () \ { \ drectve_section (); \ fprintf (STREAM, "\t.ascii \" -export:%s\"\n", \ - MCORE_STRIP_NAME_ENCODING (NAME)); \ + (* targetm.strip_name_encoding) (NAME)); \ } \ while (0); diff --git a/gcc/config/mcore/mcore.c b/gcc/config/mcore/mcore.c index 61fc5bddbff..7276d813e27 100644 --- a/gcc/config/mcore/mcore.c +++ b/gcc/config/mcore/mcore.c @@ -139,6 +139,7 @@ static void mcore_asm_named_section PARAMS ((const char *, #endif static void mcore_unique_section PARAMS ((tree, int)); static void mcore_encode_section_info PARAMS ((tree, int)); +static const char *mcore_strip_name_encoding PARAMS ((const char *)); /* Initialize the GCC target structure. */ #ifdef TARGET_DLLIMPORT_DECL_ATTRIBUTES @@ -159,6 +160,8 @@ static void mcore_encode_section_info PARAMS ((tree, int)); #define TARGET_ASM_UNIQUE_SECTION mcore_unique_section #undef TARGET_ENCODE_SECTION_INFO #define TARGET_ENCODE_SECTION_INFO mcore_encode_section_info +#undef TARGET_STRIP_NAME_ENCODING +#define TARGET_STRIP_NAME_ENCODING mcore_strip_name_encoding struct gcc_target targetm = TARGET_INITIALIZER; @@ -3467,6 +3470,15 @@ mcore_encode_section_info (decl, first) } } +/* Undo the effects of the above. */ + +static const char * +mcore_strip_name_encoding (str) + const char *str; +{ + return str + (str[0] == '@' ? 3 : 0); +} + /* MCore specific attribute support. dllexport - for exporting a function/variable that will live in a dll dllimport - for importing a function/variable from a dll @@ -3535,7 +3547,7 @@ mcore_unique_section (decl, reloc) name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); /* Strip off any encoding in name. */ - STRIP_NAME_ENCODING (name, name); + name = (* targetm.strip_name_encoding) (name); /* The object is put in, for example, section .text$foo. The linker will then ultimately place them in .text diff --git a/gcc/config/mcore/mcore.h b/gcc/config/mcore/mcore.h index da9d20c57a5..682039e3db6 100644 --- a/gcc/config/mcore/mcore.h +++ b/gcc/config/mcore/mcore.h @@ -1119,8 +1119,8 @@ switch_to_section (section, decl) \ /* Output a reference to a label. */ #undef ASM_OUTPUT_LABELREF #define ASM_OUTPUT_LABELREF(STREAM, NAME) \ - fprintf (STREAM, "%s%s", USER_LABEL_PREFIX, MCORE_STRIP_NAME_ENCODING (NAME)) - + fprintf (STREAM, "%s%s", USER_LABEL_PREFIX, \ + (* targetm.strip_name_encoding) (NAME)) /* This is how to output an assembler line that says to advance the location counter @@ -1133,16 +1133,6 @@ switch_to_section (section, decl) \ #define ASM_DECLARE_RESULT(FILE, RESULT) #endif -/* Strip export encoding from a function name. */ -#define MCORE_STRIP_NAME_ENCODING(SYM_NAME) \ - ((SYM_NAME) + ((SYM_NAME)[0] == '@' ? 3 : 0)) - -/* Strip any text from SYM_NAME added by targetm.encode_section_info - and store the result in VAR. */ -#undef STRIP_NAME_ENCODING -#define STRIP_NAME_ENCODING(VAR, SYM_NAME) \ - (VAR) = MCORE_STRIP_NAME_ENCODING (SYM_NAME) - #define MULTIPLE_SYMBOL_SPACES 1 #define SUPPORTS_ONE_ONLY 1 diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 123028c759e..9bcca17dcd3 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -10285,8 +10285,8 @@ mips_unique_section (decl, reloc) }; name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); + name = (* targetm.strip_name_encoding) (name); size = int_size_in_bytes (TREE_TYPE (decl)); - STRIP_NAME_ENCODING (name, name); /* Determine the base section we are interested in: 0=text, 1=rodata, 2=data, 3=sdata, [4=bss]. */ diff --git a/gcc/config/mmix/mmix-protos.h b/gcc/config/mmix/mmix-protos.h index baa0849480a..51f91ee2b89 100644 --- a/gcc/config/mmix/mmix-protos.h +++ b/gcc/config/mmix/mmix-protos.h @@ -33,7 +33,6 @@ extern int mmix_register_move_cost PARAMS ((enum machine_mode, enum reg_class, enum reg_class)); extern const char *mmix_text_section_asm_op PARAMS ((void)); extern const char *mmix_data_section_asm_op PARAMS ((void)); -extern const char *mmix_strip_name_encoding PARAMS ((const char *)); extern void mmix_asm_file_start PARAMS ((FILE *)); extern void mmix_asm_file_end PARAMS ((FILE *)); extern void mmix_asm_output_source_filename PARAMS ((FILE *, const char *)); diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c index d798fa91031..74c5b729030 100644 --- a/gcc/config/mmix/mmix.c +++ b/gcc/config/mmix/mmix.c @@ -99,6 +99,7 @@ static void mmix_output_octa PARAMS ((FILE *, HOST_WIDEST_INT, int)); static bool mmix_assemble_integer PARAMS ((rtx, unsigned int, int)); static void mmix_init_machine_status PARAMS ((struct function *)); static void mmix_encode_section_info PARAMS ((tree, int)); +static const char *mmix_strip_name_encoding PARAMS ((const char *)); extern void mmix_target_asm_function_prologue PARAMS ((FILE *, HOST_WIDE_INT)); @@ -130,6 +131,8 @@ extern void mmix_target_asm_function_epilogue #undef TARGET_ENCODE_SECTION_INFO #define TARGET_ENCODE_SECTION_INFO mmix_encode_section_info +#undef TARGET_STRIP_NAME_ENCODING +#define TARGET_STRIP_NAME_ENCODING mmix_strip_name_encoding struct gcc_target targetm = TARGET_INITIALIZER; @@ -1768,9 +1771,7 @@ mmix_encode_section_info (decl, first) } } -/* STRIP_NAME_ENCODING. */ - -const char * +static const char * mmix_strip_name_encoding (name) const char *name; { diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h index 9eb968b74bf..0f9d5b71698 100644 --- a/gcc/config/mmix/mmix.h +++ b/gcc/config/mmix/mmix.h @@ -907,9 +907,6 @@ typedef struct { int regs; int lib; int now_varargs; } CUMULATIVE_ARGS; #define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rodata" -#define STRIP_NAME_ENCODING(VAR, SYM_NAME) \ - (VAR) = mmix_strip_name_encoding (SYM_NAME) - /* Node: PIC */ /* (empty) */ diff --git a/gcc/config/mn10200/mn10200.h b/gcc/config/mn10200/mn10200.h index 1356fd07c04..16f5f829d1f 100644 --- a/gcc/config/mn10200/mn10200.h +++ b/gcc/config/mn10200/mn10200.h @@ -830,12 +830,8 @@ struct cum_arg { int nbytes; }; `assemble_name' uses this. */ #undef ASM_OUTPUT_LABELREF -#define ASM_OUTPUT_LABELREF(FILE, NAME) \ - do { \ - const char* real_name; \ - STRIP_NAME_ENCODING (real_name, (NAME)); \ - fprintf (FILE, "_%s", real_name); \ - } while (0) +#define ASM_OUTPUT_LABELREF(FILE, NAME) \ + fprintf (FILE, "_%s", (*targetm.strip_name_encoding) (NAME)) /* Store in OUTPUT a string (made with alloca) containing an assembler-name for a local static variable named NAME. diff --git a/gcc/config/mn10300/mn10300.h b/gcc/config/mn10300/mn10300.h index 2c1dc7af05b..ddebedd4db4 100644 --- a/gcc/config/mn10300/mn10300.h +++ b/gcc/config/mn10300/mn10300.h @@ -911,12 +911,8 @@ struct cum_arg {int nbytes; }; `assemble_name' uses this. */ #undef ASM_OUTPUT_LABELREF -#define ASM_OUTPUT_LABELREF(FILE, NAME) \ - do { \ - const char* real_name; \ - STRIP_NAME_ENCODING (real_name, (NAME)); \ - fprintf (FILE, "_%s", real_name); \ - } while (0) +#define ASM_OUTPUT_LABELREF(FILE, NAME) \ + fprintf (FILE, "_%s", (*targetm.strip_name_encoding) (NAME)) /* Store in OUTPUT a string (made with alloca) containing an assembler-name for a local static variable named NAME. diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index d12c1be910a..41e5dc05c78 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -117,6 +117,7 @@ static int pa_issue_rate PARAMS ((void)); static void pa_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT)) ATTRIBUTE_UNUSED; static void pa_encode_section_info PARAMS ((tree, int)); +static const char *pa_strip_name_encoding PARAMS ((const char *)); /* Save the operands last given to a compare for use when we generate a scc or bcc insn. */ @@ -188,6 +189,8 @@ int n_deferred_plabels = 0; #undef TARGET_ENCODE_SECTION_INFO #define TARGET_ENCODE_SECTION_INFO pa_encode_section_info +#undef TARGET_STRIP_NAME_ENCODING +#define TARGET_STRIP_NAME_ENCODING pa_strip_name_encoding struct gcc_target targetm = TARGET_INITIALIZER; @@ -6285,7 +6288,7 @@ output_call (insn, call_dest, sibcall) /* Gross. We have just implicitly taken the address of this function, mark it as such. */ - STRIP_NAME_ENCODING (real_name, name); + real_name = (*targetm.strip_name_encoding) (name); TREE_SYMBOL_REFERENCED (get_identifier (real_name)) = 1; } @@ -6460,6 +6463,15 @@ pa_encode_section_info (decl, first) } } +/* This is sort of inverse to pa_encode_section_info. */ + +static const char * +pa_strip_name_encoding (str) + const char *str; +{ + return str + (*str == '*' || *str == '@'); +} + int function_label_operand (op, mode) rtx op; diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h index 55e4311b1a3..8f432c2cc0e 100644 --- a/gcc/config/pa/pa.h +++ b/gcc/config/pa/pa.h @@ -864,79 +864,80 @@ struct hppa_args {int words, nargs_prototype, indirect; }; extern struct rtx_def *hppa_compare_op0, *hppa_compare_op1; extern enum cmp_type hppa_branch_type; -#define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION) \ -{ const char *target_name = XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0); \ - static unsigned int current_thunk_number; \ - char label[16]; \ - char *lab; \ - ASM_GENERATE_INTERNAL_LABEL (label, "LTHN", current_thunk_number); \ - STRIP_NAME_ENCODING (lab, label); \ - STRIP_NAME_ENCODING (target_name, target_name); \ - /* FIXME: total_code_bytes is not handled correctly in files with \ - mi thunks. */ \ - pa_output_function_prologue (FILE, 0); \ - if (VAL_14_BITS_P (DELTA)) \ - { \ - if (! TARGET_64BIT && ! TARGET_PORTABLE_RUNTIME && flag_pic) \ - { \ - fprintf (FILE, "\taddil LT%%%s,%%r19\n", lab); \ - fprintf (FILE, "\tldw RT%%%s(%%r1),%%r22\n", lab); \ - fprintf (FILE, "\tldw 0(%%sr0,%%r22),%%r22\n"); \ - fprintf (FILE, "\tbb,>=,n %%r22,30,.+16\n"); \ - fprintf (FILE, "\tdepi 0,31,2,%%r22\n"); \ - fprintf (FILE, "\tldw 4(%%sr0,%%r22),%%r19\n"); \ - fprintf (FILE, "\tldw 0(%%sr0,%%r22),%%r22\n"); \ +#define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, DELTA, FUNCTION) \ +do { \ + const char *target_name = XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0); \ + static unsigned int current_thunk_number; \ + char label[16]; \ + char *lab; \ + ASM_GENERATE_INTERNAL_LABEL (label, "LTHN", current_thunk_number); \ + lab = (*targetm.strip_name_encoding) (label); \ + target_name = (*targetm.strip_name_encoding) (target_name); \ + /* FIXME: total_code_bytes is not handled correctly in files with \ + mi thunks. */ \ + pa_output_function_prologue (FILE, 0); \ + if (VAL_14_BITS_P (DELTA)) \ + { \ + if (! TARGET_64BIT && ! TARGET_PORTABLE_RUNTIME && flag_pic) \ + { \ + fprintf (FILE, "\taddil LT%%%s,%%r19\n", lab); \ + fprintf (FILE, "\tldw RT%%%s(%%r1),%%r22\n", lab); \ + fprintf (FILE, "\tldw 0(%%sr0,%%r22),%%r22\n"); \ + fprintf (FILE, "\tbb,>=,n %%r22,30,.+16\n"); \ + fprintf (FILE, "\tdepi 0,31,2,%%r22\n"); \ + fprintf (FILE, "\tldw 4(%%sr0,%%r22),%%r19\n"); \ + fprintf (FILE, "\tldw 0(%%sr0,%%r22),%%r22\n"); \ fprintf (FILE, "\tldsid (%%sr0,%%r22),%%r1\n\tmtsp %%r1,%%sr0\n"); \ - fprintf (FILE, "\tbe 0(%%sr0,%%r22)\n\tldo "); \ - fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, DELTA); \ - fprintf (FILE, "(%%r26),%%r26\n"); \ - } \ - else \ - { \ - fprintf (FILE, "\tb %s\n\tldo ", target_name); \ - fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, DELTA); \ - fprintf (FILE, "(%%r26),%%r26\n"); \ - } \ - } \ - else \ - { \ - if (! TARGET_64BIT && ! TARGET_PORTABLE_RUNTIME && flag_pic) \ - { \ - fprintf (FILE, "\taddil L%%"); \ - fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, DELTA); \ - fprintf (FILE, ",%%r26\n\tldo R%%"); \ - fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, DELTA); \ - fprintf (FILE, "(%%r1),%%r26\n"); \ - fprintf (FILE, "\taddil LT%%%s,%%r19\n", lab); \ - fprintf (FILE, "\tldw RT%%%s(%%r1),%%r22\n", lab); \ - fprintf (FILE, "\tldw 0(%%sr0,%%r22),%%r22\n"); \ - fprintf (FILE, "\tbb,>=,n %%r22,30,.+16\n"); \ - fprintf (FILE, "\tdepi 0,31,2,%%r22\n"); \ - fprintf (FILE, "\tldw 4(%%sr0,%%r22),%%r19\n"); \ - fprintf (FILE, "\tldw 0(%%sr0,%%r22),%%r22\n"); \ + fprintf (FILE, "\tbe 0(%%sr0,%%r22)\n\tldo "); \ + fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, DELTA); \ + fprintf (FILE, "(%%r26),%%r26\n"); \ + } \ + else \ + { \ + fprintf (FILE, "\tb %s\n\tldo ", target_name); \ + fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, DELTA); \ + fprintf (FILE, "(%%r26),%%r26\n"); \ + } \ + } \ + else \ + { \ + if (! TARGET_64BIT && ! TARGET_PORTABLE_RUNTIME && flag_pic) \ + { \ + fprintf (FILE, "\taddil L%%"); \ + fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, DELTA); \ + fprintf (FILE, ",%%r26\n\tldo R%%"); \ + fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, DELTA); \ + fprintf (FILE, "(%%r1),%%r26\n"); \ + fprintf (FILE, "\taddil LT%%%s,%%r19\n", lab); \ + fprintf (FILE, "\tldw RT%%%s(%%r1),%%r22\n", lab); \ + fprintf (FILE, "\tldw 0(%%sr0,%%r22),%%r22\n"); \ + fprintf (FILE, "\tbb,>=,n %%r22,30,.+16\n"); \ + fprintf (FILE, "\tdepi 0,31,2,%%r22\n"); \ + fprintf (FILE, "\tldw 4(%%sr0,%%r22),%%r19\n"); \ + fprintf (FILE, "\tldw 0(%%sr0,%%r22),%%r22\n"); \ fprintf (FILE, "\tldsid (%%sr0,%%r22),%%r1\n\tmtsp %%r1,%%sr0\n"); \ - fprintf (FILE, "\tbe,n 0(%%sr0,%%r22)\n"); \ - } \ - else \ - { \ - fprintf (FILE, "\taddil L%%"); \ - fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, DELTA); \ - fprintf (FILE, ",%%r26\n\tb %s\n\tldo R%%", target_name); \ - fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, DELTA); \ - fprintf (FILE, "(%%r1),%%r26\n"); \ - } \ - } \ - fprintf (FILE, "\t.EXIT\n\t.PROCEND\n"); \ - if (! TARGET_64BIT && ! TARGET_PORTABLE_RUNTIME && flag_pic) \ - { \ - data_section (); \ - fprintf (FILE, "\t.align 4\n"); \ - ASM_OUTPUT_INTERNAL_LABEL (FILE, "LTHN", current_thunk_number); \ - fprintf (FILE, "\t.word P%%%s\n", target_name); \ - function_section (THUNK_FNDECL); \ - } \ - current_thunk_number++; \ -} + fprintf (FILE, "\tbe,n 0(%%sr0,%%r22)\n"); \ + } \ + else \ + { \ + fprintf (FILE, "\taddil L%%"); \ + fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, DELTA); \ + fprintf (FILE, ",%%r26\n\tb %s\n\tldo R%%", target_name); \ + fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, DELTA); \ + fprintf (FILE, "(%%r1),%%r26\n"); \ + } \ + } \ + fprintf (FILE, "\t.EXIT\n\t.PROCEND\n"); \ + if (! TARGET_64BIT && ! TARGET_PORTABLE_RUNTIME && flag_pic) \ + { \ + data_section (); \ + fprintf (FILE, "\t.align 4\n"); \ + ASM_OUTPUT_INTERNAL_LABEL (FILE, "LTHN", current_thunk_number); \ + fprintf (FILE, "\t.word P%%%s\n", target_name); \ + function_section (THUNK_FNDECL); \ + } \ + current_thunk_number++; \ +} while (0) /* On HPPA, we emit profiling code as rtl via PROFILE_HOOK rather than as assembly via FUNCTION_PROFILER. Just output a local label. @@ -1522,13 +1523,6 @@ do { \ #define FUNCTION_NAME_P(NAME) (*(NAME) == '@') -/* Store the user-specified part of SYMBOL_NAME in VAR. - This is sort of inverse to targetm.encode_section_info. */ - -#define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \ - (VAR) = ((SYMBOL_NAME) \ - + (*(SYMBOL_NAME) == '*' || *(SYMBOL_NAME) == '@')) - /* Specify the machine mode that this machine uses for the index in the tablejump instruction. */ #define CASE_VECTOR_MODE (TARGET_BIG_SWITCH ? TImode : DImode) diff --git a/gcc/config/pa/som.h b/gcc/config/pa/som.h index 7c17ff6b810..9f0a964f32d 100644 --- a/gcc/config/pa/som.h +++ b/gcc/config/pa/som.h @@ -131,8 +131,7 @@ do { \ that the section name will have a "." prefix. */ #define ASM_OUTPUT_FUNCTION_PREFIX(FILE, NAME) \ { \ - const char *name; \ - STRIP_NAME_ENCODING (name, NAME); \ + const char *name = (*targetm.strip_name_encoding) (NAME); \ if (TARGET_GAS && in_section == in_text) \ fputs ("\t.NSUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY\n", FILE); \ else if (TARGET_GAS) \ @@ -335,7 +334,7 @@ readonly_data () \ if (!function_label_operand (RTL, VOIDmode)) \ hppa_encode_label (RTL); \ \ - STRIP_NAME_ENCODING (name, XSTR ((RTL), 0)); \ + name = (*targetm.strip_name_encoding) (XSTR ((RTL), 0)); \ id = maybe_get_identifier (name); \ if (! id || ! TREE_SYMBOL_REFERENCED (id)) \ { \ diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index e6e8ef93a54..1a65a772271 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -169,6 +169,7 @@ static void rs6000_elf_unique_section PARAMS ((tree, int)); static void rs6000_elf_select_rtx_section PARAMS ((enum machine_mode, rtx, unsigned HOST_WIDE_INT)); static void rs6000_elf_encode_section_info PARAMS ((tree, int)); +static const char *rs6000_elf_strip_name_encoding PARAMS ((const char *)); #endif #ifdef OBJECT_FORMAT_COFF static void xcoff_asm_named_section PARAMS ((const char *, unsigned int)); @@ -177,6 +178,7 @@ static void rs6000_xcoff_select_section PARAMS ((tree, int, static void rs6000_xcoff_unique_section PARAMS ((tree, int)); static void rs6000_xcoff_select_rtx_section PARAMS ((enum machine_mode, rtx, unsigned HOST_WIDE_INT)); +static const char * rs6000_xcoff_strip_name_encoding PARAMS ((const char *)); #endif static void rs6000_xcoff_encode_section_info PARAMS ((tree, int)) ATTRIBUTE_UNUSED; @@ -10385,7 +10387,7 @@ output_toc (file, x, labelno, mode) else abort (); - STRIP_NAME_ENCODING (real_name, name); + real_name = (*targetm.strip_name_encoding) (name); if (TARGET_MINIMAL_TOC) fputs (TARGET_32BIT ? "\t.long " : DOUBLE_INT_ASM_OP, file); else @@ -10557,7 +10559,7 @@ output_profile_hook (labelno) rtx fun; ASM_GENERATE_INTERNAL_LABEL (buf, "LP", labelno); - STRIP_NAME_ENCODING (label_name, ggc_strdup (buf)); + label_name = (*targetm.strip_name_encoding) (ggc_strdup (buf)); fun = gen_rtx_SYMBOL_REF (Pmode, label_name); emit_library_call (init_one_libfunc (RS6000_MCOUNT), 0, VOIDmode, 1, @@ -11075,7 +11077,8 @@ rs6000_elf_unique_section (decl, reloc) } } - STRIP_NAME_ENCODING (name, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); + name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); + name = (*targetm.strip_name_encoding) (name); prefix = prefixes[sec][DECL_ONE_ONLY (decl)]; len = strlen (name) + strlen (prefix); string = alloca (len + 1); @@ -11167,6 +11170,15 @@ rs6000_elf_encode_section_info (decl, first) } } +static const char * +rs6000_elf_strip_name_encoding (str) + const char *str; +{ + while (*str == '*' || *str == '@') + str++; + return str; +} + #endif /* USING_ELFOS_H */ @@ -11432,7 +11444,7 @@ machopic_output_stub (file, symb, stub) static int label = 0; /* Lose our funky encoding stuff so it doesn't contaminate the stub. */ - STRIP_NAME_ENCODING (symb, symb); + symb = (*targetm.strip_name_encoding) (symb); label += 1; @@ -11671,7 +11683,7 @@ rs6000_xcoff_select_section (exp, reloc, align) static void rs6000_xcoff_unique_section (decl, reloc) tree decl; - int reloc; + int reloc ATTRIBUTE_UNUSED; { const char *name; char *string; @@ -11704,6 +11716,23 @@ rs6000_xcoff_select_rtx_section (mode, x, align) else read_only_private_data_section (); } + +/* Remove any trailing [DS] or the like from the symbol name. */ + +static const char * +rs6000_xcoff_strip_name_encoding (name) + const char *name; +{ + size_t len; + if (*name == '*') + name++; + len = strlen (name); + if (name[len - 1] == ']') + return ggc_alloc_string (name, len - 4); + else + return name; +} + #endif /* OBJECT_FORMAT_COFF */ /* Note that this is also used for ELF64. */ diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h index 0c601d05a44..8aee2e22a85 100644 --- a/gcc/config/rs6000/sysv4.h +++ b/gcc/config/rs6000/sysv4.h @@ -625,7 +625,7 @@ extern int rs6000_pic_labelno; { \ const char *desc_name, *orig_name; \ \ - STRIP_NAME_ENCODING (orig_name, NAME); \ + orig_name = (*targetm.strip_name_encoding) (NAME); \ desc_name = orig_name; \ while (*desc_name == '.') \ desc_name++; \ @@ -776,25 +776,14 @@ extern int fixuplabelno; /* Historically we have also supported stabs debugging. */ #define DBX_DEBUGGING_INFO -#undef TARGET_ENCODE_SECTION_INFO #define TARGET_ENCODE_SECTION_INFO rs6000_elf_encode_section_info +#define TARGET_STRIP_NAME_ENCODING rs6000_elf_strip_name_encoding /* The ELF version doesn't encode [DS] or whatever at the end of symbols. */ #define RS6000_OUTPUT_BASENAME(FILE, NAME) \ assemble_name (FILE, NAME) -/* This macro gets just the user-specified name - out of the string in a SYMBOL_REF. Discard - a leading * or @. */ -#define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \ -do { \ - const char *_name = SYMBOL_NAME; \ - while (*_name == '*' || *_name == '@') \ - _name++; \ - (VAR) = _name; \ -} while (0) - /* This is how to output a reference to a user-level label named NAME. `assemble_name' uses this. */ diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h index 211e1fc4c6f..90f27276b6a 100644 --- a/gcc/config/rs6000/xcoff.h +++ b/gcc/config/rs6000/xcoff.h @@ -163,6 +163,7 @@ toc_section () \ #define TARGET_ASM_SELECT_RTX_SECTION rs6000_xcoff_select_rtx_section #define TARGET_ENCODE_SECTION_INFO rs6000_xcoff_encode_section_info +#define TARGET_STRIP_NAME_ENCODING rs6000_xcoff_strip_name_encoding /* FP save and restore routines. */ #define SAVE_FP_PREFIX "._savef" @@ -183,13 +184,8 @@ toc_section () \ /* This outputs NAME to FILE up to the first null or '['. */ -#define RS6000_OUTPUT_BASENAME(FILE, NAME) \ - { \ - const char *_p; \ - \ - STRIP_NAME_ENCODING (_p, (NAME)); \ - assemble_name ((FILE), _p); \ - } +#define RS6000_OUTPUT_BASENAME(FILE, NAME) \ + assemble_name ((FILE), (*targetm.strip_name_encoding) (NAME)) /* This is how to output the definition of a user-level label named NAME, such as the label on a static function or variable NAME. */ @@ -204,28 +200,6 @@ toc_section () \ do { fputs ("\t.globl ", FILE); \ RS6000_OUTPUT_BASENAME (FILE, NAME); putc ('\n', FILE);} while (0) -/* Remove any trailing [DS] or the like from the symbol name. */ - -#define STRIP_NAME_ENCODING(VAR,NAME) \ - do \ - { \ - const char *_name = (NAME); \ - size_t _len; \ - if (*_name == '*') \ - _name++; \ - _len = strlen (_name); \ - if (_name[_len - 1] != ']') \ - (VAR) = _name; \ - else \ - { \ - char *_new_name = (char *) alloca (_len + 1); \ - strcpy (_new_name, _name); \ - _new_name[_len - 4] = '\0'; \ - (VAR) = _new_name; \ - } \ - } \ - while (0) - /* Output at beginning of assembler file. Initialize the section names for the RS/6000 at this point. diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index b84f6220a9e..0dafbc32d11 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -204,6 +204,7 @@ static bool sh_cannot_modify_jumps_p PARAMS ((void)); static bool sh_ms_bitfield_layout_p PARAMS ((tree)); static void sh_encode_section_info PARAMS ((tree, int)); +static const char *sh_strip_name_encoding PARAMS ((const char *)); /* Initialize the GCC target structure. */ #undef TARGET_ATTRIBUTE_TABLE @@ -242,6 +243,11 @@ static void sh_encode_section_info PARAMS ((tree, int)); #undef TARGET_MS_BITFIELD_LAYOUT_P #define TARGET_MS_BITFIELD_LAYOUT_P sh_ms_bitfield_layout_p +#undef TARGET_ENCODE_SECTION_INFO +#define TARGET_ENCODE_SECTION_INFO sh_encode_section_info +#undef TARGET_STRIP_NAME_ENCODING +#define TARGET_STRIP_NAME_ENCODING sh_strip_name_encoding + struct gcc_target targetm = TARGET_INITIALIZER; /* Print the operand address in x to the stream. */ @@ -6820,3 +6826,14 @@ sh_encode_section_info (decl, first) if (TARGET_SH5 && first && TREE_CODE (decl) != FUNCTION_DECL) XEXP (rtl, 0) = gen_datalabel_ref (symbol); } + +/* Undo the effects of the above. */ + +static const char * +sh_strip_name_encoding (str) + const char *str; +{ + STRIP_DATALABEL_ENCODING (str, str); + str += *str == '*'; + return str; +} diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h index 084287424de..c8e0c08cf2e 100644 --- a/gcc/config/sh/sh.h +++ b/gcc/config/sh/sh.h @@ -2681,9 +2681,6 @@ while (0) #define STRIP_DATALABEL_ENCODING(VAR, SYM_NAME) \ (VAR) = (SYM_NAME) + (DATALABEL_SYMNAME_P (SYM_NAME) \ ? strlen (SH_DATALABEL_ENCODING) : 0) -#define STRIP_NAME_ENCODING(VAR, SYM_NAME) \ - STRIP_DATALABEL_ENCODING((VAR), (SYM_NAME)), \ - (VAR) += (*(VAR) == '*') /* We can't directly access anything that contains a symbol, nor can we indirect via the constant pool. */ diff --git a/gcc/config/stormy16/stormy16.h b/gcc/config/stormy16/stormy16.h index 7ae92ee5413..7a6b166aec7 100644 --- a/gcc/config/stormy16/stormy16.h +++ b/gcc/config/stormy16/stormy16.h @@ -2489,10 +2489,6 @@ do { \ This macro is irrelevant if there is no separate readonly data section. */ #define JUMP_TABLES_IN_TEXT_SECTION 1 - -/* Decode SYM_NAME and store the real name part in VAR, sans the characters - that encode section info. */ -/* #define STRIP_NAME_ENCODING(VAR, SYM_NAME) */ /* Position Independent Code. */ diff --git a/gcc/config/v850/v850.c b/gcc/config/v850/v850.c index df4d0031765..e65dae596cb 100644 --- a/gcc/config/v850/v850.c +++ b/gcc/config/v850/v850.c @@ -61,6 +61,7 @@ static void v850_insert_attributes PARAMS ((tree, tree *)); static void v850_select_section PARAMS ((tree, int, unsigned HOST_WIDE_INT)); static void v850_encode_data_area PARAMS ((tree)); static void v850_encode_section_info PARAMS ((tree, int)); +static const char *v850_strip_name_encoding PARAMS ((const char *)); /* True if the current function has anonymous arguments. */ int current_function_anonymous_args; @@ -104,6 +105,8 @@ static int v850_interrupt_p = FALSE; #undef TARGET_ENCODE_SECTION_INFO #define TARGET_ENCODE_SECTION_INFO v850_encode_section_info +#undef TARGET_STRIP_NAME_ENCODING +#define TARGET_STRIP_NAME_ENCODING v850_strip_name_encoding struct gcc_target targetm = TARGET_INITIALIZER; @@ -2218,6 +2221,13 @@ v850_encode_section_info (decl, first) v850_encode_data_area (decl); } +static const char * +v850_strip_name_encoding (str) + const char *str; +{ + return str + (ENCODED_NAME_P (str) || *str == '*'); +} + /* Return true if the given RTX is a register which can be restored by a function epilogue. */ int diff --git a/gcc/config/v850/v850.h b/gcc/config/v850/v850.h index 54a1bec6324..bb753adbd7a 100644 --- a/gcc/config/v850/v850.h +++ b/gcc/config/v850/v850.h @@ -1194,13 +1194,8 @@ zbss_section () \ `assemble_name' uses this. */ #undef ASM_OUTPUT_LABELREF -#define ASM_OUTPUT_LABELREF(FILE, NAME) \ - do { \ - const char* real_name; \ - STRIP_NAME_ENCODING (real_name, (NAME)); \ - asm_fprintf (FILE, "%U%s", real_name); \ - } while (0) - +#define ASM_OUTPUT_LABELREF(FILE, NAME) \ + asm_fprintf (FILE, "%U%s", (*targetm.strip_name_encoding) (NAME)) /* Store in OUTPUT a string (made with alloca) containing an assembler-name for a local static variable named NAME. @@ -1427,9 +1422,6 @@ extern union tree_node * GHS_current_section_names [(int) COUNT_OF_GHS_SECTION_K || TDA_NAME_P (SYMBOL_NAME) \ || SDA_NAME_P (SYMBOL_NAME)) -#define STRIP_NAME_ENCODING(VAR, SYMBOL_NAME) \ - (VAR) = (SYMBOL_NAME) + (ENCODED_NAME_P (SYMBOL_NAME) || *(SYMBOL_NAME) == '*') - /* Define this if you have defined special-purpose predicates in the file `MACHINE.c'. This macro is called within an initializer of an array of structures. The first field in the structure is the name diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 69515b8033b..86971843b9d 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -4781,8 +4781,8 @@ The best way to modify the name string is by adding text to the beginning, with suitable punctuation to prevent any ambiguity. Allocate the new name in @code{saveable_obstack}. You will have to modify @code{ASM_OUTPUT_LABELREF} to remove and decode the added text and -output the name accordingly, and define @code{STRIP_NAME_ENCODING} to -access the original name string. +output the name accordingly, and define @code{TARGET_STRIP_NAME_ENCODING} +to access the original name string. You can check the information stored here into the @code{symbol_ref} in the definitions of the macros @code{GO_IF_LEGITIMATE_ADDRESS} and @@ -5765,12 +5765,6 @@ section, along with the assembler instructions. Otherwise, the readonly data section is used. This macro is irrelevant if there is no separate readonly data section. - -@findex STRIP_NAME_ENCODING -@item STRIP_NAME_ENCODING (@var{var}, @var{sym_name}) -Decode @var{sym_name} and store the real name part in @var{var}, sans -the characters that encode section info. Define this macro if -@code{TARGET_ENCODE_SECTION_INFO} alters the symbol's name string. @end table @deftypefn {Target Hook} void TARGET_ASM_SELECT_SECTION (tree @var{exp}, int @var{reloc}, unsigned HOST_WIDE_INT @var{align}) @@ -5838,6 +5832,12 @@ modified name string in the @code{symbol_ref} (if one bit is not enough information). @end deftypefn +@deftypefn {Target Hook} const char *TARGET_STRIP_NAME_ENCODING (const char *name) +Decode @var{name} and return the real name part, sans +the characters that @code{TARGET_ENCODE_SECTION_INFO} +may have added. +@end deftypefn + @node PIC @section Position Independent Code @cindex position independent code diff --git a/gcc/dwarf2asm.c b/gcc/dwarf2asm.c index 53a02c7fcd5..80be6513721 100644 --- a/gcc/dwarf2asm.c +++ b/gcc/dwarf2asm.c @@ -739,7 +739,7 @@ dw2_force_const_mem (x) if (GET_CODE (x) != SYMBOL_REF) abort (); - STRIP_NAME_ENCODING (str, XSTR (x, 0)); + str = (* targetm.strip_name_encoding) (XSTR (x, 0)); node = splay_tree_lookup (indirect_pool, (splay_tree_key) str); if (node) decl = (tree) node->value; diff --git a/gcc/output.h b/gcc/output.h index 82dc08341ff..e274f43bc26 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -482,14 +482,6 @@ extern rtx this_is_asm_operands; /* User label prefix in effect for this compilation. */ extern const char *user_label_prefix; -/* This macro gets just the user-specified name - out of the string in a SYMBOL_REF. On most machines, - we discard the * if any and that's all. */ -#ifndef STRIP_NAME_ENCODING -#define STRIP_NAME_ENCODING(VAR,SYMBOL_NAME) \ - (VAR) = ((SYMBOL_NAME) + ((SYMBOL_NAME)[0] == '*')) -#endif - /* Default target function prologue and epilogue assembler output. */ extern void default_function_pro_epilogue PARAMS ((FILE *, HOST_WIDE_INT)); @@ -552,6 +544,8 @@ 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 const char *default_strip_name_encoding PARAMS ((const char *)); + /* Emit data for vtable gc for GNU binutils. */ extern void assemble_vtable_entry PARAMS ((struct rtx_def *, HOST_WIDE_INT)); extern void assemble_vtable_inherit PARAMS ((struct rtx_def *, diff --git a/gcc/system.h b/gcc/system.h index d26515bc60f..465c47c285d 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -596,7 +596,7 @@ typedef char _Bool; MD_INIT_BUILTINS MD_EXPAND_BUILTIN ASM_OUTPUT_CONSTRUCTOR \ ASM_OUTPUT_DESTRUCTOR SIGNED_CHAR_SPEC MAX_CHAR_TYPE_SIZE \ WCHAR_UNSIGNED UNIQUE_SECTION SELECT_SECTION SELECT_RTX_SECTION \ - ENCODE_SECTION_INFO + ENCODE_SECTION_INFO STRIP_NAME_ENCODING /* And other obsolete target macros, or macros that used to be in target headers and were not used, and may be obsolete or may never have diff --git a/gcc/target-def.h b/gcc/target-def.h index 557081652ac..40a3af0dcbd 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -205,6 +205,10 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define TARGET_SECTION_TYPE_FLAGS default_section_type_flags #endif +#ifndef TARGET_STRIP_NAME_ENCODING +#define TARGET_STRIP_NAME_ENCODING default_strip_name_encoding +#endif + /* In hook.c. */ #define TARGET_CANNOT_MODIFY_JUMPS_P hook_void_bool_false #define TARGET_IN_SMALL_DATA_P hook_tree_bool_false @@ -233,7 +237,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. TARGET_HAVE_CTORS_DTORS, \ TARGET_CANNOT_MODIFY_JUMPS_P, \ TARGET_IN_SMALL_DATA_P, \ - TARGET_ENCODE_SECTION_INFO \ + TARGET_ENCODE_SECTION_INFO, \ + TARGET_STRIP_NAME_ENCODING \ } #include "hooks.h" diff --git a/gcc/target.h b/gcc/target.h index 97dd6d52bae..1864d4a88f9 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -247,6 +247,9 @@ struct gcc_target /* Do something target-specific to record properties of the DECL into the associated SYMBOL_REF. */ void (* encode_section_info) PARAMS ((tree, int)); + + /* Undo the effects of encode_section_info on the symbol string. */ + const char * (* strip_name_encoding) PARAMS ((const char *)); }; extern struct gcc_target targetm; diff --git a/gcc/varasm.c b/gcc/varasm.c index eb570815253..797b67689e5 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1207,7 +1207,7 @@ assemble_start_function (decl, fnname) const char *p; char *name; - STRIP_NAME_ENCODING (p, fnname); + p = (* targetm.strip_name_encoding) (fnname); name = permalloc (strlen (p) + 1); strcpy (name, p); @@ -1527,7 +1527,7 @@ assemble_variable (decl, top_level, at_end, dont_output_data) const char *p; char *xname; - STRIP_NAME_ENCODING (p, name); + p = (* targetm.strip_name_encoding) (name); xname = permalloc (strlen (p) + 1); strcpy (xname, p); first_global_object_name = xname; @@ -1786,7 +1786,7 @@ assemble_name (file, name) const char *real_name; tree id; - STRIP_NAME_ENCODING (real_name, name); + real_name = (* targetm.strip_name_encoding) (name); id = maybe_get_identifier (real_name); if (id) @@ -5477,7 +5477,7 @@ default_unique_section (decl, reloc) plen = strlen (prefix); name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); - STRIP_NAME_ENCODING (name, name); + name = (* targetm.strip_name_encoding) (name); nlen = strlen (name); string = alloca (nlen + plen + 1); @@ -5535,3 +5535,13 @@ default_elf_select_rtx_section (mode, x, align) mergeable_constant_section (mode, align, 0); } + +/* By default, we do nothing for encode_section_info, so we need not + do anything but discard the '*' marker. */ + +const char * +default_strip_name_encoding (str) + const char *str; +{ + return str + (*str == '*'); +} diff --git a/gcc/xcoffout.c b/gcc/xcoffout.c index 8396b7b334c..e0265898a9e 100644 --- a/gcc/xcoffout.c +++ b/gcc/xcoffout.c @@ -32,6 +32,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "toplev.h" #include "output.h" #include "ggc.h" +#include "target.h" #ifdef XCOFF_DEBUGGING_INFO |