public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/4] convert ASM_OUTPUT_ASCII to a hook
  2015-07-25  2:37 [PATCH 0/4] misc work to get rid of target macros tbsaunde+gcc
  2015-07-25  2:37 ` [PATCH 3/4] remove unused TARGET_DEFERRED_OUTPUT_DEFS tbsaunde+gcc
@ 2015-07-25  2:37 ` tbsaunde+gcc
  2015-07-25  6:22   ` pinskia
                     ` (2 more replies)
  2015-07-25  3:09 ` [PATCH 2/4] make TLS_COMMON_ASM_OP " tbsaunde+gcc
  2015-07-25  5:42 ` [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function tbsaunde+gcc
  3 siblings, 3 replies; 31+ messages in thread
From: tbsaunde+gcc @ 2015-07-25  2:37 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

2015-07-25  Trevor Saunders  <tsaunders@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
 
 \f
 /* 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)
 \f
 /* 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)
 \f
 /* 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

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 3/4] remove unused TARGET_DEFERRED_OUTPUT_DEFS
  2015-07-25  2:37 [PATCH 0/4] misc work to get rid of target macros tbsaunde+gcc
@ 2015-07-25  2:37 ` tbsaunde+gcc
  2015-07-31  0:55   ` Joseph Myers
  2015-07-25  2:37 ` [PATCH 1/4] convert ASM_OUTPUT_ASCII to a hook tbsaunde+gcc
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 31+ messages in thread
From: tbsaunde+gcc @ 2015-07-25  2:37 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

2015-07-24  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* config/rs6000/aix43.h (TARGET_DEFERRED_OUTPUT_DEFS): Remove.
	* defaults.h (TARGET_DEFERRED_OUTPUT_DEFS): Likewise.
	* doc/tm.texi: Regenerate.
	* doc/tm.texi.in (TARGET_DEFERRED_OUTPUT_DEFS): Remove
	documentation of TARGET_DEFERRED_OUTPUT_DEFS;
---
 gcc/config/rs6000/aix43.h | 5 -----
 gcc/defaults.h            | 6 ------
 gcc/doc/tm.texi           | 9 ---------
 gcc/doc/tm.texi.in        | 9 ---------
 4 files changed, 29 deletions(-)

diff --git a/gcc/config/rs6000/aix43.h b/gcc/config/rs6000/aix43.h
index 5bcd40f..512a634 100644
--- a/gcc/config/rs6000/aix43.h
+++ b/gcc/config/rs6000/aix43.h
@@ -150,11 +150,6 @@ do {									\
 #undef LD_INIT_SWITCH
 #define LD_INIT_SWITCH "-binitfini"
 
-/* The IBM AIX 4.x assembler doesn't support forward references in
-   .set directives.  We handle this by deferring the output of .set
-   directives to the end of the compilation unit.  */
-#define TARGET_DEFERRED_OUTPUT_DEFS(DECL,TARGET) true
-
 /* This target uses the aix64.opt file.  */
 #define TARGET_USES_AIX64_OPT 1
 
diff --git a/gcc/defaults.h b/gcc/defaults.h
index 8684c58..3ecf9fd 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -85,12 +85,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
   while (0)
 #endif
 
-/* Decide whether to defer emitting the assembler output for an equate
-   of two values.  The default is to not defer output.  */
-#ifndef TARGET_DEFERRED_OUTPUT_DEFS
-#define TARGET_DEFERRED_OUTPUT_DEFS(DECL,TARGET) false
-#endif
-
 /* This is how to output the definition of a user-level label named
    NAME, such as the label on variable NAME.  */
 
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index faa3017..8495e5c 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -8272,15 +8272,6 @@ If @code{SET_ASM_OP} is defined, a default definition is provided which is
 correct for most systems.
 @end defmac
 
-@defmac TARGET_DEFERRED_OUTPUT_DEFS (@var{decl_of_name}, @var{decl_of_value})
-A C statement that evaluates to true if the assembler code which defines
-(equates) the symbol whose tree node is @var{decl_of_name} to have the value
-of the tree node @var{decl_of_value} should be emitted near the end of the
-current compilation unit.  The default is to not defer output of defines.
-This macro affects defines output by @samp{ASM_OUTPUT_DEF} and
-@samp{ASM_OUTPUT_DEF_FROM_DECLS}.
-@end defmac
-
 @defmac ASM_OUTPUT_WEAK_ALIAS (@var{stream}, @var{name}, @var{value})
 A C statement to output to the stdio stream @var{stream} assembler code
 which defines (equates) the weak symbol @var{name} to have the value
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 72a7f84..8f5f786 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -5840,15 +5840,6 @@ If @code{SET_ASM_OP} is defined, a default definition is provided which is
 correct for most systems.
 @end defmac
 
-@defmac TARGET_DEFERRED_OUTPUT_DEFS (@var{decl_of_name}, @var{decl_of_value})
-A C statement that evaluates to true if the assembler code which defines
-(equates) the symbol whose tree node is @var{decl_of_name} to have the value
-of the tree node @var{decl_of_value} should be emitted near the end of the
-current compilation unit.  The default is to not defer output of defines.
-This macro affects defines output by @samp{ASM_OUTPUT_DEF} and
-@samp{ASM_OUTPUT_DEF_FROM_DECLS}.
-@end defmac
-
 @defmac ASM_OUTPUT_WEAK_ALIAS (@var{stream}, @var{name}, @var{value})
 A C statement to output to the stdio stream @var{stream} assembler code
 which defines (equates) the weak symbol @var{name} to have the value
-- 
2.4.0

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 0/4] misc work to get rid of target macros
@ 2015-07-25  2:37 tbsaunde+gcc
  2015-07-25  2:37 ` [PATCH 3/4] remove unused TARGET_DEFERRED_OUTPUT_DEFS tbsaunde+gcc
                   ` (3 more replies)
  0 siblings, 4 replies; 31+ messages in thread
From: tbsaunde+gcc @ 2015-07-25  2:37 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

Hi,

$subject, this gets rid of 3 macros, and moves one more closer to being a hook.

each patch bootstrapped + regtested on x86_64-linux-gnu, and the series was run through config-list.mk, ok?

thanks!

Trev


Trevor Saunders (4):
  convert ASM_OUTPUT_ASCII to a hook
  make TLS_COMMON_ASM_OP a hook
  remove unused TARGET_DEFERRED_OUTPUT_DEFS
  define ASM_OUTPUT_LABEL to the name of a function

 gcc/config/arc/arc.h              |  3 +-
 gcc/config/arm/aout.h             |  5 +--
 gcc/config/arm/arm-protos.h       |  2 +-
 gcc/config/arm/arm.c              |  7 ++--
 gcc/config/bfin/bfin.h            |  5 +--
 gcc/config/elfos.h                |  7 ++--
 gcc/config/frv/frv.h              |  6 +--
 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/i386/sol2.h            |  2 +-
 gcc/config/ia64/ia64-protos.h     |  1 +
 gcc/config/ia64/ia64.c            | 11 ++++++
 gcc/config/ia64/ia64.h            |  8 +---
 gcc/config/lm32/lm32.h            |  3 +-
 gcc/config/mep/mep.h              |  8 +---
 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            |  6 +--
 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         |  3 +-
 gcc/config/pa/pa.c                | 19 ++++++++--
 gcc/config/pa/pa.h                | 12 +-----
 gcc/config/pdp11/pdp11-protos.h   |  2 +-
 gcc/config/pdp11/pdp11.c          |  6 +--
 gcc/config/pdp11/pdp11.h          |  3 +-
 gcc/config/rs6000/aix43.h         |  5 ---
 gcc/config/rs6000/rs6000-protos.h |  3 +-
 gcc/config/rs6000/rs6000.c        | 14 +++++--
 gcc/config/rs6000/xcoff.h         |  5 +--
 gcc/config/spu/spu.h              |  3 +-
 gcc/config/visium/visium.h        |  3 +-
 gcc/defaults.h                    | 58 +----------------------------
 gcc/doc/tm.texi                   | 30 ++++-----------
 gcc/doc/tm.texi.in                | 26 +------------
 gcc/dwarf2asm.c                   |  2 +-
 gcc/output.h                      |  5 ++-
 gcc/target.def                    | 15 ++++++++
 gcc/varasm.c                      | 56 ++++++++++++++++++++++++----
 gcc/varasm.h                      |  2 +
 gcc/vmsdbgout.c                   |  8 ++--
 gcc/xcoffout.c                    |  1 +
 47 files changed, 251 insertions(+), 268 deletions(-)

-- 
2.4.0

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 2/4] make TLS_COMMON_ASM_OP a hook
  2015-07-25  2:37 [PATCH 0/4] misc work to get rid of target macros tbsaunde+gcc
  2015-07-25  2:37 ` [PATCH 3/4] remove unused TARGET_DEFERRED_OUTPUT_DEFS tbsaunde+gcc
  2015-07-25  2:37 ` [PATCH 1/4] convert ASM_OUTPUT_ASCII to a hook tbsaunde+gcc
