[gcc(refs/users/marxin/heads/casm-state)] Step #1.
Martin Liska
marxin@gcc.gnu.org
Wed Sep 8 09:28:31 GMT 2021
https://gcc.gnu.org/g:00bb57fcbb1034a8986e725cb3706523b2291fbc
commit 00bb57fcbb1034a8986e725cb3706523b2291fbc
Author: Martin Liska <mliska@suse.cz>
Date: Tue Sep 7 13:32:57 2021 +0200
Step #1.
Diff:
---
gcc/config/i386/i386.c | 12 ++++++------
gcc/output.h | 25 +++++++++++++++++++------
gcc/toplev.c | 37 ++++++++++++++++++++-----------------
gcc/varasm.c | 8 --------
4 files changed, 45 insertions(+), 37 deletions(-)
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index dc649f96d0d..ba2ca033f5a 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -1567,7 +1567,7 @@ ix86_function_naked (const_tree fn)
/* Write the extra assembler code needed to declare a function properly. */
void
-ix86_asm_output_function_label (FILE *asm_out_file, const char *fname,
+ix86_asm_output_function_label (FILE *out_file, const char *fname,
tree decl)
{
bool is_ms_hook = ix86_function_ms_hook_prologue (decl);
@@ -1581,14 +1581,14 @@ ix86_asm_output_function_label (FILE *asm_out_file, const char *fname,
unsigned int filler_cc = 0xcccccccc;
for (i = 0; i < filler_count; i += 4)
- fprintf (asm_out_file, ASM_LONG " %#x\n", filler_cc);
+ fprintf (out_file, ASM_LONG " %#x\n", filler_cc);
}
#ifdef SUBTARGET_ASM_UNWIND_INIT
- SUBTARGET_ASM_UNWIND_INIT (asm_out_file);
+ SUBTARGET_ASM_UNWIND_INIT (out_file);
#endif
- ASM_OUTPUT_LABEL (asm_out_file, fname);
+ ASM_OUTPUT_LABEL (out_file, fname);
/* Output magic byte marker, if hot-patch attribute is set. */
if (is_ms_hook)
@@ -1597,14 +1597,14 @@ ix86_asm_output_function_label (FILE *asm_out_file, const char *fname,
{
/* leaq [%rsp + 0], %rsp */
fputs (ASM_BYTE "0x48, 0x8d, 0xa4, 0x24, 0x00, 0x00, 0x00, 0x00\n",
- asm_out_file);
+ out_file);
}
else
{
/* movl.s %edi, %edi
push %ebp
movl.s %esp, %ebp */
- fputs (ASM_BYTE "0x8b, 0xff, 0x55, 0x8b, 0xec\n", asm_out_file);
+ fputs (ASM_BYTE "0x8b, 0xff, 0x55, 0x8b, 0xec\n", out_file);
}
}
}
diff --git a/gcc/output.h b/gcc/output.h
index 73ca4545f4f..c7ee25c2bd4 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -313,9 +313,25 @@ extern rtx_sequence *final_sequence;
/* File in which assembler code is being written. */
-#ifdef BUFSIZ
-extern FILE *asm_out_file;
-#endif
+struct GTY(()) asm_out_state
+{
+ asm_out_state (): out_file (NULL), m_in_section (NULL),
+ m_in_cold_section_p (false)
+ {}
+
+ /* Assembly output stream. */
+ FILE * GTY((skip)) out_file;
+
+ section *m_in_section;
+ bool m_in_cold_section_p;
+};
+
+extern GTY(()) asm_out_state *casm;
+
+/* Helper macro for commonly used accesses. */
+#define asm_out_file casm->out_file
+#define in_section casm->m_in_section
+#define in_cold_section_p casm->m_in_cold_section_p
/* The first global object in the file. */
extern const char *first_global_object_name;
@@ -526,9 +542,6 @@ extern GTY(()) section *comm_section;
extern GTY(()) section *lcomm_section;
extern GTY(()) section *bss_noswitch_section;
-extern GTY(()) section *in_section;
-extern GTY(()) bool in_cold_section_p;
-
extern section *get_unnamed_section (unsigned int, void (*) (const void *),
const void *);
extern section *get_section (const char *, unsigned int, tree,
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 319d9e14481..87e057f4f92 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -171,7 +171,8 @@ const char *user_label_prefix;
/* Output files for assembler code (real compiler output)
and debugging dumps. */
-FILE *asm_out_file;
+asm_out_state *casm;
+
FILE *aux_info_file;
FILE *callgraph_info_file = NULL;
static bitmap callgraph_info_external_printed;
@@ -555,13 +556,13 @@ compile_file (void)
if (flag_generate_lto && !flag_fat_lto_objects)
{
#if defined ASM_OUTPUT_ALIGNED_DECL_COMMON
- ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file, NULL_TREE, "__gnu_lto_slim",
+ ASM_OUTPUT_ALIGNED_DECL_COMMON (casm->out_file, NULL_TREE, "__gnu_lto_slim",
HOST_WIDE_INT_1U, 8);
#elif defined ASM_OUTPUT_ALIGNED_COMMON
- ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, "__gnu_lto_slim",
+ ASM_OUTPUT_ALIGNED_COMMON (casm->out_file, "__gnu_lto_slim",
HOST_WIDE_INT_1U, 8);
#else
- ASM_OUTPUT_COMMON (asm_out_file, "__gnu_lto_slim",
+ ASM_OUTPUT_COMMON (casm->out_file, "__gnu_lto_slim",
HOST_WIDE_INT_1U,
HOST_WIDE_INT_1U);
#endif
@@ -699,7 +700,7 @@ void
init_asm_output (const char *name)
{
if (name == NULL && asm_file_name == 0)
- asm_out_file = stdout;
+ casm->out_file = stdout;
else
{
if (asm_file_name == 0)
@@ -713,17 +714,17 @@ init_asm_output (const char *name)
asm_file_name = dumpname;
}
if (!strcmp (asm_file_name, "-"))
- asm_out_file = stdout;
+ casm->out_file = stdout;
else if (!canonical_filename_eq (asm_file_name, name)
|| !strcmp (asm_file_name, HOST_BIT_BUCKET))
- asm_out_file = fopen (asm_file_name, "w");
+ casm->out_file = fopen (asm_file_name, "w");
else
/* Use UNKOWN_LOCATION to prevent gcc from printing the first
line in the current file. */
fatal_error (UNKNOWN_LOCATION,
"input file %qs is the same as output file",
asm_file_name);
- if (asm_out_file == 0)
+ if (casm->out_file == 0)
fatal_error (UNKNOWN_LOCATION,
"cannot open %qs for writing: %m", asm_file_name);
}
@@ -750,14 +751,14 @@ init_asm_output (const char *name)
if (flag_verbose_asm)
{
- print_version (asm_out_file, ASM_COMMENT_START, true);
- fputs (ASM_COMMENT_START, asm_out_file);
- fputs (" options passed: ", asm_out_file);
+ print_version (casm->out_file, ASM_COMMENT_START, true);
+ fputs (ASM_COMMENT_START, casm->out_file);
+ fputs (" options passed: ", casm->out_file);
char *cmdline = gen_command_line_string (save_decoded_options,
save_decoded_options_count);
- fputs (cmdline, asm_out_file);
+ fputs (cmdline, casm->out_file);
free (cmdline);
- fputc ('\n', asm_out_file);
+ fputc ('\n', casm->out_file);
}
}
}
@@ -1115,6 +1116,9 @@ general_init (const char *argv0, bool init_signals)
symtab = new (ggc_alloc <symbol_table> ()) symbol_table ();
+ /* Initialize ASM out state. */
+ casm = new (ggc_alloc<asm_out_state> ()) asm_out_state ();
+
statistics_early_init ();
debuginfo_early_init ();
}
@@ -2084,13 +2088,12 @@ finalize (bool no_backend)
whether fclose returns an error, since the pages might still be on the
buffer chain while the file is open. */
- if (asm_out_file)
+ if (casm->out_file)
{
- if (ferror (asm_out_file) != 0)
+ if (ferror (casm->out_file) != 0)
fatal_error (input_location, "error writing to %s: %m", asm_file_name);
- if (fclose (asm_out_file) != 0)
+ if (fclose (casm->out_file) != 0)
fatal_error (input_location, "error closing %s: %m", asm_file_name);
- asm_out_file = NULL;
}
if (stack_usage_file)
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 53cf6dea3f3..b876063f5be 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -159,14 +159,6 @@ section *exception_section;
first call to switch_to_eh_frame_section. */
section *eh_frame_section;
-/* asm_out_file's current section. This is NULL if no section has yet
- been selected or if we lose track of what the current section is. */
-section *in_section;
-
-/* True if code for the current function is currently being directed
- at the cold section. */
-bool in_cold_section_p;
-
/* The following global holds the "function name" for the code in the
cold section of a function, if hot/cold function splitting is enabled
and there was actually code that went into the cold section. A
More information about the Gcc-cvs
mailing list