This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Minor optimization: Turn a large macro into a function
- From: Andi Kleen <ak at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 2 Feb 2007 18:03:29 +0100
- Subject: [PATCH] Minor optimization: Turn a large macro into a function
Noticed this while looking for something else. On i386-elf
ASM_OUTPUT_ASCII() is a quite long and complex macro, but it is called 6
times. Call it from a common function instead to shrink the compiler
executable slightly. This also gives better type checking.
No functional changes.
I suspect this change could be done for far more config/ macros -- a lot
of them seem to be quite big and likely called multiple times.
Passed bootstrap/test on x86_64-linux.
-Andi
2007-02-02 Andi Kleen <ak@suse.de>
* varasm.c (asm_output_ascii): Add.
* output.h (asm_output_ascii): Declare.
* varasm.c, dwarf2asm.c: Call asm_output_ascii.
Index: gcc/dwarf2asm.c
===================================================================
--- gcc/dwarf2asm.c (revision 121493)
+++ gcc/dwarf2asm.c (working copy)
@@ -277,7 +277,7 @@
is a null termination in the string buffer. */
if (orig_len == (size_t) -1)
len += 1;
- ASM_OUTPUT_ASCII (asm_out_file, str, len);
+ asm_output_ascii (asm_out_file, str, len);
if (orig_len != (size_t) -1)
assemble_integer (const0_rtx, 1, BITS_PER_UNIT, 1);
}
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c (revision 121493)
+++ gcc/varasm.c (working copy)
@@ -1553,6 +1553,14 @@
}
}
+/* Output a string */
+
+void
+asm_output_ascii (FILE *file, const char *str, int length)
+{
+ ASM_OUTPUT_ASCII (file, str, length);
+}
+
/* Assemble a string constant with the specified C string as contents. */
void
@@ -1569,7 +1577,7 @@
if (thissize > maximum)
thissize = maximum;
- ASM_OUTPUT_ASCII (asm_out_file, p, thissize);
+ asm_output_ascii (asm_out_file, p, thissize);
pos += thissize;
p += thissize;
@@ -6273,14 +6281,14 @@
unsigned int len = strlen (buffer);
snprintf (buffer + len, sizeof buffer - len, " %s", name);
- ASM_OUTPUT_ASCII (asm_out_file, buffer, strlen (buffer));
+ asm_output_ascii (asm_out_file, buffer, strlen (buffer));
ASM_OUTPUT_SKIP (asm_out_file, (unsigned HOST_WIDE_INT) 1);
previous_name_held_back = FALSE;
}
else
{
strncpy (buffer, name, sizeof buffer);
- ASM_OUTPUT_ASCII (asm_out_file, buffer, strlen (buffer));
+ asm_output_ascii (asm_out_file, buffer, strlen (buffer));
ASM_OUTPUT_SKIP (asm_out_file, (unsigned HOST_WIDE_INT) 1);
}
}
@@ -6288,7 +6296,7 @@
{
if (previous_name_held_back)
{
- ASM_OUTPUT_ASCII (asm_out_file, buffer, strlen (buffer));
+ asm_output_ascii (asm_out_file, buffer, strlen (buffer));
ASM_OUTPUT_SKIP (asm_out_file, (unsigned HOST_WIDE_INT) 1);
}
@@ -6307,7 +6315,7 @@
{
if (previous_name_held_back)
{
- ASM_OUTPUT_ASCII (asm_out_file, buffer, strlen (buffer));
+ asm_output_ascii (asm_out_file, buffer, strlen (buffer));
ASM_OUTPUT_SKIP (asm_out_file, (unsigned HOST_WIDE_INT) 1);
}
}
Index: gcc/output.h
===================================================================
--- gcc/output.h (revision 121493)
+++ gcc/output.h (working copy)
@@ -218,6 +218,9 @@
/* Assemble a string constant with the specified C string as contents. */
extern void assemble_string (const char *, int);
+/* Output a string */
+extern void asm_output_ascii (FILE *, const char *, int);
+
/* Similar, for calling a library function FUN. */
extern void assemble_external_libcall (rtx);