From: Nicholas Piggin <npiggin@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Nicholas Piggin <npiggin@gmail.com>
Subject: [PATCH 9/9] powerpc/64s: Work around llvm-as not recognising pla
Date: Wed, 26 Apr 2023 15:58:47 +1000 [thread overview]
Message-ID: <20230426055848.402993-11-npiggin@gmail.com> (raw)
In-Reply-To: <20230426055848.402993-1-npiggin@gmail.com>
llvm-as does not recognise the pla mnemonic, which is used for pcrel
address generation. Use the equivalent paddi opcode instead. Clang
can not build working pcrel kernels yet, but this patch does allow it
to build a non-working pcrel kernel with llvm-as.
This could be unconditional or use a raw encoding, but this gives a
placeholder to track the issue.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
arch/powerpc/Kconfig | 5 +++++
arch/powerpc/include/asm/ppc_asm.h | 5 +++++
arch/powerpc/kernel/vector.S | 6 ++++++
3 files changed, 16 insertions(+)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 39cd8d3ff846..2f7840577f7f 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -22,6 +22,11 @@ config CC_HAS_PCREL
# do pcrel yet.
def_bool PPC64 && CC_IS_GCC && $(cc-option, -mcpu=power10 -mpcrel)
+config AS_HAS_MISSING_PLA_INSN
+ # llvm-as is missing some extended mnemonics including pla
+ # (https://github.com/llvm/llvm-project/issues/62373).
+ def_bool AS_IS_LLVM
+
config 32BIT
bool
default y if PPC32
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index 5f05a984b103..736202ebc1be 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -380,8 +380,13 @@ GLUE(.,name):
rldimi reg, tmp, 32, 0
#ifdef CONFIG_PPC_KERNEL_PCREL
+#ifdef CONFIG_AS_HAS_MISSING_PLA_INSN
+#define LOAD_REG_ADDR(reg,name) \
+ paddi reg,0,name@pcrel,1
+#else
#define LOAD_REG_ADDR(reg,name) \
pla reg,name@pcrel
+#endif
#else
#define LOAD_REG_ADDR(reg,name) \
diff --git a/arch/powerpc/kernel/vector.S b/arch/powerpc/kernel/vector.S
index fcc0ad6d9c7b..c2feaea5e673 100644
--- a/arch/powerpc/kernel/vector.S
+++ b/arch/powerpc/kernel/vector.S
@@ -178,9 +178,15 @@ fphalf:
.quad 0x3fe0000000000000 /* 0.5 */
#ifdef CONFIG_PPC_KERNEL_PCREL
+#ifdef CONFIG_AS_HAS_MISSING_PLA_INSN
+#define LDCONST(fr, name) \
+ paddi r11,0,name@pcrel,1; \
+ lfd fr,0(r11)
+#else
#define LDCONST(fr, name) \
pla r11,name@pcrel; \
lfd fr,0(r11)
+#endif
#else
#define LDCONST(fr, name) \
addis r11,r2,name@toc@ha; \
--
2.40.0
next prev parent reply other threads:[~2023-04-26 6:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-26 5:58 [PATCH 0/9] powerpc: Build fixes Nicholas Piggin
2023-04-26 5:58 ` [PATCH 1/9] powerpc: Fix merge conflict between pcrel and copy_thread changes Nicholas Piggin
2023-04-26 5:58 ` [PATCH 2/9] powerpc/64s: Disable pcrel code model on Clang Nicholas Piggin
2023-04-26 5:58 ` [PATCH 3/9] powerpc/boot: Seperate target flags from BOOTCFLAGS Nicholas Piggin
2023-04-26 5:58 ` [PATCH 4/9] powerpc/boot: Seperate CPP " Nicholas Piggin
2023-04-26 5:58 ` [PATCH 5/9] powerpc/boot: Separate BOOTCFLAGS from BOOTASFLAGS Nicholas Piggin
2023-04-26 15:11 ` Linus Torvalds
2023-04-26 5:58 ` [PATCH 6/9] powerpc/boot: Clean up Makefile after cflags and asflags separation Nicholas Piggin
2023-04-26 5:58 ` [PATCH 6/9] powerpc/boot: clean up Makefile flags Nicholas Piggin
2023-04-26 5:58 ` [PATCH 7/9] powerpc/build: Remove -pipe from compilation flags Nicholas Piggin
2023-04-26 5:58 ` [PATCH 8/9] powerpc/64s: Permit d-form memops in asm when building with prefix on clang Nicholas Piggin
2023-04-26 5:58 ` Nicholas Piggin [this message]
2023-04-26 12:01 ` (subset) [PATCH 0/9] powerpc: Build fixes Michael Ellerman
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=20230426055848.402993-11-npiggin@gmail.com \
--to=npiggin@gmail.com \
--cc=linuxppc-dev@lists.ozlabs.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: link
Be 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 NNTP newsgroup(s).