@ 2015-07-25  3:09 ` tbsaunde+gcc
  2015-07-25  5:42 ` [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function tbsaunde+gcc
  3 siblings, 0 replies; 31+ messages in thread
From: tbsaunde+gcc @ 2015-07-25  3:09 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

2015-07-24  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* config/i386/sol2.h: Adjust.
	* defaults.h: Likewise.
	* doc/tm.texi: Regenerate.
	* doc/tm.texi.in: Remove documentation of removed
	TLS_COMMON_ASM_OP macro.
	* target.def (tls_common_asm_op): New hook.
---
 gcc/config/i386/sol2.h | 2 +-
 gcc/defaults.h         | 6 +-----
 gcc/doc/tm.texi        | 7 +++----
 gcc/doc/tm.texi.in     | 6 +-----
 gcc/target.def         | 6 ++++++
 5 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/gcc/config/i386/sol2.h b/gcc/config/i386/sol2.h
index 9b725ad..d8e9c86 100644
--- a/gcc/config/i386/sol2.h
+++ b/gcc/config/i386/sol2.h
@@ -149,7 +149,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #ifndef USE_GAS
 /* The Sun assembler uses .tcomm for TLS common sections.  */
-#define TLS_COMMON_ASM_OP ".tcomm"
+#define TARGET_TLS_COMMON_ASM_OP ".tcomm"
 
 /* Similar to the Sun assembler on SPARC, the native assembler requires
    TLS objects to be declared as @tls_obj (not @tls_object).  Unlike SPARC,
diff --git a/gcc/defaults.h b/gcc/defaults.h
index dedf896..8684c58 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -73,15 +73,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define IFUNC_ASM_TYPE "gnu_indirect_function"
 #endif
 
-#ifndef TLS_COMMON_ASM_OP
-#define TLS_COMMON_ASM_OP ".tls_common"
-#endif
-
 #if defined (HAVE_AS_TLS) && !defined (ASM_OUTPUT_TLS_COMMON)
 #define ASM_OUTPUT_TLS_COMMON(FILE, DECL, NAME, SIZE)			\
   do									\
     {									\
-      fprintf ((FILE), "\t%s\t", TLS_COMMON_ASM_OP);			\
+      fprintf ((FILE), "\t%s\t", targetm.tls_common_asm_op);		\
       assemble_name ((FILE), (NAME));					\
       fprintf ((FILE), "," HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",		\
 	       (SIZE), DECL_ALIGN (DECL) / BITS_PER_UNIT);		\
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 4d19252..faa3017 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -6968,11 +6968,10 @@ containing the assembler operation to identify the following data as
 uninitialized, writable small data.
 @end defmac
 
-@defmac TLS_COMMON_ASM_OP
-If defined, a C expression whose value is a string containing the
-assembler operation to identify the following data as thread-local
+@deftypevr {Target Hook} {const char *} TARGET_TLS_COMMON_ASM_OP
+The assembler operation to identify the following data as thread-local
 common data.  The default is @code{".tls_common"}.
-@end defmac
+@end deftypevr
 
 @defmac TLS_SECTION_ASM_FLAG
 If defined, a C expression whose value is a character constant
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index e75e818..72a7f84 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -4908,11 +4908,7 @@ containing the assembler operation to identify the following data as
 uninitialized, writable small data.
 @end defmac
 
-@defmac TLS_COMMON_ASM_OP
-If defined, a C expression whose value is a string containing the
-assembler operation to identify the following data as thread-local
-common data.  The default is @code{".tls_common"}.
-@end defmac
+@hook TARGET_TLS_COMMON_ASM_OP
 
 @defmac TLS_SECTION_ASM_FLAG
 If defined, a C expression whose value is a character constant
diff --git a/gcc/target.def b/gcc/target.def
index ed438de..64ae8d4 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -5752,6 +5752,12 @@ DEFHOOKPOD
 The default value is false.",
  bool, false)
 
+DEFHOOKPOD
+(tls_common_asm_op,
+"The assembler operation to identify the following data as thread-local\n\
+common data.  The default is @code{\".tls_common\"}.",
+const char *, ".tls_common")
+
 /* True if a small readonly data section is supported.  */
 DEFHOOKPOD
 (have_srodata_section,
-- 
2.4.0

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-07-25  2:37 [PATCH 0/4] misc work to get rid of target macros tbsaunde+gcc
                   ` (2 preceding siblings ...)
  2015-07-25  3:09 ` [PATCH 2/4] make TLS_COMMON_ASM_OP " tbsaunde+gcc
@ 2015-07-25  5:42 ` tbsaunde+gcc
  2015-07-25 18:34   ` Segher Boessenkool
  2015-07-27  9:17   ` Richard Biener
  3 siblings, 2 replies; 31+ messages in thread
From: tbsaunde+gcc @ 2015-07-25  5:42 UTC (permalink / raw)
  To: gcc-patches

From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

	* config/arc/arc.h, config/bfin/bfin.h, config/frv/frv.h,
	config/ia64/ia64-protos.h, config/ia64/ia64.c, config/ia64/ia64.h,
	config/lm32/lm32.h, config/mep/mep.h, config/mmix/mmix.h,
	config/rs6000/rs6000.c, config/rs6000/xcoff.h, config/spu/spu.h,
	config/visium/visium.h, defaults.h: Define ASM_OUTPUT_LABEL to
the name of a function.
	* output.h (default_output_label): New prototype.
	* varasm.c (default_output_label): New function.
	* vmsdbgout.c: Include tm_p.h.
	* xcoffout.c: Likewise.
---
 gcc/config/arc/arc.h              |  3 +--
 gcc/config/bfin/bfin.h            |  5 +----
 gcc/config/frv/frv.h              |  6 +-----
 gcc/config/ia64/ia64-protos.h     |  1 +
 gcc/config/ia64/ia64.c            | 11 +++++++++++
 gcc/config/ia64/ia64.h            |  8 +-------
 gcc/config/lm32/lm32.h            |  3 +--
 gcc/config/mep/mep.h              |  8 +-------
 gcc/config/mmix/mmix.h            |  3 +--
 gcc/config/pa/pa-protos.h         |  1 +
 gcc/config/pa/pa.c                | 12 ++++++++++++
 gcc/config/pa/pa.h                |  9 +--------
 gcc/config/rs6000/rs6000-protos.h |  1 +
 gcc/config/rs6000/rs6000.c        |  8 ++++++++
 gcc/config/rs6000/xcoff.h         |  3 +--
 gcc/config/spu/spu.h              |  3 +--
 gcc/config/visium/visium.h        |  3 +--
 gcc/defaults.h                    |  6 +-----
 gcc/output.h                      |  3 +++
 gcc/varasm.c                      |  9 +++++++++
 gcc/vmsdbgout.c                   |  1 +
 gcc/xcoffout.c                    |  1 +
 22 files changed, 60 insertions(+), 48 deletions(-)

diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h
index d98cce1..d3747b9 100644
--- a/gcc/config/arc/arc.h
+++ b/gcc/config/arc/arc.h
@@ -1245,8 +1245,7 @@ do {									\
 
 /* 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.  */
-#define ASM_OUTPUT_LABEL(FILE, NAME) \
-do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
+#define ASM_OUTPUT_LABEL default_output_label
 
 #define ASM_NAME_P(NAME) ( NAME[0]=='*')
 
diff --git a/gcc/config/bfin/bfin.h b/gcc/config/bfin/bfin.h
index 26ba7c2..08906aa 100644
--- a/gcc/config/bfin/bfin.h
+++ b/gcc/config/bfin/bfin.h
@@ -1044,10 +1044,7 @@ typedef enum directives {
     ASM_OUTPUT_LABEL(FILE, NAME);	\
   } while (0)
 
-#define ASM_OUTPUT_LABEL(FILE, NAME)    \
-  do {  assemble_name (FILE, NAME);		\
-        fputs (":\n",FILE);			\
-      } while (0)
+#define ASM_OUTPUT_LABEL default_output_label
 
 #define ASM_OUTPUT_LABELREF(FILE,NAME) 	\
     do {  fprintf (FILE, "_%s", NAME); \
diff --git a/gcc/config/frv/frv.h b/gcc/config/frv/frv.h
index b0d66fd..1d25974 100644
--- a/gcc/config/frv/frv.h
+++ b/gcc/config/frv/frv.h
@@ -1668,11 +1668,7 @@ do {                                                                   	\
    `assemble_name (STREAM, NAME)' to output the name itself; before and after
    that, output the additional assembler syntax for defining the name, and a
    newline.  */
-#define ASM_OUTPUT_LABEL(STREAM, NAME)					\
-do {									\
-  assemble_name (STREAM, NAME);						\
-  fputs (":\n", STREAM);						\
-} while (0)
+#define ASM_OUTPUT_LABEL default_output_label
 
 /* Globalizing directive for a label.  */
 #define GLOBAL_ASM_OP "\t.globl "
diff --git a/gcc/config/ia64/ia64-protos.h b/gcc/config/ia64/ia64-protos.h
index 29fc714..8e540e4 100644
--- a/gcc/config/ia64/ia64-protos.h
+++ b/gcc/config/ia64/ia64-protos.h
@@ -72,6 +72,7 @@ extern rtx ia64_expand_builtin (tree, rtx, rtx, machine_mode, int);
 extern rtx ia64_va_arg (tree, tree);
 #endif /* RTX_CODE */
 
+extern void ia64_output_label (FILE *f, const char *label);
 extern void ia64_asm_output_external (FILE *, tree, const char *);
 extern void ia64_vms_output_aligned_decl_common (FILE *, tree, const char *,
 						 unsigned HOST_WIDE_INT,
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index 779fc58..e07ebb5 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -10522,6 +10522,17 @@ ia64_hpux_function_arg_padding (machine_mode mode, const_tree type)
    return DEFAULT_FUNCTION_ARG_PADDING (mode, type);
 }
 
+/* Assemble a label.  */
+
+void
+ia64_output_label (FILE *f, const char *label)
+{
+  ia64_asm_output_label = 1;
+  assemble_name (f, label);
+  fputs (":\n", f);
+  ia64_asm_output_label = 0;
+}
+
 /* Emit text to declare externally defined variables and functions, because
    the Intel assembler does not support undefined externals.  */
 
diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h
index 4b62423..1afa7b7 100644
--- a/gcc/config/ia64/ia64.h
+++ b/gcc/config/ia64/ia64.h
@@ -1246,13 +1246,7 @@ do {									\
    why ia64_asm_output_label exists.  */
 
 extern int ia64_asm_output_label;
-#define ASM_OUTPUT_LABEL(STREAM, NAME)					\
-do {									\
-  ia64_asm_output_label = 1;						\
-  assemble_name (STREAM, NAME);						\
-  fputs (":\n", STREAM);						\
-  ia64_asm_output_label = 0;						\
-} while (0)
+#define ASM_OUTPUT_LABEL ia64_output_label
 
 /* Globalizing directive for a label.  */
 #define GLOBAL_ASM_OP "\t.global "
diff --git a/gcc/config/lm32/lm32.h b/gcc/config/lm32/lm32.h
index 986383f..9e8c667 100644
--- a/gcc/config/lm32/lm32.h
+++ b/gcc/config/lm32/lm32.h
@@ -443,8 +443,7 @@ do 									\
 }									\
 while (0)
 
-#define ASM_OUTPUT_LABEL(FILE, NAME) \
-  do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
+#define ASM_OUTPUT_LABEL default_output_label
 
 #define ASM_OUTPUT_LABELREF(FILE,NAME)	\
   do {					\
diff --git a/gcc/config/mep/mep.h b/gcc/config/mep/mep.h
index f7322cb7..8a9d447 100644
--- a/gcc/config/mep/mep.h
+++ b/gcc/config/mep/mep.h
@@ -625,13 +625,7 @@ typedef struct
 #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
 	mep_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 0)
 
-#define ASM_OUTPUT_LABEL(STREAM, NAME)		\
-  do						\
-    {						\
-      assemble_name (STREAM, NAME);		\
-      fputs (":\n", STREAM);			\
-    }						\
-  while (0)
+#define ASM_OUTPUT_LABEL default_output_label
 
 /* Globalizing directive for a label.  */
 #define GLOBAL_ASM_OP "\t.globl "
diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h
index 29d39bc..aac5aa0 100644
--- a/gcc/config/mmix/mmix.h
+++ b/gcc/config/mmix/mmix.h
@@ -647,8 +647,7 @@ typedef struct { int regs; int lib; } CUMULATIVE_ARGS;
 
 /* Node: Label Output */
 
-#define ASM_OUTPUT_LABEL(STREAM, NAME) \
- mmix_asm_output_label (STREAM, NAME)
+#define ASM_OUTPUT_LABEL mmix_asm_output_label
 
 #define ASM_OUTPUT_INTERNAL_LABEL(STREAM, NAME) \
  mmix_asm_output_internal_label (STREAM, NAME)
diff --git a/gcc/config/pa/pa-protos.h b/gcc/config/pa/pa-protos.h
index 0e13cd5..46a3e3b 100644
--- a/gcc/config/pa/pa-protos.h
+++ b/gcc/config/pa/pa-protos.h
@@ -110,6 +110,7 @@ extern void pa_asm_output_aligned_common (FILE *, const char *,
 extern void pa_asm_output_aligned_local (FILE *, const char *,
 					 unsigned HOST_WIDE_INT,
 					 unsigned int);
+extern void pa_output_label (FILE *f, const char *label);
 extern void pa_hpux_asm_output_external (FILE *, tree, const char *);
 extern bool pa_cannot_change_mode_class (machine_mode, machine_mode,
 					 enum reg_class);
diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c
index b24413a..2bcaa7e 100644
--- a/gcc/config/pa/pa.c
+++ b/gcc/config/pa/pa.c
@@ -9761,6 +9761,18 @@ pa_reloc_rw_mask (void)
   return 3;
 }
 
+/* Assemble a lable.  */
+
+void
+pa_output_label (FILE *f, const char *label)
+{
+  assemble_name (f, label);
+  if (TARGET_GAS)
+    fputs (":\n", f);
+  else
+    fputc ('\n', (f));
+}
+
 static void
 pa_globalize_label (FILE *stream, const char *name)
 {
diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h
index bdfbb16..595a10b 100644
--- a/gcc/config/pa/pa.h
+++ b/gcc/config/pa/pa.h
@@ -1107,14 +1107,7 @@ do {									     \
 /* 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.  */
 
-#define ASM_OUTPUT_LABEL(FILE,NAME) \
-  do {							\
-    assemble_name ((FILE), (NAME));			\
-    if (TARGET_GAS)					\
-      fputs (":\n", (FILE));				\
-    else						\
-      fputc ('\n', (FILE));				\
-  } while (0)
+#define ASM_OUTPUT_LABEL pa_output_label
 
 /* This is how to output a reference to a user-level label named NAME.
    `assemble_name' uses this.  */
diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h
index 560a825..031614f 100644
--- a/gcc/config/rs6000/rs6000-protos.h
+++ b/gcc/config/rs6000/rs6000-protos.h
@@ -169,6 +169,7 @@ extern int function_ok_for_sibcall (tree);
 extern int rs6000_reg_parm_stack_space (tree, bool);
 extern void rs6000_xcoff_declare_function_name (FILE *, const char *, tree);
 extern void rs6000_xcoff_declare_object_name (FILE *, const char *, tree);
+extern void rs6000_xcoff_output_label (FILE *f, const char *label);
 extern void rs6000_elf_declare_function_name (FILE *, const char *, tree);
 extern bool rs6000_elf_in_small_data_p (const_tree);
 #ifdef ARGS_SIZE_RTX
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index c8794b4..a214010 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -30364,6 +30364,14 @@ rs6000_xcoff_asm_output_anchor (rtx symbol)
   fprintf (asm_out_file, "\n");
 }
 
+/* Assemble the given label.  */
+void
+rs6000_xcoff_output_label (FILE *f, const char *label)
+{
+  RS6000_OUTPUT_BASENAME (f, label);
+  fputs (":\n", f);
+}
+
 static void
 rs6000_xcoff_asm_globalize_label (FILE *stream, const char *name)
 {
diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h
index 8b0cb27..263e239 100644
--- a/gcc/config/rs6000/xcoff.h
+++ b/gcc/config/rs6000/xcoff.h
@@ -119,8 +119,7 @@
 /* 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.  */
 
-#define ASM_OUTPUT_LABEL(FILE,NAME)	\
-  do { RS6000_OUTPUT_BASENAME (FILE, NAME); fputs (":\n", FILE); } while (0)
+#define ASM_OUTPUT_LABEL rs6000_xcoff_output_label
 
 /* This is how to output a command to make the user-level label named NAME
    defined for reference from other files.  */
diff --git a/gcc/config/spu/spu.h b/gcc/config/spu/spu.h
index 25fa435..f35b55e 100644
--- a/gcc/config/spu/spu.h
+++ b/gcc/config/spu/spu.h
@@ -443,8 +443,7 @@ do {									\
 
 \f
 /* Label Output */
-#define ASM_OUTPUT_LABEL(FILE,NAME)	\
-  do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
+#define ASM_OUTPUT_LABEL default_output_label
 
 #define ASM_OUTPUT_LABELREF(FILE, NAME) \
   asm_fprintf (FILE, "%U%s", default_strip_name_encoding (NAME))
diff --git a/gcc/config/visium/visium.h b/gcc/config/visium/visium.h
index a2ab61c..6457c55 100644
--- a/gcc/config/visium/visium.h
+++ b/gcc/config/visium/visium.h
@@ -1440,8 +1440,7 @@ do									\
    `assemble_name (STREAM, NAME)' to output the name itself; before
    and after that, output the additional assembler syntax for defining
    the name, and a newline. */
-#define ASM_OUTPUT_LABEL(STREAM,NAME)     \
-  do { assemble_name (STREAM, NAME); fputs (":\n", STREAM); } while (0)
+#define ASM_OUTPUT_LABEL default_output_label
 
 /* Globalizing directive for a label */
 #define GLOBAL_ASM_OP "\t.global "
diff --git a/gcc/defaults.h b/gcc/defaults.h
index 3ecf9fd..b1465de 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -89,11 +89,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    NAME, such as the label on variable NAME.  */
 
 #ifndef ASM_OUTPUT_LABEL
-#define ASM_OUTPUT_LABEL(FILE,NAME) \
-  do {						\
-    assemble_name ((FILE), (NAME));		\
-    fputs (":\n", (FILE));			\
-  } while (0)
+#define ASM_OUTPUT_LABEL default_output_label
 #endif
 
 /* This is how to output the definition of a user-level label named
diff --git a/gcc/output.h b/gcc/output.h
index 8aa648a..07172d5 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -246,6 +246,9 @@ extern void assemble_name_raw (FILE *, const char *);
    be marked as referenced.  */
 extern void assemble_name (FILE *, const char *);
 
+/* Assemble a label.  */
+extern void default_output_label (FILE *f, const char *label);
+
 /* Return the assembler directive for creating a given kind of integer
    object.  SIZE is the number of bytes in the object and ALIGNED_P
    indicates whether it is known to be aligned.  Return NULL if the
diff --git a/gcc/varasm.c b/gcc/varasm.c
index c2bfbf0..9c5f12d 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -2580,6 +2580,15 @@ assemble_name (FILE *file, const char *name)
   assemble_name_raw (file, name);
 }
 
+/* Assemble a label.  */
+
+void
+default_output_label (FILE *f, const char *label)
+{
+  assemble_name (f, label);
+  fputs (":\n", f);
+}
+
 /* Allocate SIZE bytes writable static space with a gensym name
    and return an RTX to refer to its address.  */
 
diff --git a/gcc/vmsdbgout.c b/gcc/vmsdbgout.c
index 0204740..d04b8fb 100644
--- a/gcc/vmsdbgout.c
+++ b/gcc/vmsdbgout.c
@@ -37,6 +37,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "langhooks.h"
 #include "function.h"
 #include "target.h"
+#include "tm_p.h"
 
 /* Difference in seconds between the VMS Epoch and the Unix Epoch */
 static const long long vms_epoch_offset = 3506716800ll;
diff --git a/gcc/xcoffout.c b/gcc/xcoffout.c
index 0f11115..83959c8 100644
--- a/gcc/xcoffout.c
+++ b/gcc/xcoffout.c
@@ -35,6 +35,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "output.h"
 #include "target.h"
 #include "debug.h"
+#include "tm_p.h"
 
 #ifdef XCOFF_DEBUGGING_INFO
 
-- 
2.4.0

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 1/4] convert ASM_OUTPUT_ASCII to a hook
  2015-07-25  2:37 ` [PATCH 1/4] convert ASM_OUTPUT_ASCII to a hook tbsaunde+gcc
@ 2015-07-25  6:22   ` pinskia
  2015-07-25 19:44     ` Trevor Saunders
  2015-07-25 17:02   ` Segher Boessenkool
  2015-07-27 20:51   ` Richard Sandiford
  2 siblings, 1 reply; 31+ messages in thread
From: pinskia @ 2015-07-25  6:22 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: gcc-patches





> On Jul 24, 2015, at 7:36 PM, tbsaunde+gcc@tbsaunde.org wrote:
> 
> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
> 
> gcc/ChangeLog:
> 
> 2015-07-25  Trevor Saunders  <tsaunders@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)

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 the rest of the target macro conversions look correct and kept the casting. Just this one seems missing. 

Thanks,
Andrew

> {
> -  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
> 
> \f
> /* 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)
> \f
> /* 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)
> \f
> /* 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
> 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 1/4] convert ASM_OUTPUT_ASCII to a hook
  2015-07-25  2:37 ` [PATCH 1/4] convert ASM_OUTPUT_ASCII to a hook tbsaunde+gcc
  2015-07-25  6:22   ` pinskia
@ 2015-07-25 17:02   ` Segher Boessenkool
  2015-07-27 20:51   ` Richard Sandiford
  2 siblings, 0 replies; 31+ messages in thread
From: Segher Boessenkool @ 2015-07-25 17:02 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: gcc-patches

On Fri, Jul 24, 2015 at 10:36:57PM -0400, tbsaunde+gcc@tbsaunde.org wrote:
> -@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}.

   ^ stray space

> -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.

Typoes ("defalt", "Berkely").

> +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)

Both here as well, of course.

> -   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

targetm?


Segher

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-07-25  5:42 ` [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function tbsaunde+gcc
@ 2015-07-25 18:34   ` Segher Boessenkool
  2015-07-25 19:27     ` Trevor Saunders
  2015-07-27  9:17   ` Richard Biener
  1 sibling, 1 reply; 31+ messages in thread
From: Segher Boessenkool @ 2015-07-25 18:34 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: gcc-patches

On Fri, Jul 24, 2015 at 10:37:00PM -0400, tbsaunde+gcc@tbsaunde.org wrote:
> --- a/gcc/config/pa/pa.c
> +++ b/gcc/config/pa/pa.c
> @@ -9761,6 +9761,18 @@ pa_reloc_rw_mask (void)
>    return 3;
>  }
>  
> +/* Assemble a lable.  */

Typo.

> +void
> +pa_output_label (FILE *f, const char *label)
> +{
> +  assemble_name (f, label);
> +  if (TARGET_GAS)
> +    fputs (":\n", f);
> +  else
> +    fputc ('\n', (f));

You forgot to remove the extra parens here :-)

If so many targets use default_assemble_label, can you make it an actual
default instead of defining it everywhere?


Segher

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-07-25 18:34   ` Segher Boessenkool
@ 2015-07-25 19:27     ` Trevor Saunders
  2015-07-25 19:44       ` Segher Boessenkool
  0 siblings, 1 reply; 31+ messages in thread
From: Trevor Saunders @ 2015-07-25 19:27 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: tbsaunde+gcc, gcc-patches

On Sat, Jul 25, 2015 at 10:59:19AM -0500, Segher Boessenkool wrote:
> On Fri, Jul 24, 2015 at 10:37:00PM -0400, tbsaunde+gcc@tbsaunde.org wrote:
> > --- a/gcc/config/pa/pa.c
> > +++ b/gcc/config/pa/pa.c
> > @@ -9761,6 +9761,18 @@ pa_reloc_rw_mask (void)
> >    return 3;
> >  }
> >  
> > +/* Assemble a lable.  */
> 
> Typo.
> 
> > +void
> > +pa_output_label (FILE *f, const char *label)
> > +{
> > +  assemble_name (f, label);
> > +  if (TARGET_GAS)
> > +    fputs (":\n", f);
> > +  else
> > +    fputc ('\n', (f));
> 
> You forgot to remove the extra parens here :-)
> 
> If so many targets use default_assemble_label, can you make it an actual
> default instead of defining it everywhere?

 Well, it is the default, but many targets do over ride it to set it to
 the default ;)  Its certainly possible to remove some of those cases,
 but that seems like the sort of thing one might want to test more than
 just making sure gcc/ builds, and I'm not really set up to do that.  Is
 there a problem with leaving this for target maintainers to do?  It
 seems like an improvement over what we have, and I don't think they are
 getting in anyones way.

 Trev

> 
> 
> Segher

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 1/4] convert ASM_OUTPUT_ASCII to a hook
  2015-07-25  6:22   ` pinskia
@ 2015-07-25 19:44     ` Trevor Saunders
  0 siblings, 0 replies; 31+ messages in thread
From: Trevor Saunders @ 2015-07-25 19:44 UTC (permalink / raw)
  To: pinskia; +Cc: tbsaunde+gcc, gcc-patches

On Fri, Jul 24, 2015 at 08:09:26PM -0700, pinskia@gmail.com wrote:
> 
> 
> 
> 
> > On Jul 24, 2015, at 7:36 PM, tbsaunde+gcc@tbsaunde.org wrote:
> > +++ 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)
> 
> 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 the rest of the target macro conversions look correct and kept the casting. Just this one seems missing. 

hrm I think that might be a real issue.  that function just assigns p[i]
to an int and then passes that to ISPRINT and putc or printf.  I'm not
totally sure sign extending and then passingto ISPriNt is ok, so its
probably best to change it to int c = (unsigned char) p[i];  I'll make
that change if nobody objects and it seems like the right thing to do.

Trev

> 
> Thanks,
> Andrew
> 
> > {
> > -  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
> > 
> > \f
> > /* 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)
> > \f
> > /* 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)
> > \f
> > /* 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
> > 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-07-25 19:27     ` Trevor Saunders
@ 2015-07-25 19:44       ` Segher Boessenkool
  0 siblings, 0 replies; 31+ messages in thread
From: Segher Boessenkool @ 2015-07-25 19:44 UTC (permalink / raw)
  To: Trevor Saunders; +Cc: tbsaunde+gcc, gcc-patches

On Sat, Jul 25, 2015 at 02:40:56PM -0400, Trevor Saunders wrote:
> > If so many targets use default_assemble_label, can you make it an actual
> > default instead of defining it everywhere?
> 
>  Well, it is the default, but many targets do over ride it to set it to
>  the default ;)

Right, noticed that too late :-)

>  Its certainly possible to remove some of those cases,
>  but that seems like the sort of thing one might want to test more than
>  just making sure gcc/ builds, and I'm not really set up to do that.  Is
>  there a problem with leaving this for target maintainers to do?  It
>  seems like an improvement over what we have, and I don't think they are
>  getting in anyones way.

If you're not confident removing it yourself, then don't.  It isn't
getting in anyone's way, simply because there is so *much* clutter...


Segher

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-07-25  5:42 ` [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function tbsaunde+gcc
  2015-07-25 18:34   ` Segher Boessenkool
@ 2015-07-27  9:17   ` Richard Biener
  2015-07-28  6:45     ` Trevor Saunders
  2015-08-05 10:58     ` Trevor Saunders
  1 sibling, 2 replies; 31+ messages in thread
From: Richard Biener @ 2015-07-27  9:17 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: GCC Patches

On Sat, Jul 25, 2015 at 4:37 AM,  <tbsaunde+gcc@tbsaunde.org> wrote:
> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>
>         * config/arc/arc.h, config/bfin/bfin.h, config/frv/frv.h,
>         config/ia64/ia64-protos.h, config/ia64/ia64.c, config/ia64/ia64.h,
>         config/lm32/lm32.h, config/mep/mep.h, config/mmix/mmix.h,
>         config/rs6000/rs6000.c, config/rs6000/xcoff.h, config/spu/spu.h,
>         config/visium/visium.h, defaults.h: Define ASM_OUTPUT_LABEL to
> the name of a function.
>         * output.h (default_output_label): New prototype.
>         * varasm.c (default_output_label): New function.
>         * vmsdbgout.c: Include tm_p.h.
>         * xcoffout.c: Likewise.

Just a general remark - the GCC output machinery is known to be slow,
adding indirect calls might be not the very best idea without refactoring
some of it.

Did you do any performance measurements for artificial testcases
exercising the specific bits you change?

Richard.

> ---
>  gcc/config/arc/arc.h              |  3 +--
>  gcc/config/bfin/bfin.h            |  5 +----
>  gcc/config/frv/frv.h              |  6 +-----
>  gcc/config/ia64/ia64-protos.h     |  1 +
>  gcc/config/ia64/ia64.c            | 11 +++++++++++
>  gcc/config/ia64/ia64.h            |  8 +-------
>  gcc/config/lm32/lm32.h            |  3 +--
>  gcc/config/mep/mep.h              |  8 +-------
>  gcc/config/mmix/mmix.h            |  3 +--
>  gcc/config/pa/pa-protos.h         |  1 +
>  gcc/config/pa/pa.c                | 12 ++++++++++++
>  gcc/config/pa/pa.h                |  9 +--------
>  gcc/config/rs6000/rs6000-protos.h |  1 +
>  gcc/config/rs6000/rs6000.c        |  8 ++++++++
>  gcc/config/rs6000/xcoff.h         |  3 +--
>  gcc/config/spu/spu.h              |  3 +--
>  gcc/config/visium/visium.h        |  3 +--
>  gcc/defaults.h                    |  6 +-----
>  gcc/output.h                      |  3 +++
>  gcc/varasm.c                      |  9 +++++++++
>  gcc/vmsdbgout.c                   |  1 +
>  gcc/xcoffout.c                    |  1 +
>  22 files changed, 60 insertions(+), 48 deletions(-)
>
> diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h
> index d98cce1..d3747b9 100644
> --- a/gcc/config/arc/arc.h
> +++ b/gcc/config/arc/arc.h
> @@ -1245,8 +1245,7 @@ do {                                                                      \
>
>  /* 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.  */
> -#define ASM_OUTPUT_LABEL(FILE, NAME) \
> -do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
> +#define ASM_OUTPUT_LABEL default_output_label
>
>  #define ASM_NAME_P(NAME) ( NAME[0]=='*')
>
> diff --git a/gcc/config/bfin/bfin.h b/gcc/config/bfin/bfin.h
> index 26ba7c2..08906aa 100644
> --- a/gcc/config/bfin/bfin.h
> +++ b/gcc/config/bfin/bfin.h
> @@ -1044,10 +1044,7 @@ typedef enum directives {
>      ASM_OUTPUT_LABEL(FILE, NAME);      \
>    } while (0)
>
> -#define ASM_OUTPUT_LABEL(FILE, NAME)    \
> -  do {  assemble_name (FILE, NAME);            \
> -        fputs (":\n",FILE);                    \
> -      } while (0)
> +#define ASM_OUTPUT_LABEL default_output_label
>
>  #define ASM_OUTPUT_LABELREF(FILE,NAME)         \
>      do {  fprintf (FILE, "_%s", NAME); \
> diff --git a/gcc/config/frv/frv.h b/gcc/config/frv/frv.h
> index b0d66fd..1d25974 100644
> --- a/gcc/config/frv/frv.h
> +++ b/gcc/config/frv/frv.h
> @@ -1668,11 +1668,7 @@ do {                                                                     \
>     `assemble_name (STREAM, NAME)' to output the name itself; before and after
>     that, output the additional assembler syntax for defining the name, and a
>     newline.  */
> -#define ASM_OUTPUT_LABEL(STREAM, NAME)                                 \
> -do {                                                                   \
> -  assemble_name (STREAM, NAME);                                                \
> -  fputs (":\n", STREAM);                                               \
> -} while (0)
> +#define ASM_OUTPUT_LABEL default_output_label
>
>  /* Globalizing directive for a label.  */
>  #define GLOBAL_ASM_OP "\t.globl "
> diff --git a/gcc/config/ia64/ia64-protos.h b/gcc/config/ia64/ia64-protos.h
> index 29fc714..8e540e4 100644
> --- a/gcc/config/ia64/ia64-protos.h
> +++ b/gcc/config/ia64/ia64-protos.h
> @@ -72,6 +72,7 @@ extern rtx ia64_expand_builtin (tree, rtx, rtx, machine_mode, int);
>  extern rtx ia64_va_arg (tree, tree);
>  #endif /* RTX_CODE */
>
> +extern void ia64_output_label (FILE *f, const char *label);
>  extern void ia64_asm_output_external (FILE *, tree, const char *);
>  extern void ia64_vms_output_aligned_decl_common (FILE *, tree, const char *,
>                                                  unsigned HOST_WIDE_INT,
> diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
> index 779fc58..e07ebb5 100644
> --- a/gcc/config/ia64/ia64.c
> +++ b/gcc/config/ia64/ia64.c
> @@ -10522,6 +10522,17 @@ ia64_hpux_function_arg_padding (machine_mode mode, const_tree type)
>     return DEFAULT_FUNCTION_ARG_PADDING (mode, type);
>  }
>
> +/* Assemble a label.  */
> +
> +void
> +ia64_output_label (FILE *f, const char *label)
> +{
> +  ia64_asm_output_label = 1;
> +  assemble_name (f, label);
> +  fputs (":\n", f);
> +  ia64_asm_output_label = 0;
> +}
> +
>  /* Emit text to declare externally defined variables and functions, because
>     the Intel assembler does not support undefined externals.  */
>
> diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h
> index 4b62423..1afa7b7 100644
> --- a/gcc/config/ia64/ia64.h
> +++ b/gcc/config/ia64/ia64.h
> @@ -1246,13 +1246,7 @@ do {                                                                     \
>     why ia64_asm_output_label exists.  */
>
>  extern int ia64_asm_output_label;
> -#define ASM_OUTPUT_LABEL(STREAM, NAME)                                 \
> -do {                                                                   \
> -  ia64_asm_output_label = 1;                                           \
> -  assemble_name (STREAM, NAME);                                                \
> -  fputs (":\n", STREAM);                                               \
> -  ia64_asm_output_label = 0;                                           \
> -} while (0)
> +#define ASM_OUTPUT_LABEL ia64_output_label
>
>  /* Globalizing directive for a label.  */
>  #define GLOBAL_ASM_OP "\t.global "
> diff --git a/gcc/config/lm32/lm32.h b/gcc/config/lm32/lm32.h
> index 986383f..9e8c667 100644
> --- a/gcc/config/lm32/lm32.h
> +++ b/gcc/config/lm32/lm32.h
> @@ -443,8 +443,7 @@ do                                                                  \
>  }                                                                      \
>  while (0)
>
> -#define ASM_OUTPUT_LABEL(FILE, NAME) \
> -  do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
> +#define ASM_OUTPUT_LABEL default_output_label
>
>  #define ASM_OUTPUT_LABELREF(FILE,NAME) \
>    do {                                 \
> diff --git a/gcc/config/mep/mep.h b/gcc/config/mep/mep.h
> index f7322cb7..8a9d447 100644
> --- a/gcc/config/mep/mep.h
> +++ b/gcc/config/mep/mep.h
> @@ -625,13 +625,7 @@ typedef struct
>  #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
>         mep_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 0)
>
> -#define ASM_OUTPUT_LABEL(STREAM, NAME)         \
> -  do                                           \
> -    {                                          \
> -      assemble_name (STREAM, NAME);            \
> -      fputs (":\n", STREAM);                   \
> -    }                                          \
> -  while (0)
> +#define ASM_OUTPUT_LABEL default_output_label
>
>  /* Globalizing directive for a label.  */
>  #define GLOBAL_ASM_OP "\t.globl "
> diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h
> index 29d39bc..aac5aa0 100644
> --- a/gcc/config/mmix/mmix.h
> +++ b/gcc/config/mmix/mmix.h
> @@ -647,8 +647,7 @@ typedef struct { int regs; int lib; } CUMULATIVE_ARGS;
>
>  /* Node: Label Output */
>
> -#define ASM_OUTPUT_LABEL(STREAM, NAME) \
> - mmix_asm_output_label (STREAM, NAME)
> +#define ASM_OUTPUT_LABEL mmix_asm_output_label
>
>  #define ASM_OUTPUT_INTERNAL_LABEL(STREAM, NAME) \
>   mmix_asm_output_internal_label (STREAM, NAME)
> diff --git a/gcc/config/pa/pa-protos.h b/gcc/config/pa/pa-protos.h
> index 0e13cd5..46a3e3b 100644
> --- a/gcc/config/pa/pa-protos.h
> +++ b/gcc/config/pa/pa-protos.h
> @@ -110,6 +110,7 @@ extern void pa_asm_output_aligned_common (FILE *, const char *,
>  extern void pa_asm_output_aligned_local (FILE *, const char *,
>                                          unsigned HOST_WIDE_INT,
>                                          unsigned int);
> +extern void pa_output_label (FILE *f, const char *label);
>  extern void pa_hpux_asm_output_external (FILE *, tree, const char *);
>  extern bool pa_cannot_change_mode_class (machine_mode, machine_mode,
>                                          enum reg_class);
> diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c
> index b24413a..2bcaa7e 100644
> --- a/gcc/config/pa/pa.c
> +++ b/gcc/config/pa/pa.c
> @@ -9761,6 +9761,18 @@ pa_reloc_rw_mask (void)
>    return 3;
>  }
>
> +/* Assemble a lable.  */
> +
> +void
> +pa_output_label (FILE *f, const char *label)
> +{
> +  assemble_name (f, label);
> +  if (TARGET_GAS)
> +    fputs (":\n", f);
> +  else
> +    fputc ('\n', (f));
> +}
> +
>  static void
>  pa_globalize_label (FILE *stream, const char *name)
>  {
> diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h
> index bdfbb16..595a10b 100644
> --- a/gcc/config/pa/pa.h
> +++ b/gcc/config/pa/pa.h
> @@ -1107,14 +1107,7 @@ do {                                                                          \
>  /* 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.  */
>
> -#define ASM_OUTPUT_LABEL(FILE,NAME) \
> -  do {                                                 \
> -    assemble_name ((FILE), (NAME));                    \
> -    if (TARGET_GAS)                                    \
> -      fputs (":\n", (FILE));                           \
> -    else                                               \
> -      fputc ('\n', (FILE));                            \
> -  } while (0)
> +#define ASM_OUTPUT_LABEL pa_output_label
>
>  /* This is how to output a reference to a user-level label named NAME.
>     `assemble_name' uses this.  */
> diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h
> index 560a825..031614f 100644
> --- a/gcc/config/rs6000/rs6000-protos.h
> +++ b/gcc/config/rs6000/rs6000-protos.h
> @@ -169,6 +169,7 @@ extern int function_ok_for_sibcall (tree);
>  extern int rs6000_reg_parm_stack_space (tree, bool);
>  extern void rs6000_xcoff_declare_function_name (FILE *, const char *, tree);
>  extern void rs6000_xcoff_declare_object_name (FILE *, const char *, tree);
> +extern void rs6000_xcoff_output_label (FILE *f, const char *label);
>  extern void rs6000_elf_declare_function_name (FILE *, const char *, tree);
>  extern bool rs6000_elf_in_small_data_p (const_tree);
>  #ifdef ARGS_SIZE_RTX
> diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> index c8794b4..a214010 100644
> --- a/gcc/config/rs6000/rs6000.c
> +++ b/gcc/config/rs6000/rs6000.c
> @@ -30364,6 +30364,14 @@ rs6000_xcoff_asm_output_anchor (rtx symbol)
>    fprintf (asm_out_file, "\n");
>  }
>
> +/* Assemble the given label.  */
> +void
> +rs6000_xcoff_output_label (FILE *f, const char *label)
> +{
> +  RS6000_OUTPUT_BASENAME (f, label);
> +  fputs (":\n", f);
> +}
> +
>  static void
>  rs6000_xcoff_asm_globalize_label (FILE *stream, const char *name)
>  {
> diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h
> index 8b0cb27..263e239 100644
> --- a/gcc/config/rs6000/xcoff.h
> +++ b/gcc/config/rs6000/xcoff.h
> @@ -119,8 +119,7 @@
>  /* 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.  */
>
> -#define ASM_OUTPUT_LABEL(FILE,NAME)    \
> -  do { RS6000_OUTPUT_BASENAME (FILE, NAME); fputs (":\n", FILE); } while (0)
> +#define ASM_OUTPUT_LABEL rs6000_xcoff_output_label
>
>  /* This is how to output a command to make the user-level label named NAME
>     defined for reference from other files.  */
> diff --git a/gcc/config/spu/spu.h b/gcc/config/spu/spu.h
> index 25fa435..f35b55e 100644
> --- a/gcc/config/spu/spu.h
> +++ b/gcc/config/spu/spu.h
> @@ -443,8 +443,7 @@ do {                                                                        \
>
>
>  /* Label Output */
> -#define ASM_OUTPUT_LABEL(FILE,NAME)    \
> -  do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
> +#define ASM_OUTPUT_LABEL default_output_label
>
>  #define ASM_OUTPUT_LABELREF(FILE, NAME) \
>    asm_fprintf (FILE, "%U%s", default_strip_name_encoding (NAME))
> diff --git a/gcc/config/visium/visium.h b/gcc/config/visium/visium.h
> index a2ab61c..6457c55 100644
> --- a/gcc/config/visium/visium.h
> +++ b/gcc/config/visium/visium.h
> @@ -1440,8 +1440,7 @@ do                                                                        \
>     `assemble_name (STREAM, NAME)' to output the name itself; before
>     and after that, output the additional assembler syntax for defining
>     the name, and a newline. */
> -#define ASM_OUTPUT_LABEL(STREAM,NAME)     \
> -  do { assemble_name (STREAM, NAME); fputs (":\n", STREAM); } while (0)
> +#define ASM_OUTPUT_LABEL default_output_label
>
>  /* Globalizing directive for a label */
>  #define GLOBAL_ASM_OP "\t.global "
> diff --git a/gcc/defaults.h b/gcc/defaults.h
> index 3ecf9fd..b1465de 100644
> --- a/gcc/defaults.h
> +++ b/gcc/defaults.h
> @@ -89,11 +89,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>     NAME, such as the label on variable NAME.  */
>
>  #ifndef ASM_OUTPUT_LABEL
> -#define ASM_OUTPUT_LABEL(FILE,NAME) \
> -  do {                                         \
> -    assemble_name ((FILE), (NAME));            \
> -    fputs (":\n", (FILE));                     \
> -  } while (0)
> +#define ASM_OUTPUT_LABEL default_output_label
>  #endif
>
>  /* This is how to output the definition of a user-level label named
> diff --git a/gcc/output.h b/gcc/output.h
> index 8aa648a..07172d5 100644
> --- a/gcc/output.h
> +++ b/gcc/output.h
> @@ -246,6 +246,9 @@ extern void assemble_name_raw (FILE *, const char *);
>     be marked as referenced.  */
>  extern void assemble_name (FILE *, const char *);
>
> +/* Assemble a label.  */
> +extern void default_output_label (FILE *f, const char *label);
> +
>  /* Return the assembler directive for creating a given kind of integer
>     object.  SIZE is the number of bytes in the object and ALIGNED_P
>     indicates whether it is known to be aligned.  Return NULL if the
> diff --git a/gcc/varasm.c b/gcc/varasm.c
> index c2bfbf0..9c5f12d 100644
> --- a/gcc/varasm.c
> +++ b/gcc/varasm.c
> @@ -2580,6 +2580,15 @@ assemble_name (FILE *file, const char *name)
>    assemble_name_raw (file, name);
>  }
>
> +/* Assemble a label.  */
> +
> +void
> +default_output_label (FILE *f, const char *label)
> +{
> +  assemble_name (f, label);
> +  fputs (":\n", f);
> +}
> +
>  /* Allocate SIZE bytes writable static space with a gensym name
>     and return an RTX to refer to its address.  */
>
> diff --git a/gcc/vmsdbgout.c b/gcc/vmsdbgout.c
> index 0204740..d04b8fb 100644
> --- a/gcc/vmsdbgout.c
> +++ b/gcc/vmsdbgout.c
> @@ -37,6 +37,7 @@ along with GCC; see the file COPYING3.  If not see
>  #include "langhooks.h"
>  #include "function.h"
>  #include "target.h"
> +#include "tm_p.h"
>
>  /* Difference in seconds between the VMS Epoch and the Unix Epoch */
>  static const long long vms_epoch_offset = 3506716800ll;
> diff --git a/gcc/xcoffout.c b/gcc/xcoffout.c
> index 0f11115..83959c8 100644
> --- a/gcc/xcoffout.c
> +++ b/gcc/xcoffout.c
> @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3.  If not see
>  #include "output.h"
>  #include "target.h"
>  #include "debug.h"
> +#include "tm_p.h"
>
>  #ifdef XCOFF_DEBUGGING_INFO
>
> --
> 2.4.0
>

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 1/4] convert ASM_OUTPUT_ASCII to a hook
  2015-07-25  2:37 ` [PATCH 1/4] convert ASM_OUTPUT_ASCII to a hook tbsaunde+gcc
  2015-07-25  6:22   ` pinskia
  2015-07-25 17:02   ` Segher Boessenkool
@ 2015-07-27 20:51   ` Richard Sandiford
  2 siblings, 0 replies; 31+ messages in thread
From: Richard Sandiford @ 2015-07-27 20:51 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: gcc-patches

tbsaunde+gcc@tbsaunde.org writes:
> +/* 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;
> +	    }

"_ascii_bytes = p;" onwards seems to be indented too far.

> +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)

Preexisting, but how about s/an assembly instruction/assembly instructions/
(or "assembly directives"?), just to emphasise that more than one instruction
can be used.

> @@ -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++)
> +      {

Some strange indentation here too.

Thanks,
Richard

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-07-27  9:17   ` Richard Biener
@ 2015-07-28  6:45     ` Trevor Saunders
  2015-07-29 23:05       ` Jeff Law
  2015-08-05 10:58     ` Trevor Saunders
  1 sibling, 1 reply; 31+ messages in thread
From: Trevor Saunders @ 2015-07-28  6:45 UTC (permalink / raw)
  To: Richard Biener; +Cc: tbsaunde+gcc, GCC Patches

On Mon, Jul 27, 2015 at 11:06:58AM +0200, Richard Biener wrote:
> On Sat, Jul 25, 2015 at 4:37 AM,  <tbsaunde+gcc@tbsaunde.org> wrote:
> > From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
> >
> >         * config/arc/arc.h, config/bfin/bfin.h, config/frv/frv.h,
> >         config/ia64/ia64-protos.h, config/ia64/ia64.c, config/ia64/ia64.h,
> >         config/lm32/lm32.h, config/mep/mep.h, config/mmix/mmix.h,
> >         config/rs6000/rs6000.c, config/rs6000/xcoff.h, config/spu/spu.h,
> >         config/visium/visium.h, defaults.h: Define ASM_OUTPUT_LABEL to
> > the name of a function.
> >         * output.h (default_output_label): New prototype.
> >         * varasm.c (default_output_label): New function.
> >         * vmsdbgout.c: Include tm_p.h.
> >         * xcoffout.c: Likewise.
> 
> Just a general remark - the GCC output machinery is known to be slow,
> adding indirect calls might be not the very best idea without refactoring
> some of it.

ah, I wasn't aware of that.  On the other hand some of these hooks seem
to generally be big so the call over head might not matter that much.  I
suppose if this is something we really care about we might want to
consider pushing the libgas project farther so we can avoid all this
text formatting all together.

> Did you do any performance measurements for artificial testcases
> exercising the specific bits you change?

no since I wasn't aware it was a concern.  I can try to do that in the
next couple days.

thanks!

Trev

> 
> Richard.
> 
> > ---
> >  gcc/config/arc/arc.h              |  3 +--
> >  gcc/config/bfin/bfin.h            |  5 +----
> >  gcc/config/frv/frv.h              |  6 +-----
> >  gcc/config/ia64/ia64-protos.h     |  1 +
> >  gcc/config/ia64/ia64.c            | 11 +++++++++++
> >  gcc/config/ia64/ia64.h            |  8 +-------
> >  gcc/config/lm32/lm32.h            |  3 +--
> >  gcc/config/mep/mep.h              |  8 +-------
> >  gcc/config/mmix/mmix.h            |  3 +--
> >  gcc/config/pa/pa-protos.h         |  1 +
> >  gcc/config/pa/pa.c                | 12 ++++++++++++
> >  gcc/config/pa/pa.h                |  9 +--------
> >  gcc/config/rs6000/rs6000-protos.h |  1 +
> >  gcc/config/rs6000/rs6000.c        |  8 ++++++++
> >  gcc/config/rs6000/xcoff.h         |  3 +--
> >  gcc/config/spu/spu.h              |  3 +--
> >  gcc/config/visium/visium.h        |  3 +--
> >  gcc/defaults.h                    |  6 +-----
> >  gcc/output.h                      |  3 +++
> >  gcc/varasm.c                      |  9 +++++++++
> >  gcc/vmsdbgout.c                   |  1 +
> >  gcc/xcoffout.c                    |  1 +
> >  22 files changed, 60 insertions(+), 48 deletions(-)
> >
> > diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h
> > index d98cce1..d3747b9 100644
> > --- a/gcc/config/arc/arc.h
> > +++ b/gcc/config/arc/arc.h
> > @@ -1245,8 +1245,7 @@ do {                                                                      \
> >
> >  /* 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.  */
> > -#define ASM_OUTPUT_LABEL(FILE, NAME) \
> > -do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
> > +#define ASM_OUTPUT_LABEL default_output_label
> >
> >  #define ASM_NAME_P(NAME) ( NAME[0]=='*')
> >
> > diff --git a/gcc/config/bfin/bfin.h b/gcc/config/bfin/bfin.h
> > index 26ba7c2..08906aa 100644
> > --- a/gcc/config/bfin/bfin.h
> > +++ b/gcc/config/bfin/bfin.h
> > @@ -1044,10 +1044,7 @@ typedef enum directives {
> >      ASM_OUTPUT_LABEL(FILE, NAME);      \
> >    } while (0)
> >
> > -#define ASM_OUTPUT_LABEL(FILE, NAME)    \
> > -  do {  assemble_name (FILE, NAME);            \
> > -        fputs (":\n",FILE);                    \
> > -      } while (0)
> > +#define ASM_OUTPUT_LABEL default_output_label
> >
> >  #define ASM_OUTPUT_LABELREF(FILE,NAME)         \
> >      do {  fprintf (FILE, "_%s", NAME); \
> > diff --git a/gcc/config/frv/frv.h b/gcc/config/frv/frv.h
> > index b0d66fd..1d25974 100644
> > --- a/gcc/config/frv/frv.h
> > +++ b/gcc/config/frv/frv.h
> > @@ -1668,11 +1668,7 @@ do {                                                                     \
> >     `assemble_name (STREAM, NAME)' to output the name itself; before and after
> >     that, output the additional assembler syntax for defining the name, and a
> >     newline.  */
> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)                                 \
> > -do {                                                                   \
> > -  assemble_name (STREAM, NAME);                                                \
> > -  fputs (":\n", STREAM);                                               \
> > -} while (0)
> > +#define ASM_OUTPUT_LABEL default_output_label
> >
> >  /* Globalizing directive for a label.  */
> >  #define GLOBAL_ASM_OP "\t.globl "
> > diff --git a/gcc/config/ia64/ia64-protos.h b/gcc/config/ia64/ia64-protos.h
> > index 29fc714..8e540e4 100644
> > --- a/gcc/config/ia64/ia64-protos.h
> > +++ b/gcc/config/ia64/ia64-protos.h
> > @@ -72,6 +72,7 @@ extern rtx ia64_expand_builtin (tree, rtx, rtx, machine_mode, int);
> >  extern rtx ia64_va_arg (tree, tree);
> >  #endif /* RTX_CODE */
> >
> > +extern void ia64_output_label (FILE *f, const char *label);
> >  extern void ia64_asm_output_external (FILE *, tree, const char *);
> >  extern void ia64_vms_output_aligned_decl_common (FILE *, tree, const char *,
> >                                                  unsigned HOST_WIDE_INT,
> > diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
> > index 779fc58..e07ebb5 100644
> > --- a/gcc/config/ia64/ia64.c
> > +++ b/gcc/config/ia64/ia64.c
> > @@ -10522,6 +10522,17 @@ ia64_hpux_function_arg_padding (machine_mode mode, const_tree type)
> >     return DEFAULT_FUNCTION_ARG_PADDING (mode, type);
> >  }
> >
> > +/* Assemble a label.  */
> > +
> > +void
> > +ia64_output_label (FILE *f, const char *label)
> > +{
> > +  ia64_asm_output_label = 1;
> > +  assemble_name (f, label);
> > +  fputs (":\n", f);
> > +  ia64_asm_output_label = 0;
> > +}
> > +
> >  /* Emit text to declare externally defined variables and functions, because
> >     the Intel assembler does not support undefined externals.  */
> >
> > diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h
> > index 4b62423..1afa7b7 100644
> > --- a/gcc/config/ia64/ia64.h
> > +++ b/gcc/config/ia64/ia64.h
> > @@ -1246,13 +1246,7 @@ do {                                                                     \
> >     why ia64_asm_output_label exists.  */
> >
> >  extern int ia64_asm_output_label;
> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)                                 \
> > -do {                                                                   \
> > -  ia64_asm_output_label = 1;                                           \
> > -  assemble_name (STREAM, NAME);                                                \
> > -  fputs (":\n", STREAM);                                               \
> > -  ia64_asm_output_label = 0;                                           \
> > -} while (0)
> > +#define ASM_OUTPUT_LABEL ia64_output_label
> >
> >  /* Globalizing directive for a label.  */
> >  #define GLOBAL_ASM_OP "\t.global "
> > diff --git a/gcc/config/lm32/lm32.h b/gcc/config/lm32/lm32.h
> > index 986383f..9e8c667 100644
> > --- a/gcc/config/lm32/lm32.h
> > +++ b/gcc/config/lm32/lm32.h
> > @@ -443,8 +443,7 @@ do                                                                  \
> >  }                                                                      \
> >  while (0)
> >
> > -#define ASM_OUTPUT_LABEL(FILE, NAME) \
> > -  do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
> > +#define ASM_OUTPUT_LABEL default_output_label
> >
> >  #define ASM_OUTPUT_LABELREF(FILE,NAME) \
> >    do {                                 \
> > diff --git a/gcc/config/mep/mep.h b/gcc/config/mep/mep.h
> > index f7322cb7..8a9d447 100644
> > --- a/gcc/config/mep/mep.h
> > +++ b/gcc/config/mep/mep.h
> > @@ -625,13 +625,7 @@ typedef struct
> >  #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
> >         mep_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 0)
> >
> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)         \
> > -  do                                           \
> > -    {                                          \
> > -      assemble_name (STREAM, NAME);            \
> > -      fputs (":\n", STREAM);                   \
> > -    }                                          \
> > -  while (0)
> > +#define ASM_OUTPUT_LABEL default_output_label
> >
> >  /* Globalizing directive for a label.  */
> >  #define GLOBAL_ASM_OP "\t.globl "
> > diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h
> > index 29d39bc..aac5aa0 100644
> > --- a/gcc/config/mmix/mmix.h
> > +++ b/gcc/config/mmix/mmix.h
> > @@ -647,8 +647,7 @@ typedef struct { int regs; int lib; } CUMULATIVE_ARGS;
> >
> >  /* Node: Label Output */
> >
> > -#define ASM_OUTPUT_LABEL(STREAM, NAME) \
> > - mmix_asm_output_label (STREAM, NAME)
> > +#define ASM_OUTPUT_LABEL mmix_asm_output_label
> >
> >  #define ASM_OUTPUT_INTERNAL_LABEL(STREAM, NAME) \
> >   mmix_asm_output_internal_label (STREAM, NAME)
> > diff --git a/gcc/config/pa/pa-protos.h b/gcc/config/pa/pa-protos.h
> > index 0e13cd5..46a3e3b 100644
> > --- a/gcc/config/pa/pa-protos.h
> > +++ b/gcc/config/pa/pa-protos.h
> > @@ -110,6 +110,7 @@ extern void pa_asm_output_aligned_common (FILE *, const char *,
> >  extern void pa_asm_output_aligned_local (FILE *, const char *,
> >                                          unsigned HOST_WIDE_INT,
> >                                          unsigned int);
> > +extern void pa_output_label (FILE *f, const char *label);
> >  extern void pa_hpux_asm_output_external (FILE *, tree, const char *);
> >  extern bool pa_cannot_change_mode_class (machine_mode, machine_mode,
> >                                          enum reg_class);
> > diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c
> > index b24413a..2bcaa7e 100644
> > --- a/gcc/config/pa/pa.c
> > +++ b/gcc/config/pa/pa.c
> > @@ -9761,6 +9761,18 @@ pa_reloc_rw_mask (void)
> >    return 3;
> >  }
> >
> > +/* Assemble a lable.  */
> > +
> > +void
> > +pa_output_label (FILE *f, const char *label)
> > +{
> > +  assemble_name (f, label);
> > +  if (TARGET_GAS)
> > +    fputs (":\n", f);
> > +  else
> > +    fputc ('\n', (f));
> > +}
> > +
> >  static void
> >  pa_globalize_label (FILE *stream, const char *name)
> >  {
> > diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h
> > index bdfbb16..595a10b 100644
> > --- a/gcc/config/pa/pa.h
> > +++ b/gcc/config/pa/pa.h
> > @@ -1107,14 +1107,7 @@ do {                                                                          \
> >  /* 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.  */
> >
> > -#define ASM_OUTPUT_LABEL(FILE,NAME) \
> > -  do {                                                 \
> > -    assemble_name ((FILE), (NAME));                    \
> > -    if (TARGET_GAS)                                    \
> > -      fputs (":\n", (FILE));                           \
> > -    else                                               \
> > -      fputc ('\n', (FILE));                            \
> > -  } while (0)
> > +#define ASM_OUTPUT_LABEL pa_output_label
> >
> >  /* This is how to output a reference to a user-level label named NAME.
> >     `assemble_name' uses this.  */
> > diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h
> > index 560a825..031614f 100644
> > --- a/gcc/config/rs6000/rs6000-protos.h
> > +++ b/gcc/config/rs6000/rs6000-protos.h
> > @@ -169,6 +169,7 @@ extern int function_ok_for_sibcall (tree);
> >  extern int rs6000_reg_parm_stack_space (tree, bool);
> >  extern void rs6000_xcoff_declare_function_name (FILE *, const char *, tree);
> >  extern void rs6000_xcoff_declare_object_name (FILE *, const char *, tree);
> > +extern void rs6000_xcoff_output_label (FILE *f, const char *label);
> >  extern void rs6000_elf_declare_function_name (FILE *, const char *, tree);
> >  extern bool rs6000_elf_in_small_data_p (const_tree);
> >  #ifdef ARGS_SIZE_RTX
> > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> > index c8794b4..a214010 100644
> > --- a/gcc/config/rs6000/rs6000.c
> > +++ b/gcc/config/rs6000/rs6000.c
> > @@ -30364,6 +30364,14 @@ rs6000_xcoff_asm_output_anchor (rtx symbol)
> >    fprintf (asm_out_file, "\n");
> >  }
> >
> > +/* Assemble the given label.  */
> > +void
> > +rs6000_xcoff_output_label (FILE *f, const char *label)
> > +{
> > +  RS6000_OUTPUT_BASENAME (f, label);
> > +  fputs (":\n", f);
> > +}
> > +
> >  static void
> >  rs6000_xcoff_asm_globalize_label (FILE *stream, const char *name)
> >  {
> > diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h
> > index 8b0cb27..263e239 100644
> > --- a/gcc/config/rs6000/xcoff.h
> > +++ b/gcc/config/rs6000/xcoff.h
> > @@ -119,8 +119,7 @@
> >  /* 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.  */
> >
> > -#define ASM_OUTPUT_LABEL(FILE,NAME)    \
> > -  do { RS6000_OUTPUT_BASENAME (FILE, NAME); fputs (":\n", FILE); } while (0)
> > +#define ASM_OUTPUT_LABEL rs6000_xcoff_output_label
> >
> >  /* This is how to output a command to make the user-level label named NAME
> >     defined for reference from other files.  */
> > diff --git a/gcc/config/spu/spu.h b/gcc/config/spu/spu.h
> > index 25fa435..f35b55e 100644
> > --- a/gcc/config/spu/spu.h
> > +++ b/gcc/config/spu/spu.h
> > @@ -443,8 +443,7 @@ do {                                                                        \
> >
> >
> >  /* Label Output */
> > -#define ASM_OUTPUT_LABEL(FILE,NAME)    \
> > -  do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
> > +#define ASM_OUTPUT_LABEL default_output_label
> >
> >  #define ASM_OUTPUT_LABELREF(FILE, NAME) \
> >    asm_fprintf (FILE, "%U%s", default_strip_name_encoding (NAME))
> > diff --git a/gcc/config/visium/visium.h b/gcc/config/visium/visium.h
> > index a2ab61c..6457c55 100644
> > --- a/gcc/config/visium/visium.h
> > +++ b/gcc/config/visium/visium.h
> > @@ -1440,8 +1440,7 @@ do                                                                        \
> >     `assemble_name (STREAM, NAME)' to output the name itself; before
> >     and after that, output the additional assembler syntax for defining
> >     the name, and a newline. */
> > -#define ASM_OUTPUT_LABEL(STREAM,NAME)     \
> > -  do { assemble_name (STREAM, NAME); fputs (":\n", STREAM); } while (0)
> > +#define ASM_OUTPUT_LABEL default_output_label
> >
> >  /* Globalizing directive for a label */
> >  #define GLOBAL_ASM_OP "\t.global "
> > diff --git a/gcc/defaults.h b/gcc/defaults.h
> > index 3ecf9fd..b1465de 100644
> > --- a/gcc/defaults.h
> > +++ b/gcc/defaults.h
> > @@ -89,11 +89,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> >     NAME, such as the label on variable NAME.  */
> >
> >  #ifndef ASM_OUTPUT_LABEL
> > -#define ASM_OUTPUT_LABEL(FILE,NAME) \
> > -  do {                                         \
> > -    assemble_name ((FILE), (NAME));            \
> > -    fputs (":\n", (FILE));                     \
> > -  } while (0)
> > +#define ASM_OUTPUT_LABEL default_output_label
> >  #endif
> >
> >  /* This is how to output the definition of a user-level label named
> > diff --git a/gcc/output.h b/gcc/output.h
> > index 8aa648a..07172d5 100644
> > --- a/gcc/output.h
> > +++ b/gcc/output.h
> > @@ -246,6 +246,9 @@ extern void assemble_name_raw (FILE *, const char *);
> >     be marked as referenced.  */
> >  extern void assemble_name (FILE *, const char *);
> >
> > +/* Assemble a label.  */
> > +extern void default_output_label (FILE *f, const char *label);
> > +
> >  /* Return the assembler directive for creating a given kind of integer
> >     object.  SIZE is the number of bytes in the object and ALIGNED_P
> >     indicates whether it is known to be aligned.  Return NULL if the
> > diff --git a/gcc/varasm.c b/gcc/varasm.c
> > index c2bfbf0..9c5f12d 100644
> > --- a/gcc/varasm.c
> > +++ b/gcc/varasm.c
> > @@ -2580,6 +2580,15 @@ assemble_name (FILE *file, const char *name)
> >    assemble_name_raw (file, name);
> >  }
> >
> > +/* Assemble a label.  */
> > +
> > +void
> > +default_output_label (FILE *f, const char *label)
> > +{
> > +  assemble_name (f, label);
> > +  fputs (":\n", f);
> > +}
> > +
> >  /* Allocate SIZE bytes writable static space with a gensym name
> >     and return an RTX to refer to its address.  */
> >
> > diff --git a/gcc/vmsdbgout.c b/gcc/vmsdbgout.c
> > index 0204740..d04b8fb 100644
> > --- a/gcc/vmsdbgout.c
> > +++ b/gcc/vmsdbgout.c
> > @@ -37,6 +37,7 @@ along with GCC; see the file COPYING3.  If not see
> >  #include "langhooks.h"
> >  #include "function.h"
> >  #include "target.h"
> > +#include "tm_p.h"
> >
> >  /* Difference in seconds between the VMS Epoch and the Unix Epoch */
> >  static const long long vms_epoch_offset = 3506716800ll;
> > diff --git a/gcc/xcoffout.c b/gcc/xcoffout.c
> > index 0f11115..83959c8 100644
> > --- a/gcc/xcoffout.c
> > +++ b/gcc/xcoffout.c
> > @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3.  If not see
> >  #include "output.h"
> >  #include "target.h"
> >  #include "debug.h"
> > +#include "tm_p.h"
> >
> >  #ifdef XCOFF_DEBUGGING_INFO
> >
> > --
> > 2.4.0
> >

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-07-28  6:45     ` Trevor Saunders
@ 2015-07-29 23:05       ` Jeff Law
  0 siblings, 0 replies; 31+ messages in thread
From: Jeff Law @ 2015-07-29 23:05 UTC (permalink / raw)
  To: Trevor Saunders, Richard Biener; +Cc: tbsaunde+gcc, GCC Patches

On 07/27/2015 09:47 PM, Trevor Saunders wrote:
> On Mon, Jul 27, 2015 at 11:06:58AM +0200, Richard Biener wrote:
>> On Sat, Jul 25, 2015 at 4:37 AM,  <tbsaunde+gcc@tbsaunde.org> wrote:
>>> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>>>
>>>          * config/arc/arc.h, config/bfin/bfin.h, config/frv/frv.h,
>>>          config/ia64/ia64-protos.h, config/ia64/ia64.c, config/ia64/ia64.h,
>>>          config/lm32/lm32.h, config/mep/mep.h, config/mmix/mmix.h,
>>>          config/rs6000/rs6000.c, config/rs6000/xcoff.h, config/spu/spu.h,
>>>          config/visium/visium.h, defaults.h: Define ASM_OUTPUT_LABEL to
>>> the name of a function.
>>>          * output.h (default_output_label): New prototype.
>>>          * varasm.c (default_output_label): New function.
>>>          * vmsdbgout.c: Include tm_p.h.
>>>          * xcoffout.c: Likewise.
>>
>> Just a general remark - the GCC output machinery is known to be slow,
>> adding indirect calls might be not the very best idea without refactoring
>> some of it.
>
> ah, I wasn't aware of that.  On the other hand some of these hooks seem
> to generally be big so the call over head might not matter that much.  I
> suppose if this is something we really care about we might want to
> consider pushing the libgas project farther so we can avoid all this
> text formatting all together.
They're definitely slow, but I've always considered that overhead as in 
the noise relative to what it takes to run through the optimizer passes.

I'm tentatively supported of libgas, but I have concerns as well.  I've 
been burned by (for example) vendor assemblers which didn't have a means 
(assembler directives) to correctly handle certain programs.  The 
vendor's compiler didn't have the problem because it just blasted .o 
files and didn't pass them through the assembler.  I'd hate to see us 
repeating those mistakes.

Jeff

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 3/4] remove unused TARGET_DEFERRED_OUTPUT_DEFS
  2015-07-25  2:37 ` [PATCH 3/4] remove unused TARGET_DEFERRED_OUTPUT_DEFS tbsaunde+gcc
@ 2015-07-31  0:55   ` Joseph Myers
  0 siblings, 0 replies; 31+ messages in thread
From: Joseph Myers @ 2015-07-31  0:55 UTC (permalink / raw)
  To: tbsaunde+gcc; +Cc: gcc-patches

On Fri, 24 Jul 2015, tbsaunde+gcc@tbsaunde.org wrote:

> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
> 
> gcc/ChangeLog:
> 
> 2015-07-24  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
> 
> 	* config/rs6000/aix43.h (TARGET_DEFERRED_OUTPUT_DEFS): Remove.
> 	* defaults.h (TARGET_DEFERRED_OUTPUT_DEFS): Likewise.
> 	* doc/tm.texi: Regenerate.
> 	* doc/tm.texi.in (TARGET_DEFERRED_OUTPUT_DEFS): Remove
> 	documentation of TARGET_DEFERRED_OUTPUT_DEFS;

Whether just removed or converted to a hook, any removed target macro 
should be poisoned in system.h to avoid new targets being added that 
accidentally define the macro without it being effective.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-07-27  9:17   ` Richard Biener
  2015-07-28  6:45     ` Trevor Saunders
@ 2015-08-05 10:58     ` Trevor Saunders
  2015-08-05 11:47       ` Richard Biener
  1 sibling, 1 reply; 31+ messages in thread
From: Trevor Saunders @ 2015-08-05 10:58 UTC (permalink / raw)
  To: Richard Biener; +Cc: tbsaunde+gcc, GCC Patches

On Mon, Jul 27, 2015 at 11:06:58AM +0200, Richard Biener wrote:
> On Sat, Jul 25, 2015 at 4:37 AM,  <tbsaunde+gcc@tbsaunde.org> wrote:
> > From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
> >
> >         * config/arc/arc.h, config/bfin/bfin.h, config/frv/frv.h,
> >         config/ia64/ia64-protos.h, config/ia64/ia64.c, config/ia64/ia64.h,
> >         config/lm32/lm32.h, config/mep/mep.h, config/mmix/mmix.h,
> >         config/rs6000/rs6000.c, config/rs6000/xcoff.h, config/spu/spu.h,
> >         config/visium/visium.h, defaults.h: Define ASM_OUTPUT_LABEL to
> > the name of a function.
> >         * output.h (default_output_label): New prototype.
> >         * varasm.c (default_output_label): New function.
> >         * vmsdbgout.c: Include tm_p.h.
> >         * xcoffout.c: Likewise.
> 
> Just a general remark - the GCC output machinery is known to be slow,
> adding indirect calls might be not the very best idea without refactoring
> some of it.
> 
> Did you do any performance measurements for artificial testcases
> exercising the specific bits you change?

sorry about the delay, but I finally got a chance to do some perf tests
of the first patch.  I took three test cases fold-const.ii, insn-emit.ii
and a random .i from firefox and did 3 trials of the length of 100
compilations.  The only non default flag was -std=gnu++11.

results before patch hookizing output_ascii

fold-const.ii
real    3m18.051s
user    2m41.340s
sys     0m36.544s
real    3m18.141s
user    2m42.236s
sys     0m35.740s
real    3m18.297s
user    2m42.316s
sys     0m35.804s

insn-emit.ii
real    9m58.229s
user    8m26.960s
sys     1m31.224s
real    9m57.857s
user    8m24.616s
sys     1m33.072s
real    9m57.922s
user    8m25.232s
sys     1m32.512s

mozilla.ii
real    8m5.732s
user    6m44.888s
sys     1m20.764s
real    8m5.404s
user    6m44.468s
sys     1m20.856s
real    7m59.197s
user    6m39.632s
sys     1m19.472s

after patch

fold-const.ii
real    3m18.488s
user    2m41.972s
sys     0m36.388s
real    3m18.215s
user    2m41.640s
sys     0m36.432s
real    3m18.368s
user    2m42.492s
sys     0m35.720s

insn-emit.ii
real    10m4.700s
user    8m32.536s
sys     1m32.120s
real    10m4.241s
user    8m31.456s
sys     1m32.728s
real    10m4.515s
user    8m32.056s
sys     1m32.396s

mozilla.ii
real    7m58.018s
user    6m38.008s
sys     1m19.924s
real    7m59.269s
user    6m37.736s
sys     1m21.448s
real    7m58.254s
user    6m37.828s
sys     1m20.324s

So, roughly that looks to me like a range from improving by .5% to
regressing by 1%.  I'm not sure what could cause an improvement, so I
kind of wonder how valid these results are.

Another question is how one can refactor the output machinary to be
faster.  My first  thought is to buffer text internally before calling
stdio functions, but that seems like a giant job.

thanks!

Trev

far outside of noise,
> 
> Richard.
> 
> > ---
> >  gcc/config/arc/arc.h              |  3 +--
> >  gcc/config/bfin/bfin.h            |  5 +----
> >  gcc/config/frv/frv.h              |  6 +-----
> >  gcc/config/ia64/ia64-protos.h     |  1 +
> >  gcc/config/ia64/ia64.c            | 11 +++++++++++
> >  gcc/config/ia64/ia64.h            |  8 +-------
> >  gcc/config/lm32/lm32.h            |  3 +--
> >  gcc/config/mep/mep.h              |  8 +-------
> >  gcc/config/mmix/mmix.h            |  3 +--
> >  gcc/config/pa/pa-protos.h         |  1 +
> >  gcc/config/pa/pa.c                | 12 ++++++++++++
> >  gcc/config/pa/pa.h                |  9 +--------
> >  gcc/config/rs6000/rs6000-protos.h |  1 +
> >  gcc/config/rs6000/rs6000.c        |  8 ++++++++
> >  gcc/config/rs6000/xcoff.h         |  3 +--
> >  gcc/config/spu/spu.h              |  3 +--
> >  gcc/config/visium/visium.h        |  3 +--
> >  gcc/defaults.h                    |  6 +-----
> >  gcc/output.h                      |  3 +++
> >  gcc/varasm.c                      |  9 +++++++++
> >  gcc/vmsdbgout.c                   |  1 +
> >  gcc/xcoffout.c                    |  1 +
> >  22 files changed, 60 insertions(+), 48 deletions(-)
> >
> > diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h
> > index d98cce1..d3747b9 100644
> > --- a/gcc/config/arc/arc.h
> > +++ b/gcc/config/arc/arc.h
> > @@ -1245,8 +1245,7 @@ do {                                                                      \
> >
> >  /* 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.  */
> > -#define ASM_OUTPUT_LABEL(FILE, NAME) \
> > -do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
> > +#define ASM_OUTPUT_LABEL default_output_label
> >
> >  #define ASM_NAME_P(NAME) ( NAME[0]=='*')
> >
> > diff --git a/gcc/config/bfin/bfin.h b/gcc/config/bfin/bfin.h
> > index 26ba7c2..08906aa 100644
> > --- a/gcc/config/bfin/bfin.h
> > +++ b/gcc/config/bfin/bfin.h
> > @@ -1044,10 +1044,7 @@ typedef enum directives {
> >      ASM_OUTPUT_LABEL(FILE, NAME);      \
> >    } while (0)
> >
> > -#define ASM_OUTPUT_LABEL(FILE, NAME)    \
> > -  do {  assemble_name (FILE, NAME);            \
> > -        fputs (":\n",FILE);                    \
> > -      } while (0)
> > +#define ASM_OUTPUT_LABEL default_output_label
> >
> >  #define ASM_OUTPUT_LABELREF(FILE,NAME)         \
> >      do {  fprintf (FILE, "_%s", NAME); \
> > diff --git a/gcc/config/frv/frv.h b/gcc/config/frv/frv.h
> > index b0d66fd..1d25974 100644
> > --- a/gcc/config/frv/frv.h
> > +++ b/gcc/config/frv/frv.h
> > @@ -1668,11 +1668,7 @@ do {                                                                     \
> >     `assemble_name (STREAM, NAME)' to output the name itself; before and after
> >     that, output the additional assembler syntax for defining the name, and a
> >     newline.  */
> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)                                 \
> > -do {                                                                   \
> > -  assemble_name (STREAM, NAME);                                                \
> > -  fputs (":\n", STREAM);                                               \
> > -} while (0)
> > +#define ASM_OUTPUT_LABEL default_output_label
> >
> >  /* Globalizing directive for a label.  */
> >  #define GLOBAL_ASM_OP "\t.globl "
> > diff --git a/gcc/config/ia64/ia64-protos.h b/gcc/config/ia64/ia64-protos.h
> > index 29fc714..8e540e4 100644
> > --- a/gcc/config/ia64/ia64-protos.h
> > +++ b/gcc/config/ia64/ia64-protos.h
> > @@ -72,6 +72,7 @@ extern rtx ia64_expand_builtin (tree, rtx, rtx, machine_mode, int);
> >  extern rtx ia64_va_arg (tree, tree);
> >  #endif /* RTX_CODE */
> >
> > +extern void ia64_output_label (FILE *f, const char *label);
> >  extern void ia64_asm_output_external (FILE *, tree, const char *);
> >  extern void ia64_vms_output_aligned_decl_common (FILE *, tree, const char *,
> >                                                  unsigned HOST_WIDE_INT,
> > diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
> > index 779fc58..e07ebb5 100644
> > --- a/gcc/config/ia64/ia64.c
> > +++ b/gcc/config/ia64/ia64.c
> > @@ -10522,6 +10522,17 @@ ia64_hpux_function_arg_padding (machine_mode mode, const_tree type)
> >     return DEFAULT_FUNCTION_ARG_PADDING (mode, type);
> >  }
> >
> > +/* Assemble a label.  */
> > +
> > +void
> > +ia64_output_label (FILE *f, const char *label)
> > +{
> > +  ia64_asm_output_label = 1;
> > +  assemble_name (f, label);
> > +  fputs (":\n", f);
> > +  ia64_asm_output_label = 0;
> > +}
> > +
> >  /* Emit text to declare externally defined variables and functions, because
> >     the Intel assembler does not support undefined externals.  */
> >
> > diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h
> > index 4b62423..1afa7b7 100644
> > --- a/gcc/config/ia64/ia64.h
> > +++ b/gcc/config/ia64/ia64.h
> > @@ -1246,13 +1246,7 @@ do {                                                                     \
> >     why ia64_asm_output_label exists.  */
> >
> >  extern int ia64_asm_output_label;
> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)                                 \
> > -do {                                                                   \
> > -  ia64_asm_output_label = 1;                                           \
> > -  assemble_name (STREAM, NAME);                                                \
> > -  fputs (":\n", STREAM);                                               \
> > -  ia64_asm_output_label = 0;                                           \
> > -} while (0)
> > +#define ASM_OUTPUT_LABEL ia64_output_label
> >
> >  /* Globalizing directive for a label.  */
> >  #define GLOBAL_ASM_OP "\t.global "
> > diff --git a/gcc/config/lm32/lm32.h b/gcc/config/lm32/lm32.h
> > index 986383f..9e8c667 100644
> > --- a/gcc/config/lm32/lm32.h
> > +++ b/gcc/config/lm32/lm32.h
> > @@ -443,8 +443,7 @@ do                                                                  \
> >  }                                                                      \
> >  while (0)
> >
> > -#define ASM_OUTPUT_LABEL(FILE, NAME) \
> > -  do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
> > +#define ASM_OUTPUT_LABEL default_output_label
> >
> >  #define ASM_OUTPUT_LABELREF(FILE,NAME) \
> >    do {                                 \
> > diff --git a/gcc/config/mep/mep.h b/gcc/config/mep/mep.h
> > index f7322cb7..8a9d447 100644
> > --- a/gcc/config/mep/mep.h
> > +++ b/gcc/config/mep/mep.h
> > @@ -625,13 +625,7 @@ typedef struct
> >  #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
> >         mep_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 0)
> >
> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)         \
> > -  do                                           \
> > -    {                                          \
> > -      assemble_name (STREAM, NAME);            \
> > -      fputs (":\n", STREAM);                   \
> > -    }                                          \
> > -  while (0)
> > +#define ASM_OUTPUT_LABEL default_output_label
> >
> >  /* Globalizing directive for a label.  */
> >  #define GLOBAL_ASM_OP "\t.globl "
> > diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h
> > index 29d39bc..aac5aa0 100644
> > --- a/gcc/config/mmix/mmix.h
> > +++ b/gcc/config/mmix/mmix.h
> > @@ -647,8 +647,7 @@ typedef struct { int regs; int lib; } CUMULATIVE_ARGS;
> >
> >  /* Node: Label Output */
> >
> > -#define ASM_OUTPUT_LABEL(STREAM, NAME) \
> > - mmix_asm_output_label (STREAM, NAME)
> > +#define ASM_OUTPUT_LABEL mmix_asm_output_label
> >
> >  #define ASM_OUTPUT_INTERNAL_LABEL(STREAM, NAME) \
> >   mmix_asm_output_internal_label (STREAM, NAME)
> > diff --git a/gcc/config/pa/pa-protos.h b/gcc/config/pa/pa-protos.h
> > index 0e13cd5..46a3e3b 100644
> > --- a/gcc/config/pa/pa-protos.h
> > +++ b/gcc/config/pa/pa-protos.h
> > @@ -110,6 +110,7 @@ extern void pa_asm_output_aligned_common (FILE *, const char *,
> >  extern void pa_asm_output_aligned_local (FILE *, const char *,
> >                                          unsigned HOST_WIDE_INT,
> >                                          unsigned int);
> > +extern void pa_output_label (FILE *f, const char *label);
> >  extern void pa_hpux_asm_output_external (FILE *, tree, const char *);
> >  extern bool pa_cannot_change_mode_class (machine_mode, machine_mode,
> >                                          enum reg_class);
> > diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c
> > index b24413a..2bcaa7e 100644
> > --- a/gcc/config/pa/pa.c
> > +++ b/gcc/config/pa/pa.c
> > @@ -9761,6 +9761,18 @@ pa_reloc_rw_mask (void)
> >    return 3;
> >  }
> >
> > +/* Assemble a lable.  */
> > +
> > +void
> > +pa_output_label (FILE *f, const char *label)
> > +{
> > +  assemble_name (f, label);
> > +  if (TARGET_GAS)
> > +    fputs (":\n", f);
> > +  else
> > +    fputc ('\n', (f));
> > +}
> > +
> >  static void
> >  pa_globalize_label (FILE *stream, const char *name)
> >  {
> > diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h
> > index bdfbb16..595a10b 100644
> > --- a/gcc/config/pa/pa.h
> > +++ b/gcc/config/pa/pa.h
> > @@ -1107,14 +1107,7 @@ do {                                                                          \
> >  /* 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.  */
> >
> > -#define ASM_OUTPUT_LABEL(FILE,NAME) \
> > -  do {                                                 \
> > -    assemble_name ((FILE), (NAME));                    \
> > -    if (TARGET_GAS)                                    \
> > -      fputs (":\n", (FILE));                           \
> > -    else                                               \
> > -      fputc ('\n', (FILE));                            \
> > -  } while (0)
> > +#define ASM_OUTPUT_LABEL pa_output_label
> >
> >  /* This is how to output a reference to a user-level label named NAME.
> >     `assemble_name' uses this.  */
> > diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h
> > index 560a825..031614f 100644
> > --- a/gcc/config/rs6000/rs6000-protos.h
> > +++ b/gcc/config/rs6000/rs6000-protos.h
> > @@ -169,6 +169,7 @@ extern int function_ok_for_sibcall (tree);
> >  extern int rs6000_reg_parm_stack_space (tree, bool);
> >  extern void rs6000_xcoff_declare_function_name (FILE *, const char *, tree);
> >  extern void rs6000_xcoff_declare_object_name (FILE *, const char *, tree);
> > +extern void rs6000_xcoff_output_label (FILE *f, const char *label);
> >  extern void rs6000_elf_declare_function_name (FILE *, const char *, tree);
> >  extern bool rs6000_elf_in_small_data_p (const_tree);
> >  #ifdef ARGS_SIZE_RTX
> > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> > index c8794b4..a214010 100644
> > --- a/gcc/config/rs6000/rs6000.c
> > +++ b/gcc/config/rs6000/rs6000.c
> > @@ -30364,6 +30364,14 @@ rs6000_xcoff_asm_output_anchor (rtx symbol)
> >    fprintf (asm_out_file, "\n");
> >  }
> >
> > +/* Assemble the given label.  */
> > +void
> > +rs6000_xcoff_output_label (FILE *f, const char *label)
> > +{
> > +  RS6000_OUTPUT_BASENAME (f, label);
> > +  fputs (":\n", f);
> > +}
> > +
> >  static void
> >  rs6000_xcoff_asm_globalize_label (FILE *stream, const char *name)
> >  {
> > diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h
> > index 8b0cb27..263e239 100644
> > --- a/gcc/config/rs6000/xcoff.h
> > +++ b/gcc/config/rs6000/xcoff.h
> > @@ -119,8 +119,7 @@
> >  /* 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.  */
> >
> > -#define ASM_OUTPUT_LABEL(FILE,NAME)    \
> > -  do { RS6000_OUTPUT_BASENAME (FILE, NAME); fputs (":\n", FILE); } while (0)
> > +#define ASM_OUTPUT_LABEL rs6000_xcoff_output_label
> >
> >  /* This is how to output a command to make the user-level label named NAME
> >     defined for reference from other files.  */
> > diff --git a/gcc/config/spu/spu.h b/gcc/config/spu/spu.h
> > index 25fa435..f35b55e 100644
> > --- a/gcc/config/spu/spu.h
> > +++ b/gcc/config/spu/spu.h
> > @@ -443,8 +443,7 @@ do {                                                                        \
> >
> >
> >  /* Label Output */
> > -#define ASM_OUTPUT_LABEL(FILE,NAME)    \
> > -  do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
> > +#define ASM_OUTPUT_LABEL default_output_label
> >
> >  #define ASM_OUTPUT_LABELREF(FILE, NAME) \
> >    asm_fprintf (FILE, "%U%s", default_strip_name_encoding (NAME))
> > diff --git a/gcc/config/visium/visium.h b/gcc/config/visium/visium.h
> > index a2ab61c..6457c55 100644
> > --- a/gcc/config/visium/visium.h
> > +++ b/gcc/config/visium/visium.h
> > @@ -1440,8 +1440,7 @@ do                                                                        \
> >     `assemble_name (STREAM, NAME)' to output the name itself; before
> >     and after that, output the additional assembler syntax for defining
> >     the name, and a newline. */
> > -#define ASM_OUTPUT_LABEL(STREAM,NAME)     \
> > -  do { assemble_name (STREAM, NAME); fputs (":\n", STREAM); } while (0)
> > +#define ASM_OUTPUT_LABEL default_output_label
> >
> >  /* Globalizing directive for a label */
> >  #define GLOBAL_ASM_OP "\t.global "
> > diff --git a/gcc/defaults.h b/gcc/defaults.h
> > index 3ecf9fd..b1465de 100644
> > --- a/gcc/defaults.h
> > +++ b/gcc/defaults.h
> > @@ -89,11 +89,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> >     NAME, such as the label on variable NAME.  */
> >
> >  #ifndef ASM_OUTPUT_LABEL
> > -#define ASM_OUTPUT_LABEL(FILE,NAME) \
> > -  do {                                         \
> > -    assemble_name ((FILE), (NAME));            \
> > -    fputs (":\n", (FILE));                     \
> > -  } while (0)
> > +#define ASM_OUTPUT_LABEL default_output_label
> >  #endif
> >
> >  /* This is how to output the definition of a user-level label named
> > diff --git a/gcc/output.h b/gcc/output.h
> > index 8aa648a..07172d5 100644
> > --- a/gcc/output.h
> > +++ b/gcc/output.h
> > @@ -246,6 +246,9 @@ extern void assemble_name_raw (FILE *, const char *);
> >     be marked as referenced.  */
> >  extern void assemble_name (FILE *, const char *);
> >
> > +/* Assemble a label.  */
> > +extern void default_output_label (FILE *f, const char *label);
> > +
> >  /* Return the assembler directive for creating a given kind of integer
> >     object.  SIZE is the number of bytes in the object and ALIGNED_P
> >     indicates whether it is known to be aligned.  Return NULL if the
> > diff --git a/gcc/varasm.c b/gcc/varasm.c
> > index c2bfbf0..9c5f12d 100644
> > --- a/gcc/varasm.c
> > +++ b/gcc/varasm.c
> > @@ -2580,6 +2580,15 @@ assemble_name (FILE *file, const char *name)
> >    assemble_name_raw (file, name);
> >  }
> >
> > +/* Assemble a label.  */
> > +
> > +void
> > +default_output_label (FILE *f, const char *label)
> > +{
> > +  assemble_name (f, label);
> > +  fputs (":\n", f);
> > +}
> > +
> >  /* Allocate SIZE bytes writable static space with a gensym name
> >     and return an RTX to refer to its address.  */
> >
> > diff --git a/gcc/vmsdbgout.c b/gcc/vmsdbgout.c
> > index 0204740..d04b8fb 100644
> > --- a/gcc/vmsdbgout.c
> > +++ b/gcc/vmsdbgout.c
> > @@ -37,6 +37,7 @@ along with GCC; see the file COPYING3.  If not see
> >  #include "langhooks.h"
> >  #include "function.h"
> >  #include "target.h"
> > +#include "tm_p.h"
> >
> >  /* Difference in seconds between the VMS Epoch and the Unix Epoch */
> >  static const long long vms_epoch_offset = 3506716800ll;
> > diff --git a/gcc/xcoffout.c b/gcc/xcoffout.c
> > index 0f11115..83959c8 100644
> > --- a/gcc/xcoffout.c
> > +++ b/gcc/xcoffout.c
> > @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3.  If not see
> >  #include "output.h"
> >  #include "target.h"
> >  #include "debug.h"
> > +#include "tm_p.h"
> >
> >  #ifdef XCOFF_DEBUGGING_INFO
> >
> > --
> > 2.4.0
> >

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-08-05 10:58     ` Trevor Saunders
@ 2015-08-05 11:47       ` Richard Biener
  2015-08-05 13:38         ` Trevor Saunders
  2015-08-05 15:28         ` David Malcolm
  0 siblings, 2 replies; 31+ messages in thread
From: Richard Biener @ 2015-08-05 11:47 UTC (permalink / raw)
  To: Trevor Saunders; +Cc: tbsaunde+gcc, GCC Patches

On Wed, Aug 5, 2015 at 12:57 PM, Trevor Saunders <tbsaunde@tbsaunde.org> wrote:
> On Mon, Jul 27, 2015 at 11:06:58AM +0200, Richard Biener wrote:
>> On Sat, Jul 25, 2015 at 4:37 AM,  <tbsaunde+gcc@tbsaunde.org> wrote:
>> > From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>> >
>> >         * config/arc/arc.h, config/bfin/bfin.h, config/frv/frv.h,
>> >         config/ia64/ia64-protos.h, config/ia64/ia64.c, config/ia64/ia64.h,
>> >         config/lm32/lm32.h, config/mep/mep.h, config/mmix/mmix.h,
>> >         config/rs6000/rs6000.c, config/rs6000/xcoff.h, config/spu/spu.h,
>> >         config/visium/visium.h, defaults.h: Define ASM_OUTPUT_LABEL to
>> > the name of a function.
>> >         * output.h (default_output_label): New prototype.
>> >         * varasm.c (default_output_label): New function.
>> >         * vmsdbgout.c: Include tm_p.h.
>> >         * xcoffout.c: Likewise.
>>
>> Just a general remark - the GCC output machinery is known to be slow,
>> adding indirect calls might be not the very best idea without refactoring
>> some of it.
>>
>> Did you do any performance measurements for artificial testcases
>> exercising the specific bits you change?
>
> sorry about the delay, but I finally got a chance to do some perf tests
> of the first patch.  I took three test cases fold-const.ii, insn-emit.ii
> and a random .i from firefox and did 3 trials of the length of 100
> compilations.  The only non default flag was -std=gnu++11.
>
> results before patch hookizing output_ascii
>
> fold-const.ii
> real    3m18.051s
> user    2m41.340s
> sys     0m36.544s
> real    3m18.141s
> user    2m42.236s
> sys     0m35.740s
> real    3m18.297s
> user    2m42.316s
> sys     0m35.804s
>
> insn-emit.ii
> real    9m58.229s
> user    8m26.960s
> sys     1m31.224s
> real    9m57.857s
> user    8m24.616s
> sys     1m33.072s
> real    9m57.922s
> user    8m25.232s
> sys     1m32.512s
>
> mozilla.ii
> real    8m5.732s
> user    6m44.888s
> sys     1m20.764s
> real    8m5.404s
> user    6m44.468s
> sys     1m20.856s
> real    7m59.197s
> user    6m39.632s
> sys     1m19.472s
>
> after patch
>
> fold-const.ii
> real    3m18.488s
> user    2m41.972s
> sys     0m36.388s
> real    3m18.215s
> user    2m41.640s
> sys     0m36.432s
> real    3m18.368s
> user    2m42.492s
> sys     0m35.720s
>
> insn-emit.ii
> real    10m4.700s
> user    8m32.536s
> sys     1m32.120s
> real    10m4.241s
> user    8m31.456s
> sys     1m32.728s
> real    10m4.515s
> user    8m32.056s
> sys     1m32.396s
>
> mozilla.ii
> real    7m58.018s
> user    6m38.008s
> sys     1m19.924s
> real    7m59.269s
> user    6m37.736s
> sys     1m21.448s
> real    7m58.254s
> user    6m37.828s
> sys     1m20.324s
>
> So, roughly that looks to me like a range from improving by .5% to
> regressing by 1%.  I'm not sure what could cause an improvement, so I
> kind of wonder how valid these results are.

Hmm, indeed.  The speedup looks suspicious.

> Another question is how one can refactor the output machinary to be
> faster.  My first  thought is to buffer text internally before calling
> stdio functions, but that seems like a giant job.

stdio functions are already buffering, so I don't know either.

But yes, going the libas route would improve things here, or for
example enhancing gas to be able to eat target binary data
without the need to encode it in printable characters...

.raw_data number-of-bytes
<raw data>

Makes it quite unparsable to editors of course ...

Richard.

> thanks!
>
> Trev
>
> far outside of noise,
>>
>> Richard.
>>
>> > ---
>> >  gcc/config/arc/arc.h              |  3 +--
>> >  gcc/config/bfin/bfin.h            |  5 +----
>> >  gcc/config/frv/frv.h              |  6 +-----
>> >  gcc/config/ia64/ia64-protos.h     |  1 +
>> >  gcc/config/ia64/ia64.c            | 11 +++++++++++
>> >  gcc/config/ia64/ia64.h            |  8 +-------
>> >  gcc/config/lm32/lm32.h            |  3 +--
>> >  gcc/config/mep/mep.h              |  8 +-------
>> >  gcc/config/mmix/mmix.h            |  3 +--
>> >  gcc/config/pa/pa-protos.h         |  1 +
>> >  gcc/config/pa/pa.c                | 12 ++++++++++++
>> >  gcc/config/pa/pa.h                |  9 +--------
>> >  gcc/config/rs6000/rs6000-protos.h |  1 +
>> >  gcc/config/rs6000/rs6000.c        |  8 ++++++++
>> >  gcc/config/rs6000/xcoff.h         |  3 +--
>> >  gcc/config/spu/spu.h              |  3 +--
>> >  gcc/config/visium/visium.h        |  3 +--
>> >  gcc/defaults.h                    |  6 +-----
>> >  gcc/output.h                      |  3 +++
>> >  gcc/varasm.c                      |  9 +++++++++
>> >  gcc/vmsdbgout.c                   |  1 +
>> >  gcc/xcoffout.c                    |  1 +
>> >  22 files changed, 60 insertions(+), 48 deletions(-)
>> >
>> > diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h
>> > index d98cce1..d3747b9 100644
>> > --- a/gcc/config/arc/arc.h
>> > +++ b/gcc/config/arc/arc.h
>> > @@ -1245,8 +1245,7 @@ do {                                                                      \
>> >
>> >  /* 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.  */
>> > -#define ASM_OUTPUT_LABEL(FILE, NAME) \
>> > -do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
>> > +#define ASM_OUTPUT_LABEL default_output_label
>> >
>> >  #define ASM_NAME_P(NAME) ( NAME[0]=='*')
>> >
>> > diff --git a/gcc/config/bfin/bfin.h b/gcc/config/bfin/bfin.h
>> > index 26ba7c2..08906aa 100644
>> > --- a/gcc/config/bfin/bfin.h
>> > +++ b/gcc/config/bfin/bfin.h
>> > @@ -1044,10 +1044,7 @@ typedef enum directives {
>> >      ASM_OUTPUT_LABEL(FILE, NAME);      \
>> >    } while (0)
>> >
>> > -#define ASM_OUTPUT_LABEL(FILE, NAME)    \
>> > -  do {  assemble_name (FILE, NAME);            \
>> > -        fputs (":\n",FILE);                    \
>> > -      } while (0)
>> > +#define ASM_OUTPUT_LABEL default_output_label
>> >
>> >  #define ASM_OUTPUT_LABELREF(FILE,NAME)         \
>> >      do {  fprintf (FILE, "_%s", NAME); \
>> > diff --git a/gcc/config/frv/frv.h b/gcc/config/frv/frv.h
>> > index b0d66fd..1d25974 100644
>> > --- a/gcc/config/frv/frv.h
>> > +++ b/gcc/config/frv/frv.h
>> > @@ -1668,11 +1668,7 @@ do {                                                                     \
>> >     `assemble_name (STREAM, NAME)' to output the name itself; before and after
>> >     that, output the additional assembler syntax for defining the name, and a
>> >     newline.  */
>> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)                                 \
>> > -do {                                                                   \
>> > -  assemble_name (STREAM, NAME);                                                \
>> > -  fputs (":\n", STREAM);                                               \
>> > -} while (0)
>> > +#define ASM_OUTPUT_LABEL default_output_label
>> >
>> >  /* Globalizing directive for a label.  */
>> >  #define GLOBAL_ASM_OP "\t.globl "
>> > diff --git a/gcc/config/ia64/ia64-protos.h b/gcc/config/ia64/ia64-protos.h
>> > index 29fc714..8e540e4 100644
>> > --- a/gcc/config/ia64/ia64-protos.h
>> > +++ b/gcc/config/ia64/ia64-protos.h
>> > @@ -72,6 +72,7 @@ extern rtx ia64_expand_builtin (tree, rtx, rtx, machine_mode, int);
>> >  extern rtx ia64_va_arg (tree, tree);
>> >  #endif /* RTX_CODE */
>> >
>> > +extern void ia64_output_label (FILE *f, const char *label);
>> >  extern void ia64_asm_output_external (FILE *, tree, const char *);
>> >  extern void ia64_vms_output_aligned_decl_common (FILE *, tree, const char *,
>> >                                                  unsigned HOST_WIDE_INT,
>> > diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
>> > index 779fc58..e07ebb5 100644
>> > --- a/gcc/config/ia64/ia64.c
>> > +++ b/gcc/config/ia64/ia64.c
>> > @@ -10522,6 +10522,17 @@ ia64_hpux_function_arg_padding (machine_mode mode, const_tree type)
>> >     return DEFAULT_FUNCTION_ARG_PADDING (mode, type);
>> >  }
>> >
>> > +/* Assemble a label.  */
>> > +
>> > +void
>> > +ia64_output_label (FILE *f, const char *label)
>> > +{
>> > +  ia64_asm_output_label = 1;
>> > +  assemble_name (f, label);
>> > +  fputs (":\n", f);
>> > +  ia64_asm_output_label = 0;
>> > +}
>> > +
>> >  /* Emit text to declare externally defined variables and functions, because
>> >     the Intel assembler does not support undefined externals.  */
>> >
>> > diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h
>> > index 4b62423..1afa7b7 100644
>> > --- a/gcc/config/ia64/ia64.h
>> > +++ b/gcc/config/ia64/ia64.h
>> > @@ -1246,13 +1246,7 @@ do {                                                                     \
>> >     why ia64_asm_output_label exists.  */
>> >
>> >  extern int ia64_asm_output_label;
>> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)                                 \
>> > -do {                                                                   \
>> > -  ia64_asm_output_label = 1;                                           \
>> > -  assemble_name (STREAM, NAME);                                                \
>> > -  fputs (":\n", STREAM);                                               \
>> > -  ia64_asm_output_label = 0;                                           \
>> > -} while (0)
>> > +#define ASM_OUTPUT_LABEL ia64_output_label
>> >
>> >  /* Globalizing directive for a label.  */
>> >  #define GLOBAL_ASM_OP "\t.global "
>> > diff --git a/gcc/config/lm32/lm32.h b/gcc/config/lm32/lm32.h
>> > index 986383f..9e8c667 100644
>> > --- a/gcc/config/lm32/lm32.h
>> > +++ b/gcc/config/lm32/lm32.h
>> > @@ -443,8 +443,7 @@ do                                                                  \
>> >  }                                                                      \
>> >  while (0)
>> >
>> > -#define ASM_OUTPUT_LABEL(FILE, NAME) \
>> > -  do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
>> > +#define ASM_OUTPUT_LABEL default_output_label
>> >
>> >  #define ASM_OUTPUT_LABELREF(FILE,NAME) \
>> >    do {                                 \
>> > diff --git a/gcc/config/mep/mep.h b/gcc/config/mep/mep.h
>> > index f7322cb7..8a9d447 100644
>> > --- a/gcc/config/mep/mep.h
>> > +++ b/gcc/config/mep/mep.h
>> > @@ -625,13 +625,7 @@ typedef struct
>> >  #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
>> >         mep_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 0)
>> >
>> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)         \
>> > -  do                                           \
>> > -    {                                          \
>> > -      assemble_name (STREAM, NAME);            \
>> > -      fputs (":\n", STREAM);                   \
>> > -    }                                          \
>> > -  while (0)
>> > +#define ASM_OUTPUT_LABEL default_output_label
>> >
>> >  /* Globalizing directive for a label.  */
>> >  #define GLOBAL_ASM_OP "\t.globl "
>> > diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h
>> > index 29d39bc..aac5aa0 100644
>> > --- a/gcc/config/mmix/mmix.h
>> > +++ b/gcc/config/mmix/mmix.h
>> > @@ -647,8 +647,7 @@ typedef struct { int regs; int lib; } CUMULATIVE_ARGS;
>> >
>> >  /* Node: Label Output */
>> >
>> > -#define ASM_OUTPUT_LABEL(STREAM, NAME) \
>> > - mmix_asm_output_label (STREAM, NAME)
>> > +#define ASM_OUTPUT_LABEL mmix_asm_output_label
>> >
>> >  #define ASM_OUTPUT_INTERNAL_LABEL(STREAM, NAME) \
>> >   mmix_asm_output_internal_label (STREAM, NAME)
>> > diff --git a/gcc/config/pa/pa-protos.h b/gcc/config/pa/pa-protos.h
>> > index 0e13cd5..46a3e3b 100644
>> > --- a/gcc/config/pa/pa-protos.h
>> > +++ b/gcc/config/pa/pa-protos.h
>> > @@ -110,6 +110,7 @@ extern void pa_asm_output_aligned_common (FILE *, const char *,
>> >  extern void pa_asm_output_aligned_local (FILE *, const char *,
>> >                                          unsigned HOST_WIDE_INT,
>> >                                          unsigned int);
>> > +extern void pa_output_label (FILE *f, const char *label);
>> >  extern void pa_hpux_asm_output_external (FILE *, tree, const char *);
>> >  extern bool pa_cannot_change_mode_class (machine_mode, machine_mode,
>> >                                          enum reg_class);
>> > diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c
>> > index b24413a..2bcaa7e 100644
>> > --- a/gcc/config/pa/pa.c
>> > +++ b/gcc/config/pa/pa.c
>> > @@ -9761,6 +9761,18 @@ pa_reloc_rw_mask (void)
>> >    return 3;
>> >  }
>> >
>> > +/* Assemble a lable.  */
>> > +
>> > +void
>> > +pa_output_label (FILE *f, const char *label)
>> > +{
>> > +  assemble_name (f, label);
>> > +  if (TARGET_GAS)
>> > +    fputs (":\n", f);
>> > +  else
>> > +    fputc ('\n', (f));
>> > +}
>> > +
>> >  static void
>> >  pa_globalize_label (FILE *stream, const char *name)
>> >  {
>> > diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h
>> > index bdfbb16..595a10b 100644
>> > --- a/gcc/config/pa/pa.h
>> > +++ b/gcc/config/pa/pa.h
>> > @@ -1107,14 +1107,7 @@ do {                                                                          \
>> >  /* 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.  */
>> >
>> > -#define ASM_OUTPUT_LABEL(FILE,NAME) \
>> > -  do {                                                 \
>> > -    assemble_name ((FILE), (NAME));                    \
>> > -    if (TARGET_GAS)                                    \
>> > -      fputs (":\n", (FILE));                           \
>> > -    else                                               \
>> > -      fputc ('\n', (FILE));                            \
>> > -  } while (0)
>> > +#define ASM_OUTPUT_LABEL pa_output_label
>> >
>> >  /* This is how to output a reference to a user-level label named NAME.
>> >     `assemble_name' uses this.  */
>> > diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h
>> > index 560a825..031614f 100644
>> > --- a/gcc/config/rs6000/rs6000-protos.h
>> > +++ b/gcc/config/rs6000/rs6000-protos.h
>> > @@ -169,6 +169,7 @@ extern int function_ok_for_sibcall (tree);
>> >  extern int rs6000_reg_parm_stack_space (tree, bool);
>> >  extern void rs6000_xcoff_declare_function_name (FILE *, const char *, tree);
>> >  extern void rs6000_xcoff_declare_object_name (FILE *, const char *, tree);
>> > +extern void rs6000_xcoff_output_label (FILE *f, const char *label);
>> >  extern void rs6000_elf_declare_function_name (FILE *, const char *, tree);
>> >  extern bool rs6000_elf_in_small_data_p (const_tree);
>> >  #ifdef ARGS_SIZE_RTX
>> > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
>> > index c8794b4..a214010 100644
>> > --- a/gcc/config/rs6000/rs6000.c
>> > +++ b/gcc/config/rs6000/rs6000.c
>> > @@ -30364,6 +30364,14 @@ rs6000_xcoff_asm_output_anchor (rtx symbol)
>> >    fprintf (asm_out_file, "\n");
>> >  }
>> >
>> > +/* Assemble the given label.  */
>> > +void
>> > +rs6000_xcoff_output_label (FILE *f, const char *label)
>> > +{
>> > +  RS6000_OUTPUT_BASENAME (f, label);
>> > +  fputs (":\n", f);
>> > +}
>> > +
>> >  static void
>> >  rs6000_xcoff_asm_globalize_label (FILE *stream, const char *name)
>> >  {
>> > diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h
>> > index 8b0cb27..263e239 100644
>> > --- a/gcc/config/rs6000/xcoff.h
>> > +++ b/gcc/config/rs6000/xcoff.h
>> > @@ -119,8 +119,7 @@
>> >  /* 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.  */
>> >
>> > -#define ASM_OUTPUT_LABEL(FILE,NAME)    \
>> > -  do { RS6000_OUTPUT_BASENAME (FILE, NAME); fputs (":\n", FILE); } while (0)
>> > +#define ASM_OUTPUT_LABEL rs6000_xcoff_output_label
>> >
>> >  /* This is how to output a command to make the user-level label named NAME
>> >     defined for reference from other files.  */
>> > diff --git a/gcc/config/spu/spu.h b/gcc/config/spu/spu.h
>> > index 25fa435..f35b55e 100644
>> > --- a/gcc/config/spu/spu.h
>> > +++ b/gcc/config/spu/spu.h
>> > @@ -443,8 +443,7 @@ do {                                                                        \
>> >
>> >
>> >  /* Label Output */
>> > -#define ASM_OUTPUT_LABEL(FILE,NAME)    \
>> > -  do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
>> > +#define ASM_OUTPUT_LABEL default_output_label
>> >
>> >  #define ASM_OUTPUT_LABELREF(FILE, NAME) \
>> >    asm_fprintf (FILE, "%U%s", default_strip_name_encoding (NAME))
>> > diff --git a/gcc/config/visium/visium.h b/gcc/config/visium/visium.h
>> > index a2ab61c..6457c55 100644
>> > --- a/gcc/config/visium/visium.h
>> > +++ b/gcc/config/visium/visium.h
>> > @@ -1440,8 +1440,7 @@ do                                                                        \
>> >     `assemble_name (STREAM, NAME)' to output the name itself; before
>> >     and after that, output the additional assembler syntax for defining
>> >     the name, and a newline. */
>> > -#define ASM_OUTPUT_LABEL(STREAM,NAME)     \
>> > -  do { assemble_name (STREAM, NAME); fputs (":\n", STREAM); } while (0)
>> > +#define ASM_OUTPUT_LABEL default_output_label
>> >
>> >  /* Globalizing directive for a label */
>> >  #define GLOBAL_ASM_OP "\t.global "
>> > diff --git a/gcc/defaults.h b/gcc/defaults.h
>> > index 3ecf9fd..b1465de 100644
>> > --- a/gcc/defaults.h
>> > +++ b/gcc/defaults.h
>> > @@ -89,11 +89,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>> >     NAME, such as the label on variable NAME.  */
>> >
>> >  #ifndef ASM_OUTPUT_LABEL
>> > -#define ASM_OUTPUT_LABEL(FILE,NAME) \
>> > -  do {                                         \
>> > -    assemble_name ((FILE), (NAME));            \
>> > -    fputs (":\n", (FILE));                     \
>> > -  } while (0)
>> > +#define ASM_OUTPUT_LABEL default_output_label
>> >  #endif
>> >
>> >  /* This is how to output the definition of a user-level label named
>> > diff --git a/gcc/output.h b/gcc/output.h
>> > index 8aa648a..07172d5 100644
>> > --- a/gcc/output.h
>> > +++ b/gcc/output.h
>> > @@ -246,6 +246,9 @@ extern void assemble_name_raw (FILE *, const char *);
>> >     be marked as referenced.  */
>> >  extern void assemble_name (FILE *, const char *);
>> >
>> > +/* Assemble a label.  */
>> > +extern void default_output_label (FILE *f, const char *label);
>> > +
>> >  /* Return the assembler directive for creating a given kind of integer
>> >     object.  SIZE is the number of bytes in the object and ALIGNED_P
>> >     indicates whether it is known to be aligned.  Return NULL if the
>> > diff --git a/gcc/varasm.c b/gcc/varasm.c
>> > index c2bfbf0..9c5f12d 100644
>> > --- a/gcc/varasm.c
>> > +++ b/gcc/varasm.c
>> > @@ -2580,6 +2580,15 @@ assemble_name (FILE *file, const char *name)
>> >    assemble_name_raw (file, name);
>> >  }
>> >
>> > +/* Assemble a label.  */
>> > +
>> > +void
>> > +default_output_label (FILE *f, const char *label)
>> > +{
>> > +  assemble_name (f, label);
>> > +  fputs (":\n", f);
>> > +}
>> > +
>> >  /* Allocate SIZE bytes writable static space with a gensym name
>> >     and return an RTX to refer to its address.  */
>> >
>> > diff --git a/gcc/vmsdbgout.c b/gcc/vmsdbgout.c
>> > index 0204740..d04b8fb 100644
>> > --- a/gcc/vmsdbgout.c
>> > +++ b/gcc/vmsdbgout.c
>> > @@ -37,6 +37,7 @@ along with GCC; see the file COPYING3.  If not see
>> >  #include "langhooks.h"
>> >  #include "function.h"
>> >  #include "target.h"
>> > +#include "tm_p.h"
>> >
>> >  /* Difference in seconds between the VMS Epoch and the Unix Epoch */
>> >  static const long long vms_epoch_offset = 3506716800ll;
>> > diff --git a/gcc/xcoffout.c b/gcc/xcoffout.c
>> > index 0f11115..83959c8 100644
>> > --- a/gcc/xcoffout.c
>> > +++ b/gcc/xcoffout.c
>> > @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3.  If not see
>> >  #include "output.h"
>> >  #include "target.h"
>> >  #include "debug.h"
>> > +#include "tm_p.h"
>> >
>> >  #ifdef XCOFF_DEBUGGING_INFO
>> >
>> > --
>> > 2.4.0
>> >

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-08-05 11:47       ` Richard Biener
@ 2015-08-05 13:38         ` Trevor Saunders
  2015-08-05 13:59           ` Richard Biener
  2015-08-05 15:28         ` David Malcolm
  1 sibling, 1 reply; 31+ messages in thread
From: Trevor Saunders @ 2015-08-05 13:38 UTC (permalink / raw)
  To: Richard Biener; +Cc: tbsaunde+gcc, GCC Patches

On Wed, Aug 05, 2015 at 01:47:30PM +0200, Richard Biener wrote:
> On Wed, Aug 5, 2015 at 12:57 PM, Trevor Saunders <tbsaunde@tbsaunde.org> wrote:
> > On Mon, Jul 27, 2015 at 11:06:58AM +0200, Richard Biener wrote:
> >> On Sat, Jul 25, 2015 at 4:37 AM,  <tbsaunde+gcc@tbsaunde.org> wrote:
> >> > From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
> >> >
> >> >         * config/arc/arc.h, config/bfin/bfin.h, config/frv/frv.h,
> >> >         config/ia64/ia64-protos.h, config/ia64/ia64.c, config/ia64/ia64.h,
> >> >         config/lm32/lm32.h, config/mep/mep.h, config/mmix/mmix.h,
> >> >         config/rs6000/rs6000.c, config/rs6000/xcoff.h, config/spu/spu.h,
> >> >         config/visium/visium.h, defaults.h: Define ASM_OUTPUT_LABEL to
> >> > the name of a function.
> >> >         * output.h (default_output_label): New prototype.
> >> >         * varasm.c (default_output_label): New function.
> >> >         * vmsdbgout.c: Include tm_p.h.
> >> >         * xcoffout.c: Likewise.
> >>
> >> Just a general remark - the GCC output machinery is known to be slow,
> >> adding indirect calls might be not the very best idea without refactoring
> >> some of it.
> >>
> >> Did you do any performance measurements for artificial testcases
> >> exercising the specific bits you change?
> >
> > sorry about the delay, but I finally got a chance to do some perf tests
> > of the first patch.  I took three test cases fold-const.ii, insn-emit.ii
> > and a random .i from firefox and did 3 trials of the length of 100
> > compilations.  The only non default flag was -std=gnu++11.
> >
> > results before patch hookizing output_ascii
> >
> > fold-const.ii
> > real    3m18.051s
> > user    2m41.340s
> > sys     0m36.544s
> > real    3m18.141s
> > user    2m42.236s
> > sys     0m35.740s
> > real    3m18.297s
> > user    2m42.316s
> > sys     0m35.804s
> >
> > insn-emit.ii
> > real    9m58.229s
> > user    8m26.960s
> > sys     1m31.224s
> > real    9m57.857s
> > user    8m24.616s
> > sys     1m33.072s
> > real    9m57.922s
> > user    8m25.232s
> > sys     1m32.512s
> >
> > mozilla.ii
> > real    8m5.732s
> > user    6m44.888s
> > sys     1m20.764s
> > real    8m5.404s
> > user    6m44.468s
> > sys     1m20.856s
> > real    7m59.197s
> > user    6m39.632s
> > sys     1m19.472s
> >
> > after patch
> >
> > fold-const.ii
> > real    3m18.488s
> > user    2m41.972s
> > sys     0m36.388s
> > real    3m18.215s
> > user    2m41.640s
> > sys     0m36.432s
> > real    3m18.368s
> > user    2m42.492s
> > sys     0m35.720s
> >
> > insn-emit.ii
> > real    10m4.700s
> > user    8m32.536s
> > sys     1m32.120s
> > real    10m4.241s
> > user    8m31.456s
> > sys     1m32.728s
> > real    10m4.515s
> > user    8m32.056s
> > sys     1m32.396s
> >
> > mozilla.ii
> > real    7m58.018s
> > user    6m38.008s
> > sys     1m19.924s
> > real    7m59.269s
> > user    6m37.736s
> > sys     1m21.448s
> > real    7m58.254s
> > user    6m37.828s
> > sys     1m20.324s
> >
> > So, roughly that looks to me like a range from improving by .5% to
> > regressing by 1%.  I'm not sure what could cause an improvement, so I
> > kind of wonder how valid these results are.
> 
> Hmm, indeed.  The speedup looks suspicious.
> 
> > Another question is how one can refactor the output machinary to be
> > faster.  My first  thought is to buffer text internally before calling
> > stdio functions, but that seems like a giant job.
> 
> stdio functions are already buffering, so I don't know either.

 yeah, but the over head of calling functions in libc is higher than
 that for functions in gcc (especially if they can get inlined)
 right?  Especially when a lot of these things seme to loop calling
 putc...

> But yes, going the libas route would improve things here, or for
> example enhancing gas to be able to eat target binary data
> without the need to encode it in printable characters...
> 
> .raw_data number-of-bytes
> <raw data>
> 
> Makes it quite unparsable to editors of course ...

The idea of having .S files that aren't reasonably editable seems kind
of silly, but I guess its up to the gas people.

Trev

> 
> Richard.
> 
> > thanks!
> >
> > Trev
> >
> > far outside of noise,
> >>
> >> Richard.
> >>
> >> > ---
> >> >  gcc/config/arc/arc.h              |  3 +--
> >> >  gcc/config/bfin/bfin.h            |  5 +----
> >> >  gcc/config/frv/frv.h              |  6 +-----
> >> >  gcc/config/ia64/ia64-protos.h     |  1 +
> >> >  gcc/config/ia64/ia64.c            | 11 +++++++++++
> >> >  gcc/config/ia64/ia64.h            |  8 +-------
> >> >  gcc/config/lm32/lm32.h            |  3 +--
> >> >  gcc/config/mep/mep.h              |  8 +-------
> >> >  gcc/config/mmix/mmix.h            |  3 +--
> >> >  gcc/config/pa/pa-protos.h         |  1 +
> >> >  gcc/config/pa/pa.c                | 12 ++++++++++++
> >> >  gcc/config/pa/pa.h                |  9 +--------
> >> >  gcc/config/rs6000/rs6000-protos.h |  1 +
> >> >  gcc/config/rs6000/rs6000.c        |  8 ++++++++
> >> >  gcc/config/rs6000/xcoff.h         |  3 +--
> >> >  gcc/config/spu/spu.h              |  3 +--
> >> >  gcc/config/visium/visium.h        |  3 +--
> >> >  gcc/defaults.h                    |  6 +-----
> >> >  gcc/output.h                      |  3 +++
> >> >  gcc/varasm.c                      |  9 +++++++++
> >> >  gcc/vmsdbgout.c                   |  1 +
> >> >  gcc/xcoffout.c                    |  1 +
> >> >  22 files changed, 60 insertions(+), 48 deletions(-)
> >> >
> >> > diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h
> >> > index d98cce1..d3747b9 100644
> >> > --- a/gcc/config/arc/arc.h
> >> > +++ b/gcc/config/arc/arc.h
> >> > @@ -1245,8 +1245,7 @@ do {                                                                      \
> >> >
> >> >  /* 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.  */
> >> > -#define ASM_OUTPUT_LABEL(FILE, NAME) \
> >> > -do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
> >> > +#define ASM_OUTPUT_LABEL default_output_label
> >> >
> >> >  #define ASM_NAME_P(NAME) ( NAME[0]=='*')
> >> >
> >> > diff --git a/gcc/config/bfin/bfin.h b/gcc/config/bfin/bfin.h
> >> > index 26ba7c2..08906aa 100644
> >> > --- a/gcc/config/bfin/bfin.h
> >> > +++ b/gcc/config/bfin/bfin.h
> >> > @@ -1044,10 +1044,7 @@ typedef enum directives {
> >> >      ASM_OUTPUT_LABEL(FILE, NAME);      \
> >> >    } while (0)
> >> >
> >> > -#define ASM_OUTPUT_LABEL(FILE, NAME)    \
> >> > -  do {  assemble_name (FILE, NAME);            \
> >> > -        fputs (":\n",FILE);                    \
> >> > -      } while (0)
> >> > +#define ASM_OUTPUT_LABEL default_output_label
> >> >
> >> >  #define ASM_OUTPUT_LABELREF(FILE,NAME)         \
> >> >      do {  fprintf (FILE, "_%s", NAME); \
> >> > diff --git a/gcc/config/frv/frv.h b/gcc/config/frv/frv.h
> >> > index b0d66fd..1d25974 100644
> >> > --- a/gcc/config/frv/frv.h
> >> > +++ b/gcc/config/frv/frv.h
> >> > @@ -1668,11 +1668,7 @@ do {                                                                     \
> >> >     `assemble_name (STREAM, NAME)' to output the name itself; before and after
> >> >     that, output the additional assembler syntax for defining the name, and a
> >> >     newline.  */
> >> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)                                 \
> >> > -do {                                                                   \
> >> > -  assemble_name (STREAM, NAME);                                                \
> >> > -  fputs (":\n", STREAM);                                               \
> >> > -} while (0)
> >> > +#define ASM_OUTPUT_LABEL default_output_label
> >> >
> >> >  /* Globalizing directive for a label.  */
> >> >  #define GLOBAL_ASM_OP "\t.globl "
> >> > diff --git a/gcc/config/ia64/ia64-protos.h b/gcc/config/ia64/ia64-protos.h
> >> > index 29fc714..8e540e4 100644
> >> > --- a/gcc/config/ia64/ia64-protos.h
> >> > +++ b/gcc/config/ia64/ia64-protos.h
> >> > @@ -72,6 +72,7 @@ extern rtx ia64_expand_builtin (tree, rtx, rtx, machine_mode, int);
> >> >  extern rtx ia64_va_arg (tree, tree);
> >> >  #endif /* RTX_CODE */
> >> >
> >> > +extern void ia64_output_label (FILE *f, const char *label);
> >> >  extern void ia64_asm_output_external (FILE *, tree, const char *);
> >> >  extern void ia64_vms_output_aligned_decl_common (FILE *, tree, const char *,
> >> >                                                  unsigned HOST_WIDE_INT,
> >> > diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
> >> > index 779fc58..e07ebb5 100644
> >> > --- a/gcc/config/ia64/ia64.c
> >> > +++ b/gcc/config/ia64/ia64.c
> >> > @@ -10522,6 +10522,17 @@ ia64_hpux_function_arg_padding (machine_mode mode, const_tree type)
> >> >     return DEFAULT_FUNCTION_ARG_PADDING (mode, type);
> >> >  }
> >> >
> >> > +/* Assemble a label.  */
> >> > +
> >> > +void
> >> > +ia64_output_label (FILE *f, const char *label)
> >> > +{
> >> > +  ia64_asm_output_label = 1;
> >> > +  assemble_name (f, label);
> >> > +  fputs (":\n", f);
> >> > +  ia64_asm_output_label = 0;
> >> > +}
> >> > +
> >> >  /* Emit text to declare externally defined variables and functions, because
> >> >     the Intel assembler does not support undefined externals.  */
> >> >
> >> > diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h
> >> > index 4b62423..1afa7b7 100644
> >> > --- a/gcc/config/ia64/ia64.h
> >> > +++ b/gcc/config/ia64/ia64.h
> >> > @@ -1246,13 +1246,7 @@ do {                                                                     \
> >> >     why ia64_asm_output_label exists.  */
> >> >
> >> >  extern int ia64_asm_output_label;
> >> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)                                 \
> >> > -do {                                                                   \
> >> > -  ia64_asm_output_label = 1;                                           \
> >> > -  assemble_name (STREAM, NAME);                                                \
> >> > -  fputs (":\n", STREAM);                                               \
> >> > -  ia64_asm_output_label = 0;                                           \
> >> > -} while (0)
> >> > +#define ASM_OUTPUT_LABEL ia64_output_label
> >> >
> >> >  /* Globalizing directive for a label.  */
> >> >  #define GLOBAL_ASM_OP "\t.global "
> >> > diff --git a/gcc/config/lm32/lm32.h b/gcc/config/lm32/lm32.h
> >> > index 986383f..9e8c667 100644
> >> > --- a/gcc/config/lm32/lm32.h
> >> > +++ b/gcc/config/lm32/lm32.h
> >> > @@ -443,8 +443,7 @@ do                                                                  \
> >> >  }                                                                      \
> >> >  while (0)
> >> >
> >> > -#define ASM_OUTPUT_LABEL(FILE, NAME) \
> >> > -  do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
> >> > +#define ASM_OUTPUT_LABEL default_output_label
> >> >
> >> >  #define ASM_OUTPUT_LABELREF(FILE,NAME) \
> >> >    do {                                 \
> >> > diff --git a/gcc/config/mep/mep.h b/gcc/config/mep/mep.h
> >> > index f7322cb7..8a9d447 100644
> >> > --- a/gcc/config/mep/mep.h
> >> > +++ b/gcc/config/mep/mep.h
> >> > @@ -625,13 +625,7 @@ typedef struct
> >> >  #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
> >> >         mep_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 0)
> >> >
> >> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)         \
> >> > -  do                                           \
> >> > -    {                                          \
> >> > -      assemble_name (STREAM, NAME);            \
> >> > -      fputs (":\n", STREAM);                   \
> >> > -    }                                          \
> >> > -  while (0)
> >> > +#define ASM_OUTPUT_LABEL default_output_label
> >> >
> >> >  /* Globalizing directive for a label.  */
> >> >  #define GLOBAL_ASM_OP "\t.globl "
> >> > diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h
> >> > index 29d39bc..aac5aa0 100644
> >> > --- a/gcc/config/mmix/mmix.h
> >> > +++ b/gcc/config/mmix/mmix.h
> >> > @@ -647,8 +647,7 @@ typedef struct { int regs; int lib; } CUMULATIVE_ARGS;
> >> >
> >> >  /* Node: Label Output */
> >> >
> >> > -#define ASM_OUTPUT_LABEL(STREAM, NAME) \
> >> > - mmix_asm_output_label (STREAM, NAME)
> >> > +#define ASM_OUTPUT_LABEL mmix_asm_output_label
> >> >
> >> >  #define ASM_OUTPUT_INTERNAL_LABEL(STREAM, NAME) \
> >> >   mmix_asm_output_internal_label (STREAM, NAME)
> >> > diff --git a/gcc/config/pa/pa-protos.h b/gcc/config/pa/pa-protos.h
> >> > index 0e13cd5..46a3e3b 100644
> >> > --- a/gcc/config/pa/pa-protos.h
> >> > +++ b/gcc/config/pa/pa-protos.h
> >> > @@ -110,6 +110,7 @@ extern void pa_asm_output_aligned_common (FILE *, const char *,
> >> >  extern void pa_asm_output_aligned_local (FILE *, const char *,
> >> >                                          unsigned HOST_WIDE_INT,
> >> >                                          unsigned int);
> >> > +extern void pa_output_label (FILE *f, const char *label);
> >> >  extern void pa_hpux_asm_output_external (FILE *, tree, const char *);
> >> >  extern bool pa_cannot_change_mode_class (machine_mode, machine_mode,
> >> >                                          enum reg_class);
> >> > diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c
> >> > index b24413a..2bcaa7e 100644
> >> > --- a/gcc/config/pa/pa.c
> >> > +++ b/gcc/config/pa/pa.c
> >> > @@ -9761,6 +9761,18 @@ pa_reloc_rw_mask (void)
> >> >    return 3;
> >> >  }
> >> >
> >> > +/* Assemble a lable.  */
> >> > +
> >> > +void
> >> > +pa_output_label (FILE *f, const char *label)
> >> > +{
> >> > +  assemble_name (f, label);
> >> > +  if (TARGET_GAS)
> >> > +    fputs (":\n", f);
> >> > +  else
> >> > +    fputc ('\n', (f));
> >> > +}
> >> > +
> >> >  static void
> >> >  pa_globalize_label (FILE *stream, const char *name)
> >> >  {
> >> > diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h
> >> > index bdfbb16..595a10b 100644
> >> > --- a/gcc/config/pa/pa.h
> >> > +++ b/gcc/config/pa/pa.h
> >> > @@ -1107,14 +1107,7 @@ do {                                                                          \
> >> >  /* 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.  */
> >> >
> >> > -#define ASM_OUTPUT_LABEL(FILE,NAME) \
> >> > -  do {                                                 \
> >> > -    assemble_name ((FILE), (NAME));                    \
> >> > -    if (TARGET_GAS)                                    \
> >> > -      fputs (":\n", (FILE));                           \
> >> > -    else                                               \
> >> > -      fputc ('\n', (FILE));                            \
> >> > -  } while (0)
> >> > +#define ASM_OUTPUT_LABEL pa_output_label
> >> >
> >> >  /* This is how to output a reference to a user-level label named NAME.
> >> >     `assemble_name' uses this.  */
> >> > diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h
> >> > index 560a825..031614f 100644
> >> > --- a/gcc/config/rs6000/rs6000-protos.h
> >> > +++ b/gcc/config/rs6000/rs6000-protos.h
> >> > @@ -169,6 +169,7 @@ extern int function_ok_for_sibcall (tree);
> >> >  extern int rs6000_reg_parm_stack_space (tree, bool);
> >> >  extern void rs6000_xcoff_declare_function_name (FILE *, const char *, tree);
> >> >  extern void rs6000_xcoff_declare_object_name (FILE *, const char *, tree);
> >> > +extern void rs6000_xcoff_output_label (FILE *f, const char *label);
> >> >  extern void rs6000_elf_declare_function_name (FILE *, const char *, tree);
> >> >  extern bool rs6000_elf_in_small_data_p (const_tree);
> >> >  #ifdef ARGS_SIZE_RTX
> >> > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> >> > index c8794b4..a214010 100644
> >> > --- a/gcc/config/rs6000/rs6000.c
> >> > +++ b/gcc/config/rs6000/rs6000.c
> >> > @@ -30364,6 +30364,14 @@ rs6000_xcoff_asm_output_anchor (rtx symbol)
> >> >    fprintf (asm_out_file, "\n");
> >> >  }
> >> >
> >> > +/* Assemble the given label.  */
> >> > +void
> >> > +rs6000_xcoff_output_label (FILE *f, const char *label)
> >> > +{
> >> > +  RS6000_OUTPUT_BASENAME (f, label);
> >> > +  fputs (":\n", f);
> >> > +}
> >> > +
> >> >  static void
> >> >  rs6000_xcoff_asm_globalize_label (FILE *stream, const char *name)
> >> >  {
> >> > diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h
> >> > index 8b0cb27..263e239 100644
> >> > --- a/gcc/config/rs6000/xcoff.h
> >> > +++ b/gcc/config/rs6000/xcoff.h
> >> > @@ -119,8 +119,7 @@
> >> >  /* 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.  */
> >> >
> >> > -#define ASM_OUTPUT_LABEL(FILE,NAME)    \
> >> > -  do { RS6000_OUTPUT_BASENAME (FILE, NAME); fputs (":\n", FILE); } while (0)
> >> > +#define ASM_OUTPUT_LABEL rs6000_xcoff_output_label
> >> >
> >> >  /* This is how to output a command to make the user-level label named NAME
> >> >     defined for reference from other files.  */
> >> > diff --git a/gcc/config/spu/spu.h b/gcc/config/spu/spu.h
> >> > index 25fa435..f35b55e 100644
> >> > --- a/gcc/config/spu/spu.h
> >> > +++ b/gcc/config/spu/spu.h
> >> > @@ -443,8 +443,7 @@ do {                                                                        \
> >> >
> >> >
> >> >  /* Label Output */
> >> > -#define ASM_OUTPUT_LABEL(FILE,NAME)    \
> >> > -  do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
> >> > +#define ASM_OUTPUT_LABEL default_output_label
> >> >
> >> >  #define ASM_OUTPUT_LABELREF(FILE, NAME) \
> >> >    asm_fprintf (FILE, "%U%s", default_strip_name_encoding (NAME))
> >> > diff --git a/gcc/config/visium/visium.h b/gcc/config/visium/visium.h
> >> > index a2ab61c..6457c55 100644
> >> > --- a/gcc/config/visium/visium.h
> >> > +++ b/gcc/config/visium/visium.h
> >> > @@ -1440,8 +1440,7 @@ do                                                                        \
> >> >     `assemble_name (STREAM, NAME)' to output the name itself; before
> >> >     and after that, output the additional assembler syntax for defining
> >> >     the name, and a newline. */
> >> > -#define ASM_OUTPUT_LABEL(STREAM,NAME)     \
> >> > -  do { assemble_name (STREAM, NAME); fputs (":\n", STREAM); } while (0)
> >> > +#define ASM_OUTPUT_LABEL default_output_label
> >> >
> >> >  /* Globalizing directive for a label */
> >> >  #define GLOBAL_ASM_OP "\t.global "
> >> > diff --git a/gcc/defaults.h b/gcc/defaults.h
> >> > index 3ecf9fd..b1465de 100644
> >> > --- a/gcc/defaults.h
> >> > +++ b/gcc/defaults.h
> >> > @@ -89,11 +89,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> >> >     NAME, such as the label on variable NAME.  */
> >> >
> >> >  #ifndef ASM_OUTPUT_LABEL
> >> > -#define ASM_OUTPUT_LABEL(FILE,NAME) \
> >> > -  do {                                         \
> >> > -    assemble_name ((FILE), (NAME));            \
> >> > -    fputs (":\n", (FILE));                     \
> >> > -  } while (0)
> >> > +#define ASM_OUTPUT_LABEL default_output_label
> >> >  #endif
> >> >
> >> >  /* This is how to output the definition of a user-level label named
> >> > diff --git a/gcc/output.h b/gcc/output.h
> >> > index 8aa648a..07172d5 100644
> >> > --- a/gcc/output.h
> >> > +++ b/gcc/output.h
> >> > @@ -246,6 +246,9 @@ extern void assemble_name_raw (FILE *, const char *);
> >> >     be marked as referenced.  */
> >> >  extern void assemble_name (FILE *, const char *);
> >> >
> >> > +/* Assemble a label.  */
> >> > +extern void default_output_label (FILE *f, const char *label);
> >> > +
> >> >  /* Return the assembler directive for creating a given kind of integer
> >> >     object.  SIZE is the number of bytes in the object and ALIGNED_P
> >> >     indicates whether it is known to be aligned.  Return NULL if the
> >> > diff --git a/gcc/varasm.c b/gcc/varasm.c
> >> > index c2bfbf0..9c5f12d 100644
> >> > --- a/gcc/varasm.c
> >> > +++ b/gcc/varasm.c
> >> > @@ -2580,6 +2580,15 @@ assemble_name (FILE *file, const char *name)
> >> >    assemble_name_raw (file, name);
> >> >  }
> >> >
> >> > +/* Assemble a label.  */
> >> > +
> >> > +void
> >> > +default_output_label (FILE *f, const char *label)
> >> > +{
> >> > +  assemble_name (f, label);
> >> > +  fputs (":\n", f);
> >> > +}
> >> > +
> >> >  /* Allocate SIZE bytes writable static space with a gensym name
> >> >     and return an RTX to refer to its address.  */
> >> >
> >> > diff --git a/gcc/vmsdbgout.c b/gcc/vmsdbgout.c
> >> > index 0204740..d04b8fb 100644
> >> > --- a/gcc/vmsdbgout.c
> >> > +++ b/gcc/vmsdbgout.c
> >> > @@ -37,6 +37,7 @@ along with GCC; see the file COPYING3.  If not see
> >> >  #include "langhooks.h"
> >> >  #include "function.h"
> >> >  #include "target.h"
> >> > +#include "tm_p.h"
> >> >
> >> >  /* Difference in seconds between the VMS Epoch and the Unix Epoch */
> >> >  static const long long vms_epoch_offset = 3506716800ll;
> >> > diff --git a/gcc/xcoffout.c b/gcc/xcoffout.c
> >> > index 0f11115..83959c8 100644
> >> > --- a/gcc/xcoffout.c
> >> > +++ b/gcc/xcoffout.c
> >> > @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3.  If not see
> >> >  #include "output.h"
> >> >  #include "target.h"
> >> >  #include "debug.h"
> >> > +#include "tm_p.h"
> >> >
> >> >  #ifdef XCOFF_DEBUGGING_INFO
> >> >
> >> > --
> >> > 2.4.0
> >> >

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-08-05 13:38         ` Trevor Saunders
@ 2015-08-05 13:59           ` Richard Biener
  2015-08-05 22:28             ` Segher Boessenkool
  0 siblings, 1 reply; 31+ messages in thread
From: Richard Biener @ 2015-08-05 13:59 UTC (permalink / raw)
  To: Trevor Saunders; +Cc: tbsaunde+gcc, GCC Patches

On Wed, Aug 5, 2015 at 3:36 PM, Trevor Saunders <tbsaunde@tbsaunde.org> wrote:
> On Wed, Aug 05, 2015 at 01:47:30PM +0200, Richard Biener wrote:
>> On Wed, Aug 5, 2015 at 12:57 PM, Trevor Saunders <tbsaunde@tbsaunde.org> wrote:
>> > On Mon, Jul 27, 2015 at 11:06:58AM +0200, Richard Biener wrote:
>> >> On Sat, Jul 25, 2015 at 4:37 AM,  <tbsaunde+gcc@tbsaunde.org> wrote:
>> >> > From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>> >> >
>> >> >         * config/arc/arc.h, config/bfin/bfin.h, config/frv/frv.h,
>> >> >         config/ia64/ia64-protos.h, config/ia64/ia64.c, config/ia64/ia64.h,
>> >> >         config/lm32/lm32.h, config/mep/mep.h, config/mmix/mmix.h,
>> >> >         config/rs6000/rs6000.c, config/rs6000/xcoff.h, config/spu/spu.h,
>> >> >         config/visium/visium.h, defaults.h: Define ASM_OUTPUT_LABEL to
>> >> > the name of a function.
>> >> >         * output.h (default_output_label): New prototype.
>> >> >         * varasm.c (default_output_label): New function.
>> >> >         * vmsdbgout.c: Include tm_p.h.
>> >> >         * xcoffout.c: Likewise.
>> >>
>> >> Just a general remark - the GCC output machinery is known to be slow,
>> >> adding indirect calls might be not the very best idea without refactoring
>> >> some of it.
>> >>
>> >> Did you do any performance measurements for artificial testcases
>> >> exercising the specific bits you change?
>> >
>> > sorry about the delay, but I finally got a chance to do some perf tests
>> > of the first patch.  I took three test cases fold-const.ii, insn-emit.ii
>> > and a random .i from firefox and did 3 trials of the length of 100
>> > compilations.  The only non default flag was -std=gnu++11.
>> >
>> > results before patch hookizing output_ascii
>> >
>> > fold-const.ii
>> > real    3m18.051s
>> > user    2m41.340s
>> > sys     0m36.544s
>> > real    3m18.141s
>> > user    2m42.236s
>> > sys     0m35.740s
>> > real    3m18.297s
>> > user    2m42.316s
>> > sys     0m35.804s
>> >
>> > insn-emit.ii
>> > real    9m58.229s
>> > user    8m26.960s
>> > sys     1m31.224s
>> > real    9m57.857s
>> > user    8m24.616s
>> > sys     1m33.072s
>> > real    9m57.922s
>> > user    8m25.232s
>> > sys     1m32.512s
>> >
>> > mozilla.ii
>> > real    8m5.732s
>> > user    6m44.888s
>> > sys     1m20.764s
>> > real    8m5.404s
>> > user    6m44.468s
>> > sys     1m20.856s
>> > real    7m59.197s
>> > user    6m39.632s
>> > sys     1m19.472s
>> >
>> > after patch
>> >
>> > fold-const.ii
>> > real    3m18.488s
>> > user    2m41.972s
>> > sys     0m36.388s
>> > real    3m18.215s
>> > user    2m41.640s
>> > sys     0m36.432s
>> > real    3m18.368s
>> > user    2m42.492s
>> > sys     0m35.720s
>> >
>> > insn-emit.ii
>> > real    10m4.700s
>> > user    8m32.536s
>> > sys     1m32.120s
>> > real    10m4.241s
>> > user    8m31.456s
>> > sys     1m32.728s
>> > real    10m4.515s
>> > user    8m32.056s
>> > sys     1m32.396s
>> >
>> > mozilla.ii
>> > real    7m58.018s
>> > user    6m38.008s
>> > sys     1m19.924s
>> > real    7m59.269s
>> > user    6m37.736s
>> > sys     1m21.448s
>> > real    7m58.254s
>> > user    6m37.828s
>> > sys     1m20.324s
>> >
>> > So, roughly that looks to me like a range from improving by .5% to
>> > regressing by 1%.  I'm not sure what could cause an improvement, so I
>> > kind of wonder how valid these results are.
>>
>> Hmm, indeed.  The speedup looks suspicious.
>>
>> > Another question is how one can refactor the output machinary to be
>> > faster.  My first  thought is to buffer text internally before calling
>> > stdio functions, but that seems like a giant job.
>>
>> stdio functions are already buffering, so I don't know either.
>
>  yeah, but the over head of calling functions in libc is higher than
>  that for functions in gcc (especially if they can get inlined)
>  right?  Especially when a lot of these things seme to loop calling
>  putc...

obstacks are used elsewhere to do char buffering.  But not sure how
easy it is to pick low-hanging fruit here.

I suppose it would be nice to isolate the hot parts of the output machinery
only during a bootstrap for example.

>> But yes, going the libas route would improve things here, or for
>> example enhancing gas to be able to eat target binary data
>> without the need to encode it in printable characters...
>>
>> .raw_data number-of-bytes
>> <raw data>
>>
>> Makes it quite unparsable to editors of course ...
>
> The idea of having .S files that aren't reasonably editable seems kind
> of silly, but I guess its up to the gas people.

Heh, indeed.  Maybe instead do

.insert_from_file  <filename>

and do that only when we are using -pipe or so.

Richard.

> Trev
>
>>
>> Richard.
>>
>> > thanks!
>> >
>> > Trev
>> >
>> > far outside of noise,
>> >>
>> >> Richard.
>> >>
>> >> > ---
>> >> >  gcc/config/arc/arc.h              |  3 +--
>> >> >  gcc/config/bfin/bfin.h            |  5 +----
>> >> >  gcc/config/frv/frv.h              |  6 +-----
>> >> >  gcc/config/ia64/ia64-protos.h     |  1 +
>> >> >  gcc/config/ia64/ia64.c            | 11 +++++++++++
>> >> >  gcc/config/ia64/ia64.h            |  8 +-------
>> >> >  gcc/config/lm32/lm32.h            |  3 +--
>> >> >  gcc/config/mep/mep.h              |  8 +-------
>> >> >  gcc/config/mmix/mmix.h            |  3 +--
>> >> >  gcc/config/pa/pa-protos.h         |  1 +
>> >> >  gcc/config/pa/pa.c                | 12 ++++++++++++
>> >> >  gcc/config/pa/pa.h                |  9 +--------
>> >> >  gcc/config/rs6000/rs6000-protos.h |  1 +
>> >> >  gcc/config/rs6000/rs6000.c        |  8 ++++++++
>> >> >  gcc/config/rs6000/xcoff.h         |  3 +--
>> >> >  gcc/config/spu/spu.h              |  3 +--
>> >> >  gcc/config/visium/visium.h        |  3 +--
>> >> >  gcc/defaults.h                    |  6 +-----
>> >> >  gcc/output.h                      |  3 +++
>> >> >  gcc/varasm.c                      |  9 +++++++++
>> >> >  gcc/vmsdbgout.c                   |  1 +
>> >> >  gcc/xcoffout.c                    |  1 +
>> >> >  22 files changed, 60 insertions(+), 48 deletions(-)
>> >> >
>> >> > diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h
>> >> > index d98cce1..d3747b9 100644
>> >> > --- a/gcc/config/arc/arc.h
>> >> > +++ b/gcc/config/arc/arc.h
>> >> > @@ -1245,8 +1245,7 @@ do {                                                                      \
>> >> >
>> >> >  /* 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.  */
>> >> > -#define ASM_OUTPUT_LABEL(FILE, NAME) \
>> >> > -do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
>> >> > +#define ASM_OUTPUT_LABEL default_output_label
>> >> >
>> >> >  #define ASM_NAME_P(NAME) ( NAME[0]=='*')
>> >> >
>> >> > diff --git a/gcc/config/bfin/bfin.h b/gcc/config/bfin/bfin.h
>> >> > index 26ba7c2..08906aa 100644
>> >> > --- a/gcc/config/bfin/bfin.h
>> >> > +++ b/gcc/config/bfin/bfin.h
>> >> > @@ -1044,10 +1044,7 @@ typedef enum directives {
>> >> >      ASM_OUTPUT_LABEL(FILE, NAME);      \
>> >> >    } while (0)
>> >> >
>> >> > -#define ASM_OUTPUT_LABEL(FILE, NAME)    \
>> >> > -  do {  assemble_name (FILE, NAME);            \
>> >> > -        fputs (":\n",FILE);                    \
>> >> > -      } while (0)
>> >> > +#define ASM_OUTPUT_LABEL default_output_label
>> >> >
>> >> >  #define ASM_OUTPUT_LABELREF(FILE,NAME)         \
>> >> >      do {  fprintf (FILE, "_%s", NAME); \
>> >> > diff --git a/gcc/config/frv/frv.h b/gcc/config/frv/frv.h
>> >> > index b0d66fd..1d25974 100644
>> >> > --- a/gcc/config/frv/frv.h
>> >> > +++ b/gcc/config/frv/frv.h
>> >> > @@ -1668,11 +1668,7 @@ do {                                                                     \
>> >> >     `assemble_name (STREAM, NAME)' to output the name itself; before and after
>> >> >     that, output the additional assembler syntax for defining the name, and a
>> >> >     newline.  */
>> >> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)                                 \
>> >> > -do {                                                                   \
>> >> > -  assemble_name (STREAM, NAME);                                                \
>> >> > -  fputs (":\n", STREAM);                                               \
>> >> > -} while (0)
>> >> > +#define ASM_OUTPUT_LABEL default_output_label
>> >> >
>> >> >  /* Globalizing directive for a label.  */
>> >> >  #define GLOBAL_ASM_OP "\t.globl "
>> >> > diff --git a/gcc/config/ia64/ia64-protos.h b/gcc/config/ia64/ia64-protos.h
>> >> > index 29fc714..8e540e4 100644
>> >> > --- a/gcc/config/ia64/ia64-protos.h
>> >> > +++ b/gcc/config/ia64/ia64-protos.h
>> >> > @@ -72,6 +72,7 @@ extern rtx ia64_expand_builtin (tree, rtx, rtx, machine_mode, int);
>> >> >  extern rtx ia64_va_arg (tree, tree);
>> >> >  #endif /* RTX_CODE */
>> >> >
>> >> > +extern void ia64_output_label (FILE *f, const char *label);
>> >> >  extern void ia64_asm_output_external (FILE *, tree, const char *);
>> >> >  extern void ia64_vms_output_aligned_decl_common (FILE *, tree, const char *,
>> >> >                                                  unsigned HOST_WIDE_INT,
>> >> > diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
>> >> > index 779fc58..e07ebb5 100644
>> >> > --- a/gcc/config/ia64/ia64.c
>> >> > +++ b/gcc/config/ia64/ia64.c
>> >> > @@ -10522,6 +10522,17 @@ ia64_hpux_function_arg_padding (machine_mode mode, const_tree type)
>> >> >     return DEFAULT_FUNCTION_ARG_PADDING (mode, type);
>> >> >  }
>> >> >
>> >> > +/* Assemble a label.  */
>> >> > +
>> >> > +void
>> >> > +ia64_output_label (FILE *f, const char *label)
>> >> > +{
>> >> > +  ia64_asm_output_label = 1;
>> >> > +  assemble_name (f, label);
>> >> > +  fputs (":\n", f);
>> >> > +  ia64_asm_output_label = 0;
>> >> > +}
>> >> > +
>> >> >  /* Emit text to declare externally defined variables and functions, because
>> >> >     the Intel assembler does not support undefined externals.  */
>> >> >
>> >> > diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h
>> >> > index 4b62423..1afa7b7 100644
>> >> > --- a/gcc/config/ia64/ia64.h
>> >> > +++ b/gcc/config/ia64/ia64.h
>> >> > @@ -1246,13 +1246,7 @@ do {                                                                     \
>> >> >     why ia64_asm_output_label exists.  */
>> >> >
>> >> >  extern int ia64_asm_output_label;
>> >> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)                                 \
>> >> > -do {                                                                   \
>> >> > -  ia64_asm_output_label = 1;                                           \
>> >> > -  assemble_name (STREAM, NAME);                                                \
>> >> > -  fputs (":\n", STREAM);                                               \
>> >> > -  ia64_asm_output_label = 0;                                           \
>> >> > -} while (0)
>> >> > +#define ASM_OUTPUT_LABEL ia64_output_label
>> >> >
>> >> >  /* Globalizing directive for a label.  */
>> >> >  #define GLOBAL_ASM_OP "\t.global "
>> >> > diff --git a/gcc/config/lm32/lm32.h b/gcc/config/lm32/lm32.h
>> >> > index 986383f..9e8c667 100644
>> >> > --- a/gcc/config/lm32/lm32.h
>> >> > +++ b/gcc/config/lm32/lm32.h
>> >> > @@ -443,8 +443,7 @@ do                                                                  \
>> >> >  }                                                                      \
>> >> >  while (0)
>> >> >
>> >> > -#define ASM_OUTPUT_LABEL(FILE, NAME) \
>> >> > -  do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
>> >> > +#define ASM_OUTPUT_LABEL default_output_label
>> >> >
>> >> >  #define ASM_OUTPUT_LABELREF(FILE,NAME) \
>> >> >    do {                                 \
>> >> > diff --git a/gcc/config/mep/mep.h b/gcc/config/mep/mep.h
>> >> > index f7322cb7..8a9d447 100644
>> >> > --- a/gcc/config/mep/mep.h
>> >> > +++ b/gcc/config/mep/mep.h
>> >> > @@ -625,13 +625,7 @@ typedef struct
>> >> >  #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
>> >> >         mep_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 0)
>> >> >
>> >> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)         \
>> >> > -  do                                           \
>> >> > -    {                                          \
>> >> > -      assemble_name (STREAM, NAME);            \
>> >> > -      fputs (":\n", STREAM);                   \
>> >> > -    }                                          \
>> >> > -  while (0)
>> >> > +#define ASM_OUTPUT_LABEL default_output_label
>> >> >
>> >> >  /* Globalizing directive for a label.  */
>> >> >  #define GLOBAL_ASM_OP "\t.globl "
>> >> > diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h
>> >> > index 29d39bc..aac5aa0 100644
>> >> > --- a/gcc/config/mmix/mmix.h
>> >> > +++ b/gcc/config/mmix/mmix.h
>> >> > @@ -647,8 +647,7 @@ typedef struct { int regs; int lib; } CUMULATIVE_ARGS;
>> >> >
>> >> >  /* Node: Label Output */
>> >> >
>> >> > -#define ASM_OUTPUT_LABEL(STREAM, NAME) \
>> >> > - mmix_asm_output_label (STREAM, NAME)
>> >> > +#define ASM_OUTPUT_LABEL mmix_asm_output_label
>> >> >
>> >> >  #define ASM_OUTPUT_INTERNAL_LABEL(STREAM, NAME) \
>> >> >   mmix_asm_output_internal_label (STREAM, NAME)
>> >> > diff --git a/gcc/config/pa/pa-protos.h b/gcc/config/pa/pa-protos.h
>> >> > index 0e13cd5..46a3e3b 100644
>> >> > --- a/gcc/config/pa/pa-protos.h
>> >> > +++ b/gcc/config/pa/pa-protos.h
>> >> > @@ -110,6 +110,7 @@ extern void pa_asm_output_aligned_common (FILE *, const char *,
>> >> >  extern void pa_asm_output_aligned_local (FILE *, const char *,
>> >> >                                          unsigned HOST_WIDE_INT,
>> >> >                                          unsigned int);
>> >> > +extern void pa_output_label (FILE *f, const char *label);
>> >> >  extern void pa_hpux_asm_output_external (FILE *, tree, const char *);
>> >> >  extern bool pa_cannot_change_mode_class (machine_mode, machine_mode,
>> >> >                                          enum reg_class);
>> >> > diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c
>> >> > index b24413a..2bcaa7e 100644
>> >> > --- a/gcc/config/pa/pa.c
>> >> > +++ b/gcc/config/pa/pa.c
>> >> > @@ -9761,6 +9761,18 @@ pa_reloc_rw_mask (void)
>> >> >    return 3;
>> >> >  }
>> >> >
>> >> > +/* Assemble a lable.  */
>> >> > +
>> >> > +void
>> >> > +pa_output_label (FILE *f, const char *label)
>> >> > +{
>> >> > +  assemble_name (f, label);
>> >> > +  if (TARGET_GAS)
>> >> > +    fputs (":\n", f);
>> >> > +  else
>> >> > +    fputc ('\n', (f));
>> >> > +}
>> >> > +
>> >> >  static void
>> >> >  pa_globalize_label (FILE *stream, const char *name)
>> >> >  {
>> >> > diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h
>> >> > index bdfbb16..595a10b 100644
>> >> > --- a/gcc/config/pa/pa.h
>> >> > +++ b/gcc/config/pa/pa.h
>> >> > @@ -1107,14 +1107,7 @@ do {                                                                          \
>> >> >  /* 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.  */
>> >> >
>> >> > -#define ASM_OUTPUT_LABEL(FILE,NAME) \
>> >> > -  do {                                                 \
>> >> > -    assemble_name ((FILE), (NAME));                    \
>> >> > -    if (TARGET_GAS)                                    \
>> >> > -      fputs (":\n", (FILE));                           \
>> >> > -    else                                               \
>> >> > -      fputc ('\n', (FILE));                            \
>> >> > -  } while (0)
>> >> > +#define ASM_OUTPUT_LABEL pa_output_label
>> >> >
>> >> >  /* This is how to output a reference to a user-level label named NAME.
>> >> >     `assemble_name' uses this.  */
>> >> > diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h
>> >> > index 560a825..031614f 100644
>> >> > --- a/gcc/config/rs6000/rs6000-protos.h
>> >> > +++ b/gcc/config/rs6000/rs6000-protos.h
>> >> > @@ -169,6 +169,7 @@ extern int function_ok_for_sibcall (tree);
>> >> >  extern int rs6000_reg_parm_stack_space (tree, bool);
>> >> >  extern void rs6000_xcoff_declare_function_name (FILE *, const char *, tree);
>> >> >  extern void rs6000_xcoff_declare_object_name (FILE *, const char *, tree);
>> >> > +extern void rs6000_xcoff_output_label (FILE *f, const char *label);
>> >> >  extern void rs6000_elf_declare_function_name (FILE *, const char *, tree);
>> >> >  extern bool rs6000_elf_in_small_data_p (const_tree);
>> >> >  #ifdef ARGS_SIZE_RTX
>> >> > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
>> >> > index c8794b4..a214010 100644
>> >> > --- a/gcc/config/rs6000/rs6000.c
>> >> > +++ b/gcc/config/rs6000/rs6000.c
>> >> > @@ -30364,6 +30364,14 @@ rs6000_xcoff_asm_output_anchor (rtx symbol)
>> >> >    fprintf (asm_out_file, "\n");
>> >> >  }
>> >> >
>> >> > +/* Assemble the given label.  */
>> >> > +void
>> >> > +rs6000_xcoff_output_label (FILE *f, const char *label)
>> >> > +{
>> >> > +  RS6000_OUTPUT_BASENAME (f, label);
>> >> > +  fputs (":\n", f);
>> >> > +}
>> >> > +
>> >> >  static void
>> >> >  rs6000_xcoff_asm_globalize_label (FILE *stream, const char *name)
>> >> >  {
>> >> > diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h
>> >> > index 8b0cb27..263e239 100644
>> >> > --- a/gcc/config/rs6000/xcoff.h
>> >> > +++ b/gcc/config/rs6000/xcoff.h
>> >> > @@ -119,8 +119,7 @@
>> >> >  /* 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.  */
>> >> >
>> >> > -#define ASM_OUTPUT_LABEL(FILE,NAME)    \
>> >> > -  do { RS6000_OUTPUT_BASENAME (FILE, NAME); fputs (":\n", FILE); } while (0)
>> >> > +#define ASM_OUTPUT_LABEL rs6000_xcoff_output_label
>> >> >
>> >> >  /* This is how to output a command to make the user-level label named NAME
>> >> >     defined for reference from other files.  */
>> >> > diff --git a/gcc/config/spu/spu.h b/gcc/config/spu/spu.h
>> >> > index 25fa435..f35b55e 100644
>> >> > --- a/gcc/config/spu/spu.h
>> >> > +++ b/gcc/config/spu/spu.h
>> >> > @@ -443,8 +443,7 @@ do {                                                                        \
>> >> >
>> >> >
>> >> >  /* Label Output */
>> >> > -#define ASM_OUTPUT_LABEL(FILE,NAME)    \
>> >> > -  do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
>> >> > +#define ASM_OUTPUT_LABEL default_output_label
>> >> >
>> >> >  #define ASM_OUTPUT_LABELREF(FILE, NAME) \
>> >> >    asm_fprintf (FILE, "%U%s", default_strip_name_encoding (NAME))
>> >> > diff --git a/gcc/config/visium/visium.h b/gcc/config/visium/visium.h
>> >> > index a2ab61c..6457c55 100644
>> >> > --- a/gcc/config/visium/visium.h
>> >> > +++ b/gcc/config/visium/visium.h
>> >> > @@ -1440,8 +1440,7 @@ do                                                                        \
>> >> >     `assemble_name (STREAM, NAME)' to output the name itself; before
>> >> >     and after that, output the additional assembler syntax for defining
>> >> >     the name, and a newline. */
>> >> > -#define ASM_OUTPUT_LABEL(STREAM,NAME)     \
>> >> > -  do { assemble_name (STREAM, NAME); fputs (":\n", STREAM); } while (0)
>> >> > +#define ASM_OUTPUT_LABEL default_output_label
>> >> >
>> >> >  /* Globalizing directive for a label */
>> >> >  #define GLOBAL_ASM_OP "\t.global "
>> >> > diff --git a/gcc/defaults.h b/gcc/defaults.h
>> >> > index 3ecf9fd..b1465de 100644
>> >> > --- a/gcc/defaults.h
>> >> > +++ b/gcc/defaults.h
>> >> > @@ -89,11 +89,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>> >> >     NAME, such as the label on variable NAME.  */
>> >> >
>> >> >  #ifndef ASM_OUTPUT_LABEL
>> >> > -#define ASM_OUTPUT_LABEL(FILE,NAME) \
>> >> > -  do {                                         \
>> >> > -    assemble_name ((FILE), (NAME));            \
>> >> > -    fputs (":\n", (FILE));                     \
>> >> > -  } while (0)
>> >> > +#define ASM_OUTPUT_LABEL default_output_label
>> >> >  #endif
>> >> >
>> >> >  /* This is how to output the definition of a user-level label named
>> >> > diff --git a/gcc/output.h b/gcc/output.h
>> >> > index 8aa648a..07172d5 100644
>> >> > --- a/gcc/output.h
>> >> > +++ b/gcc/output.h
>> >> > @@ -246,6 +246,9 @@ extern void assemble_name_raw (FILE *, const char *);
>> >> >     be marked as referenced.  */
>> >> >  extern void assemble_name (FILE *, const char *);
>> >> >
>> >> > +/* Assemble a label.  */
>> >> > +extern void default_output_label (FILE *f, const char *label);
>> >> > +
>> >> >  /* Return the assembler directive for creating a given kind of integer
>> >> >     object.  SIZE is the number of bytes in the object and ALIGNED_P
>> >> >     indicates whether it is known to be aligned.  Return NULL if the
>> >> > diff --git a/gcc/varasm.c b/gcc/varasm.c
>> >> > index c2bfbf0..9c5f12d 100644
>> >> > --- a/gcc/varasm.c
>> >> > +++ b/gcc/varasm.c
>> >> > @@ -2580,6 +2580,15 @@ assemble_name (FILE *file, const char *name)
>> >> >    assemble_name_raw (file, name);
>> >> >  }
>> >> >
>> >> > +/* Assemble a label.  */
>> >> > +
>> >> > +void
>> >> > +default_output_label (FILE *f, const char *label)
>> >> > +{
>> >> > +  assemble_name (f, label);
>> >> > +  fputs (":\n", f);
>> >> > +}
>> >> > +
>> >> >  /* Allocate SIZE bytes writable static space with a gensym name
>> >> >     and return an RTX to refer to its address.  */
>> >> >
>> >> > diff --git a/gcc/vmsdbgout.c b/gcc/vmsdbgout.c
>> >> > index 0204740..d04b8fb 100644
>> >> > --- a/gcc/vmsdbgout.c
>> >> > +++ b/gcc/vmsdbgout.c
>> >> > @@ -37,6 +37,7 @@ along with GCC; see the file COPYING3.  If not see
>> >> >  #include "langhooks.h"
>> >> >  #include "function.h"
>> >> >  #include "target.h"
>> >> > +#include "tm_p.h"
>> >> >
>> >> >  /* Difference in seconds between the VMS Epoch and the Unix Epoch */
>> >> >  static const long long vms_epoch_offset = 3506716800ll;
>> >> > diff --git a/gcc/xcoffout.c b/gcc/xcoffout.c
>> >> > index 0f11115..83959c8 100644
>> >> > --- a/gcc/xcoffout.c
>> >> > +++ b/gcc/xcoffout.c
>> >> > @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3.  If not see
>> >> >  #include "output.h"
>> >> >  #include "target.h"
>> >> >  #include "debug.h"
>> >> > +#include "tm_p.h"
>> >> >
>> >> >  #ifdef XCOFF_DEBUGGING_INFO
>> >> >
>> >> > --
>> >> > 2.4.0
>> >> >

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-08-05 11:47       ` Richard Biener
  2015-08-05 13:38         ` Trevor Saunders
@ 2015-08-05 15:28         ` David Malcolm
  2015-08-05 15:34           ` David Malcolm
  1 sibling, 1 reply; 31+ messages in thread
From: David Malcolm @ 2015-08-05 15:28 UTC (permalink / raw)
  To: Richard Biener; +Cc: Trevor Saunders, tbsaunde+gcc, GCC Patches

On Wed, 2015-08-05 at 13:47 +0200, Richard Biener wrote:
> On Wed, Aug 5, 2015 at 12:57 PM, Trevor Saunders <tbsaunde@tbsaunde.org> wrote:
> > On Mon, Jul 27, 2015 at 11:06:58AM +0200, Richard Biener wrote:
> >> On Sat, Jul 25, 2015 at 4:37 AM,  <tbsaunde+gcc@tbsaunde.org> wrote:
> >> > From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
> >> >
> >> >         * config/arc/arc.h, config/bfin/bfin.h, config/frv/frv.h,
> >> >         config/ia64/ia64-protos.h, config/ia64/ia64.c, config/ia64/ia64.h,
> >> >         config/lm32/lm32.h, config/mep/mep.h, config/mmix/mmix.h,
> >> >         config/rs6000/rs6000.c, config/rs6000/xcoff.h, config/spu/spu.h,
> >> >         config/visium/visium.h, defaults.h: Define ASM_OUTPUT_LABEL to
> >> > the name of a function.
> >> >         * output.h (default_output_label): New prototype.
> >> >         * varasm.c (default_output_label): New function.
> >> >         * vmsdbgout.c: Include tm_p.h.
> >> >         * xcoffout.c: Likewise.
> >>
> >> Just a general remark - the GCC output machinery is known to be slow,
> >> adding indirect calls might be not the very best idea without refactoring
> >> some of it.
> >>
> >> Did you do any performance measurements for artificial testcases
> >> exercising the specific bits you change?
> >
> > sorry about the delay, but I finally got a chance to do some perf tests
> > of the first patch.  I took three test cases fold-const.ii, insn-emit.ii
> > and a random .i from firefox and did 3 trials of the length of 100
> > compilations.  The only non default flag was -std=gnu++11.
> >
> > results before patch hookizing output_ascii
> >
> > fold-const.ii
> > real    3m18.051s
> > user    2m41.340s
> > sys     0m36.544s
> > real    3m18.141s
> > user    2m42.236s
> > sys     0m35.740s
> > real    3m18.297s
> > user    2m42.316s
> > sys     0m35.804s
> >
> > insn-emit.ii
> > real    9m58.229s
> > user    8m26.960s
> > sys     1m31.224s
> > real    9m57.857s
> > user    8m24.616s
> > sys     1m33.072s
> > real    9m57.922s
> > user    8m25.232s
> > sys     1m32.512s
> >
> > mozilla.ii
> > real    8m5.732s
> > user    6m44.888s
> > sys     1m20.764s
> > real    8m5.404s
> > user    6m44.468s
> > sys     1m20.856s
> > real    7m59.197s
> > user    6m39.632s
> > sys     1m19.472s
> >
> > after patch
> >
> > fold-const.ii
> > real    3m18.488s
> > user    2m41.972s
> > sys     0m36.388s
> > real    3m18.215s
> > user    2m41.640s
> > sys     0m36.432s
> > real    3m18.368s
> > user    2m42.492s
> > sys     0m35.720s
> >
> > insn-emit.ii
> > real    10m4.700s
> > user    8m32.536s
> > sys     1m32.120s
> > real    10m4.241s
> > user    8m31.456s
> > sys     1m32.728s
> > real    10m4.515s
> > user    8m32.056s
> > sys     1m32.396s
> >
> > mozilla.ii
> > real    7m58.018s
> > user    6m38.008s
> > sys     1m19.924s
> > real    7m59.269s
> > user    6m37.736s
> > sys     1m21.448s
> > real    7m58.254s
> > user    6m37.828s
> > sys     1m20.324s
> >
> > So, roughly that looks to me like a range from improving by .5% to
> > regressing by 1%.  I'm not sure what could cause an improvement, so I
> > kind of wonder how valid these results are.
> 
> Hmm, indeed.  The speedup looks suspicious.
> 
> > Another question is how one can refactor the output machinary to be
> > faster.  My first  thought is to buffer text internally before calling
> > stdio functions, but that seems like a giant job.
> 
> stdio functions are already buffering, so I don't know either.
> 
> But yes, going the libas route would improve things here, or for
> example enhancing gas to be able to eat target binary data
> without the need to encode it in printable characters...
> 
> .raw_data number-of-bytes
> <raw data>
> 
> Makes it quite unparsable to editors of course ...

A middle-ground might be to do both:

.raw_data number-of-bytes
<raw data>


> Richard.
> 
> > thanks!
> >
> > Trev
> >
> > far outside of noise,
> >>
> >> Richard.
> >>
> >> > ---
> >> >  gcc/config/arc/arc.h              |  3 +--
> >> >  gcc/config/bfin/bfin.h            |  5 +----
> >> >  gcc/config/frv/frv.h              |  6 +-----
> >> >  gcc/config/ia64/ia64-protos.h     |  1 +
> >> >  gcc/config/ia64/ia64.c            | 11 +++++++++++
> >> >  gcc/config/ia64/ia64.h            |  8 +-------
> >> >  gcc/config/lm32/lm32.h            |  3 +--
> >> >  gcc/config/mep/mep.h              |  8 +-------
> >> >  gcc/config/mmix/mmix.h            |  3 +--
> >> >  gcc/config/pa/pa-protos.h         |  1 +
> >> >  gcc/config/pa/pa.c                | 12 ++++++++++++
> >> >  gcc/config/pa/pa.h                |  9 +--------
> >> >  gcc/config/rs6000/rs6000-protos.h |  1 +
> >> >  gcc/config/rs6000/rs6000.c        |  8 ++++++++
> >> >  gcc/config/rs6000/xcoff.h         |  3 +--
> >> >  gcc/config/spu/spu.h              |  3 +--
> >> >  gcc/config/visium/visium.h        |  3 +--
> >> >  gcc/defaults.h                    |  6 +-----
> >> >  gcc/output.h                      |  3 +++
> >> >  gcc/varasm.c                      |  9 +++++++++
> >> >  gcc/vmsdbgout.c                   |  1 +
> >> >  gcc/xcoffout.c                    |  1 +
> >> >  22 files changed, 60 insertions(+), 48 deletions(-)
> >> >
> >> > diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h
> >> > index d98cce1..d3747b9 100644
> >> > --- a/gcc/config/arc/arc.h
> >> > +++ b/gcc/config/arc/arc.h
> >> > @@ -1245,8 +1245,7 @@ do {                                                                      \
> >> >
> >> >  /* 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.  */
> >> > -#define ASM_OUTPUT_LABEL(FILE, NAME) \
> >> > -do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
> >> > +#define ASM_OUTPUT_LABEL default_output_label
> >> >
> >> >  #define ASM_NAME_P(NAME) ( NAME[0]=='*')
> >> >
> >> > diff --git a/gcc/config/bfin/bfin.h b/gcc/config/bfin/bfin.h
> >> > index 26ba7c2..08906aa 100644
> >> > --- a/gcc/config/bfin/bfin.h
> >> > +++ b/gcc/config/bfin/bfin.h
> >> > @@ -1044,10 +1044,7 @@ typedef enum directives {
> >> >      ASM_OUTPUT_LABEL(FILE, NAME);      \
> >> >    } while (0)
> >> >
> >> > -#define ASM_OUTPUT_LABEL(FILE, NAME)    \
> >> > -  do {  assemble_name (FILE, NAME);            \
> >> > -        fputs (":\n",FILE);                    \
> >> > -      } while (0)
> >> > +#define ASM_OUTPUT_LABEL default_output_label
> >> >
> >> >  #define ASM_OUTPUT_LABELREF(FILE,NAME)         \
> >> >      do {  fprintf (FILE, "_%s", NAME); \
> >> > diff --git a/gcc/config/frv/frv.h b/gcc/config/frv/frv.h
> >> > index b0d66fd..1d25974 100644
> >> > --- a/gcc/config/frv/frv.h
> >> > +++ b/gcc/config/frv/frv.h
> >> > @@ -1668,11 +1668,7 @@ do {                                                                     \
> >> >     `assemble_name (STREAM, NAME)' to output the name itself; before and after
> >> >     that, output the additional assembler syntax for defining the name, and a
> >> >     newline.  */
> >> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)                                 \
> >> > -do {                                                                   \
> >> > -  assemble_name (STREAM, NAME);                                                \
> >> > -  fputs (":\n", STREAM);                                               \
> >> > -} while (0)
> >> > +#define ASM_OUTPUT_LABEL default_output_label
> >> >
> >> >  /* Globalizing directive for a label.  */
> >> >  #define GLOBAL_ASM_OP "\t.globl "
> >> > diff --git a/gcc/config/ia64/ia64-protos.h b/gcc/config/ia64/ia64-protos.h
> >> > index 29fc714..8e540e4 100644
> >> > --- a/gcc/config/ia64/ia64-protos.h
> >> > +++ b/gcc/config/ia64/ia64-protos.h
> >> > @@ -72,6 +72,7 @@ extern rtx ia64_expand_builtin (tree, rtx, rtx, machine_mode, int);
> >> >  extern rtx ia64_va_arg (tree, tree);
> >> >  #endif /* RTX_CODE */
> >> >
> >> > +extern void ia64_output_label (FILE *f, const char *label);
> >> >  extern void ia64_asm_output_external (FILE *, tree, const char *);
> >> >  extern void ia64_vms_output_aligned_decl_common (FILE *, tree, const char *,
> >> >                                                  unsigned HOST_WIDE_INT,
> >> > diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
> >> > index 779fc58..e07ebb5 100644
> >> > --- a/gcc/config/ia64/ia64.c
> >> > +++ b/gcc/config/ia64/ia64.c
> >> > @@ -10522,6 +10522,17 @@ ia64_hpux_function_arg_padding (machine_mode mode, const_tree type)
> >> >     return DEFAULT_FUNCTION_ARG_PADDING (mode, type);
> >> >  }
> >> >
> >> > +/* Assemble a label.  */
> >> > +
> >> > +void
> >> > +ia64_output_label (FILE *f, const char *label)
> >> > +{
> >> > +  ia64_asm_output_label = 1;
> >> > +  assemble_name (f, label);
> >> > +  fputs (":\n", f);
> >> > +  ia64_asm_output_label = 0;
> >> > +}
> >> > +
> >> >  /* Emit text to declare externally defined variables and functions, because
> >> >     the Intel assembler does not support undefined externals.  */
> >> >
> >> > diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h
> >> > index 4b62423..1afa7b7 100644
> >> > --- a/gcc/config/ia64/ia64.h
> >> > +++ b/gcc/config/ia64/ia64.h
> >> > @@ -1246,13 +1246,7 @@ do {                                                                     \
> >> >     why ia64_asm_output_label exists.  */
> >> >
> >> >  extern int ia64_asm_output_label;
> >> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)                                 \
> >> > -do {                                                                   \
> >> > -  ia64_asm_output_label = 1;                                           \
> >> > -  assemble_name (STREAM, NAME);                                                \
> >> > -  fputs (":\n", STREAM);                                               \
> >> > -  ia64_asm_output_label = 0;                                           \
> >> > -} while (0)
> >> > +#define ASM_OUTPUT_LABEL ia64_output_label
> >> >
> >> >  /* Globalizing directive for a label.  */
> >> >  #define GLOBAL_ASM_OP "\t.global "
> >> > diff --git a/gcc/config/lm32/lm32.h b/gcc/config/lm32/lm32.h
> >> > index 986383f..9e8c667 100644
> >> > --- a/gcc/config/lm32/lm32.h
> >> > +++ b/gcc/config/lm32/lm32.h
> >> > @@ -443,8 +443,7 @@ do                                                                  \
> >> >  }                                                                      \
> >> >  while (0)
> >> >
> >> > -#define ASM_OUTPUT_LABEL(FILE, NAME) \
> >> > -  do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
> >> > +#define ASM_OUTPUT_LABEL default_output_label
> >> >
> >> >  #define ASM_OUTPUT_LABELREF(FILE,NAME) \
> >> >    do {                                 \
> >> > diff --git a/gcc/config/mep/mep.h b/gcc/config/mep/mep.h
> >> > index f7322cb7..8a9d447 100644
> >> > --- a/gcc/config/mep/mep.h
> >> > +++ b/gcc/config/mep/mep.h
> >> > @@ -625,13 +625,7 @@ typedef struct
> >> >  #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
> >> >         mep_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 0)
> >> >
> >> > -#define ASM_OUTPUT_LABEL(STREAM, NAME)         \
> >> > -  do                                           \
> >> > -    {                                          \
> >> > -      assemble_name (STREAM, NAME);            \
> >> > -      fputs (":\n", STREAM);                   \
> >> > -    }                                          \
> >> > -  while (0)
> >> > +#define ASM_OUTPUT_LABEL default_output_label
> >> >
> >> >  /* Globalizing directive for a label.  */
> >> >  #define GLOBAL_ASM_OP "\t.globl "
> >> > diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h
> >> > index 29d39bc..aac5aa0 100644
> >> > --- a/gcc/config/mmix/mmix.h
> >> > +++ b/gcc/config/mmix/mmix.h
> >> > @@ -647,8 +647,7 @@ typedef struct { int regs; int lib; } CUMULATIVE_ARGS;
> >> >
> >> >  /* Node: Label Output */
> >> >
> >> > -#define ASM_OUTPUT_LABEL(STREAM, NAME) \
> >> > - mmix_asm_output_label (STREAM, NAME)
> >> > +#define ASM_OUTPUT_LABEL mmix_asm_output_label
> >> >
> >> >  #define ASM_OUTPUT_INTERNAL_LABEL(STREAM, NAME) \
> >> >   mmix_asm_output_internal_label (STREAM, NAME)
> >> > diff --git a/gcc/config/pa/pa-protos.h b/gcc/config/pa/pa-protos.h
> >> > index 0e13cd5..46a3e3b 100644
> >> > --- a/gcc/config/pa/pa-protos.h
> >> > +++ b/gcc/config/pa/pa-protos.h
> >> > @@ -110,6 +110,7 @@ extern void pa_asm_output_aligned_common (FILE *, const char *,
> >> >  extern void pa_asm_output_aligned_local (FILE *, const char *,
> >> >                                          unsigned HOST_WIDE_INT,
> >> >                                          unsigned int);
> >> > +extern void pa_output_label (FILE *f, const char *label);
> >> >  extern void pa_hpux_asm_output_external (FILE *, tree, const char *);
> >> >  extern bool pa_cannot_change_mode_class (machine_mode, machine_mode,
> >> >                                          enum reg_class);
> >> > diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c
> >> > index b24413a..2bcaa7e 100644
> >> > --- a/gcc/config/pa/pa.c
> >> > +++ b/gcc/config/pa/pa.c
> >> > @@ -9761,6 +9761,18 @@ pa_reloc_rw_mask (void)
> >> >    return 3;
> >> >  }
> >> >
> >> > +/* Assemble a lable.  */
> >> > +
> >> > +void
> >> > +pa_output_label (FILE *f, const char *label)
> >> > +{
> >> > +  assemble_name (f, label);
> >> > +  if (TARGET_GAS)
> >> > +    fputs (":\n", f);
> >> > +  else
> >> > +    fputc ('\n', (f));
> >> > +}
> >> > +
> >> >  static void
> >> >  pa_globalize_label (FILE *stream, const char *name)
> >> >  {
> >> > diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h
> >> > index bdfbb16..595a10b 100644
> >> > --- a/gcc/config/pa/pa.h
> >> > +++ b/gcc/config/pa/pa.h
> >> > @@ -1107,14 +1107,7 @@ do {                                                                          \
> >> >  /* 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.  */
> >> >
> >> > -#define ASM_OUTPUT_LABEL(FILE,NAME) \
> >> > -  do {                                                 \
> >> > -    assemble_name ((FILE), (NAME));                    \
> >> > -    if (TARGET_GAS)                                    \
> >> > -      fputs (":\n", (FILE));                           \
> >> > -    else                                               \
> >> > -      fputc ('\n', (FILE));                            \
> >> > -  } while (0)
> >> > +#define ASM_OUTPUT_LABEL pa_output_label
> >> >
> >> >  /* This is how to output a reference to a user-level label named NAME.
> >> >     `assemble_name' uses this.  */
> >> > diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h
> >> > index 560a825..031614f 100644
> >> > --- a/gcc/config/rs6000/rs6000-protos.h
> >> > +++ b/gcc/config/rs6000/rs6000-protos.h
> >> > @@ -169,6 +169,7 @@ extern int function_ok_for_sibcall (tree);
> >> >  extern int rs6000_reg_parm_stack_space (tree, bool);
> >> >  extern void rs6000_xcoff_declare_function_name (FILE *, const char *, tree);
> >> >  extern void rs6000_xcoff_declare_object_name (FILE *, const char *, tree);
> >> > +extern void rs6000_xcoff_output_label (FILE *f, const char *label);
> >> >  extern void rs6000_elf_declare_function_name (FILE *, const char *, tree);
> >> >  extern bool rs6000_elf_in_small_data_p (const_tree);
> >> >  #ifdef ARGS_SIZE_RTX
> >> > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> >> > index c8794b4..a214010 100644
> >> > --- a/gcc/config/rs6000/rs6000.c
> >> > +++ b/gcc/config/rs6000/rs6000.c
> >> > @@ -30364,6 +30364,14 @@ rs6000_xcoff_asm_output_anchor (rtx symbol)
> >> >    fprintf (asm_out_file, "\n");
> >> >  }
> >> >
> >> > +/* Assemble the given label.  */
> >> > +void
> >> > +rs6000_xcoff_output_label (FILE *f, const char *label)
> >> > +{
> >> > +  RS6000_OUTPUT_BASENAME (f, label);
> >> > +  fputs (":\n", f);
> >> > +}
> >> > +
> >> >  static void
> >> >  rs6000_xcoff_asm_globalize_label (FILE *stream, const char *name)
> >> >  {
> >> > diff --git a/gcc/config/rs6000/xcoff.h b/gcc/config/rs6000/xcoff.h
> >> > index 8b0cb27..263e239 100644
> >> > --- a/gcc/config/rs6000/xcoff.h
> >> > +++ b/gcc/config/rs6000/xcoff.h
> >> > @@ -119,8 +119,7 @@
> >> >  /* 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.  */
> >> >
> >> > -#define ASM_OUTPUT_LABEL(FILE,NAME)    \
> >> > -  do { RS6000_OUTPUT_BASENAME (FILE, NAME); fputs (":\n", FILE); } while (0)
> >> > +#define ASM_OUTPUT_LABEL rs6000_xcoff_output_label
> >> >
> >> >  /* This is how to output a command to make the user-level label named NAME
> >> >     defined for reference from other files.  */
> >> > diff --git a/gcc/config/spu/spu.h b/gcc/config/spu/spu.h
> >> > index 25fa435..f35b55e 100644
> >> > --- a/gcc/config/spu/spu.h
> >> > +++ b/gcc/config/spu/spu.h
> >> > @@ -443,8 +443,7 @@ do {                                                                        \
> >> >
> >> >
> >> >  /* Label Output */
> >> > -#define ASM_OUTPUT_LABEL(FILE,NAME)    \
> >> > -  do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0)
> >> > +#define ASM_OUTPUT_LABEL default_output_label
> >> >
> >> >  #define ASM_OUTPUT_LABELREF(FILE, NAME) \
> >> >    asm_fprintf (FILE, "%U%s", default_strip_name_encoding (NAME))
> >> > diff --git a/gcc/config/visium/visium.h b/gcc/config/visium/visium.h
> >> > index a2ab61c..6457c55 100644
> >> > --- a/gcc/config/visium/visium.h
> >> > +++ b/gcc/config/visium/visium.h
> >> > @@ -1440,8 +1440,7 @@ do                                                                        \
> >> >     `assemble_name (STREAM, NAME)' to output the name itself; before
> >> >     and after that, output the additional assembler syntax for defining
> >> >     the name, and a newline. */
> >> > -#define ASM_OUTPUT_LABEL(STREAM,NAME)     \
> >> > -  do { assemble_name (STREAM, NAME); fputs (":\n", STREAM); } while (0)
> >> > +#define ASM_OUTPUT_LABEL default_output_label
> >> >
> >> >  /* Globalizing directive for a label */
> >> >  #define GLOBAL_ASM_OP "\t.global "
> >> > diff --git a/gcc/defaults.h b/gcc/defaults.h
> >> > index 3ecf9fd..b1465de 100644
> >> > --- a/gcc/defaults.h
> >> > +++ b/gcc/defaults.h
> >> > @@ -89,11 +89,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
> >> >     NAME, such as the label on variable NAME.  */
> >> >
> >> >  #ifndef ASM_OUTPUT_LABEL
> >> > -#define ASM_OUTPUT_LABEL(FILE,NAME) \
> >> > -  do {                                         \
> >> > -    assemble_name ((FILE), (NAME));            \
> >> > -    fputs (":\n", (FILE));                     \
> >> > -  } while (0)
> >> > +#define ASM_OUTPUT_LABEL default_output_label
> >> >  #endif
> >> >
> >> >  /* This is how to output the definition of a user-level label named
> >> > diff --git a/gcc/output.h b/gcc/output.h
> >> > index 8aa648a..07172d5 100644
> >> > --- a/gcc/output.h
> >> > +++ b/gcc/output.h
> >> > @@ -246,6 +246,9 @@ extern void assemble_name_raw (FILE *, const char *);
> >> >     be marked as referenced.  */
> >> >  extern void assemble_name (FILE *, const char *);
> >> >
> >> > +/* Assemble a label.  */
> >> > +extern void default_output_label (FILE *f, const char *label);
> >> > +
> >> >  /* Return the assembler directive for creating a given kind of integer
> >> >     object.  SIZE is the number of bytes in the object and ALIGNED_P
> >> >     indicates whether it is known to be aligned.  Return NULL if the
> >> > diff --git a/gcc/varasm.c b/gcc/varasm.c
> >> > index c2bfbf0..9c5f12d 100644
> >> > --- a/gcc/varasm.c
> >> > +++ b/gcc/varasm.c
> >> > @@ -2580,6 +2580,15 @@ assemble_name (FILE *file, const char *name)
> >> >    assemble_name_raw (file, name);
> >> >  }
> >> >
> >> > +/* Assemble a label.  */
> >> > +
> >> > +void
> >> > +default_output_label (FILE *f, const char *label)
> >> > +{
> >> > +  assemble_name (f, label);
> >> > +  fputs (":\n", f);
> >> > +}
> >> > +
> >> >  /* Allocate SIZE bytes writable static space with a gensym name
> >> >     and return an RTX to refer to its address.  */
> >> >
> >> > diff --git a/gcc/vmsdbgout.c b/gcc/vmsdbgout.c
> >> > index 0204740..d04b8fb 100644
> >> > --- a/gcc/vmsdbgout.c
> >> > +++ b/gcc/vmsdbgout.c
> >> > @@ -37,6 +37,7 @@ along with GCC; see the file COPYING3.  If not see
> >> >  #include "langhooks.h"
> >> >  #include "function.h"
> >> >  #include "target.h"
> >> > +#include "tm_p.h"
> >> >
> >> >  /* Difference in seconds between the VMS Epoch and the Unix Epoch */
> >> >  static const long long vms_epoch_offset = 3506716800ll;
> >> > diff --git a/gcc/xcoffout.c b/gcc/xcoffout.c
> >> > index 0f11115..83959c8 100644
> >> > --- a/gcc/xcoffout.c
> >> > +++ b/gcc/xcoffout.c
> >> > @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3.  If not see
> >> >  #include "output.h"
> >> >  #include "target.h"
> >> >  #include "debug.h"
> >> > +#include "tm_p.h"
> >> >
> >> >  #ifdef XCOFF_DEBUGGING_INFO
> >> >
> >> > --
> >> > 2.4.0
> >> >


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-08-05 15:28         ` David Malcolm
@ 2015-08-05 15:34           ` David Malcolm
  2015-08-05 20:23             ` Trevor Saunders
  0 siblings, 1 reply; 31+ messages in thread
From: David Malcolm @ 2015-08-05 15:34 UTC (permalink / raw)
  To: Richard Biener; +Cc: Trevor Saunders, tbsaunde+gcc, GCC Patches

On Wed, 2015-08-05 at 11:28 -0400, David Malcolm wrote:
> On Wed, 2015-08-05 at 13:47 +0200, Richard Biener wrote:
> > On Wed, Aug 5, 2015 at 12:57 PM, Trevor Saunders <tbsaunde@tbsaunde.org> wrote:
> > > On Mon, Jul 27, 2015 at 11:06:58AM +0200, Richard Biener wrote:
> > >> On Sat, Jul 25, 2015 at 4:37 AM,  <tbsaunde+gcc@tbsaunde.org> wrote:
> > >> > From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
> > >> >
> > >> >         * config/arc/arc.h, config/bfin/bfin.h, config/frv/frv.h,
> > >> >         config/ia64/ia64-protos.h, config/ia64/ia64.c, config/ia64/ia64.h,
> > >> >         config/lm32/lm32.h, config/mep/mep.h, config/mmix/mmix.h,
> > >> >         config/rs6000/rs6000.c, config/rs6000/xcoff.h, config/spu/spu.h,
> > >> >         config/visium/visium.h, defaults.h: Define ASM_OUTPUT_LABEL to
> > >> > the name of a function.
> > >> >         * output.h (default_output_label): New prototype.
> > >> >         * varasm.c (default_output_label): New function.
> > >> >         * vmsdbgout.c: Include tm_p.h.
> > >> >         * xcoffout.c: Likewise.
> > >>
> > >> Just a general remark - the GCC output machinery is known to be slow,
> > >> adding indirect calls might be not the very best idea without refactoring
> > >> some of it.
> > >>
> > >> Did you do any performance measurements for artificial testcases
> > >> exercising the specific bits you change?
> > >
> > > sorry about the delay, but I finally got a chance to do some perf tests
> > > of the first patch.  I took three test cases fold-const.ii, insn-emit.ii
> > > and a random .i from firefox and did 3 trials of the length of 100
> > > compilations.  The only non default flag was -std=gnu++11.
> > >
> > > results before patch hookizing output_ascii
> > >
> > > fold-const.ii
> > > real    3m18.051s
> > > user    2m41.340s
> > > sys     0m36.544s
> > > real    3m18.141s
> > > user    2m42.236s
> > > sys     0m35.740s
> > > real    3m18.297s
> > > user    2m42.316s
> > > sys     0m35.804s
> > >
> > > insn-emit.ii
> > > real    9m58.229s
> > > user    8m26.960s
> > > sys     1m31.224s
> > > real    9m57.857s
> > > user    8m24.616s
> > > sys     1m33.072s
> > > real    9m57.922s
> > > user    8m25.232s
> > > sys     1m32.512s
> > >
> > > mozilla.ii
> > > real    8m5.732s
> > > user    6m44.888s
> > > sys     1m20.764s
> > > real    8m5.404s
> > > user    6m44.468s
> > > sys     1m20.856s
> > > real    7m59.197s
> > > user    6m39.632s
> > > sys     1m19.472s
> > >
> > > after patch
> > >
> > > fold-const.ii
> > > real    3m18.488s
> > > user    2m41.972s
> > > sys     0m36.388s
> > > real    3m18.215s
> > > user    2m41.640s
> > > sys     0m36.432s
> > > real    3m18.368s
> > > user    2m42.492s
> > > sys     0m35.720s
> > >
> > > insn-emit.ii
> > > real    10m4.700s
> > > user    8m32.536s
> > > sys     1m32.120s
> > > real    10m4.241s
> > > user    8m31.456s
> > > sys     1m32.728s
> > > real    10m4.515s
> > > user    8m32.056s
> > > sys     1m32.396s
> > >
> > > mozilla.ii
> > > real    7m58.018s
> > > user    6m38.008s
> > > sys     1m19.924s
> > > real    7m59.269s
> > > user    6m37.736s
> > > sys     1m21.448s
> > > real    7m58.254s
> > > user    6m37.828s
> > > sys     1m20.324s
> > >
> > > So, roughly that looks to me like a range from improving by .5% to
> > > regressing by 1%.  I'm not sure what could cause an improvement, so I
> > > kind of wonder how valid these results are.
> > 
> > Hmm, indeed.  The speedup looks suspicious.
> > 
> > > Another question is how one can refactor the output machinary to be
> > > faster.  My first  thought is to buffer text internally before calling
> > > stdio functions, but that seems like a giant job.
> > 
> > stdio functions are already buffering, so I don't know either.
> > 
> > But yes, going the libas route would improve things here, or for
> > example enhancing gas to be able to eat target binary data
> > without the need to encode it in printable characters...
> > 
> > .raw_data number-of-bytes
> > <raw data>
> > 
> > Makes it quite unparsable to editors of course ...
> 
> A middle-ground might be to do both:
> 
> .raw_data number-of-bytes
> <raw data>

Sorry, I hit "Send" too early; I meant something like this as a
middle-ground:

  .raw_data number-of-bytes
  <raw data>

  ; comment giving the formatted text

so that cc1 etc are doing the formatting work to make the comment, so
that human readers can see what the raw data is meant to be, but the
assembler doesn't have to do work to parse it.

FWIW, I once had a go at hiding asm_out_file behind a class interface,
trying to build up higher-level methods on top of raw text printing.
Maybe that's a viable migration strategy  (I didn't finish that patch).

[...]

Dave

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-08-05 15:34           ` David Malcolm
@ 2015-08-05 20:23             ` Trevor Saunders
  2015-08-06 18:48               ` David Malcolm
  0 siblings, 1 reply; 31+ messages in thread
From: Trevor Saunders @ 2015-08-05 20:23 UTC (permalink / raw)
  To: David Malcolm; +Cc: Richard Biener, tbsaunde+gcc, GCC Patches

On Wed, Aug 05, 2015 at 11:34:28AM -0400, David Malcolm wrote:
> On Wed, 2015-08-05 at 11:28 -0400, David Malcolm wrote:
> > On Wed, 2015-08-05 at 13:47 +0200, Richard Biener wrote:
> > > On Wed, Aug 5, 2015 at 12:57 PM, Trevor Saunders <tbsaunde@tbsaunde.org> wrote:
> > > > On Mon, Jul 27, 2015 at 11:06:58AM +0200, Richard Biener wrote:
> > > >> On Sat, Jul 25, 2015 at 4:37 AM,  <tbsaunde+gcc@tbsaunde.org> wrote:
> > > >> > From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
> > > >> >
> > > >> >         * config/arc/arc.h, config/bfin/bfin.h, config/frv/frv.h,
> > > >> >         config/ia64/ia64-protos.h, config/ia64/ia64.c, config/ia64/ia64.h,
> > > >> >         config/lm32/lm32.h, config/mep/mep.h, config/mmix/mmix.h,
> > > >> >         config/rs6000/rs6000.c, config/rs6000/xcoff.h, config/spu/spu.h,
> > > >> >         config/visium/visium.h, defaults.h: Define ASM_OUTPUT_LABEL to
> > > >> > the name of a function.
> > > >> >         * output.h (default_output_label): New prototype.
> > > >> >         * varasm.c (default_output_label): New function.
> > > >> >         * vmsdbgout.c: Include tm_p.h.
> > > >> >         * xcoffout.c: Likewise.
> > > >>
> > > >> Just a general remark - the GCC output machinery is known to be slow,
> > > >> adding indirect calls might be not the very best idea without refactoring
> > > >> some of it.
> > > >>
> > > >> Did you do any performance measurements for artificial testcases
> > > >> exercising the specific bits you change?
> > > >
> > > > sorry about the delay, but I finally got a chance to do some perf tests
> > > > of the first patch.  I took three test cases fold-const.ii, insn-emit.ii
> > > > and a random .i from firefox and did 3 trials of the length of 100
> > > > compilations.  The only non default flag was -std=gnu++11.
> > > >
> > > > results before patch hookizing output_ascii
> > > >
> > > > fold-const.ii
> > > > real    3m18.051s
> > > > user    2m41.340s
> > > > sys     0m36.544s
> > > > real    3m18.141s
> > > > user    2m42.236s
> > > > sys     0m35.740s
> > > > real    3m18.297s
> > > > user    2m42.316s
> > > > sys     0m35.804s
> > > >
> > > > insn-emit.ii
> > > > real    9m58.229s
> > > > user    8m26.960s
> > > > sys     1m31.224s
> > > > real    9m57.857s
> > > > user    8m24.616s
> > > > sys     1m33.072s
> > > > real    9m57.922s
> > > > user    8m25.232s
> > > > sys     1m32.512s
> > > >
> > > > mozilla.ii
> > > > real    8m5.732s
> > > > user    6m44.888s
> > > > sys     1m20.764s
> > > > real    8m5.404s
> > > > user    6m44.468s
> > > > sys     1m20.856s
> > > > real    7m59.197s
> > > > user    6m39.632s
> > > > sys     1m19.472s
> > > >
> > > > after patch
> > > >
> > > > fold-const.ii
> > > > real    3m18.488s
> > > > user    2m41.972s
> > > > sys     0m36.388s
> > > > real    3m18.215s
> > > > user    2m41.640s
> > > > sys     0m36.432s
> > > > real    3m18.368s
> > > > user    2m42.492s
> > > > sys     0m35.720s
> > > >
> > > > insn-emit.ii
> > > > real    10m4.700s
> > > > user    8m32.536s
> > > > sys     1m32.120s
> > > > real    10m4.241s
> > > > user    8m31.456s
> > > > sys     1m32.728s
> > > > real    10m4.515s
> > > > user    8m32.056s
> > > > sys     1m32.396s
> > > >
> > > > mozilla.ii
> > > > real    7m58.018s
> > > > user    6m38.008s
> > > > sys     1m19.924s
> > > > real    7m59.269s
> > > > user    6m37.736s
> > > > sys     1m21.448s
> > > > real    7m58.254s
> > > > user    6m37.828s
> > > > sys     1m20.324s
> > > >
> > > > So, roughly that looks to me like a range from improving by .5% to
> > > > regressing by 1%.  I'm not sure what could cause an improvement, so I
> > > > kind of wonder how valid these results are.
> > > 
> > > Hmm, indeed.  The speedup looks suspicious.
> > > 
> > > > Another question is how one can refactor the output machinary to be
> > > > faster.  My first  thought is to buffer text internally before calling
> > > > stdio functions, but that seems like a giant job.
> > > 
> > > stdio functions are already buffering, so I don't know either.
> > > 
> > > But yes, going the libas route would improve things here, or for
> > > example enhancing gas to be able to eat target binary data
> > > without the need to encode it in printable characters...
> > > 
> > > .raw_data number-of-bytes
> > > <raw data>
> > > 
> > > Makes it quite unparsable to editors of course ...
> > 
> > A middle-ground might be to do both:
> > 
> > .raw_data number-of-bytes
> > <raw data>
> 
> Sorry, I hit "Send" too early; I meant something like this as a
> middle-ground:
> 
>   .raw_data number-of-bytes
>   <raw data>
> 
>   ; comment giving the formatted text
> 
> so that cc1 etc are doing the formatting work to make the comment, so
> that human readers can see what the raw data is meant to be, but the
> assembler doesn't have to do work to parse it.

well, having random bytes in the file might still screw up editors, and
I'd kind of expect that to be slower over all since gcc still does the
formating, and both gcc and as do more IO.

> FWIW, I once had a go at hiding asm_out_file behind a class interface,
> trying to build up higher-level methods on top of raw text printing.
> Maybe that's a viable migration strategy  (I didn't finish that patch).

I was thinking about trying that, but I couldn't think of a good way to
do it incrementally.

Trev

> 
> [...]
> 
> Dave
> 

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-08-05 13:59           ` Richard Biener
@ 2015-08-05 22:28             ` Segher Boessenkool
  0 siblings, 0 replies; 31+ messages in thread
From: Segher Boessenkool @ 2015-08-05 22:28 UTC (permalink / raw)
  To: Richard Biener; +Cc: Trevor Saunders, tbsaunde+gcc, GCC Patches

On Wed, Aug 05, 2015 at 03:59:18PM +0200, Richard Biener wrote:
> >> Makes it quite unparsable to editors of course ...
> >
> > The idea of having .S files that aren't reasonably editable seems kind
> > of silly, but I guess its up to the gas people.
> 
> Heh, indeed.  Maybe instead do
> 
> .insert_from_file  <filename>
> 
> and do that only when we are using -pipe or so.

That's ".incbin".  Do we really want to go through the headaches of using
extra files though?  Is this really a bottleneck?  Will it even help?


Segher

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-08-05 20:23             ` Trevor Saunders
@ 2015-08-06 18:48               ` David Malcolm
  2015-08-06 19:36                 ` Richard Sandiford
  0 siblings, 1 reply; 31+ messages in thread
From: David Malcolm @ 2015-08-06 18:48 UTC (permalink / raw)
  To: Trevor Saunders; +Cc: Richard Biener, tbsaunde+gcc, GCC Patches

[-- Attachment #1: Type: text/plain, Size: 5335 bytes --]

On Wed, 2015-08-05 at 16:22 -0400, Trevor Saunders wrote:
> On Wed, Aug 05, 2015 at 11:34:28AM -0400, David Malcolm wrote:
> > On Wed, 2015-08-05 at 11:28 -0400, David Malcolm wrote:
> > > On Wed, 2015-08-05 at 13:47 +0200, Richard Biener wrote:
> > > > On Wed, Aug 5, 2015 at 12:57 PM, Trevor Saunders <tbsaunde@tbsaunde.org> wrote:
> > > > > On Mon, Jul 27, 2015 at 11:06:58AM +0200, Richard Biener wrote:
> > > > >> On Sat, Jul 25, 2015 at 4:37 AM,  <tbsaunde+gcc@tbsaunde.org> wrote:
> > > > >> > From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
> > > > >> >
> > > > >> >         * config/arc/arc.h, config/bfin/bfin.h, config/frv/frv.h,
> > > > >> >         config/ia64/ia64-protos.h, config/ia64/ia64.c, config/ia64/ia64.h,
> > > > >> >         config/lm32/lm32.h, config/mep/mep.h, config/mmix/mmix.h,
> > > > >> >         config/rs6000/rs6000.c, config/rs6000/xcoff.h, config/spu/spu.h,
> > > > >> >         config/visium/visium.h, defaults.h: Define ASM_OUTPUT_LABEL to
> > > > >> > the name of a function.
> > > > >> >         * output.h (default_output_label): New prototype.
> > > > >> >         * varasm.c (default_output_label): New function.
> > > > >> >         * vmsdbgout.c: Include tm_p.h.
> > > > >> >         * xcoffout.c: Likewise.
> > > > >>
> > > > >> Just a general remark - the GCC output machinery is known to be slow,
> > > > >> adding indirect calls might be not the very best idea without refactoring
> > > > >> some of it.
> > > > >>
> > > > >> Did you do any performance measurements for artificial testcases
> > > > >> exercising the specific bits you change?
> > > > >
> > > > > sorry about the delay, but I finally got a chance to do some perf tests
> > > > > of the first patch.  I took three test cases fold-const.ii, insn-emit.ii
> > > > > and a random .i from firefox and did 3 trials of the length of 100
> > > > > compilations.  The only non default flag was -std=gnu++11.
> > > > >
[...snip results...]
> > > > >
> > > > > So, roughly that looks to me like a range from improving by .5% to
> > > > > regressing by 1%.  I'm not sure what could cause an improvement, so I
> > > > > kind of wonder how valid these results are.
> > > > 
> > > > Hmm, indeed.  The speedup looks suspicious.
> > > > 
> > > > > Another question is how one can refactor the output machinary to be
> > > > > faster.  My first  thought is to buffer text internally before calling
> > > > > stdio functions, but that seems like a giant job.
> > > > 
> > > > stdio functions are already buffering, so I don't know either.
> > > > 
> > > > But yes, going the libas route would improve things here, or for
> > > > example enhancing gas to be able to eat target binary data
> > > > without the need to encode it in printable characters...
> > > > 
> > > > .raw_data number-of-bytes
> > > > <raw data>
> > > > 
> > > > Makes it quite unparsable to editors of course ...
> > > 
> > > A middle-ground might be to do both:
> > > 
> > > .raw_data number-of-bytes
> > > <raw data>
> > 
> > Sorry, I hit "Send" too early; I meant something like this as a
> > middle-ground:
> > 
> >   .raw_data number-of-bytes
> >   <raw data>
> > 
> >   ; comment giving the formatted text
> > 
> > so that cc1 etc are doing the formatting work to make the comment, so
> > that human readers can see what the raw data is meant to be, but the
> > assembler doesn't have to do work to parse it.
> 
> well, having random bytes in the file might still screw up editors, and
> I'd kind of expect that to be slower over all since gcc still does the
> formating, and both gcc and as do more IO.
> 
> > FWIW, I once had a go at hiding asm_out_file behind a class interface,
> > trying to build up higher-level methods on top of raw text printing.
> > Maybe that's a viable migration strategy  (I didn't finish that patch).
> 
> I was thinking about trying that, but I couldn't think of a good way to
> do it incrementally.
> 
> Trev

Attached is a patch from some experimentation, very much a
work-in-progress.

It eliminates the macro ASM_OUTPUT_LABEL in favor of calls to a method
of an "output" object:

  g_output.output_label (lab);

g_output would be a thin wrapper around asm_out_file (with the
assumption that asm_out_file never changes to point at anything else).

One idea here is to gradually replace uses of asm_out_file with methods
of g_output, giving us a possible approach for tackling the "don't
format so much and then parse it again" optimization.

Another idea here is to use templates and specialization in place of
target macros, to capture things in the type system;
g_output is actually:

  output<target_t> g_output;

which has a default implementation of output_label corresponding to the
current default ASM_OUTPUT_LABEL:

template <typename Target>
inline void
output<Target>::output_label (const char *name)
{
  assemble_name (name);
  puts (":\n");  
}

...but a specific Target traits class could have a specialization e.g.

template <>
inline void
output<target_arm>::output_label (const char *name)
{
  arm_asm_output_labelref (name);
}

This could give us (I hope) equivalent performance to the current
macro-based approach, but without using the preprocessor, albeit adding
some C++ (the non-trivial use of templates gives me pause).

That said, I've barely tested it; posting here in the hope it's
constructive.

Dave

[-- Attachment #2: 0001-Work-in-progress-experiments-with-hiding-asm_out_fil.patch --]
[-- Type: text/x-patch, Size: 23893 bytes --]

From 011370666913836bd66f8b433e57780434c5aab1 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Mon, 6 Jul 2015 14:53:20 -0400
Subject: [PATCH] Work-in-progress experiments with hiding asm_out_file

---
 gcc/config/elfos.h      |  2 +-
 gcc/config/i386/i386.c  | 36 +++++++++++++++---------------
 gcc/config/i386/i386.md |  8 +++----
 gcc/config/i386/sse.md  |  2 +-
 gcc/defaults.h          | 11 ----------
 gcc/dwarf2out.c         | 58 ++++++++++++++++++++++++-------------------------
 gcc/except.c            |  8 +++----
 gcc/final.c             |  3 ++-
 gcc/output.h            | 51 +++++++++++++++++++++++++++++++++++++++++++
 gcc/toplev.c            |  3 +++
 gcc/varasm.c            | 16 +++++++-------
 11 files changed, 121 insertions(+), 77 deletions(-)

diff --git a/gcc/config/elfos.h b/gcc/config/elfos.h
index bcc3870..3ea3376 100644
--- a/gcc/config/elfos.h
+++ b/gcc/config/elfos.h
@@ -333,7 +333,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 	  ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);			\
 	}								\
 									\
-      ASM_OUTPUT_LABEL (FILE, NAME);					\
+      g_output.output_label (NAME);					\
     }									\
   while (0)
 
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 128c5af..fe78ffb 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -6398,7 +6398,7 @@ ix86_asm_output_function_label (FILE *asm_out_file, const char *fname,
   SUBTARGET_ASM_UNWIND_INIT (asm_out_file);
 #endif
 
-  ASM_OUTPUT_LABEL (asm_out_file, fname);
+  g_output.output_label (fname);
 
   /* Output magic byte marker, if hot-patch attribute is set.  */
   if (is_ms_hook)
@@ -9877,7 +9877,7 @@ ix86_code_end (void)
 	  fputs ("\n\t.private_extern\t", asm_out_file);
 	  assemble_name (asm_out_file, name);
 	  putc ('\n', asm_out_file);
-	  ASM_OUTPUT_LABEL (asm_out_file, name);
+	  g_output.output_label (name);
 	  DECL_WEAK (decl) = 1;
 	}
       else
@@ -9898,7 +9898,7 @@ ix86_code_end (void)
       else
 	{
 	  switch_to_section (text_section);
-	  ASM_OUTPUT_LABEL (asm_out_file, name);
+	  g_output.output_label (name);
 	}
 
       DECL_INITIAL (decl) = make_node (BLOCK);
@@ -9985,7 +9985,7 @@ output_set_got (rtx dest, rtx label)
       /* Output the Mach-O "canonical" pic base label name ("Lxx$pb") here.
          This is what will be referenced by the Mach-O PIC subsystem.  */
       if (machopic_should_output_picbase_label () || !label)
-	ASM_OUTPUT_LABEL (asm_out_file, MACHOPIC_FUNCTION_BASE_NAME);
+	g_output.output_label (MACHOPIC_FUNCTION_BASE_NAME);
 
       /* When we are restoring the pic base at the site of a nonlocal label,
          and we decided to emit the pic base above, we will still output a
@@ -11180,9 +11180,9 @@ output_adjust_stack_and_probe (rtx reg)
   xops[0] = stack_pointer_rtx;
   xops[1] = reg;
   output_asm_insn ("cmp%z0\t{%1, %0|%0, %1}", xops);
-  fputs ("\tje\t", asm_out_file);
-  assemble_name_raw (asm_out_file, end_lab);
-  fputc ('\n', asm_out_file);
+  g_output.puts ("\tje\t");
+  g_output.assemble_name_raw (end_lab);
+  g_output.puts ("\n");
 
   /* SP = SP + PROBE_INTERVAL.  */
   xops[1] = GEN_INT (PROBE_INTERVAL);
@@ -11303,9 +11303,9 @@ output_probe_stack_range (rtx reg, rtx end)
   xops[0] = reg;
   xops[1] = end;
   output_asm_insn ("cmp%z0\t{%1, %0|%0, %1}", xops);
-  fputs ("\tje\t", asm_out_file);
-  assemble_name_raw (asm_out_file, end_lab);
-  fputc ('\n', asm_out_file);
+  g_output.puts ("\tje\t");
+  g_output.assemble_name_raw (end_lab);
+  g_output.puts ("\n");
 
   /* TEST_ADDR = TEST_ADDR + PROBE_INTERVAL.  */
   xops[1] = GEN_INT (PROBE_INTERVAL);
@@ -11317,9 +11317,9 @@ output_probe_stack_range (rtx reg, rtx end)
   xops[2] = const0_rtx;
   output_asm_insn ("or%z0\t{%2, (%0,%1)|DWORD PTR [%0+%1], %2}", xops);
 
-  fprintf (asm_out_file, "\tjmp\t");
-  assemble_name_raw (asm_out_file, loop_lab);
-  fputc ('\n', asm_out_file);
+  g_output.puts ("\tjmp\t");
+  g_output.assemble_name_raw (loop_lab);
+  g_output.puts ("\n");
 
   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, end_lab);
 
@@ -14731,7 +14731,7 @@ output_pic_addr_const (FILE *file, rtx x, int code)
       /* FALLTHRU */
     case CODE_LABEL:
       ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (x));
-      assemble_name (asm_out_file, buf);
+      g_output.assemble_name (buf);
       break;
 
     case CONST_INT:
@@ -43256,16 +43256,16 @@ x86_file_start (void)
 {
   default_file_start ();
   if (TARGET_16BIT)
-    fputs ("\t.code16gcc\n", asm_out_file);
+    g_output.puts ("\t.code16gcc\n");
 #if TARGET_MACHO
   darwin_file_start ();
 #endif
   if (X86_FILE_START_VERSION_DIRECTIVE)
-    fputs ("\t.version\t\"01.01\"\n", asm_out_file);
+    g_output.puts ("\t.version\t\"01.01\"\n");
   if (X86_FILE_START_FLTUSED)
-    fputs ("\t.global\t__fltused\n", asm_out_file);
+    g_output.puts ("\t.global\t__fltused\n");
   if (ix86_asm_dialect == ASM_INTEL)
-    fputs ("\t.intel_syntax noprefix\n", asm_out_file);
+    g_output.puts ("\t.intel_syntax noprefix\n");
 }
 
 int
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 5c5c1fc..14c62a5 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -12137,7 +12137,7 @@
   gcc_assert (IN_RANGE (num, 1, 8));
 
   while (num--)
-    fputs ("\tnop\n", asm_out_file);
+    g_output.puts ("\tnop\n");
 
   return "";
 }
@@ -13224,11 +13224,11 @@
   "TARGET_64BIT"
 {
   if (!TARGET_X32)
-    fputs (ASM_BYTE "0x66\n", asm_out_file);
+    g_output.puts (ASM_BYTE "0x66\n");
   output_asm_insn
     ("lea{q}\t{%E1@tlsgd(%%rip), %%rdi|rdi, %E1@tlsgd[rip]}", operands);
-  fputs (ASM_SHORT "0x6666\n", asm_out_file);
-  fputs ("\trex64\n", asm_out_file);
+  g_output.puts (ASM_SHORT "0x6666\n");
+  g_output.puts ("\trex64\n");
   if (TARGET_SUN_TLS)
     return "call\t%p2@plt";
   return "call\t%P2";
diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index 0970f0e..f52dc02 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -13296,7 +13296,7 @@
   /* We can't use %^ here due to ASM_OUTPUT_OPCODE processing
      that requires %v to be at the beginning of the opcode name.  */
   if (Pmode != word_mode)
-    fputs ("\taddr32", asm_out_file);
+    g_output.puts ("\taddr32");
   return "%vmaskmovdqu\t{%2, %1|%1, %2}";
 }
   [(set_attr "type" "ssemov")
diff --git a/gcc/defaults.h b/gcc/defaults.h
index 9d38ba1..320c43d 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -136,17 +136,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #endif
 
 /* This is how to output the definition of a user-level label named
-   NAME, such as the label on variable NAME.  */
-
-#ifndef ASM_OUTPUT_LABEL
-#define ASM_OUTPUT_LABEL(FILE,NAME) \
-  do {						\
-    assemble_name ((FILE), (NAME));		\
-    fputs (":\n", (FILE));			\
-  } while (0)
-#endif
-
-/* This is how to output the definition of a user-level label named
    NAME, such as the label on a function.  */
 
 #ifndef ASM_OUTPUT_FUNCTION_LABEL
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 2c7dc71..a25847f 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -484,7 +484,7 @@ switch_to_eh_frame_section (bool back)
 	  ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE));
 	  targetm.asm_out.globalize_label (asm_out_file,
 					   IDENTIFIER_POINTER (label));
-	  ASM_OUTPUT_LABEL (asm_out_file, IDENTIFIER_POINTER (label));
+	  g_output.output_label (IDENTIFIER_POINTER (label));
 	}
     }
 }
@@ -600,7 +600,7 @@ output_fde (dw_fde_ref fde, bool for_eh, bool second,
 			 " indicating 64-bit DWARF extension");
   dw2_asm_output_delta (for_eh ? 4 : DWARF_OFFSET_SIZE, l2, l1,
 			"FDE Length");
-  ASM_OUTPUT_LABEL (asm_out_file, l1);
+  g_output.output_label (l1);
 
   if (for_eh)
     dw2_asm_output_delta (4, l1, section_start_label, "FDE CIE offset");
@@ -703,7 +703,7 @@ output_fde (dw_fde_ref fde, bool for_eh, bool second,
   /* Pad the FDE out to an address sized boundary.  */
   ASM_OUTPUT_ALIGN (asm_out_file,
 		    floor_log2 ((for_eh ? PTR_SIZE : DWARF2_ADDR_SIZE)));
-  ASM_OUTPUT_LABEL (asm_out_file, l2);
+  g_output.output_label (l2);
 
   j += 2;
 }
@@ -790,7 +790,7 @@ output_call_frame_info (int for_eh)
   switch_to_frame_table_section (for_eh, false);
 
   ASM_GENERATE_INTERNAL_LABEL (section_start_label, FRAME_BEGIN_LABEL, for_eh);
-  ASM_OUTPUT_LABEL (asm_out_file, section_start_label);
+  g_output.output_label (section_start_label);
 
   /* Output the CIE.  */
   ASM_GENERATE_INTERNAL_LABEL (l1, CIE_AFTER_SIZE_LABEL, for_eh);
@@ -800,7 +800,7 @@ output_call_frame_info (int for_eh)
       "Initial length escape value indicating 64-bit DWARF extension");
   dw2_asm_output_delta (for_eh ? 4 : DWARF_OFFSET_SIZE, l2, l1,
 			"Length of Common Information Entry");
-  ASM_OUTPUT_LABEL (asm_out_file, l1);
+  g_output.output_label (l1);
 
   /* Now that the CIE pointer is PC-relative for EH,
      use 0 to identify the CIE.  */
@@ -926,7 +926,7 @@ output_call_frame_info (int for_eh)
   /* Pad the CIE out to an address sized boundary.  */
   ASM_OUTPUT_ALIGN (asm_out_file,
 		    floor_log2 (for_eh ? PTR_SIZE : DWARF2_ADDR_SIZE));
-  ASM_OUTPUT_LABEL (asm_out_file, l2);
+  g_output.output_label (l2);
 
   /* Loop through all of the FDE's.  */
   FOR_EACH_VEC_ELT (*fde_vec, i, fde)
@@ -1160,7 +1160,7 @@ dwarf2out_end_epilogue (unsigned int line ATTRIBUTE_UNUSED,
      function.  */
   ASM_GENERATE_INTERNAL_LABEL (label, FUNC_END_LABEL,
 			       current_function_funcdef_no);
-  ASM_OUTPUT_LABEL (asm_out_file, label);
+  g_output.output_label (label);
   fde = cfun->fde;
   gcc_assert (fde != NULL);
   if (fde->dw_fde_second_begin == NULL)
@@ -8680,7 +8680,7 @@ output_die_symbol (dw_die_ref die)
        will break.  */
     targetm.asm_out.globalize_label (asm_out_file, sym);
 
-  ASM_OUTPUT_LABEL (asm_out_file, sym);
+  g_output.output_label (sym);
 }
 
 /* Return a new location list, given the begin and end range, and the
@@ -8722,7 +8722,7 @@ output_loc_list (dw_loc_list_ref list_head)
     return;
   list_head->emitted = true;
 
-  ASM_OUTPUT_LABEL (asm_out_file, list_head->ll_symbol);
+  g_output.output_label (list_head->ll_symbol);
 
   /* Walk the location list, and output each range + expression.  */
   for (curr = list_head; curr != NULL; curr = curr->dw_loc_next)
@@ -9228,7 +9228,7 @@ output_comp_unit (dw_die_ref die, int output_if_empty)
   else
     {
       switch_to_section (debug_info_section);
-      ASM_OUTPUT_LABEL (asm_out_file, debug_info_section_label);
+      g_output.output_label (debug_info_section_label);
       info_section_emitted = true;
     }
 
@@ -9323,7 +9323,7 @@ output_skeleton_debug_sections (dw_die_ref comp_unit)
   remove_AT (comp_unit, DW_AT_language);
 
   switch_to_section (debug_skeleton_info_section);
-  ASM_OUTPUT_LABEL (asm_out_file, debug_skeleton_info_section_label);
+  g_output.output_label (debug_skeleton_info_section_label);
 
   /* Produce the skeleton compilation-unit header.  This one differs enough from
      a normal CU header that it's better not to call output_compilation_unit
@@ -9348,7 +9348,7 @@ output_skeleton_debug_sections (dw_die_ref comp_unit)
 
   /* Build the skeleton debug_abbrev section.  */
   switch_to_section (debug_skeleton_abbrev_section);
-  ASM_OUTPUT_LABEL (asm_out_file, debug_skeleton_abbrev_section_label);
+  g_output.output_label (debug_skeleton_abbrev_section_label);
 
   output_die_abbrevs (SKELETON_COMP_DIE_ABBREV, comp_unit);
 
@@ -10380,11 +10380,11 @@ output_line_info (bool prologue_only)
       "Initial length escape value indicating 64-bit DWARF extension");
   dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1,
 			"Length of Source Line Info");
-  ASM_OUTPUT_LABEL (asm_out_file, l1);
+  g_output.output_label (l1);
 
   dw2_asm_output_data (2, ver, "DWARF Version");
   dw2_asm_output_delta (DWARF_OFFSET_SIZE, p2, p1, "Prolog Length");
-  ASM_OUTPUT_LABEL (asm_out_file, p1);
+  g_output.output_label (p1);
 
   /* Define the architecture-dependent minimum instruction length (in bytes).
      In this implementation of DWARF, this field is used for information
@@ -10432,11 +10432,11 @@ output_line_info (bool prologue_only)
 
   /* Write out the information about the files we use.  */
   output_file_names ();
-  ASM_OUTPUT_LABEL (asm_out_file, p2);
+  g_output.output_label (p2);
   if (prologue_only)
     {
       /* Output the marker for the end of the line number info.  */
-      ASM_OUTPUT_LABEL (asm_out_file, l2);
+      g_output.output_label (l2);
       return;
     }
 
@@ -10467,7 +10467,7 @@ output_line_info (bool prologue_only)
     output_one_line_info_table (text_section_line_info);
 
   /* Output the marker for the end of the line number info.  */
-  ASM_OUTPUT_LABEL (asm_out_file, l2);
+  g_output.output_label (l2);
 }
 \f
 /* Given a pointer to a tree node for some base type, return a pointer to
@@ -22485,7 +22485,7 @@ dwarf2out_begin_function (tree fun)
       gcc_assert (current_function_decl == fun);
       cold_text_section = unlikely_text_section ();
       switch_to_section (cold_text_section);
-      ASM_OUTPUT_LABEL (asm_out_file, cold_text_section_label);
+      g_output.output_label (cold_text_section_label);
       switch_to_section (sec);
     }
 
@@ -23146,7 +23146,7 @@ output_macinfo (void)
 	  ASM_GENERATE_INTERNAL_LABEL (label,
 				       DEBUG_MACRO_SECTION_LABEL,
 				       ref->lineno);
-	  ASM_OUTPUT_LABEL (asm_out_file, label);
+	  g_output.output_label (label);
 	  ref->code = 0;
 	  ref->info = NULL;
 	  dw2_asm_output_data (2, 4, "DWARF macro version number");
@@ -23297,7 +23297,7 @@ dwarf2out_init (const char *filename ATTRIBUTE_UNUSED)
     vec_alloc (macinfo_table, 64);
 
   switch_to_section (text_section);
-  ASM_OUTPUT_LABEL (asm_out_file, text_section_label);
+  g_output.output_label (text_section_label);
 
   /* Make sure the line number table for .text always exists.  */
   text_section_line_info = new_line_info_table ();
