* [PATCH] RISC-V: Use .p2align for code-alignment
@ 2022-11-13 20:41 Philipp Tomsich
2022-11-15 16:37 ` Jeff Law
0 siblings, 1 reply; 4+ messages in thread
From: Philipp Tomsich @ 2022-11-13 20:41 UTC (permalink / raw)
To: gcc-patches
Cc: Christoph Muellner, Palmer Dabbelt, Vineet Gupta, Kito Cheng,
Jeff Law, Philipp Tomsich
RISC-V's .p2align (currently) ignores the max-skip argument. As we
have experimental patches underway to address this in a
backwards-compatible manner, let's prepare GCC for the day when
binutils gets updated.
gcc/ChangeLog:
* config/riscv/riscv.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Implement.
Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
---
gcc/config/riscv/riscv.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
index 2d0d170645c..c216173cf6b 100644
--- a/gcc/config/riscv/riscv.h
+++ b/gcc/config/riscv/riscv.h
@@ -938,6 +938,24 @@ typedef struct {
fprintf (STREAM, "\t.word\t%sL%d-%sL%d\n", \
LOCAL_LABEL_PREFIX, VALUE, LOCAL_LABEL_PREFIX, REL)
+#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
+/* Support for -falign-* switches. Use .p2align to ensure that code
+ sections are padded with NOP instructions, rather than zeros. */
+#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \
+ do \
+ { \
+ if ((LOG) != 0) \
+ { \
+ if ((MAX_SKIP) == 0) \
+ fprintf ((FILE), "\t.p2align %d\n", (int) (LOG)); \
+ else \
+ fprintf ((FILE), "\t.p2align %d,,%d\n", \
+ (int) (LOG), (int) (MAX_SKIP)); \
+ } \
+ } while (0)
+
+#endif /* HAVE_GAS_MAX_SKIP_P2ALIGN */
+
/* This is how to output an assembler line
that says to advance the location counter
to a multiple of 2**LOG bytes. */
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] RISC-V: Use .p2align for code-alignment
2022-11-13 20:41 [PATCH] RISC-V: Use .p2align for code-alignment Philipp Tomsich
@ 2022-11-15 16:37 ` Jeff Law
2022-11-15 21:14 ` Philipp Tomsich
0 siblings, 1 reply; 4+ messages in thread
From: Jeff Law @ 2022-11-15 16:37 UTC (permalink / raw)
To: Philipp Tomsich, gcc-patches
Cc: Christoph Muellner, Palmer Dabbelt, Vineet Gupta, Kito Cheng, Jeff Law
[-- Attachment #1: Type: text/plain, Size: 630 bytes --]
On 11/13/22 13:41, Philipp Tomsich wrote:
> RISC-V's .p2align (currently) ignores the max-skip argument. As we
> have experimental patches underway to address this in a
> backwards-compatible manner, let's prepare GCC for the day when
> binutils gets updated.
>
> gcc/ChangeLog:
>
> * config/riscv/riscv.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Implement.
What are the implications if we start using p2align immediately when the
current (broken?) state of the assembler? I'm pretty sure configure is
already turning on HAVE_GAS_SKIP_P2ALIGN. From a native risc-v build:
auto-host.h:#define HAVE_GAS_MAX_SKIP_P2ALIGN 1
jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] RISC-V: Use .p2align for code-alignment
2022-11-15 16:37 ` Jeff Law
@ 2022-11-15 21:14 ` Philipp Tomsich
2022-11-16 0:36 ` Philipp Tomsich
0 siblings, 1 reply; 4+ messages in thread
From: Philipp Tomsich @ 2022-11-15 21:14 UTC (permalink / raw)
To: Jeff Law
Cc: gcc-patches, Christoph Muellner, Palmer Dabbelt, Vineet Gupta,
Kito Cheng, Jeff Law
Jeff,
On Tue, 15 Nov 2022 at 17:37, Jeff Law <jeffreyalaw@gmail.com> wrote:
>
>
> On 11/13/22 13:41, Philipp Tomsich wrote:
>
> RISC-V's .p2align (currently) ignores the max-skip argument. As we
> have experimental patches underway to address this in a
> backwards-compatible manner, let's prepare GCC for the day when
> binutils gets updated.
>
> gcc/ChangeLog:
>
> * config/riscv/riscv.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Implement.
>
>
> What are the implications if we start using p2align immediately when the current (broken?) state of the assembler? I'm pretty sure configure is already turning on HAVE_GAS_SKIP_P2ALIGN. From a native risc-v build:
>
>
> auto-host.h:#define HAVE_GAS_MAX_SKIP_P2ALIGN 1
This is your tree, which has the (partial fix — i.e., the best we can
do without breaking backward compatibility) for .p2align.
When building against upstream binutils, this should not be defined.
Philipp.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] RISC-V: Use .p2align for code-alignment
2022-11-15 21:14 ` Philipp Tomsich
@ 2022-11-16 0:36 ` Philipp Tomsich
0 siblings, 0 replies; 4+ messages in thread
From: Philipp Tomsich @ 2022-11-16 0:36 UTC (permalink / raw)
To: Jeff Law
Cc: gcc-patches, Christoph Muellner, Palmer Dabbelt, Vineet Gupta,
Kito Cheng, Jeff Law
On Tue, 15 Nov 2022 at 22:14, Philipp Tomsich <philipp.tomsich@vrull.eu> wrote:
>
> Jeff,
>
> On Tue, 15 Nov 2022 at 17:37, Jeff Law <jeffreyalaw@gmail.com> wrote:
> >
> >
> > On 11/13/22 13:41, Philipp Tomsich wrote:
> >
> > RISC-V's .p2align (currently) ignores the max-skip argument. As we
> > have experimental patches underway to address this in a
> > backwards-compatible manner, let's prepare GCC for the day when
> > binutils gets updated.
> >
> > gcc/ChangeLog:
> >
> > * config/riscv/riscv.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Implement.
> >
> >
> > What are the implications if we start using p2align immediately when the current (broken?) state of the assembler? I'm pretty sure configure is already turning on HAVE_GAS_SKIP_P2ALIGN. From a native risc-v build:
> >
> >
> > auto-host.h:#define HAVE_GAS_MAX_SKIP_P2ALIGN 1
>
> This is your tree, which has the (partial fix — i.e., the best we can
> do without breaking backward compatibility) for .p2align.
> When building against upstream binutils, this should not be defined.
After rereading the generated configure-script, I've changed my mind
The check the does nothing to ensure that the max-skip is actually
honored and only tests whether it is accepted.
Having the max-skip silently ignored may still be the lesser evil.
Philipp.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-11-16 0:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-13 20:41 [PATCH] RISC-V: Use .p2align for code-alignment Philipp Tomsich
2022-11-15 16:37 ` Jeff Law
2022-11-15 21:14 ` Philipp Tomsich
2022-11-16 0:36 ` Philipp Tomsich
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).