public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Matthew Malcomson <matmal01@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] Declare all constants with an associated size Date: Tue, 21 Sep 2021 09:14:40 +0000 (GMT) [thread overview] Message-ID: <20210921091440.D4197385801A@sourceware.org> (raw) https://gcc.gnu.org/g:e3653f9e4f8bbd822de3ab7db22a3b10f8a9895d commit e3653f9e4f8bbd822de3ab7db22a3b10f8a9895d Author: Matthew Malcomson <matthew.malcomson@arm.com> Date: Thu Sep 16 11:33:49 2021 +0100 Declare all constants with an associated size For PureCap we have introduced an indirection layer for loading the address of objects. For each indirected object, rather than calculate a pointer directly we load a capability from a table. The runtime populates this table. To populate the table we create a CAPINIT relocation for each entry. The linker requires a size for every symbol that we create a CAPINIT relocation for. This patch adds a `.size` directive to all constants with a DECL by implementing the `TARGET_ASM_DECLARE_CONSTANT_NAME` target hook. It adds a `.size` directive to every CONSTANT_POOL_ADDRESS_P symbol by adding the relevant code to `output_constant_pool_1`. It adds a `.size` directive to the .LTRAMP0 symbol in `assemble_trampoline_template`. There is still more work to do in this area -- there are more instances of this linker complaint in the testsuite -- but these are only for symbols that have an explicit size of zero. Such symbols are currently given the bounds of the entire section, and investigation into any alternative is a task for the future. This commit also adds a `.type` directive on each such object since we are adding the `.size` directive and specifying that these things are objects seems a nice add-on. We also introduce a helper function that emits the `.type` and `.size` directives for an object given its size. This patch removes a lot of link errors in the testsuite after the introduction of the indirection table containing `.capinit` relocations for any symbol that is loaded in code. Diff: --- gcc/config/aarch64/aarch64.c | 12 ++++++++++++ gcc/output.h | 5 +++++ gcc/varasm.c | 17 ++++++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 6f34ee8c672..53b479e8c9d 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -11636,6 +11636,15 @@ aarch64_use_anchors_for_symbol_p (const_rtx x) return default_use_anchors_for_symbol_p (x); } +static void +aarch64_declare_constant_name (FILE *file, const char *name, + const_tree exp ATTRIBUTE_UNUSED, + HOST_WIDE_INT size) +{ + assemble_object_type_and_size (file, name, size); + return default_asm_declare_constant_name (file, name, exp, size); +} + /* Select appropriate section for constants depending on where we place literal pools. */ @@ -24814,6 +24823,9 @@ aarch64_libgcc_floating_mode_supported_p #undef TARGET_CAPABILITY_MODE #define TARGET_CAPABILITY_MODE aarch64_target_capability_mode +#undef TARGET_ASM_DECLARE_CONSTANT_NAME +#define TARGET_ASM_DECLARE_CONSTANT_NAME aarch64_declare_constant_name + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-aarch64.h" diff --git a/gcc/output.h b/gcc/output.h index 378fd196b2f..8705aeb2981 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -231,6 +231,11 @@ extern void assemble_external_libcall (rtx); /* Assemble a label named NAME. */ extern void assemble_label (FILE *, const char *); +/* Assemble the type and size directives associated with a label. + Assume that the label is an object (since all use cases at the moment are + for objects. */ +extern void assemble_object_type_and_size (FILE *, const char *, HOST_WIDE_INT); + /* Output to FILE (an assembly file) a reference to NAME. If NAME starts with a *, the rest of NAME is output verbatim. Otherwise NAME is transformed in a target-specific way (usually by the diff --git a/gcc/varasm.c b/gcc/varasm.c index d5f41d5ec25..c3c0d1959a5 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -2514,6 +2514,15 @@ assemble_label (FILE *file, const char *name) ASM_OUTPUT_LABEL (file, name); } +void +assemble_object_type_and_size (FILE *file, const char *in_name, + HOST_WIDE_INT size) +{ + const char *name = targetm.strip_name_encoding (in_name); + asm_fprintf (file, "\t.type\t%s, %%object\n", name); + asm_fprintf (file, "\t.size\t%s, %" PRId64 "\n", name, size); +} + /* Set the symbol_referenced flag for ID. */ void mark_referenced (tree id) @@ -2681,6 +2690,9 @@ assemble_trampoline_template (void) set_mem_align (initial_trampoline, TRAMPOLINE_ALIGNMENT); set_mem_size (initial_trampoline, TRAMPOLINE_SIZE); + /* Output the relevant size for the trampoline. */ + assemble_object_type_and_size (asm_out_file, label, TRAMPOLINE_SIZE); + return initial_trampoline; } \f @@ -4105,7 +4117,10 @@ output_constant_pool_1 (class constant_descriptor_rtx *desc, assemble_align (align); /* Output the label. */ - targetm.asm_out.internal_label (asm_out_file, "LC", desc->labelno); + char buf[42]; + ASM_GENERATE_INTERNAL_LABEL (buf, "LC", desc->labelno); + assemble_object_type_and_size (asm_out_file, buf, GET_MODE_SIZE (desc->mode)); + ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, buf); /* Output the data. Pass actual alignment value while emitting string constant to asm code
reply other threads:[~2021-09-21 9:14 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210921091440.D4197385801A@sourceware.org \ --to=matmal01@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).