@@ -23319,7 +23319,7 @@ dwarf2out_assembly_start (void)
       && dwarf2out_do_cfi_asm ()
       && (!(flag_unwind_tables || flag_exceptions)
 	  || targetm_common.except_unwind_info (&global_options) != UI_DWARF2))
-    fprintf (asm_out_file, "\t.cfi_sections\t.debug_frame\n");
+    g_output.puts ("\t.cfi_sections\t.debug_frame\n");
 }
 
 /* A helper function for dwarf2out_finish called through
@@ -23394,7 +23394,7 @@ output_indirect_string (indirect_string_node **h, void *)
   node->form = find_string_form (node);
   if (node->form == DW_FORM_strp && node->refcount > 0)
     {
-      ASM_OUTPUT_LABEL (asm_out_file, node->label);
+      g_output.output_label (node->label);
       assemble_string (node->str, strlen (node->str) + 1);
     }
 
@@ -25352,7 +25352,7 @@ dwarf2out_finish (const char *filename)
                         ranges_section_label);
 
       switch_to_section (debug_addr_section);
-      ASM_OUTPUT_LABEL (asm_out_file, debug_addr_section_label);
+      g_output.output_label (debug_addr_section_label);
       output_addr_table ();
     }
 
@@ -25367,7 +25367,7 @@ dwarf2out_finish (const char *filename)
   if (abbrev_die_table_in_use != 1)
     {
       switch_to_section (debug_abbrev_section);
-      ASM_OUTPUT_LABEL (asm_out_file, abbrev_section_label);
+      g_output.output_label (abbrev_section_label);
       output_abbrev_section ();
     }
 
@@ -25376,7 +25376,7 @@ dwarf2out_finish (const char *filename)
     {
       /* Output the location lists info.  */
       switch_to_section (debug_loc_section);
