From: Trevor Saunders <tbsaunde+...@tbsaunde.org> gcc/ChangeLog:
2015-07-25 Trevor Saunders <tsaund...@mozilla.com> * defaults.h (ASM_OUTPUT_ASCII): Remove default definition. * doc/tm.texi: Regenerate. * doc/tm.texi.in (ASM_OUTPUT_ASCII): Remove documentation of removed macro. * target.def (output_ascii): New hook. * config/arm/aout.h, config/arm/arm-protos.h, config/arm/arm.c, config/elfos.h, config/i386/att.h, config/i386/i386-protos.h, config/i386/i386.c, config/i386/i386elf.h, config/mips/mips.c, config/mips/mips.h, config/mmix/mmix-protos.h, config/mmix/mmix.c, config/mmix/mmix.h, config/nvptx/nvptx-protos.h, config/nvptx/nvptx.c, config/nvptx/nvptx.h, config/pa/pa-protos.h, config/pa/pa.c, config/pa/pa.h, config/pdp11/pdp11-protos.h, config/pdp11/pdp11.c, config/pdp11/pdp11.h, config/rs6000/rs6000-protos.h, config/rs6000/rs6000.c, config/rs6000/xcoff.h, dwarf2asm.c, output.h, varasm.c, varasm.h, vmsdbgout.c: Adjust. --- gcc/config/arm/aout.h | 5 +-- gcc/config/arm/arm-protos.h | 2 +- gcc/config/arm/arm.c | 7 ++-- gcc/config/elfos.h | 7 ++-- gcc/config/i386/att.h | 13 +------ gcc/config/i386/i386-protos.h | 2 + gcc/config/i386/i386.c | 77 +++++++++++++++++++++++++++++++++++++++ gcc/config/i386/i386elf.h | 51 +------------------------- gcc/config/mips/mips.c | 2 +- gcc/config/mips/mips.h | 4 +- gcc/config/mmix/mmix-protos.h | 2 +- gcc/config/mmix/mmix.c | 4 +- gcc/config/mmix/mmix.h | 3 +- gcc/config/nvptx/nvptx-protos.h | 2 +- gcc/config/nvptx/nvptx.c | 2 +- gcc/config/nvptx/nvptx.h | 5 +-- gcc/config/pa/pa-protos.h | 2 +- gcc/config/pa/pa.c | 7 ++-- gcc/config/pa/pa.h | 3 +- gcc/config/pdp11/pdp11-protos.h | 2 +- gcc/config/pdp11/pdp11.c | 6 +-- gcc/config/pdp11/pdp11.h | 3 +- gcc/config/rs6000/rs6000-protos.h | 2 +- gcc/config/rs6000/rs6000.c | 6 +-- gcc/config/rs6000/xcoff.h | 2 +- gcc/defaults.h | 40 -------------------- gcc/doc/tm.texi | 14 +++---- gcc/doc/tm.texi.in | 11 +----- gcc/dwarf2asm.c | 2 +- gcc/output.h | 2 +- gcc/target.def | 9 +++++ gcc/varasm.c | 47 ++++++++++++++++++++---- gcc/varasm.h | 2 + gcc/vmsdbgout.c | 7 ++-- 34 files changed, 179 insertions(+), 176 deletions(-) diff --git a/gcc/config/arm/aout.h b/gcc/config/arm/aout.h index 6973d15..c5e63eb 100644 --- a/gcc/config/arm/aout.h +++ b/gcc/config/arm/aout.h @@ -241,9 +241,8 @@ while (0) -#undef ASM_OUTPUT_ASCII -#define ASM_OUTPUT_ASCII(STREAM, PTR, LEN) \ - output_ascii_pseudo_op (STREAM, (const unsigned char *) (PTR), LEN) +#undef TARGET_ASM_OUTPUT_ASCII +#define TARGET_ASM_OUTPUT_ASCII output_ascii_pseudo_op /* Output a gap. In fact we fill it with nulls. */ #undef ASM_OUTPUT_SKIP diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h index 62f91ef..6fc4787d 100644 --- a/gcc/config/arm/arm-protos.h +++ b/gcc/config/arm/arm-protos.h @@ -144,7 +144,7 @@ extern int arm_attr_length_move_neon (rtx_insn *); extern int arm_address_offset_is_imm (rtx_insn *); extern const char *output_add_immediate (rtx *); extern const char *arithmetic_instr (rtx, int); -extern void output_ascii_pseudo_op (FILE *, const unsigned char *, int); +extern void output_ascii_pseudo_op (FILE *, const char *, size_t); extern const char *output_return_instruction (rtx, bool, bool, bool); extern void arm_poke_function_name (FILE *, const char *); extern void arm_final_prescan_insn (rtx_insn *); diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index eeab8a8..f03abf7 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -18963,14 +18963,13 @@ int_log2 (HOST_WIDE_INT power) #define MAX_ASCII_LEN 51 void -output_ascii_pseudo_op (FILE *stream, const unsigned char *p, int len) +output_ascii_pseudo_op (FILE *stream, const char *p, size_t len) { - int i; int len_so_far = 0; fputs ("\t.ascii\t\"", stream); - for (i = 0; i < len; i++) + for (size_t i = 0; i < len; i++) { int c = p[i]; @@ -19586,7 +19585,7 @@ arm_poke_function_name (FILE *stream, const char *name) length = strlen (name) + 1; alignlength = ROUND_UP_WORD (length); - ASM_OUTPUT_ASCII (stream, name, length); + targetm.asm_out.output_ascii (stream, name, length); ASM_OUTPUT_ALIGN (stream, 2); x = GEN_INT ((unsigned HOST_WIDE_INT) 0xff000000 + alignlength); assemble_aligned_integer (UNITS_PER_WORD, x); diff --git a/gcc/config/elfos.h b/gcc/config/elfos.h index bcc3870..d2cbbfb 100644 --- a/gcc/config/elfos.h +++ b/gcc/config/elfos.h @@ -385,7 +385,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see while (0) #endif -/* A table of bytes codes used by the ASM_OUTPUT_ASCII and +/* A table of bytes codes used by the TARGET_ASM_OUTPUT_ASCII and ASM_OUTPUT_LIMITED_STRING macros. Each byte in the table corresponds to a particular byte value [0..255]. For any given byte value, if the value in the corresponding table @@ -442,9 +442,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see character sequence which end with NUL (and which are shorter than STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */ -#undef ASM_OUTPUT_ASCII -#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \ - default_elf_asm_output_ascii ((FILE), (STR), (LENGTH)); +#undef TARGET_ASM_OUTPUT_ASCII +#define TARGET_ASM_OUTPUT_ASCII default_elf_asm_output_ascii /* Allow the use of the -frecord-gcc-switches switch via the elf_record_gcc_switches function defined in varasm.c. */ diff --git a/gcc/config/i386/att.h b/gcc/config/i386/att.h index f58bef9..45210b7 100644 --- a/gcc/config/i386/att.h +++ b/gcc/config/i386/att.h @@ -37,17 +37,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see /* How to output an ASCII string constant. */ -#undef ASM_OUTPUT_ASCII -#define ASM_OUTPUT_ASCII(FILE, PTR, SIZE) \ -do \ -{ size_t i = 0, limit = (SIZE); \ - while (i < limit) \ - { if (i%10 == 0) { if (i!=0) putc ('\n', (FILE)); \ - fputs (ASM_BYTE, (FILE)); } \ - else putc (',', (FILE)); \ - fprintf ((FILE), "0x%x", ((PTR)[i++] & 0377)) ;} \ - putc ('\n', (FILE)); \ -} while (0) +#undef TARGET_ASM_OUTPUT_ASCII +#define TARGET_ASM_OUTPUT_ASCII ix86_att_output_ascii /* Output at beginning of assembler file. */ #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index 6a17ef4..0b5e64f 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -152,6 +152,8 @@ extern machine_mode ix86_fp_compare_mode (enum rtx_code); extern rtx ix86_libcall_value (machine_mode); extern bool ix86_function_arg_regno_p (int); +extern void ix86_elf_output_ascii (FILE *, const char *, size_t); +extern void ix86_att_output_ascii (FILE *, const char *, size_t); extern void ix86_asm_output_function_label (FILE *, const char *, tree); extern void ix86_call_abi_override (const_tree); extern int ix86_reg_parm_stack_space (const_tree); diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index d6b4508..1e07243 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -96,10 +96,18 @@ static rtx legitimize_dllimport_symbol (rtx, bool); static rtx legitimize_pe_coff_extern_decl (rtx, bool); static rtx legitimize_pe_coff_symbol (rtx, bool); +#ifndef ASM_OUTPUT_LIMITED_STRING +#define ASM_OUTPUT_LIMITED_STRING(a, b) +#endif + #ifndef CHECK_STACK_LIMIT #define CHECK_STACK_LIMIT (-1) #endif +#ifndef ELF_STRING_LIMIT +#define ELF_STRING_LIMIT 0 +#endif + /* Return index of given mode in mult and division cost tables. */ #define MODE_INDEX(mode) \ ((mode) == QImode ? 0 \ @@ -6387,6 +6395,75 @@ ix86_cfun_abi (void) return cfun->machine->call_abi; } +/* The routine used to output sequences of byte values. We use a special + version of this for most svr4 targets because doing so makes the + generated assembly code more compact (and thus faster to assemble) + as well as more readable. Note that if we find subparts of the + character sequence which end with NUL (and which are shorter than + ELF_STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */ + +void +ix86_elf_output_ascii (FILE *f, const char *string, size_t length) +{ + const unsigned char *_ascii_bytes = (const unsigned char *) string; + const unsigned char *limit = _ascii_bytes + length; + unsigned bytes_in_chunk = 0; + for (; _ascii_bytes < limit; _ascii_bytes++) + { + const unsigned char *p; + if (bytes_in_chunk >= 64) + { + fputc ('\n', f); + bytes_in_chunk = 0; + } + for (p = _ascii_bytes; p < limit && *p != '\0'; p++) + continue; + if (p < limit && (p - _ascii_bytes) <= (long) ELF_STRING_LIMIT) + { + if (bytes_in_chunk > 0) + { + fputc ('\n', f); + bytes_in_chunk = 0; + } + ASM_OUTPUT_LIMITED_STRING (f, (const char *) _ascii_bytes); + _ascii_bytes = p; + } + else + { + if (bytes_in_chunk == 0) + fputs (ASM_BYTE, f); + else + fputc (',', f); + fprintf (f, "0x%02x", *_ascii_bytes); \ + bytes_in_chunk += 5; + } + } + + if (bytes_in_chunk > 0) + fputc ('\n', f); +} + +void +ix86_att_output_ascii (FILE *f, const char *ptr, size_t length) +{ + size_t i = 0, limit = length; + while (i < limit) + { + if (i%10 == 0) + { + if (i!=0) + putc ('\n', f); + + fputs (ASM_BYTE, f); + } + else + putc (',', f); + fprintf (f, "0x%x", (ptr[i++] & 0377)); + } + + putc ('\n', f); +} + /* Write the extra assembler code needed to declare a function properly. */ void diff --git a/gcc/config/i386/i386elf.h b/gcc/config/i386/i386elf.h index aed5e04..608c77c 100644 --- a/gcc/config/i386/i386elf.h +++ b/gcc/config/i386/i386elf.h @@ -40,55 +40,8 @@ along with GCC; see the file COPYING3. If not see #define DBX_REGISTER_NUMBER(n) \ (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n]) -/* The routine used to output sequences of byte values. We use a special - version of this for most svr4 targets because doing so makes the - generated assembly code more compact (and thus faster to assemble) - as well as more readable. Note that if we find subparts of the - character sequence which end with NUL (and which are shorter than - ELF_STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */ - -#undef ASM_OUTPUT_ASCII -#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \ - do \ - { \ - const unsigned char *_ascii_bytes = \ - (const unsigned char *) (STR); \ - const unsigned char *limit = _ascii_bytes + (LENGTH); \ - unsigned bytes_in_chunk = 0; \ - for (; _ascii_bytes < limit; _ascii_bytes++) \ - { \ - const unsigned char *p; \ - if (bytes_in_chunk >= 64) \ - { \ - fputc ('\n', (FILE)); \ - bytes_in_chunk = 0; \ - } \ - for (p = _ascii_bytes; p < limit && *p != '\0'; p++) \ - continue; \ - if (p < limit && (p - _ascii_bytes) <= (long) ELF_STRING_LIMIT) \ - { \ - if (bytes_in_chunk > 0) \ - { \ - fputc ('\n', (FILE)); \ - bytes_in_chunk = 0; \ - } \ - ASM_OUTPUT_LIMITED_STRING ((FILE), (const char *) _ascii_bytes); \ - _ascii_bytes = p; \ - } \ - else \ - { \ - if (bytes_in_chunk == 0) \ - fputs (ASM_BYTE, (FILE)); \ - else \ - fputc (',', (FILE)); \ - fprintf ((FILE), "0x%02x", *_ascii_bytes); \ - bytes_in_chunk += 5; \ - } \ - } \ - if (bytes_in_chunk > 0) \ - fputc ('\n', (FILE)); \ - } \ - while (0) +#undef TARGET_ASM_OUTPUT_ASCII +#define TARGET_ASM_OUTPUT_ASCII ix86_elf_output_ascii #define LOCAL_LABEL_PREFIX "." diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index bf0f84f..2b06630 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -9129,7 +9129,7 @@ mips_dspalu_bypass_p (rtx out_insn, rtx in_insn) return false; } -/* Implement ASM_OUTPUT_ASCII. */ +/* Implement TARGET_ASM_OUTPUT_ASCII. */ void mips_output_ascii (FILE *stream, const char *string, size_t len) diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index d17a833..93486c4 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -2922,8 +2922,8 @@ do { \ fprintf (STREAM, "\t.space\t" HOST_WIDE_INT_PRINT_UNSIGNED"\n", (SIZE)) /* This is how to output a string. */ -#undef ASM_OUTPUT_ASCII -#define ASM_OUTPUT_ASCII mips_output_ascii +#undef TARGET_ASM_OUTPUT_ASCII +#define TARGET_ASM_OUTPUT_ASCII mips_output_ascii /* Default to -G 8 */ diff --git a/gcc/config/mmix/mmix-protos.h b/gcc/config/mmix/mmix-protos.h index 9c08963..3b87129 100644 --- a/gcc/config/mmix/mmix-protos.h +++ b/gcc/config/mmix/mmix-protos.h @@ -28,7 +28,7 @@ extern int mmix_reversible_cc_mode (machine_mode); extern const char *mmix_text_section_asm_op (void); extern const char *mmix_data_section_asm_op (void); extern void mmix_output_quoted_string (FILE *, const char *, int); -extern void mmix_asm_output_ascii (FILE *, const char *, int); +extern void mmix_asm_output_ascii (FILE *, const char *, size_t); extern void mmix_asm_output_label (FILE *, const char *); extern void mmix_asm_output_internal_label (FILE *, const char *); extern void mmix_asm_weaken_label (FILE *, const char *); diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c index 16e734c..a891fb1 100644 --- a/gcc/config/mmix/mmix.c +++ b/gcc/config/mmix/mmix.c @@ -1401,10 +1401,10 @@ mmix_assemble_integer (rtx x, unsigned int size, int aligned_p) return default_assemble_integer (x, size, aligned_p); } -/* ASM_OUTPUT_ASCII. */ +/* TARGET_ASM_OUTPUT_ASCII. */ void -mmix_asm_output_ascii (FILE *stream, const char *string, int length) +mmix_asm_output_ascii (FILE *stream, const char *string, size_t length) { while (length > 0) { diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h index d15d90e..29d39bc 100644 --- a/gcc/config/mmix/mmix.h +++ b/gcc/config/mmix/mmix.h @@ -634,8 +634,7 @@ typedef struct { int regs; int lib; } CUMULATIVE_ARGS; /* Node: Data Output */ -#define ASM_OUTPUT_ASCII(STREAM, PTR, LEN) \ - mmix_asm_output_ascii (STREAM, PTR, LEN) +#define TARGET_ASM_OUTPUT_ASCII mmix_asm_output_ascii /* Node: Uninitialized Data */ diff --git a/gcc/config/nvptx/nvptx-protos.h b/gcc/config/nvptx/nvptx-protos.h index 2ade946..94306d5 100644 --- a/gcc/config/nvptx/nvptx-protos.h +++ b/gcc/config/nvptx/nvptx-protos.h @@ -27,7 +27,7 @@ extern void nvptx_declare_object_name (FILE *file, const char *name, extern void nvptx_record_needed_fndecl (tree decl); extern void nvptx_function_end (FILE *); extern void nvptx_output_skip (FILE *, unsigned HOST_WIDE_INT); -extern void nvptx_output_ascii (FILE *, const char *, unsigned HOST_WIDE_INT); +extern void nvptx_output_ascii (FILE *, const char *, size_t); extern void nvptx_register_pragmas (void); extern const char *nvptx_section_for_decl (const_tree); diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index 5d9b41f..5b58fb2 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -1355,7 +1355,7 @@ nvptx_output_skip (FILE *, unsigned HOST_WIDE_INT size) ignore the FILE arg. */ void -nvptx_output_ascii (FILE *, const char *str, unsigned HOST_WIDE_INT size) +nvptx_output_ascii (FILE *, const char *str, size_t size) { for (unsigned HOST_WIDE_INT i = 0; i < size; i++) nvptx_assemble_value (str[i], 1); diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h index 502e43d..f3c1014 100644 --- a/gcc/config/nvptx/nvptx.h +++ b/gcc/config/nvptx/nvptx.h @@ -297,9 +297,8 @@ struct GTY(()) machine_function #define ASM_OUTPUT_SKIP(FILE, N) \ nvptx_output_skip (FILE, N) -#undef ASM_OUTPUT_ASCII -#define ASM_OUTPUT_ASCII(FILE, STR, LENGTH) \ - nvptx_output_ascii (FILE, STR, LENGTH); +#undef TARGET_ASM_OUTPUT_ASCII +#define TARGET_ASM_OUTPUT_ASCII nvptx_output_ascii #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \ nvptx_declare_object_name (FILE, NAME, DECL) diff --git a/gcc/config/pa/pa-protos.h b/gcc/config/pa/pa-protos.h index 58cc463..0e13cd5 100644 --- a/gcc/config/pa/pa-protos.h +++ b/gcc/config/pa/pa-protos.h @@ -89,7 +89,7 @@ extern int pa_mem_shadd_constant_p (int); extern int pa_shadd_constant_p (int); extern int pa_zdepi_cint_p (unsigned HOST_WIDE_INT); -extern void pa_output_ascii (FILE *, const char *, int); +extern void pa_output_ascii (FILE *, const char *, size_t); extern HOST_WIDE_INT pa_compute_frame_size (HOST_WIDE_INT, int *); extern void pa_expand_prologue (void); extern void pa_expand_epilogue (void); diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index 7cf540c..b24413a 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -3287,9 +3287,8 @@ pa_assemble_integer (rtx x, unsigned int size, int aligned_p) /* Output an ascii string. */ void -pa_output_ascii (FILE *file, const char *p, int size) +pa_output_ascii (FILE *file, const char *p, size_t size) { - int i; int chars_output; unsigned char partial_output[16]; /* Max space 4 chars can occupy. */ @@ -3302,10 +3301,10 @@ pa_output_ascii (FILE *file, const char *p, int size) fputs ("\t.STRING \"", file); chars_output = 0; - for (i = 0; i < size; i += 4) + for (size_t i = 0; i < size; i += 4) { int co = 0; - int io = 0; + size_t io = 0; for (io = 0, co = 0; io < MIN (4, size - i); io++) { register unsigned int c = (unsigned char) p[i + io]; diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h index 9fd036f..bdfbb16 100644 --- a/gcc/config/pa/pa.h +++ b/gcc/config/pa/pa.h @@ -1160,8 +1160,7 @@ do { \ #define TARGET_ASM_GLOBALIZE_LABEL pa_globalize_label -#define ASM_OUTPUT_ASCII(FILE, P, SIZE) \ - pa_output_ascii ((FILE), (P), (SIZE)) +#define TARGET_ASM_OUTPUT_ASCII pa_output_ascii /* Jump tables are always placed in the text section. Technically, it is possible to put them in the readonly data section. This has the diff --git a/gcc/config/pdp11/pdp11-protos.h b/gcc/config/pdp11/pdp11-protos.h index 86c6da3..dfb4dca 100644 --- a/gcc/config/pdp11/pdp11-protos.h +++ b/gcc/config/pdp11/pdp11-protos.h @@ -43,7 +43,7 @@ extern enum reg_class pdp11_regno_reg_class (int); #endif /* RTX_CODE */ -extern void output_ascii (FILE *, const char *, int); +extern void output_ascii (FILE *, const char *, size_t); extern void pdp11_asm_output_var (FILE *, const char *, int, int, bool); extern void pdp11_expand_prologue (void); extern void pdp11_expand_epilogue (void); diff --git a/gcc/config/pdp11/pdp11.c b/gcc/config/pdp11/pdp11.c index f0c2a5d..d916914 100644 --- a/gcc/config/pdp11/pdp11.c +++ b/gcc/config/pdp11/pdp11.c @@ -689,15 +689,13 @@ output_move_multiple (rtx *operands) /* Output an ascii string. */ void -output_ascii (FILE *file, const char *p, int size) +output_ascii (FILE *file, const char *p, size_t size) { - int i; - /* This used to output .byte "string", which doesn't work with the UNIX assembler and I think not with DEC ones either. */ fprintf (file, "\t.byte "); - for (i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) { register int c = p[i]; if (c < 0) diff --git a/gcc/config/pdp11/pdp11.h b/gcc/config/pdp11/pdp11.h index 1d947f3..fe7a436 100644 --- a/gcc/config/pdp11/pdp11.h +++ b/gcc/config/pdp11/pdp11.h @@ -591,8 +591,7 @@ extern rtx cc0_reg_rtx; #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \ sprintf (LABEL, "*%s_%lu", PREFIX, (unsigned long)(NUM)) -#define ASM_OUTPUT_ASCII(FILE, P, SIZE) \ - output_ascii (FILE, P, SIZE) +#define TARGET_ASM_OUTPUT_ASCII output_ascii /* This is how to output an element of a case-vector that is absolute. */ diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h index f5d3476..560a825 100644 --- a/gcc/config/rs6000/rs6000-protos.h +++ b/gcc/config/rs6000/rs6000-protos.h @@ -181,7 +181,7 @@ extern enum direction function_arg_padding (machine_mode, const_tree); extern int direct_return (void); extern int first_reg_to_save (void); extern int first_fp_reg_to_save (void); -extern void output_ascii (FILE *, const char *, int); +extern void output_ascii (FILE *, const char *, size_t); extern void rs6000_gen_section_name (char **, const char *, const char *); extern void output_function_profiler (FILE *, int); extern void output_profile_hook (int); diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 2eecde6..c8794b4 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -27016,16 +27016,16 @@ output_toc (FILE *file, rtx x, int labelno, machine_mode mode) so we must artificially break them up early. */ void -output_ascii (FILE *file, const char *p, int n) +output_ascii (FILE *file, const char *p, size_t n) { char c; - int i, count_string; + int count_string; const char *for_string = "\t.byte \""; const char *for_decimal = "\t.byte "; const char *to_close = NULL; count_string = 0; - for (i = 0; i < n; i++) + for (size_t i = 0; i < n; i++) { c = *p++; if (c >= ' ' && c < 0177) diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h index 0bfe9d9..8b0cb27 100644 --- a/gcc/config/rs6000/xcoff.h +++ b/gcc/config/rs6000/xcoff.h @@ -201,7 +201,7 @@ /* This is how to output an assembler line to define N characters starting at P to FILE. */ -#define ASM_OUTPUT_ASCII(FILE, P, N) output_ascii ((FILE), (P), (N)) +#define TARGET_ASM_OUTPUT_ASCII output_ascii /* This is how to advance the location counter by SIZE bytes. */ diff --git a/gcc/defaults.h b/gcc/defaults.h index 9d38ba1..dedf896 100644 --- a/gcc/defaults.h +++ b/gcc/defaults.h @@ -56,46 +56,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see } while (0) #endif -/* Choose a reasonable default for ASM_OUTPUT_ASCII. */ - -#ifndef ASM_OUTPUT_ASCII -#define ASM_OUTPUT_ASCII(MYFILE, MYSTRING, MYLENGTH) \ - do { \ - FILE *_hide_asm_out_file = (MYFILE); \ - const unsigned char *_hide_p = (const unsigned char *) (MYSTRING); \ - int _hide_thissize = (MYLENGTH); \ - { \ - FILE *asm_out_file = _hide_asm_out_file; \ - const unsigned char *p = _hide_p; \ - int thissize = _hide_thissize; \ - int i; \ - fprintf (asm_out_file, "\t.ascii \""); \ - \ - for (i = 0; i < thissize; i++) \ - { \ - int c = p[i]; \ - if (c == '\"' || c == '\\') \ - putc ('\\', asm_out_file); \ - if (ISPRINT (c)) \ - putc (c, asm_out_file); \ - else \ - { \ - fprintf (asm_out_file, "\\%o", c); \ - /* After an octal-escape, if a digit follows, \ - terminate one string constant and start another. \ - The VAX assembler fails to stop reading the escape \ - after three digits, so this is the only way we \ - can get it to parse the data properly. */ \ - if (i < thissize - 1 && ISDIGIT (p[i + 1])) \ - fprintf (asm_out_file, "\"\n\t.ascii \""); \ - } \ - } \ - fprintf (asm_out_file, "\"\n"); \ - } \ - } \ - while (0) -#endif - /* This is how we tell the assembler to equate two values. */ #ifdef SET_ASM_OP #ifndef ASM_OUTPUT_DEF diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index b911b7d..4d19252 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -7570,16 +7570,12 @@ itself, by calling, for example, @code{output_operand_lossage}, it may just return @code{true}. @end deftypefn -@defmac ASM_OUTPUT_ASCII (@var{stream}, @var{ptr}, @var{len}) -A C statement to output to the stdio stream @var{stream} an assembler -instruction to assemble a string constant containing the @var{len} -bytes at @var{ptr}. @var{ptr} will be a C expression of type -@code{char *} and @var{len} a C expression of type @code{int}. +@deftypefn {Target Hook} void TARGET_ASM_OUTPUT_ASCII (FILE *@var{f}, const char *@var{str}, size_t @var{length}) +A target hook to output an assembly instruction to assemble a string + constant containing the @var{length} bytes at @var{str}. -If the assembler has a @code{.ascii} pseudo-op as found in the -Berkeley Unix assembler, do not define the macro -@code{ASM_OUTPUT_ASCII}. -@end defmac +The defalt hook uses the @code{.ascii} pseudo op as found in the Berkely Unix assembler. +@end deftypefn @defmac ASM_OUTPUT_FDESC (@var{stream}, @var{decl}, @var{n}) A C statement to output word @var{n} of a function descriptor for diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 47550cc..e75e818 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -5210,16 +5210,7 @@ It must not be modified by command-line option processing. @hook TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA -@defmac ASM_OUTPUT_ASCII (@var{stream}, @var{ptr}, @var{len}) -A C statement to output to the stdio stream @var{stream} an assembler -instruction to assemble a string constant containing the @var{len} -bytes at @var{ptr}. @var{ptr} will be a C expression of type -@code{char *} and @var{len} a C expression of type @code{int}. - -If the assembler has a @code{.ascii} pseudo-op as found in the -Berkeley Unix assembler, do not define the macro -@code{ASM_OUTPUT_ASCII}. -@end defmac +@hook TARGET_ASM_OUTPUT_ASCII @defmac ASM_OUTPUT_FDESC (@var{stream}, @var{decl}, @var{n}) A C statement to output word @var{n} of a function descriptor for diff --git a/gcc/dwarf2asm.c b/gcc/dwarf2asm.c index 9f3c4b1..393a309 100644 --- a/gcc/dwarf2asm.c +++ b/gcc/dwarf2asm.c @@ -327,7 +327,7 @@ dw2_asm_output_nstring (const char *str, size_t orig_len, is a null termination in the string buffer. */ if (orig_len == (size_t) -1) len += 1; - ASM_OUTPUT_ASCII (asm_out_file, str, len); + targetm.asm_out.output_ascii (asm_out_file, str, len); if (orig_len != (size_t) -1) assemble_integer (const0_rtx, 1, BITS_PER_UNIT, 1); } diff --git a/gcc/output.h b/gcc/output.h index 4ce6eea..8aa648a 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -602,7 +602,7 @@ extern void file_end_indicate_split_stack (void); extern void default_elf_asm_output_external (FILE *file, tree, const char *); extern void default_elf_asm_output_limited_string (FILE *, const char *); -extern void default_elf_asm_output_ascii (FILE *, const char *, unsigned int); +extern void default_elf_asm_output_ascii (FILE *, const char *, size_t); extern void default_elf_internal_label (FILE *, const char *, unsigned long); extern void default_elf_init_array_asm_out_constructor (rtx, int); diff --git a/gcc/target.def b/gcc/target.def index 4edc209..ed438de 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -872,6 +872,15 @@ return @code{true}.", bool, (FILE *file, rtx x), hook_bool_FILEptr_rtx_false) +DEFHOOK +(output_ascii, + "A target hook to output an assembly instruction to assemble a string\n\ + constant containing the @var{length} bytes at @var{str}.\n\ +\n\ +The defalt hook uses the @code{.ascii} pseudo op as found in the Berkely Unix assembler.", + void, (FILE *f, const char *str, size_t length), + default_output_ascii) + /* ??? The TARGET_PRINT_OPERAND* hooks are part of the asm_out struct, even though that is not reflected in the macro name to override their initializers. */ diff --git a/gcc/varasm.c b/gcc/varasm.c index 6a4ba0b..c2bfbf0 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1921,7 +1921,7 @@ assemble_string (const char *p, int size) if (thissize > maximum) thissize = maximum; - ASM_OUTPUT_ASCII (asm_out_file, p, thissize); + targetm.asm_out.output_ascii (asm_out_file, p, thissize); pos += thissize; p += thissize; @@ -7456,10 +7456,10 @@ output_object_blocks (void) FIXME: This code does not correctly handle double quote characters that appear inside strings, (it strips them rather than preserving them). - FIXME: ASM_OUTPUT_ASCII, as defined in config/elfos.h will not emit NUL - characters - instead it treats them as sub-string separators. Since - we want to emit NUL strings terminators into the object file we have to use - ASM_OUTPUT_SKIP. */ + FIXME: target.asm_out.output_ascii, as defined in config/elfos.h will not + emit NUL characters - instead it treats them as sub-string separators. + Since we want to emit NUL strings terminators into the object file we have + to use ASM_OUTPUT_SKIP. */ int elf_record_gcc_switches (print_switch_type type, const char * name) @@ -7467,7 +7467,7 @@ elf_record_gcc_switches (print_switch_type type, const char * name) switch (type) { case SWITCH_TYPE_PASSED: - ASM_OUTPUT_ASCII (asm_out_file, name, strlen (name)); + targetm.asm_out.output_ascii (asm_out_file, name, strlen (name)); ASM_OUTPUT_SKIP (asm_out_file, (unsigned HOST_WIDE_INT) 1); break; @@ -7586,6 +7586,37 @@ make_debug_expr_from_rtl (const_rtx exp) return dval; } +/* Default implementation of TARGET_ASM_OUTPUT_ASCII using .ascii. */ + +void +default_output_ascii (FILE *f, const char *str, size_t length) +{ + const unsigned char *p = (const unsigned char *) str; + + fprintf (f, "\t.ascii \""); + for (unsigned int i = 0; i < length; i++) + { + int c = p[i]; + if (c == '\"' || c == '\\') + putc ('\\', f); + if (ISPRINT (c)) + putc (c, asm_out_file); \ + else + { + fprintf (f, "\\%o", c); + /* After an octal-escape, if a digit follows, + terminate one string constant and start another. + The VAX assembler fails to stop reading the escape + after three digits, so this is the only way we + can get it to parse the data properly. */ + if (i < length - 1 && ISDIGIT (p[i + 1])) + fprintf (f, "\"\n\t.ascii \""); + } + } + + fprintf (f, "\"\n"); +} + #ifdef ELF_ASCII_ESCAPES /* Default ASM_OUTPUT_LIMITED_STRING for ELF targets. */ @@ -7621,10 +7652,10 @@ default_elf_asm_output_limited_string (FILE *f, const char *s) putc ('\n', f); } -/* Default ASM_OUTPUT_ASCII for ELF targets. */ +/* Default TARGET_ASM_OUTPUT_ASCII for ELF targets. */ void -default_elf_asm_output_ascii (FILE *f, const char *s, unsigned int len) +default_elf_asm_output_ascii (FILE *f, const char *s, size_t len) { const char *limit = s + len; const char *last_null = NULL; diff --git a/gcc/varasm.h b/gcc/varasm.h index 0d7d563..4e99c40 100644 --- a/gcc/varasm.h +++ b/gcc/varasm.h @@ -79,4 +79,6 @@ extern rtx assemble_static_space (unsigned HOST_WIDE_INT); extern rtx assemble_trampoline_template (void); +extern void default_output_ascii (FILE *f, const char *str, size_t length); + #endif // GCC_VARASM_H diff --git a/gcc/vmsdbgout.c b/gcc/vmsdbgout.c index d41d4b2..0204740 100644 --- a/gcc/vmsdbgout.c +++ b/gcc/vmsdbgout.c @@ -350,9 +350,10 @@ static char text_end_label[MAX_ARTIFICIAL_LABEL_BYTES]; (unsigned long long) VALUE) #endif -/* This is similar to the default ASM_OUTPUT_ASCII, except that no trailing - newline is produced. When flag_verbose_asm is asserted, we add commentary - at the end of the line, so we must avoid output of a newline here. */ +/* This is similar to the default targetm.asm_out.output_ascii, except that no + trailing newline is produced. When flag_verbose_asm is asserted, we add + commentary at the end of the line, so we must avoid output of a newline + here. */ #ifndef ASM_OUTPUT_DEBUG_STRING #define ASM_OUTPUT_DEBUG_STRING(FILE,P) \ do \ -- 2.4.0