[PATCH 9/9] powerpc/64s: Work around llvm-as not recognising pla
Nicholas Piggin
npiggin at gmail.com
Wed Apr 26 15:58:47 AEST 2023
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 at 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 at pcrel,1
+#else
#define LOAD_REG_ADDR(reg,name) \
pla reg,name at 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 at pcrel,1; \
+ lfd fr,0(r11)
+#else
#define LDCONST(fr, name) \
pla r11,name at pcrel; \
lfd fr,0(r11)
+#endif
#else
#define LDCONST(fr, name) \
addis r11,r2,name at toc@ha; \
--
2.40.0
More information about the Linuxppc-dev
mailing list