-      ASM_OUTPUT_LABEL (asm_out_file, loc_section_label);
+      g_output.output_label (loc_section_label);
       output_location_lists (comp_unit_die ());
     }
 
@@ -25399,7 +25399,7 @@ dwarf2out_finish (const char *filename)
   if (ranges_table_in_use)
     {
       switch_to_section (debug_ranges_section);
-      ASM_OUTPUT_LABEL (asm_out_file, ranges_section_label);
+      g_output.output_label (ranges_section_label);
       output_ranges ();
     }
 
@@ -25407,7 +25407,7 @@ dwarf2out_finish (const char *filename)
   if (have_macinfo)
     {
       switch_to_section (debug_macinfo_section);
-      ASM_OUTPUT_LABEL (asm_out_file, macinfo_section_label);
+      g_output.output_label (macinfo_section_label);
       output_macinfo ();
       dw2_asm_output_data (1, 0, "End compilation unit");
     }
@@ -25419,14 +25419,14 @@ dwarf2out_finish (const char *filename)
      examining the file.  This is done late so that any filenames
      used by the debug_info section are marked as 'used'.  */
   switch_to_section (debug_line_section);
-  ASM_OUTPUT_LABEL (asm_out_file, debug_line_section_label);
+  g_output.output_label (debug_line_section_label);
   if (! DWARF2_ASM_LINE_DEBUG_INFO)
     output_line_info (false);
 
   if (dwarf_split_debug_info && info_section_emitted)
     {
       switch_to_section (debug_skeleton_line_section);
-      ASM_OUTPUT_LABEL (asm_out_file, debug_skeleton_line_section_label);
+      g_output.output_label (debug_skeleton_line_section_label);
       output_line_info (true);
     }
 
