This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: Rewrite score_output_external
- From: "H. J. Lu" <hjl at lucon dot org>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 15 Jan 2007 11:10:03 -0800
- Subject: PATCH: Rewrite score_output_external
This patch rewrote score_output_external, which is only called once
by process_pending_assemble_externals at the end of compilation. There
is no need for TARGET_ASM_FILE_END anymore.
H.J.
----
2007-01-15 H.J. Lu <hongjiu.lu@intel.com>
* config/score/score-protos.h (score_output_external): Make it
return void.
* config/score/score.c (TARGET_ASM_FILE_END): Removed.
(extern_head): Likewise.
(th_asm_file_end): Likewise.
(score_output_external): Rewritten.
* onfig/score/score.h (ASM_OUTPUT_EXTERNAL): Undef before
define.
(extern_list): Removed.
(extern_head): Likewise.
--- gcc/config/score/score-protos.h.global 2007-01-09 16:43:03.000000000 -0800
+++ gcc/config/score/score-protos.h 2007-01-15 10:06:55.000000000 -0800
@@ -76,7 +76,7 @@ void score_declare_object (FILE *stream,
void score_declare_object_name (FILE *stream, const char *name, tree decl);
-int score_output_external (FILE *file, tree decl, const char *name);
+void score_output_external (FILE *file, tree decl, const char *name);
void score_print_operand (FILE *file, rtx op, int letter);
--- gcc/config/score/score.c.global 2007-01-09 16:43:03.000000000 -0800
+++ gcc/config/score/score.c 2007-01-15 10:13:33.000000000 -0800
@@ -74,9 +74,6 @@ static int score_address_cost (rtx);
#undef TARGET_ASM_FILE_START
#define TARGET_ASM_FILE_START th_asm_file_start
-#undef TARGET_ASM_FILE_END
-#define TARGET_ASM_FILE_END th_asm_file_end
-
#undef TARGET_ASM_FUNCTION_PROLOGUE
#define TARGET_ASM_FUNCTION_PROLOGUE th_function_prologue
@@ -462,33 +459,6 @@ th_asm_file_start (void)
fprintf (asm_out_file, "\t.set pic\n");
}
-/* Implement TARGET_ASM_FILE_END. When using assembler macros, emit
- .externs for any small-data variables that turned out to be external. */
-struct extern_list *extern_head = 0;
-
-static void
-th_asm_file_end (void)
-{
- tree name_tree;
- struct extern_list *p;
- if (extern_head)
- {
- fputs ("\n", asm_out_file);
- for (p = extern_head; p != 0; p = p->next)
- {
- name_tree = get_identifier (p->name);
- if (!TREE_ASM_WRITTEN (name_tree)
- && TREE_SYMBOL_REFERENCED (name_tree))
- {
- TREE_ASM_WRITTEN (name_tree) = 1;
- fputs ("\t.extern\t", asm_out_file);
- assemble_name (asm_out_file, p->name);
- fprintf (asm_out_file, ", %d\n", p->size);
- }
- }
- }
-}
-
static unsigned int sdata_max;
int
@@ -1096,21 +1066,27 @@ score_address_cost (rtx addr)
}
/* Implement ASM_OUTPUT_EXTERNAL macro. */
-int
-score_output_external (FILE *file ATTRIBUTE_UNUSED,
- tree decl, const char *name)
+void
+score_output_external (FILE *file, tree decl, const char *name)
{
- register struct extern_list *p;
-
- if (th_in_small_data_p (decl))
- {
- p = (struct extern_list *) ggc_alloc (sizeof (struct extern_list));
- p->next = extern_head;
- p->name = name;
- p->size = int_size_in_bytes (TREE_TYPE (decl));
- extern_head = p;
+ /* We output the name if and only if TREE_SYMBOL_REFERENCED is
+ set in order to avoid putting out names that are never really
+ used. */
+ if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
+ {
+#ifdef USING_ELFOS_H
+ if (targetm.binds_local_p (decl))
+ maybe_assemble_visibility (decl);
+#endif
+
+ if (th_in_small_data_p (decl))
+ {
+ fputs ("\t.extern\t", file);
+ assemble_name (file, name);
+ fprintf (file, ", %ld\n",
+ int_size_in_bytes (TREE_TYPE (decl)));
+ }
}
- return 0;
}
/* Output format asm string. */
--- gcc/config/score/score.h.global 2007-01-09 16:43:03.000000000 -0800
+++ gcc/config/score/score.h 2007-01-15 10:14:10.000000000 -0800
@@ -773,6 +773,7 @@ typedef struct score_args
output anything and let undefined symbol become external. However
the assembler uses length information on externals to allocate in
data/sdata bss/sbss, thereby saving exec time. */
+#undef ASM_OUTPUT_EXTERNAL
#define ASM_OUTPUT_EXTERNAL(STREAM, DECL, NAME) \
score_output_external (STREAM, DECL, NAME)
@@ -936,12 +937,3 @@ typedef struct score_args
/* Give call MEMs SImode since it is the "most permissive" mode
for 32-bit targets. */
#define FUNCTION_MODE Pmode
-
-struct extern_list GTY ((chain_next ("%h.next")))
-{
- struct extern_list *next; /* next external */
- const char *name; /* name of the external */
- int size; /* size in bytes */
-};
-
-extern GTY (()) struct extern_list *extern_head;