Skip to content

Commit 6165002

Browse files
committed
LoongArch: Add vector extensions support
Add LoongArch's vector extensions support, which including 128bit LSX (i.e., Loongson SIMD eXtension) and 256bit LASX (i.e., Loongson Advanced SIMD eXtension). Linux kernel doesn't use vector itself, it only handle exceptions and context save/restore. So it only needs a subset of these instructions: * Vector load/store: vld vst vldx vstx xvld xvst xvldx xvstx * 8bit-elements move: vpickve2gr.b xvpickve2gr.b vinsgr2vr.b xvinsgr2vr.b * 16bit-elements move: vpickve2gr.h xvpickve2gr.h vinsgr2vr.h xvinsgr2vr.h * 32bit-elements move: vpickve2gr.w xvpickve2gr.w vinsgr2vr.w xvinsgr2vr.w * 64bit-elements move: vpickve2gr.d xvpickve2gr.d vinsgr2vr.d xvinsgr2vr.d * Elements permute: vpermi.w vpermi.d xvpermi.w xvpermi.d xvpermi.q Introduce AS_HAS_LSX_EXTENSION and AS_HAS_LASX_EXTENSION to avoid non- vector toolchains complains unsupported instructions. Signed-off-by: Huacai Chen <[email protected]>
1 parent aa5e65d commit 6165002

File tree

11 files changed

+1452
-23
lines changed

11 files changed

+1452
-23
lines changed

arch/loongarch/Kconfig

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,6 @@ config 32BIT
164164
config 64BIT
165165
def_bool y
166166

167-
config CPU_HAS_FPU
168-
bool
169-
default y
170-
171-
config CPU_HAS_PREFETCH
172-
bool
173-
default y
174-
175167
config GENERIC_BUG
176168
def_bool y
177169
depends on BUG
@@ -247,6 +239,12 @@ config AS_HAS_EXPLICIT_RELOCS
247239
config AS_HAS_FCSR_CLASS
248240
def_bool $(as-instr,movfcsr2gr \$t0$(comma)\$fcsr0)
249241

242+
config AS_HAS_LSX_EXTENSION
243+
def_bool $(as-instr,vld \$vr0$(comma)\$a0$(comma)0)
244+
245+
config AS_HAS_LASX_EXTENSION
246+
def_bool $(as-instr,xvld \$xr0$(comma)\$a0$(comma)0)
247+
250248
menu "Kernel type and options"
251249

252250
source "kernel/Kconfig.hz"
@@ -487,6 +485,43 @@ config ARCH_STRICT_ALIGN
487485
to run kernel only on systems with h/w unaligned access support in
488486
order to optimise for performance.
489487

488+
config CPU_HAS_FPU
489+
bool
490+
default y
491+
492+
config CPU_HAS_LSX
493+
bool "Support for the Loongson SIMD Extension"
494+
depends on AS_HAS_LSX_EXTENSION
495+
help
496+
Loongson SIMD Extension (LSX) introduces 128 bit wide vector registers
497+
and a set of SIMD instructions to operate on them. When this option
498+
is enabled the kernel will support allocating & switching LSX
499+
vector register contexts. If you know that your kernel will only be
500+
running on CPUs which do not support LSX or that your userland will
501+
not be making use of it then you may wish to say N here to reduce
502+
the size & complexity of your kernel.
503+
504+
If unsure, say Y.
505+
506+
config CPU_HAS_LASX
507+
bool "Support for the Loongson Advanced SIMD Extension"
508+
depends on CPU_HAS_LSX
509+
depends on AS_HAS_LASX_EXTENSION
510+
help
511+
Loongson Advanced SIMD Extension (LASX) introduces 256 bit wide vector
512+
registers and a set of SIMD instructions to operate on them. When this
513+
option is enabled the kernel will support allocating & switching LASX
514+
vector register contexts. If you know that your kernel will only be
515+
running on CPUs which do not support LASX or that your userland will
516+
not be making use of it then you may wish to say N here to reduce
517+
the size & complexity of your kernel.
518+
519+
If unsure, say Y.
520+
521+
config CPU_HAS_PREFETCH
522+
bool
523+
default y
524+
490525
config KEXEC
491526
bool "Kexec system call"
492527
select KEXEC_CORE

0 commit comments

Comments
 (0)