diff --git a/gcc/except.c b/gcc/except.c
index d59c539..d6b1ebc 100644
--- a/gcc/except.c
+++ b/gcc/except.c
@@ -3004,7 +3004,7 @@ output_one_function_exception_table (int section)
 				   current_function_funcdef_no);
       dw2_asm_output_delta_uleb128 (ttype_label, ttype_after_disp_label,
 				    "@TType base offset");
-      ASM_OUTPUT_LABEL (asm_out_file, ttype_after_disp_label);
+      g_output.output_label (ttype_after_disp_label);
 #else
       /* Ug.  Alignment queers things.  */
       unsigned int before_disp, after_disp, last_disp, disp;
@@ -3054,12 +3054,12 @@ output_one_function_exception_table (int section)
 			       current_function_funcdef_no);
   dw2_asm_output_delta_uleb128 (cs_end_label, cs_after_size_label,
 				"Call-site table length");
-  ASM_OUTPUT_LABEL (asm_out_file, cs_after_size_label);
+  g_output.output_label (cs_after_size_label);
   if (targetm_common.except_unwind_info (&global_options) == UI_SJLJ)
     sjlj_output_call_site_table ();
   else
     dw2_output_call_site_table (cs_format, section);
-  ASM_OUTPUT_LABEL (asm_out_file, cs_end_label);
+  g_output.output_label (cs_end_label);
 #else
   dw2_asm_output_data_uleb128 (call_site_len, "Call-site table length");
   if (targetm_common.except_unwind_info (&global_options) == UI_SJLJ)
