Skip to content

Commit 38bb46f

Browse files
xen0nchenhuacai
authored andcommitted
LoongArch: Prepare for assemblers with proper FCSR class support
The GNU assembler (as of 2.40) mis-treats FCSR operands as GPRs, but the LLVM IAS does not. Probe for this and refer to FCSRs as "$fcsrNN" if support is present. Signed-off-by: WANG Xuerui <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 24da024 commit 38bb46f

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

arch/loongarch/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ config SCHED_OMIT_FRAME_POINTER
241241
config AS_HAS_EXPLICIT_RELOCS
242242
def_bool $(as-instr,x:pcalau12i \$t0$(comma)%pc_hi20(x))
243243

244+
config AS_HAS_FCSR_CLASS
245+
def_bool $(as-instr,movfcsr2gr \$t0$(comma)\$fcsr0)
246+
244247
menu "Kernel type and options"
245248

246249
source "kernel/Kconfig.hz"

arch/loongarch/include/asm/fpregdef.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#define fs6 $f30
4141
#define fs7 $f31
4242

43+
#ifndef CONFIG_AS_HAS_FCSR_CLASS
4344
/*
4445
* Current binutils expects *GPRs* at FCSR position for the FCSR
4546
* operation instructions, so define aliases for those used.
@@ -48,5 +49,11 @@
4849
#define fcsr1 $r1
4950
#define fcsr2 $r2
5051
#define fcsr3 $r3
52+
#else
53+
#define fcsr0 $fcsr0
54+
#define fcsr1 $fcsr1
55+
#define fcsr2 $fcsr2
56+
#define fcsr3 $fcsr3
57+
#endif
5158

5259
#endif /* _ASM_FPREGDEF_H */

arch/loongarch/include/asm/loongarch.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1441,11 +1441,18 @@ __BUILD_CSR_OP(tlbidx)
14411441
#define EXCCODE_INT_START 64
14421442
#define EXCCODE_INT_END (EXCCODE_INT_START + EXCCODE_INT_NUM - 1)
14431443

1444-
/* FPU register names */
1444+
/* FPU Status Register Names */
1445+
#ifndef CONFIG_AS_HAS_FCSR_CLASS
14451446
#define LOONGARCH_FCSR0 $r0
14461447
#define LOONGARCH_FCSR1 $r1
14471448
#define LOONGARCH_FCSR2 $r2
14481449
#define LOONGARCH_FCSR3 $r3
1450+
#else
1451+
#define LOONGARCH_FCSR0 $fcsr0
1452+
#define LOONGARCH_FCSR1 $fcsr1
1453+
#define LOONGARCH_FCSR2 $fcsr2
1454+
#define LOONGARCH_FCSR3 $fcsr3
1455+
#endif
14491456

14501457
/* FPU Status Register Values */
14511458
#define FPU_CSR_RSVD 0xe0e0fce0

0 commit comments

Comments
 (0)