* [PATCH] LoongArch: Drop unused parse_r and parse_v macros
@ 2023-09-05 23:06 Nathan Chancellor
2023-09-06 8:35 ` WANG Xuerui
0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2023-09-05 23:06 UTC (permalink / raw)
To: chenhuacai, kernel; +Cc: loongarch, llvm, patches, Nathan Chancellor
When building with CONFIG_LTO_CLANG_FULL, there are several errors due
to the way that parse_r is defined with an __asm__ statement in a
header:
ld.lld: error: ld-temp.o <inline asm>:105:1: macro 'parse_r' is already defined
.macro parse_r var r
^
This was an issue for arch/mips as well, which was resolved by
commit 67512a8cf5a7 ("MIPS: Avoid macro redefinitions").
However, parse_r is unused in arch/loongarch after
commit 83d8b38967d2 ("LoongArch: Simplify the invtlb wrappers"), so
doing the same change does not make much sense now. Just remove parse_r
(and parse_v, which is also unused) to resolve the redefinition error.
If it needs to be brought back due to an actual use, it should be
brought back with the same changes as the aforementioned arch/mips
commit.
Closes: https://github.com/ClangBuiltLinux/linux/issues/1924
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
arch/loongarch/include/asm/asmmacro.h | 107 ---------------------------------
arch/loongarch/include/asm/loongarch.h | 43 -------------
2 files changed, 150 deletions(-)
diff --git a/arch/loongarch/include/asm/asmmacro.h b/arch/loongarch/include/asm/asmmacro.h
index 8aaecd85aa81..c9544f358c33 100644
--- a/arch/loongarch/include/asm/asmmacro.h
+++ b/arch/loongarch/include/asm/asmmacro.h
@@ -10,113 +10,6 @@
#include <asm/fpregdef.h>
#include <asm/loongarch.h>
- .macro parse_v var val
- \var = \val
- .endm
-
- .macro parse_r var r
- \var = -1
- .ifc \r, $r0
- \var = 0
- .endif
- .ifc \r, $r1
- \var = 1
- .endif
- .ifc \r, $r2
- \var = 2
- .endif
- .ifc \r, $r3
- \var = 3
- .endif
- .ifc \r, $r4
- \var = 4
- .endif
- .ifc \r, $r5
- \var = 5
- .endif
- .ifc \r, $r6
- \var = 6
- .endif
- .ifc \r, $r7
- \var = 7
- .endif
- .ifc \r, $r8
- \var = 8
- .endif
- .ifc \r, $r9
- \var = 9
- .endif
- .ifc \r, $r10
- \var = 10
- .endif
- .ifc \r, $r11
- \var = 11
- .endif
- .ifc \r, $r12
- \var = 12
- .endif
- .ifc \r, $r13
- \var = 13
- .endif
- .ifc \r, $r14
- \var = 14
- .endif
- .ifc \r, $r15
- \var = 15
- .endif
- .ifc \r, $r16
- \var = 16
- .endif
- .ifc \r, $r17
- \var = 17
- .endif
- .ifc \r, $r18
- \var = 18
- .endif
- .ifc \r, $r19
- \var = 19
- .endif
- .ifc \r, $r20
- \var = 20
- .endif
- .ifc \r, $r21
- \var = 21
- .endif
- .ifc \r, $r22
- \var = 22
- .endif
- .ifc \r, $r23
- \var = 23
- .endif
- .ifc \r, $r24
- \var = 24
- .endif
- .ifc \r, $r25
- \var = 25
- .endif
- .ifc \r, $r26
- \var = 26
- .endif
- .ifc \r, $r27
- \var = 27
- .endif
- .ifc \r, $r28
- \var = 28
- .endif
- .ifc \r, $r29
- \var = 29
- .endif
- .ifc \r, $r30
- \var = 30
- .endif
- .ifc \r, $r31
- \var = 31
- .endif
- .iflt \var
- .error "Unable to parse register name \r"
- .endif
- .endm
-
.macro cpu_save_nonscratch thread
stptr.d s0, \thread, THREAD_REG23
stptr.d s1, \thread, THREAD_REG24
diff --git a/arch/loongarch/include/asm/loongarch.h b/arch/loongarch/include/asm/loongarch.h
index d1324e8accfe..33531d432b49 100644
--- a/arch/loongarch/include/asm/loongarch.h
+++ b/arch/loongarch/include/asm/loongarch.h
@@ -12,49 +12,6 @@
#ifndef __ASSEMBLY__
#include <larchintrin.h>
-/*
- * parse_r var, r - Helper assembler macro for parsing register names.
- *
- * This converts the register name in $n form provided in \r to the
- * corresponding register number, which is assigned to the variable \var. It is
- * needed to allow explicit encoding of instructions in inline assembly where
- * registers are chosen by the compiler in $n form, allowing us to avoid using
- * fixed register numbers.
- *
- * It also allows newer instructions (not implemented by the assembler) to be
- * transparently implemented using assembler macros, instead of needing separate
- * cases depending on toolchain support.
- *
- * Simple usage example:
- * __asm__ __volatile__("parse_r addr, %0\n\t"
- * "#invtlb op, 0, %0\n\t"
- * ".word ((0x6498000) | (addr << 10) | (0 << 5) | op)"
- * : "=r" (status);
- */
-
-/* Match an individual register number and assign to \var */
-#define _IFC_REG(n) \
- ".ifc \\r, $r" #n "\n\t" \
- "\\var = " #n "\n\t" \
- ".endif\n\t"
-
-__asm__(".macro parse_r var r\n\t"
- "\\var = -1\n\t"
- _IFC_REG(0) _IFC_REG(1) _IFC_REG(2) _IFC_REG(3)
- _IFC_REG(4) _IFC_REG(5) _IFC_REG(6) _IFC_REG(7)
- _IFC_REG(8) _IFC_REG(9) _IFC_REG(10) _IFC_REG(11)
- _IFC_REG(12) _IFC_REG(13) _IFC_REG(14) _IFC_REG(15)
- _IFC_REG(16) _IFC_REG(17) _IFC_REG(18) _IFC_REG(19)
- _IFC_REG(20) _IFC_REG(21) _IFC_REG(22) _IFC_REG(23)
- _IFC_REG(24) _IFC_REG(25) _IFC_REG(26) _IFC_REG(27)
- _IFC_REG(28) _IFC_REG(29) _IFC_REG(30) _IFC_REG(31)
- ".iflt \\var\n\t"
- ".error \"Unable to parse register name \\r\"\n\t"
- ".endif\n\t"
- ".endm");
-
-#undef _IFC_REG
-
/* CPUCFG */
#define read_cpucfg(reg) __cpucfg(reg)
---
base-commit: 68800bf8cd1a5e392089f10c58730a4e6a82e41d
change-id: 20230905-loongarch-fix-clang-lto-parse_r-8b48f71eeeac
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] LoongArch: Drop unused parse_r and parse_v macros
2023-09-05 23:06 [PATCH] LoongArch: Drop unused parse_r and parse_v macros Nathan Chancellor
@ 2023-09-06 8:35 ` WANG Xuerui
2023-09-07 1:36 ` Huacai Chen
0 siblings, 1 reply; 3+ messages in thread
From: WANG Xuerui @ 2023-09-06 8:35 UTC (permalink / raw)
To: Nathan Chancellor, chenhuacai; +Cc: loongarch, llvm, patches
On 9/6/23 07:06, Nathan Chancellor wrote:
> When building with CONFIG_LTO_CLANG_FULL, there are several errors due
> to the way that parse_r is defined with an __asm__ statement in a
> header:
>
> ld.lld: error: ld-temp.o <inline asm>:105:1: macro 'parse_r' is already defined
> .macro parse_r var r
> ^
>
> This was an issue for arch/mips as well, which was resolved by
> commit 67512a8cf5a7 ("MIPS: Avoid macro redefinitions").
>
> However, parse_r is unused in arch/loongarch after
> commit 83d8b38967d2 ("LoongArch: Simplify the invtlb wrappers"), so
> doing the same change does not make much sense now. Just remove parse_r
> (and parse_v, which is also unused) to resolve the redefinition error.
> If it needs to be brought back due to an actual use, it should be
> brought back with the same changes as the aforementioned arch/mips
> commit.
>
> Closes: https://github.com/ClangBuiltLinux/linux/issues/1924
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> arch/loongarch/include/asm/asmmacro.h | 107 ---------------------------------
> arch/loongarch/include/asm/loongarch.h | 43 -------------
> 2 files changed, 150 deletions(-)
Doh, I must have overlooked this when I last refactored the relevant
helpers. Thanks for the clean-up!
Reviewed-by: WANG Xuerui <git@xen0n.name>
--
WANG "xen0n" Xuerui
Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] LoongArch: Drop unused parse_r and parse_v macros
2023-09-06 8:35 ` WANG Xuerui
@ 2023-09-07 1:36 ` Huacai Chen
0 siblings, 0 replies; 3+ messages in thread
From: Huacai Chen @ 2023-09-07 1:36 UTC (permalink / raw)
To: WANG Xuerui; +Cc: Nathan Chancellor, loongarch, llvm, patches
Queued for loongarch-next, thanks.
Huacai
On Wed, Sep 6, 2023 at 4:36 PM WANG Xuerui <kernel@xen0n.name> wrote:
>
> On 9/6/23 07:06, Nathan Chancellor wrote:
> > When building with CONFIG_LTO_CLANG_FULL, there are several errors due
> > to the way that parse_r is defined with an __asm__ statement in a
> > header:
> >
> > ld.lld: error: ld-temp.o <inline asm>:105:1: macro 'parse_r' is already defined
> > .macro parse_r var r
> > ^
> >
> > This was an issue for arch/mips as well, which was resolved by
> > commit 67512a8cf5a7 ("MIPS: Avoid macro redefinitions").
> >
> > However, parse_r is unused in arch/loongarch after
> > commit 83d8b38967d2 ("LoongArch: Simplify the invtlb wrappers"), so
> > doing the same change does not make much sense now. Just remove parse_r
> > (and parse_v, which is also unused) to resolve the redefinition error.
> > If it needs to be brought back due to an actual use, it should be
> > brought back with the same changes as the aforementioned arch/mips
> > commit.
> >
> > Closes: https://github.com/ClangBuiltLinux/linux/issues/1924
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---
> > arch/loongarch/include/asm/asmmacro.h | 107 ---------------------------------
> > arch/loongarch/include/asm/loongarch.h | 43 -------------
> > 2 files changed, 150 deletions(-)
>
> Doh, I must have overlooked this when I last refactored the relevant
> helpers. Thanks for the clean-up!
>
> Reviewed-by: WANG Xuerui <git@xen0n.name>
>
> --
> WANG "xen0n" Xuerui
>
> Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-07 1:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-05 23:06 [PATCH] LoongArch: Drop unused parse_r and parse_v macros Nathan Chancellor
2023-09-06 8:35 ` WANG Xuerui
2023-09-07 1:36 ` Huacai Chen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.