@@ -3087,7 +3087,7 @@ output_one_function_exception_table (int section)
 
 #ifdef HAVE_AS_LEB128
   if (have_tt_data)
-      ASM_OUTPUT_LABEL (asm_out_file, ttype_label);
+      g_output.output_label (ttype_label);
 #endif
 
   /* ??? Decode and interpret the data for flag_debug_asm.  */
diff --git a/gcc/final.c b/gcc/final.c
index 5d91609..23541b9 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -2116,7 +2116,7 @@ output_alternate_entry_point (FILE *file, rtx_insn *insn)
 #ifdef ASM_OUTPUT_TYPE_DIRECTIVE
       ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function");
 #endif
-      ASM_OUTPUT_LABEL (file, name);
+      g_output.output_label (name);
       break;
 
     case LABEL_NORMAL:
@@ -4876,3 +4876,4 @@ get_call_reg_set_usage (rtx_insn *insn, HARD_REG_SET *reg_set,
   COPY_HARD_REG_SET (*reg_set, default_set);
   return false;
 }
+
diff --git a/gcc/output.h b/gcc/output.h
index 4ce6eea..b33d23a 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -614,4 +614,55 @@ extern int default_address_cost (rtx, machine_mode, addr_space_t, bool);
 /* Output stack usage information.  */
 extern void output_stack_usage (void);
 
