[PATCH v2 10/20] arm64: gpr-num: add __GPR_NUM() helper
Mark Rutland
mark.rutland at arm.com
Tue Aug 4 10:04:53 PDT 2026
The gpr-num infrastructure requires users to concatenate the register
name with a long prefix in order to get a symbol that evaluates to a
compile-time constant. Doing this manually is error-prone and painful to
read.
Add a new __GPR_NUM() helper which wraps the concatenation.
For the moment I've left existing open-coded concatenation as-is. In
particular, the DEFINE_MRS_S() and DEFINE_MSR_S() macros have awkward
stringification requirements and would require invasive changes that
outweigh the benefit. I have plans to rework those in the near future to
remove the need to use gpr-num values.
Signed-off-by: Mark Rutland <mark.rutland at arm.com>
Cc: Ada Couprie Diaz <ada.coupriediaz at arm.com>
Cc: Ard Biesheuvel <ardb at kernel.org>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: James Morse <james.morse at arm.com>
Cc: Jinjie Ruan <ruanjinjie at huawei.com>
Cc: Marc Zyngier <maz at kernel.org>
Cc: Peter Zijlstra <peterz at infradead.org>
Cc: Vladimir Murzin <vladimir.murzin at arm.com>
Cc: Will Deacon <will at kernel.org>
Cc: Yang Shi <yang at os.amperecomputing.com>
---
arch/arm64/include/asm/gpr-num.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/arm64/include/asm/gpr-num.h b/arch/arm64/include/asm/gpr-num.h
index 240cd25d55c5a..30fb8a67b19f0 100644
--- a/arch/arm64/include/asm/gpr-num.h
+++ b/arch/arm64/include/asm/gpr-num.h
@@ -11,6 +11,8 @@
.equ .L__gpr_num_xzr, 31
.equ .L__gpr_num_wzr, 31
+#define __GPR_NUM(gpr) (.L__gpr_num_##gpr)
+
#else /* __ASSEMBLER__ */
#define __DEFINE_ASM_GPR_NUMS \
@@ -26,6 +28,8 @@
" wx\\n .req w\\n\n" \
" .endr\n"
+#define __GPR_NUM(gpr) "(.L__gpr_num_" gpr ")"
+
#endif /* __ASSEMBLER__ */
#endif /* __ASM_GPR_NUM_H */
--
2.30.2
More information about the linux-arm-kernel
mailing list