From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58182 invoked by alias); 25 Jul 2015 03:09:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 58167 invoked by uid 89); 25 Jul 2015 03:09:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f46.google.com Received: from mail-pa0-f46.google.com (HELO mail-pa0-f46.google.com) (209.85.220.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sat, 25 Jul 2015 03:09:35 +0000 Received: by pachj5 with SMTP id hj5so22861263pac.3 for ; Fri, 24 Jul 2015 20:09:33 -0700 (PDT) X-Received: by 10.66.147.4 with SMTP id tg4mr38837322pab.69.1437793773350; Fri, 24 Jul 2015 20:09:33 -0700 (PDT) Received: from ?IPv6:2602:304:cfd0:15a0:6c07:8d52:c4bb:60af? ([2602:304:cfd0:15a0:6c07:8d52:c4bb:60af]) by smtp.gmail.com with ESMTPSA id k5sm16995947pdb.53.2015.07.24.20.09.30 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 24 Jul 2015 20:09:31 -0700 (PDT) References: <1437791820-17927-1-git-send-email-tbsaunde+gcc@tbsaunde.org> <1437791820-17927-2-git-send-email-tbsaunde+gcc@tbsaunde.org> Mime-Version: 1.0 (1.0) In-Reply-To: <1437791820-17927-2-git-send-email-tbsaunde+gcc@tbsaunde.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Message-Id: <958557D4-91F9-43C1-8CAA-9A847545B90B@gmail.com> Cc: "gcc-patches@gcc.gnu.org" From: pinskia@gmail.com Subject: Re: [PATCH 1/4] convert ASM_OUTPUT_ASCII to a hook Date: Sat, 25 Jul 2015 06:22:00 -0000 To: "tbsaunde+gcc@tbsaunde.org" X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg02146.txt.bz2 > On Jul 24, 2015, at 7:36 PM, tbsaunde+gcc@tbsaunde.org wrote: >=20 > From: Trevor Saunders >=20 > gcc/ChangeLog: >=20 > 2015-07-25 Trevor Saunders >=20 > * 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(-) >=20 > 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) >=20 >=20 > -#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 >=20 > /* 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 >=20 > 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) You changed the signedness of p here for some targets. Can you confirm that= this code does not depend on if char is signed or unsigned? Almost all th= e rest of the target macro conversions look correct and kept the casting. J= ust this one seems missing.=20 Thanks, Andrew > { > - int i; > int len_so_far =3D 0; >=20 > fputs ("\t.ascii\t\"", stream); >=20 > - for (i =3D 0; i < len; i++) > + for (size_t i =3D 0; i < len; i++) > { > int c =3D p[i]; >=20 > @@ -19586,7 +19585,7 @@ arm_poke_function_name (FILE *stream, const char = *name) > length =3D strlen (name) + 1; > alignlength =3D ROUND_UP_WORD (length); >=20 > - ASM_OUTPUT_ASCII (stream, name, length); > + targetm.asm_out.output_ascii (stream, name, length); > ASM_OUTPUT_ALIGN (stream, 2); > x =3D 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 respective= ly. If not, see > while (0) > #endif >=20 > -/* 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 respective= ly. If not, see > character sequence which end with NUL (and which are shorter than > STRING_LIMIT) we output those using ASM_OUTPUT_LIMITED_STRING. */ >=20 > -#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 >=20 > /* 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 respectivel= y. If not, see >=20 > /* How to output an ASCII string constant. */ >=20 > -#undef ASM_OUTPUT_ASCII > -#define ASM_OUTPUT_ASCII(FILE, PTR, SIZE) \ > -do \ > -{ size_t i =3D 0, limit =3D (SIZE); \ > - while (i < limit) \ > - { if (i%10 =3D=3D 0) { if (i!=3D0) 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 >=20 > /* 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_co= de); >=20 > 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); >=20 > +#ifndef ASM_OUTPUT_LIMITED_STRING > +#define ASM_OUTPUT_LIMITED_STRING(a, b) > +#endif > + > #ifndef CHECK_STACK_LIMIT > #define CHECK_STACK_LIMIT (-1) > #endif >=20 > +#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) =3D=3D QImode ? 0 \ > @@ -6387,6 +6395,75 @@ ix86_cfun_abi (void) > return cfun->machine->call_abi; > } >=20 > +/* 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 =3D (const unsigned char *) string; > + const unsigned char *limit =3D _ascii_bytes + length; > + unsigned bytes_in_chunk =3D 0; > + for (; _ascii_bytes < limit; _ascii_bytes++) > + { > + const unsigned char *p; > + if (bytes_in_chunk >=3D 64) > + { > + fputc ('\n', f); > + bytes_in_chunk =3D 0; > + } > + for (p =3D _ascii_bytes; p < limit && *p !=3D '\0'; p++) > + continue; > + if (p < limit && (p - _ascii_bytes) <=3D (long) ELF_STRING_LIMIT) > + { > + if (bytes_in_chunk > 0) > + { > + fputc ('\n', f); > + bytes_in_chunk =3D 0; > + } > + ASM_OUTPUT_LIMITED_STRING (f, (const char *) _ascii_bytes); > + _ascii_bytes =3D p; > + } > + else > + { > + if (bytes_in_chunk =3D=3D 0) > + fputs (ASM_BYTE, f); > + else > + fputc (',', f); > + fprintf (f, "0x%02x", *_ascii_bytes); \ > + bytes_in_chunk +=3D 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 =3D 0, limit =3D length; > + while (i < limit) > + { > + if (i%10 =3D=3D 0) > + { > + if (i!=3D0) > + 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. = */ >=20 > 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]) >=20 > -/* 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 =3D \ > - (const unsigned char *) (STR); \ > - const unsigned char *limit =3D _ascii_bytes + (LENGTH); \ > - unsigned bytes_in_chunk =3D 0; \ > - for (; _ascii_bytes < limit; _ascii_bytes++) \ > - { \ > - const unsigned char *p; \ > - if (bytes_in_chunk >=3D 64) \ > - { \ > - fputc ('\n', (FILE)); \ > - bytes_in_chunk =3D 0; \ > - } \ > - for (p =3D _ascii_bytes; p < limit && *p !=3D '\0'; p++) \ > - continue; \ > - if (p < limit && (p - _ascii_bytes) <=3D (long) ELF_STRING_LIMIT) \ > - { \ > - if (bytes_in_chunk > 0) \ > - { \ > - fputc ('\n', (FILE)); \ > - bytes_in_chunk =3D 0; \ > - } \ > - ASM_OUTPUT_LIMITED_STRING ((FILE), (const char *) _ascii_bytes= ); \ > - _ascii_bytes =3D p; \ > - } \ > - else \ > - { \ > - if (bytes_in_chunk =3D=3D 0) \ > - fputs (ASM_BYTE, (FILE)); \ > - else \ > - fputc (',', (FILE)); \ > - fprintf ((FILE), "0x%02x", *_ascii_bytes); \ > - bytes_in_chunk +=3D 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 >=20 > #define LOCAL_LABEL_PREFIX "." >=20 > 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) >=20 > return false; > } > -/* Implement ASM_OUTPUT_ASCII. */ > +/* Implement TARGET_ASM_OUTPUT_ASCII. */ >=20 > 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)) >=20 > /* 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 >=20 > =0C > /* 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); > } >=20 > -/* ASM_OUTPUT_ASCII. */ > +/* TARGET_ASM_OUTPUT_ASCII. */ >=20 > 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; >=20 > /* Node: Data Output */ >=20 > -#define ASM_OUTPUT_ASCII(STREAM, PTR, LEN) \ > - mmix_asm_output_ascii (STREAM, PTR, LEN) > +#define TARGET_ASM_OUTPUT_ASCII mmix_asm_output_ascii >=20 > /* Node: Uninitialized Data */ >=20 > diff --git a/gcc/config/nvptx/nvptx-protos.h b/gcc/config/nvptx/nvptx-pro= tos.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, cons= t 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); >=20 > 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 s= ize) > ignore the FILE arg. */ >=20 > 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 =3D 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) >=20 > -#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 >=20 > #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); >=20 > -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) > =0C > /* 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. = */ >=20 > @@ -3302,10 +3301,10 @@ pa_output_ascii (FILE *file, const char *p, int s= ize) > fputs ("\t.STRING \"", file); >=20 > chars_output =3D 0; > - for (i =3D 0; i < size; i +=3D 4) > + for (size_t i =3D 0; i < size; i +=3D 4) > { > int co =3D 0; > - int io =3D 0; > + size_t io =3D 0; > for (io =3D 0, co =3D 0; io < MIN (4, size - i); io++) > { > register unsigned int c =3D (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 { \ >=20 > #define TARGET_ASM_GLOBALIZE_LABEL pa_globalize_label >=20 > -#define ASM_OUTPUT_ASCII(FILE, P, SIZE) \ > - pa_output_ascii ((FILE), (P), (SIZE)) > +#define TARGET_ASM_OUTPUT_ASCII pa_output_ascii >=20 > /* 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-pro= tos.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); >=20 > #endif /* RTX_CODE */ >=20 > -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) > =0C > /* 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 "); >=20 > - for (i =3D 0; i < size; i++) > + for (size_t i =3D 0; i < size; i++) > { > register int c =3D 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)) >=20 > -#define ASM_OUTPUT_ASCII(FILE, P, SIZE) \ > - output_ascii (FILE, P, SIZE) > +#define TARGET_ASM_OUTPUT_ASCII output_ascii >=20 > /* This is how to output an element of a case-vector that is absolute. */ >=20 > 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_m= ode, 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, mac= hine_mode mode) > so we must artificially break them up early. */ >=20 > 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 =3D "\t.byte \""; > const char *for_decimal =3D "\t.byte "; > const char *to_close =3D NULL; >=20 > count_string =3D 0; > - for (i =3D 0; i < n; i++) > + for (size_t i =3D 0; i < n; i++) > { > c =3D *p++; > if (c >=3D ' ' && 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. */ >=20 > -#define ASM_OUTPUT_ASCII(FILE, P, N) output_ascii ((FILE), (P), (N)) > +#define TARGET_ASM_OUTPUT_ASCII output_ascii >=20 > /* This is how to advance the location counter by SIZE bytes. */ >=20 > 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 respectivel= y. If not, see > } while (0) > #endif >=20 > -/* 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 =3D (MYFILE); \ > - const unsigned char *_hide_p =3D (const unsigned char *) (MYSTRING);= \ > - int _hide_thissize =3D (MYLENGTH); \ > - { \ > - FILE *asm_out_file =3D _hide_asm_out_file; \ > - const unsigned char *p =3D _hide_p; \ > - int thissize =3D _hide_thissize; \ > - int i; \ > - fprintf (asm_out_file, "\t.ascii \""); \ > - \ > - for (i =3D 0; i < thissize; i++) \ > - { \ > - int c =3D p[i]; \ > - if (c =3D=3D '\"' || c =3D=3D '\\') \ > - 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_ope= rand_lossage}, it may just > return @code{true}. > @end deftypefn >=20 > -@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}, co= nst 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}. >=20 > -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 >=20 > @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 pro= cessing. >=20 > @hook TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA >=20 > -@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 >=20 > @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 =3D=3D (size_t) -1) > len +=3D 1; > - ASM_OUTPUT_ASCII (asm_out_file, str, len); > + targetm.asm_out.output_ascii (asm_out_file, str, len); > if (orig_len !=3D (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 lo= ng); >=20 > 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) >=20 > +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 =3D maximum; >=20 > - ASM_OUTPUT_ASCII (asm_out_file, p, thissize); > + targetm.asm_out.output_ascii (asm_out_file, p, thissize); >=20 > pos +=3D thissize; > p +=3D thissize; > @@ -7456,10 +7456,10 @@ output_object_blocks (void) >=20 > FIXME: This code does not correctly handle double quote characters > that appear inside strings, (it strips them rather than preserving the= m). > - FIXME: ASM_OUTPUT_ASCII, as defined in config/elfos.h will not emit N= UL > - 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. */ >=20 > int > elf_record_gcc_switches (print_switch_type type, const char * name) > @@ -7467,7 +7467,7 @@ elf_record_gcc_switches (print_switch_type type, co= nst 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; >=20 > @@ -7586,6 +7586,37 @@ make_debug_expr_from_rtl (const_rtx exp) > return dval; > } >=20 > +/* 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 =3D (const unsigned char *) str; > + > + fprintf (f, "\t.ascii \""); > + for (unsigned int i =3D 0; i < length; i++) > + { > + int c =3D p[i]; > + if (c =3D=3D '\"' || c =3D=3D '\\') > + 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. */ >=20 > @@ -7621,10 +7652,10 @@ default_elf_asm_output_limited_string (FILE *f, c= onst char *s) > putc ('\n', f); > } >=20 > -/* Default ASM_OUTPUT_ASCII for ELF targets. */ > +/* Default TARGET_ASM_OUTPUT_ASCII for ELF targets. */ >=20 > 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 =3D s + len; > const char *last_null =3D 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_IN= T); >=20 > extern rtx assemble_trampoline_template (void); >=20 > +extern void default_output_ascii (FILE *f, const char *str, size_t lengt= h); > + > #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_BYTE= S]; > (unsigned long long) VALUE) > #endif >=20 > -/* This is similar to the default ASM_OUTPUT_ASCII, except that no trail= ing > - newline is produced. When flag_verbose_asm is asserted, we add comme= ntary > - 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 t= hat 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 newli= ne > + here. */ > #ifndef ASM_OUTPUT_DEBUG_STRING > #define ASM_OUTPUT_DEBUG_STRING(FILE,P) \ > do \ > --=20 > 2.4.0 >=20