public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/casm-refactoring-v3)] Port PPC64.
@ 2021-10-21 7:51 Martin Liska
0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2021-10-21 7:51 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:cdf435e503a365675f880de86311b5dedb7b4a7a
commit cdf435e503a365675f880de86311b5dedb7b4a7a
Author: Martin Liska <mliska@suse.cz>
Date: Thu Oct 21 09:14:35 2021 +0200
Port PPC64.
Diff:
---
gcc/config/rs6000/rs6000-internal.h | 11 +++++
gcc/config/rs6000/rs6000-logue.c | 2 +-
gcc/config/rs6000/rs6000.c | 24 +++++-----
gcc/config/rs6000/rs6000.h | 1 -
gcc/coretypes.h | 1 +
gcc/doc/tm.texi | 2 +-
gcc/output.h | 11 ++---
gcc/target.def | 4 +-
gcc/varasm.c | 88 +++++++++++++++++++++++--------------
9 files changed, 87 insertions(+), 57 deletions(-)
diff --git a/gcc/config/rs6000/rs6000-internal.h b/gcc/config/rs6000/rs6000-internal.h
index 88cf9bd5692..9898e9a6842 100644
--- a/gcc/config/rs6000/rs6000-internal.h
+++ b/gcc/config/rs6000/rs6000-internal.h
@@ -189,4 +189,15 @@ extern bool rs6000_passes_vector;
extern bool rs6000_returns_struct;
extern bool cpu_builtin_p;
+struct rs6000_asm_out_state : public asm_out_state
+{
+ struct
+ {
+ section *toc;
+ section *sdata2;
+ } target_sec;
+};
+
+#define rs6000_casm static_cast<rs6000_asm_out_state *> (casm)
+
#endif
diff --git a/gcc/config/rs6000/rs6000-logue.c b/gcc/config/rs6000/rs6000-logue.c
index 9965a8aa691..7a078817fe3 100644
--- a/gcc/config/rs6000/rs6000-logue.c
+++ b/gcc/config/rs6000/rs6000-logue.c
@@ -5506,7 +5506,7 @@ rs6000_output_function_epilogue (FILE *file)
need_toc_init = 0;
if (!toc_initialized)
{
- switch_to_section (toc_section);
+ switch_to_section (rs6000_casm->target_sec.toc);
switch_to_section (current_function_section ());
}
}
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index a601eb6728a..1dcc1948b60 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -187,9 +187,6 @@ static GTY(()) section *private_data_section;
static GTY(()) section *tls_data_section;
static GTY(()) section *tls_private_data_section;
static GTY(()) section *read_only_private_data_section;
-static GTY(()) section *sdata2_section;
-
-section *toc_section = 0;
/* Describe the vector unit used for modes. */
enum rs6000_vector rs6000_vector_unit[NUM_MACHINE_MODES];
@@ -14747,7 +14744,7 @@ rs6000_assemble_integer (rtx x, unsigned int size, int aligned_p)
section. */
if (DEFAULT_ABI == ABI_V4
&& (TARGET_RELOCATABLE || flag_pic > 1)
- && casm->in_section != toc_section
+ && casm->in_section != rs6000_casm->target_sec.toc
&& !recurse
&& !CONST_SCALAR_INT_P (x)
&& CONSTANT_P (x))
@@ -20686,15 +20683,14 @@ rs6000_elf_output_toc_section_asm_op (const void *data ATTRIBUTE_UNUSED)
/* Implement TARGET_ASM_INIT_SECTIONS. */
-static void
+static asm_out_state *
rs6000_elf_asm_init_sections (void)
{
- toc_section
- = get_unnamed_section (0, rs6000_elf_output_toc_section_asm_op, NULL);
+ rs6000_asm_out_state *state
+ = new (ggc_alloc<rs6000_asm_out_state> ()) rs6000_asm_out_state ();
+ state->init_sections ();
- sdata2_section
- = get_unnamed_section (SECTION_WRITE, output_section_asm_op,
- SDATA2_SECTION_ASM_OP);
+ return state;
}
/* Implement TARGET_SELECT_RTX_SECTION. */
@@ -20704,7 +20700,7 @@ rs6000_elf_select_rtx_section (machine_mode mode, rtx x,
unsigned HOST_WIDE_INT align)
{
if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (x, mode))
- return toc_section;
+ return rs6000_casm->target_sec.toc;
else
return default_elf_select_rtx_section (mode, x, align);
}
@@ -21418,7 +21414,7 @@ rs6000_xcoff_asm_init_sections (void)
rs6000_xcoff_output_tls_section_asm_op,
&xcoff_private_data_section_name);
- toc_section
+ rs6000_casm->target_sec.toc
= get_unnamed_section (0, rs6000_xcoff_output_toc_section_asm_op, NULL);
casm->sec.readonly_data = read_only_data_section;
@@ -21535,7 +21531,7 @@ rs6000_xcoff_select_rtx_section (machine_mode mode, rtx x,
unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
{
if (ASM_OUTPUT_SPECIAL_POOL_ENTRY_P (x, mode))
- return toc_section;
+ return rs6000_casm->target_sec.tos;
else
return read_only_private_data_section;
}
@@ -21612,7 +21608,7 @@ rs6000_xcoff_file_start (void)
fputc ('\n', asm_out_file);
if (write_symbols != NO_DEBUG)
switch_to_section (private_data_section);
- switch_to_section (toc_section);
+ switch_to_section (rs6000_casm->target_sec.tos);
switch_to_section (casm->sec.text);
if (profile_flag)
fprintf (asm_out_file, "\t.extern %s\n", RS6000_MCOUNT);
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index 3eba1c072cf..ee49446c72c 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -2606,7 +2606,6 @@ extern GTY(()) tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT];
#ifndef USED_FOR_TARGET
extern GTY(()) tree builtin_mode_to_type[MAX_MACHINE_MODE][2];
extern GTY(()) tree altivec_builtin_mask_for_load;
-extern GTY(()) section *toc_section;
/* A C structure for machine-specific, per-function data.
This is added to the cfun structure. */
diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index b4f530d57ac..181764e8eaa 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -99,6 +99,7 @@ typedef const union tree_node *const_tree;
struct gimple;
typedef gimple *gimple_seq;
struct gimple_stmt_iterator;
+struct asm_out_state;
/* Forward decls for leaf gimple subclasses (for individual gimple codes).
Keep this in the same order as the corresponding codes in gimple.def. */
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 73ea9a3d920..af90c6b6a86 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -7761,7 +7761,7 @@ readonly data section is used.
This macro is irrelevant if there is no separate readonly data section.
@end defmac
-@deftypefn {Target Hook} void TARGET_ASM_INIT_SECTIONS (void)
+@deftypefn {Target Hook} {asm_out_state *} TARGET_ASM_INIT_SECTIONS (void)
Define this hook if you need to do something special to set up the
@file{varasm.c} sections, or if your target has some special sections
of its own that you need to create.
diff --git a/gcc/output.h b/gcc/output.h
index 2c6ddb1a32e..099abed91a1 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -325,11 +325,11 @@ struct section_hasher : ggc_ptr_hash<section>
struct GTY(()) asm_out_state
{
- asm_out_state (): out_file (NULL), in_section (NULL),
- sec ({}), anchor_labelno (0), in_cold_section_p (false)
- {
- section_htab = hash_table<section_hasher>::create_ggc (31);
- }
+ /* Default constructor. */
+ asm_out_state ();
+
+ /* Initialize all sections in SEC variable. */
+ void init_sections (void);
/* Assembly output stream. */
FILE * GTY((skip)) out_file;
@@ -618,6 +618,7 @@ extern void record_tm_clone_pair (tree, tree);
extern void finish_tm_clone_pairs (void);
extern tree get_tm_clone_pair (tree);
+extern asm_out_state *default_init_sections (void);
extern void default_asm_output_source_filename (FILE *, const char *);
extern void output_file_directive (FILE *, const char *);
diff --git a/gcc/target.def b/gcc/target.def
index 87feeec2ea1..044a1f2c48f 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -429,8 +429,8 @@ of its own that you need to create.\n\
GCC calls this hook after processing the command line, but before writing\n\
any assembly code, and before calling any of the section-returning hooks\n\
described below.",
- void, (void),
- hook_void_void)
+ asm_out_state *, (void),
+ default_init_sections)
/* Tell assembler to change to section NAME with attributes FLAGS.
If DECL is non-NULL, it is the VAR_DECL or FUNCTION_DECL with
diff --git a/gcc/varasm.c b/gcc/varasm.c
index f0253383344..ae2d960104b 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -6548,81 +6548,103 @@ make_decl_one_only (tree decl, tree comdat_group)
}
}
-void
-init_varasm_once (void)
+/* Default constructor. */
+
+asm_out_state::asm_out_state ()
+: out_file (NULL), in_section (NULL),
+ sec ({}), anchor_labelno (0), in_cold_section_p (false)
{
- /* Initialize ASM out state. */
- casm = new (ggc_alloc<asm_out_state> ()) asm_out_state ();
+ section_htab = hash_table<section_hasher>::create_ggc (31);
object_block_htab = hash_table<object_block_hasher>::create_ggc (31);
const_desc_htab = hash_table<tree_descriptor_hasher>::create_ggc (1009);
shared_constant_pool = create_constant_pool ();
+}
+
+/* Initialize all sections in SEC variable. */
+void
+asm_out_state::init_sections (void)
+{
#ifdef TEXT_SECTION_ASM_OP
- casm->sec.text = get_unnamed_section (SECTION_CODE, output_section_asm_op,
- TEXT_SECTION_ASM_OP);
+ sec.text = get_unnamed_section (SECTION_CODE, output_section_asm_op,
+ TEXT_SECTION_ASM_OP);
#endif
#ifdef DATA_SECTION_ASM_OP
- casm->sec.data = get_unnamed_section (SECTION_WRITE, output_section_asm_op,
- DATA_SECTION_ASM_OP);
+ sec.data = get_unnamed_section (SECTION_WRITE, output_section_asm_op,
+ DATA_SECTION_ASM_OP);
#endif
#ifdef SDATA_SECTION_ASM_OP
- casm->sec.sdata = get_unnamed_section (SECTION_WRITE, output_section_asm_op,
- SDATA_SECTION_ASM_OP);
+ sec.sdata = get_unnamed_section (SECTION_WRITE, output_section_asm_op,
+ SDATA_SECTION_ASM_OP);
#endif
#ifdef READONLY_DATA_SECTION_ASM_OP
- casm->sec.readonly_data = get_unnamed_section (0, output_section_asm_op,
- READONLY_DATA_SECTION_ASM_OP);
+ sec.readonly_data = get_unnamed_section (0, output_section_asm_op,
+ READONLY_DATA_SECTION_ASM_OP);
#endif
#ifdef CTORS_SECTION_ASM_OP
- casm->sec.ctors = get_unnamed_section (0, output_section_asm_op,
- CTORS_SECTION_ASM_OP);
+ sec.ctors = get_unnamed_section (0, output_section_asm_op,
+ CTORS_SECTION_ASM_OP);
#endif
#ifdef DTORS_SECTION_ASM_OP
- casm->sec.dtors = get_unnamed_section (0, output_section_asm_op,
- DTORS_SECTION_ASM_OP);
+ sec.dtors = get_unnamed_section (0, output_section_asm_op,
+ DTORS_SECTION_ASM_OP);
#endif
#ifdef BSS_SECTION_ASM_OP
- casm->sec.bss = get_unnamed_section (SECTION_WRITE | SECTION_BSS,
- output_section_asm_op,
- BSS_SECTION_ASM_OP);
+ sec.bss = get_unnamed_section (SECTION_WRITE | SECTION_BSS,
+ output_section_asm_op,
+ BSS_SECTION_ASM_OP);
#endif
#ifdef SBSS_SECTION_ASM_OP
- casm->sec.sbss = get_unnamed_section (SECTION_WRITE | SECTION_BSS,
- output_section_asm_op,
- SBSS_SECTION_ASM_OP);
+ sec.sbss = get_unnamed_section (SECTION_WRITE | SECTION_BSS,
+ output_section_asm_op,
+ SBSS_SECTION_ASM_OP);
#endif
- casm->sec.tls_comm = get_noswitch_section (SECTION_WRITE | SECTION_BSS
- | SECTION_COMMON, emit_tls_common);
- casm->sec.lcomm = get_noswitch_section (SECTION_WRITE | SECTION_BSS
- | SECTION_COMMON, emit_local);
- casm->sec.comm = get_noswitch_section (SECTION_WRITE | SECTION_BSS
- | SECTION_COMMON, emit_common);
+ sec.tls_comm = get_noswitch_section (SECTION_WRITE | SECTION_BSS
+ | SECTION_COMMON, emit_tls_common);
+ sec.lcomm = get_noswitch_section (SECTION_WRITE | SECTION_BSS
+ | SECTION_COMMON, emit_local);
+ sec.comm = get_noswitch_section (SECTION_WRITE | SECTION_BSS
+ | SECTION_COMMON, emit_common);
#if defined ASM_OUTPUT_ALIGNED_BSS
- casm->sec.bss_noswitch = get_noswitch_section (SECTION_WRITE | SECTION_BSS,
- emit_bss);
+ sec.bss_noswitch = get_noswitch_section (SECTION_WRITE | SECTION_BSS,
+ emit_bss);
#endif
- targetm.asm_out.init_sections ();
+ if (sec.readonly_data == NULL)
+ sec.readonly_data = sec.text;
+}
- if (casm->sec.readonly_data == NULL)
- casm->sec.readonly_data = casm->sec.text;
+void
+init_varasm_once (void)
+{
+ casm = targetm.asm_out.init_sections ();
#ifdef ASM_OUTPUT_EXTERNAL
pending_assemble_externals_set = new hash_set<tree>;
#endif
}
+/* Default implementation of init_sections target hook. */
+
+asm_out_state *
+default_init_sections (void)
+{
+ asm_out_state *state = new (ggc_alloc<asm_out_state> ()) asm_out_state ();
+ state->init_sections ();
+ return state;
+}
+
enum tls_model
decl_default_tls_model (const_tree decl)
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-21 7:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21 7:51 [gcc(refs/users/marxin/heads/casm-refactoring-v3)] Port PPC64 Martin Liska
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).