+template <typename Target>
+class output
+{
+ public:
+  void init (FILE *outfile);
+
+  int puts (const char *s) const { return fputs (s, m_outfile); }
+  FILE *get_outfile () const { return m_outfile; }
+
+  void
+  assemble_name_raw (const char *name) { ::assemble_name_raw (m_outfile,
+							      name); }
+
+  void
+  assemble_name (const char *name) { ::assemble_name (m_outfile, name); }
+
+  /* Replacement for ASM_OUTPUT_LABEL.  */
+  void output_label (const char *name);
+
+ private:
+  FILE *m_outfile;
+};
+
+template <typename Target>
+inline void
+output<Target>::init (FILE *outfile)
+{
+  m_outfile = outfile;
+}
+
+/* Default implementation of output_label.  */
+template <typename Target>
+inline void
+output<Target>::output_label (const char *name)
+{
+  assemble_name (name);
+  puts (":\n");  
+}
+
+/* Hacked-up traits classes (each target would provide one. */
+class target_pdp11
+{
+};
+
+/* ...and this typedef would be generated at configure time.  */
+typedef target_pdp11 target_t;
+
+/* File in which assembler code is being written.  */
+/* (replacement for asm_out_file) */
+extern output<target_t> g_output;
+
 #endif /* ! GCC_OUTPUT_H */
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 5aaa120..33151ac 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -184,6 +184,7 @@ const char *user_label_prefix;
    and debugging dumps.  */
 
 FILE *asm_out_file;
+output<target_t> g_output;
 FILE *aux_info_file;
 FILE *stack_usage_file = NULL;
 
@@ -975,6 +976,8 @@ init_asm_output (const char *name)
 		     "can%'t open %qs for writing: %m", asm_file_name);
     }
 
+  g_output.init (asm_out_file);
+
   if (!flag_syntax_only)
     {
       targetm.asm_out.file_start ();
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 6a4ba0b..aa11d64 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -1746,7 +1746,7 @@ assemble_start_function (tree decl, const char *fnname)
 
       switch_to_section (unlikely_text_section ());
       assemble_align (align);
-      ASM_OUTPUT_LABEL (asm_out_file, crtl->subsections.cold_section_label);
+      g_output.output_label (crtl->subsections.cold_section_label);
 
       /* When the function starts with a cold section, we need to explicitly
 	 align the hot section and write out the hot section label.
@@ -1756,7 +1756,7 @@ assemble_start_function (tree decl, const char *fnname)
 	{
 	  switch_to_section (text_section);
 	  assemble_align (align);
-	  ASM_OUTPUT_LABEL (asm_out_file, crtl->subsections.hot_section_label);
+	  g_output.output_label (crtl->subsections.hot_section_label);
 	  hot_label_written = true;
 	  first_function_block_is_cold = true;
 	}
@@ -1769,7 +1769,7 @@ assemble_start_function (tree decl, const char *fnname)
   switch_to_section (function_section (decl));
   if (flag_reorder_blocks_and_partition
       && !hot_label_written)
-    ASM_OUTPUT_LABEL (asm_out_file, crtl->subsections.hot_section_label);
+    g_output.output_label (crtl->subsections.hot_section_label);
 
   /* Tell assembler to move to target machine's alignment for functions.  */
   align = floor_log2 (align / BITS_PER_UNIT);
@@ -1860,12 +1860,12 @@ assemble_end_function (tree decl, const char *fnname ATTRIBUTE_UNUSED)
 					IDENTIFIER_POINTER (cold_function_name),
 					decl);
 #endif
-      ASM_OUTPUT_LABEL (asm_out_file, crtl->subsections.cold_section_end_label);
+      g_output.output_label (crtl->subsections.cold_section_end_label);
       if (first_function_block_is_cold)
 	switch_to_section (text_section);
       else
 	switch_to_section (function_section (decl));
-      ASM_OUTPUT_LABEL (asm_out_file, crtl->subsections.hot_section_end_label);
+      g_output.output_label (crtl->subsections.hot_section_end_label);
       switch_to_section (save_text_section);
     }
 }
@@ -2052,7 +2052,7 @@ assemble_variable_contents (tree decl, const char *name,
   ASM_DECLARE_OBJECT_NAME (asm_out_file, name, decl);
 #else
   /* Standard thing is just output label for the object.  */
-  ASM_OUTPUT_LABEL (asm_out_file, name);
+  g_output.output_label (name);
 #endif /* ASM_DECLARE_OBJECT_NAME */
 
   if (!dont_output_data)
@@ -2499,9 +2499,9 @@ assemble_external_libcall (rtx fun)
 /* Assemble a label named NAME.  */
 
 void
-assemble_label (FILE *file, const char *name)
+assemble_label (FILE */*file*/, const char *name)
 {
-  ASM_OUTPUT_LABEL (file, name);
+  g_output.output_label (name);
 }
 
 /* Set the symbol_referenced flag for ID.  */
-- 
1.8.5.3


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-08-06 18:48               ` David Malcolm
@ 2015-08-06 19:36                 ` Richard Sandiford
  2015-08-07  4:32                   ` Trevor Saunders
  0 siblings, 1 reply; 31+ messages in thread
From: Richard Sandiford @ 2015-08-06 19:36 UTC (permalink / raw)
  To: David Malcolm; +Cc: Trevor Saunders, Richard Biener, tbsaunde+gcc, GCC Patches

David Malcolm <dmalcolm@redhat.com> writes:
> On Wed, 2015-08-05 at 16:22 -0400, Trevor Saunders wrote:
>> On Wed, Aug 05, 2015 at 11:34:28AM -0400, David Malcolm wrote:
>> > On Wed, 2015-08-05 at 11:28 -0400, David Malcolm wrote:
>> > > On Wed, 2015-08-05 at 13:47 +0200, Richard Biener wrote:
>> > > > On Wed, Aug 5, 2015 at 12:57 PM, Trevor Saunders
>> > > > <tbsaunde@tbsaunde.org> wrote:
>> > > > > On Mon, Jul 27, 2015 at 11:06:58AM +0200, Richard Biener wrote:
>> > > > >> On Sat, Jul 25, 2015 at 4:37 AM,  <tbsaunde+gcc@tbsaunde.org> wrote:
>> > > > >> > From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>> > > > >> >
>> > > > >> >         * config/arc/arc.h, config/bfin/bfin.h, config/frv/frv.h,
>> > > > >> >         config/ia64/ia64-protos.h, config/ia64/ia64.c,
>> > > > >> > config/ia64/ia64.h,
>> > > > >> >         config/lm32/lm32.h, config/mep/mep.h, config/mmix/mmix.h,
>> > > > >> >         config/rs6000/rs6000.c, config/rs6000/xcoff.h,
>> > > > >> > config/spu/spu.h,
>> > > > >> >         config/visium/visium.h, defaults.h: Define
>> > > > >> > ASM_OUTPUT_LABEL to
>> > > > >> > the name of a function.
>> > > > >> >         * output.h (default_output_label): New prototype.
>> > > > >> >         * varasm.c (default_output_label): New function.
>> > > > >> >         * vmsdbgout.c: Include tm_p.h.
>> > > > >> >         * xcoffout.c: Likewise.
>> > > > >>
>> > > > >> Just a general remark - the GCC output machinery is known to be slow,
>> > > > >> adding indirect calls might be not the very best idea without
>> > > > >> refactoring
>> > > > >> some of it.
>> > > > >>
>> > > > >> Did you do any performance measurements for artificial testcases
>> > > > >> exercising the specific bits you change?
>> > > > >
>> > > > > sorry about the delay, but I finally got a chance to do some
>> > > > > perf tests
>> > > > > of the first patch.  I took three test cases fold-const.ii,
>> > > > > insn-emit.ii
>> > > > > and a random .i from firefox and did 3 trials of the length of 100
>> > > > > compilations.  The only non default flag was -std=gnu++11.
>> > > > >
> [...snip results...]
>> > > > >
>> > > > > So, roughly that looks to me like a range from improving by .5% to
>> > > > > regressing by 1%.  I'm not sure what could cause an improvement, so I
>> > > > > kind of wonder how valid these results are.
>> > > > 
>> > > > Hmm, indeed.  The speedup looks suspicious.
>> > > > 
>> > > > > Another question is how one can refactor the output machinary to be
>> > > > > faster.  My first  thought is to buffer text internally before calling
>> > > > > stdio functions, but that seems like a giant job.
>> > > > 
>> > > > stdio functions are already buffering, so I don't know either.
>> > > > 
>> > > > But yes, going the libas route would improve things here, or for
>> > > > example enhancing gas to be able to eat target binary data
>> > > > without the need to encode it in printable characters...
>> > > > 
>> > > > .raw_data number-of-bytes
>> > > > <raw data>
>> > > > 
>> > > > Makes it quite unparsable to editors of course ...
>> > > 
>> > > A middle-ground might be to do both:
>> > > 
>> > > .raw_data number-of-bytes
>> > > <raw data>
>> > 
>> > Sorry, I hit "Send" too early; I meant something like this as a
>> > middle-ground:
>> > 
>> >   .raw_data number-of-bytes
>> >   <raw data>
>> > 
>> >   ; comment giving the formatted text
>> > 
>> > so that cc1 etc are doing the formatting work to make the comment, so
>> > that human readers can see what the raw data is meant to be, but the
>> > assembler doesn't have to do work to parse it.
>> 
>> well, having random bytes in the file might still screw up editors, and
>> I'd kind of expect that to be slower over all since gcc still does the
>> formating, and both gcc and as do more IO.
>> 
>> > FWIW, I once had a go at hiding asm_out_file behind a class interface,
>> > trying to build up higher-level methods on top of raw text printing.
>> > Maybe that's a viable migration strategy  (I didn't finish that patch).
>> 
>> I was thinking about trying that, but I couldn't think of a good way to
>> do it incrementally.
>> 
>> Trev
>
> Attached is a patch from some experimentation, very much a
> work-in-progress.
>
> It eliminates the macro ASM_OUTPUT_LABEL in favor of calls to a method
> of an "output" object:
>
>   g_output.output_label (lab);
>
> g_output would be a thin wrapper around asm_out_file (with the
> assumption that asm_out_file never changes to point at anything else).
>
> One idea here is to gradually replace uses of asm_out_file with methods
> of g_output, giving us a possible approach for tackling the "don't
> format so much and then parse it again" optimization.
>
> Another idea here is to use templates and specialization in place of
> target macros, to capture things in the type system;
> g_output is actually:
>
>   output<target_t> g_output;
>
> which has a default implementation of output_label corresponding to the
> current default ASM_OUTPUT_LABEL:
>
> template <typename Target>
> inline void
> output<Target>::output_label (const char *name)
> {
>   assemble_name (name);
>   puts (":\n");  
> }
>
> ...but a specific Target traits class could have a specialization e.g.
>
> template <>
> inline void
> output<target_arm>::output_label (const char *name)
> {
>   arm_asm_output_labelref (name);
> }
>
> This could give us (I hope) equivalent performance to the current
> macro-based approach, but without using the preprocessor, albeit adding
> some C++ (the non-trivial use of templates gives me pause).

I might be missing the point, sorry, but it sounds like this enshrines
the idea of having a single target.

An integrated assembler or tighter asm output would be nice, but when
I last checked LLVM was usually faster than GCC even when compiling to asm,
even though LLVM does use indirection (in the form of virtual functions)
for its output routines.  I don't think indirect function calls themselves
are the problem -- as long as we get the abstraction right :-)

Thanks,
Richard

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-08-06 19:36                 ` Richard Sandiford
@ 2015-08-07  4:32                   ` Trevor Saunders
  2015-08-07  9:46                     ` Richard Sandiford
  0 siblings, 1 reply; 31+ messages in thread
From: Trevor Saunders @ 2015-08-07  4:32 UTC (permalink / raw)
  To: David Malcolm, Richard Biener, tbsaunde+gcc, GCC Patches, rdsandiford

On Thu, Aug 06, 2015 at 08:36:36PM +0100, Richard Sandiford wrote:
> David Malcolm <dmalcolm@redhat.com> writes:
> > On Wed, 2015-08-05 at 16:22 -0400, Trevor Saunders wrote:
> >> On Wed, Aug 05, 2015 at 11:34:28AM -0400, David Malcolm wrote:
> >> > On Wed, 2015-08-05 at 11:28 -0400, David Malcolm wrote:
> >> > > On Wed, 2015-08-05 at 13:47 +0200, Richard Biener wrote:
> >> > > > On Wed, Aug 5, 2015 at 12:57 PM, Trevor Saunders
> >> > > > <tbsaunde@tbsaunde.org> wrote:
> >> > > > > On Mon, Jul 27, 2015 at 11:06:58AM +0200, Richard Biener wrote:
> >> > > > >> On Sat, Jul 25, 2015 at 4:37 AM,  <tbsaunde+gcc@tbsaunde.org> wrote:
> >> > > > >> > From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
> >> > > > >> >
> >> > > > >> >         * config/arc/arc.h, config/bfin/bfin.h, config/frv/frv.h,
> >> > > > >> >         config/ia64/ia64-protos.h, config/ia64/ia64.c,
> >> > > > >> > config/ia64/ia64.h,
> >> > > > >> >         config/lm32/lm32.h, config/mep/mep.h, config/mmix/mmix.h,
> >> > > > >> >         config/rs6000/rs6000.c, config/rs6000/xcoff.h,
> >> > > > >> > config/spu/spu.h,
> >> > > > >> >         config/visium/visium.h, defaults.h: Define
> >> > > > >> > ASM_OUTPUT_LABEL to
> >> > > > >> > the name of a function.
> >> > > > >> >         * output.h (default_output_label): New prototype.
> >> > > > >> >         * varasm.c (default_output_label): New function.
> >> > > > >> >         * vmsdbgout.c: Include tm_p.h.
> >> > > > >> >         * xcoffout.c: Likewise.
> >> > > > >>
> >> > > > >> Just a general remark - the GCC output machinery is known to be slow,
> >> > > > >> adding indirect calls might be not the very best idea without
> >> > > > >> refactoring
> >> > > > >> some of it.
> >> > > > >>
> >> > > > >> Did you do any performance measurements for artificial testcases
> >> > > > >> exercising the specific bits you change?
> >> > > > >
> >> > > > > sorry about the delay, but I finally got a chance to do some
> >> > > > > perf tests
> >> > > > > of the first patch.  I took three test cases fold-const.ii,
> >> > > > > insn-emit.ii
> >> > > > > and a random .i from firefox and did 3 trials of the length of 100
> >> > > > > compilations.  The only non default flag was -std=gnu++11.
> >> > > > >
> > [...snip results...]
> >> > > > >
> >> > > > > So, roughly that looks to me like a range from improving by .5% to
> >> > > > > regressing by 1%.  I'm not sure what could cause an improvement, so I
> >> > > > > kind of wonder how valid these results are.
> >> > > > 
> >> > > > Hmm, indeed.  The speedup looks suspicious.
> >> > > > 
> >> > > > > Another question is how one can refactor the output machinary to be
> >> > > > > faster.  My first  thought is to buffer text internally before calling
> >> > > > > stdio functions, but that seems like a giant job.
> >> > > > 
> >> > > > stdio functions are already buffering, so I don't know either.
> >> > > > 
> >> > > > But yes, going the libas route would improve things here, or for
> >> > > > example enhancing gas to be able to eat target binary data
> >> > > > without the need to encode it in printable characters...
> >> > > > 
> >> > > > .raw_data number-of-bytes
> >> > > > <raw data>
> >> > > > 
> >> > > > Makes it quite unparsable to editors of course ...
> >> > > 
> >> > > A middle-ground might be to do both:
> >> > > 
> >> > > .raw_data number-of-bytes
> >> > > <raw data>
> >> > 
> >> > Sorry, I hit "Send" too early; I meant something like this as a
> >> > middle-ground:
> >> > 
> >> >   .raw_data number-of-bytes
> >> >   <raw data>
> >> > 
> >> >   ; comment giving the formatted text
> >> > 
> >> > so that cc1 etc are doing the formatting work to make the comment, so
> >> > that human readers can see what the raw data is meant to be, but the
> >> > assembler doesn't have to do work to parse it.
> >> 
> >> well, having random bytes in the file might still screw up editors, and
> >> I'd kind of expect that to be slower over all since gcc still does the
> >> formating, and both gcc and as do more IO.
> >> 
> >> > FWIW, I once had a go at hiding asm_out_file behind a class interface,
> >> > trying to build up higher-level methods on top of raw text printing.
> >> > Maybe that's a viable migration strategy  (I didn't finish that patch).
> >> 
> >> I was thinking about trying that, but I couldn't think of a good way to
> >> do it incrementally.
> >> 
> >> Trev
> >
> > Attached is a patch from some experimentation, very much a
> > work-in-progress.
> >
> > It eliminates the macro ASM_OUTPUT_LABEL in favor of calls to a method
> > of an "output" object:
> >
> >   g_output.output_label (lab);
> >
> > g_output would be a thin wrapper around asm_out_file (with the
> > assumption that asm_out_file never changes to point at anything else).
> >
> > One idea here is to gradually replace uses of asm_out_file with methods
> > of g_output, giving us a possible approach for tackling the "don't
> > format so much and then parse it again" optimization.
> >
> > Another idea here is to use templates and specialization in place of
> > target macros, to capture things in the type system;
> > g_output is actually:
> >
> >   output<target_t> g_output;
> >
> > which has a default implementation of output_label corresponding to the
> > current default ASM_OUTPUT_LABEL:
> >
> > template <typename Target>
> > inline void
> > output<Target>::output_label (const char *name)
> > {
> >   assemble_name (name);
> >   puts (":\n");  
> > }
> >
> > ...but a specific Target traits class could have a specialization e.g.
> >
> > template <>
> > inline void
> > output<target_arm>::output_label (const char *name)
> > {
> >   arm_asm_output_labelref (name);
> > }
> >
> > This could give us (I hope) equivalent performance to the current
> > macro-based approach, but without using the preprocessor, albeit adding
> > some C++ (the non-trivial use of templates gives me pause).
> 
> I might be missing the point, sorry, but it sounds like this enshrines
> the idea of having a single target.

I assume you are refering to the template part?  Not totally, see
https://blog.mozilla.org/nfroyd/2014/10/30/porting-rr-to-x86-64/
for an example of building a tool that uses templates and supports
multiple targets at the same time.  That said I'm not sure I see the
advantages, and the switch statements look rather like virtual
functions.

> An integrated assembler or tighter asm output would be nice, but when
> I last checked LLVM was usually faster than GCC even when compiling to asm,
> even though LLVM does use indirection (in the form of virtual functions)
> for its output routines.  I don't think indirect function calls themselves
> are the problem -- as long as we get the abstraction right :-)

yeah, last time I looked (tbf a while ago) the C++ front end took up by
far the largest part of the time.  So it may not be terribly important,
but it would still be nice to figure out what a good design looks like.

Trev

> 
> Thanks,
> Richard

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-08-07  4:32                   ` Trevor Saunders
@ 2015-08-07  9:46                     ` Richard Sandiford
  2015-08-07 13:50                       ` Trevor Saunders
  0 siblings, 1 reply; 31+ messages in thread
From: Richard Sandiford @ 2015-08-07  9:46 UTC (permalink / raw)
  To: Trevor Saunders; +Cc: David Malcolm, Richard Biener, tbsaunde+gcc, GCC Patches

[-- Attachment #1: Type: text/plain, Size: 3560 bytes --]

Trevor Saunders <tbsaunde@tbsaunde.org> writes:
> On Thu, Aug 06, 2015 at 08:36:36PM +0100, Richard Sandiford wrote:
>> An integrated assembler or tighter asm output would be nice, but when
>> I last checked LLVM was usually faster than GCC even when compiling to asm,
>> even though LLVM does use indirection (in the form of virtual functions)
>> for its output routines.  I don't think indirect function calls themselves
>> are the problem -- as long as we get the abstraction right :-)
>
> yeah, last time I looked (tbf a while ago) the C++ front end took up by
> far the largest part of the time.  So it may not be terribly important,
> but it would still be nice to figure out what a good design looks like.

I tried getting final to output the code a large number of times.
Obviously just sticking "for (i = 0; i < n; ++i)" around something
isn't the best way of measuring performance (for all the usual reasons)
but it was interesting even so.  A lot of the time is taken in calls to
strlen and in assemble_name itself (called by ASM_OUTPUT_LABEL).
Each time we call assemble_name we do:

  real_name = targetm.strip_name_encoding (name);

  id = maybe_get_identifier (real_name);
  if (id)
    {
      tree id_orig = id;

      mark_referenced (id);
      ultimate_transparent_alias_target (&id);
      if (id != id_orig)
	name = IDENTIFIER_POINTER (id);
      gcc_assert (! TREE_CHAIN (id));
    }

Doing an identifier lookup every time we output a reference to a label
is pretty expensive.  Especially when many of the labels we're dealing
with are internal ones (basic block labels, debug labels, etc.) for which
the lookup is bound to fail.

So if compile-time for asm output is a concern, that seems like a good
place to start.  We should try harder to keep track of the identifier
behind a name (when there is one) and avoid this overhead for
internal labels.

Converting ASM_OUTPUT_LABEL to an indirect function call was in the
noise even with my for-loop hack.  The execution time of the hook is
dominated by assemble_name itself.  I hope patches like yours aren't
held up simply because they have the equivalent of a virtual function.

Also, although we seem to be paranoid about virtual functions and
indirect calls, it's worth remembering that on most targets every
call to fputs(_unlocked), fwrite(_unlocked) and strlen is a PLT call.
Our current code calls fputs several times for one line of assembly,
including for short strings like register names.  This is doubly
inefficient because:

(a) we could reduce the number of PLT calls by doing the buffering
    ourselves and

(b) the names of those registers are known at compile time (or at least
    at start-up time) and are short, but we call strlen() on them
    each time we write them out.

E.g. for the attached microbenchmark I get:

  Time taken, normalised to VERSION==1

  VERSION==1:  1.000
  VERSION==2:  1.377
  VERSION==3:  3.202 (1.638 with -minline-all-stringops)
  VERSION==4:  4.242 (2.921 with -minline-all-stringops)
  VERSION==5:  4.526
  VERSION==6:  4.543
  VERSION==7: 10.884

where the results for 5 vs. 6 are in the noise.

The 5->4 gain is by doing the buffering ourselves.  The 4->3 gain is for
keeping track of the string length rather than recomputing it each time.

This suggests that if we're serious about trying to speed up the asm output,
it would be worth adding an equivalent of LLVM's StringRef that pairs a
const char * string with its length.

Thanks,
Richard


[-- Attachment #2: output.cc --]
[-- Type: text/x-c++src, Size: 1318 bytes --]

#define _GNU_SOURCE 1

#include <stdio.h>
#include <string.h>
#include <iostream>

struct S
{
  S () : end (buffer) {}

  ~S ()
  {
    fwrite_unlocked (buffer, end - buffer, 1, stdout);
  }

#if VERSION == 3
  void __attribute__((noinline))
#else
  void
#endif
  write (const char *x, size_t len)
  {
    if (__builtin_expect (buffer + sizeof (buffer) - end < len, 0))
      {
	fwrite_unlocked (buffer, end - buffer, 1, stdout);
	end = buffer;
      }
    memcpy (end, x, len);
    end += len;
  }

#if VERSION == 1 || VERSION == 3
  template <size_t N>
  void
  write (const char (&x)[N])
  {
    write (x, N - 1);
  }
#elif VERSION == 2
  template <size_t N>
  void __attribute__((noinline))
  write (const char (&x)[N])
  {
    write (x, N - 1);
  }
#else
  void __attribute__((noinline))
  write (const char *x)
  {
    write (x, strlen (x));
  }
#endif
  char buffer[4096];
  char *end;
};

int
main ()
{
  S s;
  for (int i = 0; i < 100000000; ++i)
    {
#if VERSION <= 4
      s.write ("Hello!");
#elif VERSION == 5
      fputs_unlocked ("Hello!", stdout);
#elif VERSION == 6
      fwrite_unlocked ("Hello!", 6, 1, stdout);
#elif VERSION == 7
      std::cout << "Hello!";
#else
#error Please define VERSION
#endif
    }
  return 0;
}

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-08-07  9:46                     ` Richard Sandiford
@ 2015-08-07 13:50                       ` Trevor Saunders
  2015-08-07 20:24                         ` Richard Biener
  0 siblings, 1 reply; 31+ messages in thread
From: Trevor Saunders @ 2015-08-07 13:50 UTC (permalink / raw)
  To: David Malcolm, Richard Biener, tbsaunde+gcc, GCC Patches,
	richard.sandiford

On Fri, Aug 07, 2015 at 10:45:57AM +0100, Richard Sandiford wrote:
> Trevor Saunders <tbsaunde@tbsaunde.org> writes:
> > On Thu, Aug 06, 2015 at 08:36:36PM +0100, Richard Sandiford wrote:
> >> An integrated assembler or tighter asm output would be nice, but when
> >> I last checked LLVM was usually faster than GCC even when compiling to asm,
> >> even though LLVM does use indirection (in the form of virtual functions)
> >> for its output routines.  I don't think indirect function calls themselves
> >> are the problem -- as long as we get the abstraction right :-)
> >
> > yeah, last time I looked (tbf a while ago) the C++ front end took up by
> > far the largest part of the time.  So it may not be terribly important,
> > but it would still be nice to figure out what a good design looks like.
> 
> I tried getting final to output the code a large number of times.
> Obviously just sticking "for (i = 0; i < n; ++i)" around something
> isn't the best way of measuring performance (for all the usual reasons)
> but it was interesting even so.  A lot of the time is taken in calls to
> strlen and in assemble_name itself (called by ASM_OUTPUT_LABEL).

yeah, this data looks great.  I find it interesting that you say we
spend so much time outputting labels as opposed to instructions.

> Each time we call assemble_name we do:
> 
>   real_name = targetm.strip_name_encoding (name);
> 
>   id = maybe_get_identifier (real_name);
>   if (id)
>     {
>       tree id_orig = id;
> 
>       mark_referenced (id);
>       ultimate_transparent_alias_target (&id);
>       if (id != id_orig)
> 	name = IDENTIFIER_POINTER (id);
>       gcc_assert (! TREE_CHAIN (id));
>     }
> 
> Doing an identifier lookup every time we output a reference to a label
> is pretty expensive.  Especially when many of the labels we're dealing
> with are internal ones (basic block labels, debug labels, etc.) for which
> the lookup is bound to fail.

well, there's ASm_OUTPUT_INTERNAL_LABEL, and I think something similar
for debug labels.  I guess we don't always use those where we could.  Or
maybe the problem is we have places where we need to look at data to
find out.  Maybe it would make sense to have the generally used
output_label routine take a tree / rtx, and check if its a internal or
debug label and dispatch appropriately.

> So if compile-time for asm output is a concern, that seems like a good
> place to start.  We should try harder to keep track of the identifier
> behind a name (when there is one) and avoid this overhead for
> internal labels.
> 
> Converting ASM_OUTPUT_LABEL to an indirect function call was in the
> noise even with my for-loop hack.  The execution time of the hook is
> dominated by assemble_name itself.  I hope patches like yours aren't
> held up simply because they have the equivalent of a virtual function.

Well, I think it makes sense to reroll this series, but I think I'll
keep working on trying to replace these macros with something else.

> Also, although we seem to be paranoid about virtual functions and
> indirect calls, it's worth remembering that on most targets every
> call to fputs(_unlocked), fwrite(_unlocked) and strlen is a PLT call.
> Our current code calls fputs several times for one line of assembly,
> including for short strings like register names.  This is doubly
> inefficient because:
> 
> (a) we could reduce the number of PLT calls by doing the buffering
>     ourselves and

yeah, I mentioned that earlier, but its great to have data showing its a
win!  I think its also probably important to enabling the other
optimizations below.

> (b) the names of those registers are known at compile time (or at least
>     at start-up time) and are short, but we call strlen() on them
>     each time we write them out.

yeah, that seems like something that should be fixed, but I'm not sure
off hand where to look for the code doing this.

> E.g. for the attached microbenchmark I get:
> 
>   Time taken, normalised to VERSION==1
> 
>   VERSION==1:  1.000
>   VERSION==2:  1.377
>   VERSION==3:  3.202 (1.638 with -minline-all-stringops)
>   VERSION==4:  4.242 (2.921 with -minline-all-stringops)
>   VERSION==5:  4.526
>   VERSION==6:  4.543
>   VERSION==7: 10.884
> 
> where the results for 5 vs. 6 are in the noise.
> 
> The 5->4 gain is by doing the buffering ourselves.  The 4->3 gain is for
> keeping track of the string length rather than recomputing it each time.
> 
> This suggests that if we're serious about trying to speed up the asm output,
> it would be worth adding an equivalent of LLVM's StringRef that pairs a
> const char * string with its length.

I've thought a tiny bit about working on that, so its nice to have data.

Trev

> 
> Thanks,
> Richard
> 

> #define _GNU_SOURCE 1
> 
> #include <stdio.h>
> #include <string.h>
> #include <iostream>
> 
> struct S
> {
>   S () : end (buffer) {}
> 
>   ~S ()
>   {
>     fwrite_unlocked (buffer, end - buffer, 1, stdout);
>   }
> 
> #if VERSION == 3
>   void __attribute__((noinline))
> #else
>   void
> #endif
>   write (const char *x, size_t len)
>   {
>     if (__builtin_expect (buffer + sizeof (buffer) - end < len, 0))
>       {
> 	fwrite_unlocked (buffer, end - buffer, 1, stdout);
> 	end = buffer;
>       }
>     memcpy (end, x, len);
>     end += len;
>   }
> 
> #if VERSION == 1 || VERSION == 3
>   template <size_t N>
>   void
>   write (const char (&x)[N])
>   {
>     write (x, N - 1);
>   }
> #elif VERSION == 2
>   template <size_t N>
>   void __attribute__((noinline))
>   write (const char (&x)[N])
>   {
>     write (x, N - 1);
>   }
> #else
>   void __attribute__((noinline))
>   write (const char *x)
>   {
>     write (x, strlen (x));
>   }
> #endif
>   char buffer[4096];
>   char *end;
> };
> 
> int
> main ()
> {
>   S s;
>   for (int i = 0; i < 100000000; ++i)
>     {
> #if VERSION <= 4
>       s.write ("Hello!");
> #elif VERSION == 5
>       fputs_unlocked ("Hello!", stdout);
> #elif VERSION == 6
>       fwrite_unlocked ("Hello!", 6, 1, stdout);
> #elif VERSION == 7
>       std::cout << "Hello!";
> #else
> #error Please define VERSION
> #endif
>     }
>   return 0;
> }

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-08-07 13:50                       ` Trevor Saunders
@ 2015-08-07 20:24                         ` Richard Biener
  2015-08-07 21:52                           ` Richard Sandiford
  0 siblings, 1 reply; 31+ messages in thread
From: Richard Biener @ 2015-08-07 20:24 UTC (permalink / raw)
  To: Trevor Saunders, David Malcolm, tbsaunde+gcc, GCC Patches,
	richard.sandiford

On August 7, 2015 3:50:33 PM GMT+02:00, Trevor Saunders <tbsaunde@tbsaunde.org> wrote:
>On Fri, Aug 07, 2015 at 10:45:57AM +0100, Richard Sandiford wrote:
>> Trevor Saunders <tbsaunde@tbsaunde.org> writes:
>> > On Thu, Aug 06, 2015 at 08:36:36PM +0100, Richard Sandiford wrote:
>> >> An integrated assembler or tighter asm output would be nice, but
>when
>> >> I last checked LLVM was usually faster than GCC even when
>compiling to asm,
>> >> even though LLVM does use indirection (in the form of virtual
>functions)
>> >> for its output routines.  I don't think indirect function calls
>themselves
>> >> are the problem -- as long as we get the abstraction right :-)
>> >
>> > yeah, last time I looked (tbf a while ago) the C++ front end took
>up by
>> > far the largest part of the time.  So it may not be terribly
>important,
>> > but it would still be nice to figure out what a good design looks
>like.
>> 
>> I tried getting final to output the code a large number of times.
>> Obviously just sticking "for (i = 0; i < n; ++i)" around something
>> isn't the best way of measuring performance (for all the usual
>reasons)
>> but it was interesting even so.  A lot of the time is taken in calls
>to
>> strlen and in assemble_name itself (called by ASM_OUTPUT_LABEL).
>
>yeah, this data looks great.  I find it interesting that you say we
>spend so much time outputting labels as opposed to instructions.
>
>> Each time we call assemble_name we do:
>> 
>>   real_name = targetm.strip_name_encoding (name);
>> 
>>   id = maybe_get_identifier (real_name);
>>   if (id)
>>     {
>>       tree id_orig = id;
>> 
>>       mark_referenced (id);
>>       ultimate_transparent_alias_target (&id);
>>       if (id != id_orig)
>> 	name = IDENTIFIER_POINTER (id);
>>       gcc_assert (! TREE_CHAIN (id));
>>     }
>> 
>> Doing an identifier lookup every time we output a reference to a
>label
>> is pretty expensive.  Especially when many of the labels we're
>dealing
>> with are internal ones (basic block labels, debug labels, etc.) for
>which
>> the lookup is bound to fail.
>
>well, there's ASm_OUTPUT_INTERNAL_LABEL, and I think something similar
>for debug labels.  I guess we don't always use those where we could. 
>Or
>maybe the problem is we have places where we need to look at data to
>find out.  Maybe it would make sense to have the generally used
>output_label routine take a tree / rtx, and check if its a internal or
>debug label and dispatch appropriately.
>
>> So if compile-time for asm output is a concern, that seems like a
>good
>> place to start.  We should try harder to keep track of the identifier
>> behind a name (when there is one) and avoid this overhead for
>> internal labels.
>> 
>> Converting ASM_OUTPUT_LABEL to an indirect function call was in the
>> noise even with my for-loop hack.  The execution time of the hook is
>> dominated by assemble_name itself.  I hope patches like yours aren't
>> held up simply because they have the equivalent of a virtual
>function.
>
>Well, I think it makes sense to reroll this series, but I think I'll
>keep working on trying to replace these macros with something else.
>
>> Also, although we seem to be paranoid about virtual functions and
>> indirect calls, it's worth remembering that on most targets every
>> call to fputs(_unlocked), fwrite(_unlocked) and strlen is a PLT call.
>> Our current code calls fputs several times for one line of assembly,
>> including for short strings like register names.  This is doubly
>> inefficient because:
>> 
>> (a) we could reduce the number of PLT calls by doing the buffering
>>     ourselves and
>
>yeah, I mentioned that earlier, but its great to have data showing its
>a
>win!  I think its also probably important to enabling the other
>optimizations below.
>
>> (b) the names of those registers are known at compile time (or at
>least
>>     at start-up time) and are short, but we call strlen() on them
>>     each time we write them out.
>
>yeah, that seems like something that should be fixed, but I'm not sure
>off hand where to look for the code doing this.
>
>> E.g. for the attached microbenchmark I get:
>> 
>>   Time taken, normalised to VERSION==1
>> 
>>   VERSION==1:  1.000
>>   VERSION==2:  1.377
>>   VERSION==3:  3.202 (1.638 with -minline-all-stringops)
>>   VERSION==4:  4.242 (2.921 with -minline-all-stringops)
>>   VERSION==5:  4.526
>>   VERSION==6:  4.543
>>   VERSION==7: 10.884
>> 
>> where the results for 5 vs. 6 are in the noise.
>> 
>> The 5->4 gain is by doing the buffering ourselves.  The 4->3 gain is
>for
>> keeping track of the string length rather than recomputing it each
>time.
>> 
>> This suggests that if we're serious about trying to speed up the asm
>output,
>> it would be worth adding an equivalent of LLVM's StringRef that pairs
>a
>> const char * string with its length.
>
>I've thought a tiny bit about working on that, so its nice to have
>data.

Tree identifiers have an embedded length.
So its all about avoidibg this target hook mangling the labels.

Richard.

>Trev
>
>> 
>> Thanks,
>> Richard
>> 
>
>> #define _GNU_SOURCE 1
>> 
>> #include <stdio.h>
>> #include <string.h>
>> #include <iostream>
>> 
>> struct S
>> {
>>   S () : end (buffer) {}
>> 
>>   ~S ()
>>   {
>>     fwrite_unlocked (buffer, end - buffer, 1, stdout);
>>   }
>> 
>> #if VERSION == 3
>>   void __attribute__((noinline))
>> #else
>>   void
>> #endif
>>   write (const char *x, size_t len)
>>   {
>>     if (__builtin_expect (buffer + sizeof (buffer) - end < len, 0))
>>       {
>> 	fwrite_unlocked (buffer, end - buffer, 1, stdout);
>> 	end = buffer;
>>       }
>>     memcpy (end, x, len);
>>     end += len;
>>   }
>> 
>> #if VERSION == 1 || VERSION == 3
>>   template <size_t N>
>>   void
>>   write (const char (&x)[N])
>>   {
>>     write (x, N - 1);
>>   }
>> #elif VERSION == 2
>>   template <size_t N>
>>   void __attribute__((noinline))
>>   write (const char (&x)[N])
>>   {
>>     write (x, N - 1);
>>   }
>> #else
>>   void __attribute__((noinline))
>>   write (const char *x)
>>   {
>>     write (x, strlen (x));
>>   }
>> #endif
>>   char buffer[4096];
>>   char *end;
>> };
>> 
>> int
>> main ()
>> {
>>   S s;
>>   for (int i = 0; i < 100000000; ++i)
>>     {
>> #if VERSION <= 4
>>       s.write ("Hello!");
>> #elif VERSION == 5
>>       fputs_unlocked ("Hello!", stdout);
>> #elif VERSION == 6
>>       fwrite_unlocked ("Hello!", 6, 1, stdout);
>> #elif VERSION == 7
>>       std::cout << "Hello!";
>> #else
>> #error Please define VERSION
>> #endif
>>     }
>>   return 0;
>> }


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function
  2015-08-07 20:24                         ` Richard Biener
@ 2015-08-07 21:52                           ` Richard Sandiford
  0 siblings, 0 replies; 31+ messages in thread
From: Richard Sandiford @ 2015-08-07 21:52 UTC (permalink / raw)
  To: Richard Biener; +Cc: Trevor Saunders, David Malcolm, tbsaunde+gcc, GCC Patches

Richard Biener <richard.guenther@gmail.com> writes:
>>> E.g. for the attached microbenchmark I get:
>>> 
>>>   Time taken, normalised to VERSION==1
>>> 
>>>   VERSION==1:  1.000
>>>   VERSION==2:  1.377
>>>   VERSION==3:  3.202 (1.638 with -minline-all-stringops)
>>>   VERSION==4:  4.242 (2.921 with -minline-all-stringops)
>>>   VERSION==5:  4.526
>>>   VERSION==6:  4.543
>>>   VERSION==7: 10.884
>>> 
>>> where the results for 5 vs. 6 are in the noise.
>>> 
>>> The 5->4 gain is by doing the buffering ourselves.  The 4->3 gain is
>>for
>>> keeping track of the string length rather than recomputing it each
>>time.
>>> 
>>> This suggests that if we're serious about trying to speed up the asm
>>output,
>>> it would be worth adding an equivalent of LLVM's StringRef that pairs
>>a
>>> const char * string with its length.
>>
>>I've thought a tiny bit about working on that, so its nice to have
>>data.
>
> Tree identifiers have an embedded length.
> So its all about avoidibg this target hook mangling the labels.

Yeah, and register names start out as C strings where the length
is known at compile time.  Strings that result from sprintf have
a length given by the sprintf return value.

I think in practice most strings in GCC have (or had) a known length,
and the nice thing about StringRef-like classes is that they abstract
away the source of the length.  Even if we do have to use strlen,
the class makes sure we only calculate it once per object rather than
once per use.

Thanks,
Richard

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2015-08-07 21:52 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-25  2:37 [PATCH 0/4] misc work to get rid of target macros tbsaunde+gcc
2015-07-25  2:37 ` [PATCH 3/4] remove unused TARGET_DEFERRED_OUTPUT_DEFS tbsaunde+gcc
2015-07-31  0:55   ` Joseph Myers
2015-07-25  2:37 ` [PATCH 1/4] convert ASM_OUTPUT_ASCII to a hook tbsaunde+gcc
2015-07-25  6:22   ` pinskia
2015-07-25 19:44     ` Trevor Saunders
2015-07-25 17:02   ` Segher Boessenkool
2015-07-27 20:51   ` Richard Sandiford
2015-07-25  3:09 ` [PATCH 2/4] make TLS_COMMON_ASM_OP " tbsaunde+gcc
2015-07-25  5:42 ` [PATCH 4/4] define ASM_OUTPUT_LABEL to the name of a function tbsaunde+gcc
2015-07-25 18:34   ` Segher Boessenkool
2015-07-25 19:27     ` Trevor Saunders
2015-07-25 19:44       ` Segher Boessenkool
2015-07-27  9:17   ` Richard Biener
2015-07-28  6:45     ` Trevor Saunders
2015-07-29 23:05       ` Jeff Law
2015-08-05 10:58     ` Trevor Saunders
2015-08-05 11:47       ` Richard Biener
2015-08-05 13:38         ` Trevor Saunders
2015-08-05 13:59           ` Richard Biener
2015-08-05 22:28             ` Segher Boessenkool
2015-08-05 15:28         ` David Malcolm
2015-08-05 15:34           ` David Malcolm
2015-08-05 20:23             ` Trevor Saunders
2015-08-06 18:48               ` David Malcolm
2015-08-06 19:36                 ` Richard Sandiford
2015-08-07  4:32                   ` Trevor Saunders
2015-08-07  9:46                     ` Richard Sandiford
2015-08-07 13:50                       ` Trevor Saunders
2015-08-07 20:24                         ` Richard Biener
2015-08-07 21:52                           ` Richard Sandiford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).