[PATCH 7/13]Add loongarch64 support in contrib
| Newsgroups | gmane.lisp.steel-bank.devel |
|---|---|
| Message-ID | <[email protected]> |
This patch adds LoongArch64 support in the contrib directory. _______________________________________________ Sbcl-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sbcl-devel
0007-Add-loongarch64-support-in-contrib.patch
(application/octet-stream, 6.3 KB)
From 875390b5f3a832d6e0ffc08531aa11cd13af7853 Mon Sep 17 00:00:00 2001 From: ZiLong Wang <[email protected]> Date: Sat, 17 Jan 2026 10:19:26 +0800 Subject: [PATCH 07/13] Add loongarch support in contrib --- contrib/sb-introspect/test-driver.lisp | 2 +- contrib/sb-posix/interface.lisp | 2 +- contrib/sb-rotate-byte/compiler.lisp | 2 +- contrib/sb-rotate-byte/loongarch64-vm.lisp | 92 ++++++++++++++++++++++ contrib/sb-rotate-byte/sb-rotate-byte.asd | 3 +- 5 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 contrib/sb-rotate-byte/loongarch64-vm.lisp diff --git a/contrib/sb-introspect/test-driver.lisp b/contrib/sb-introspect/test-driver.lisp index 1e8931d47..efc346be5 100644 --- a/contrib/sb-introspect/test-driver.lisp +++ b/contrib/sb-introspect/test-driver.lisp @@ -377,7 +377,7 @@ (setq sb-ext:*evaluator-mode* :compile) (sb-ext:defglobal *large-obj* nil) -#+(and generational (or riscv x86 x86-64 ppc) (not win32) (not ubsan)) +#+(and generational (or riscv x86 x86-64 ppc loongarch64) (not win32) (not ubsan)) (progn (setq *print-array* nil) (setq *large-obj* (make-array (* sb-vm:gencgc-page-bytes 4) diff --git a/contrib/sb-posix/interface.lisp b/contrib/sb-posix/interface.lisp index 7b8e71eaf..1ba02ee4c 100644 --- a/contrib/sb-posix/interface.lisp +++ b/contrib/sb-posix/interface.lisp @@ -114,7 +114,7 @@ (eval-when (:compile-toplevel :load-toplevel) (setf *c-functions-in-runtime* (append #+netbsd '("stat" "lstat" "fstat" "readdir" "opendir") - #+(and (or arm64 riscv ppc ppc64) linux) '("stat" "lstat" "fstat")))) + #+(and (or arm64 riscv ppc ppc64 loongarch64) linux) '("stat" "lstat" "fstat")))) ;;; filesystem access diff --git a/contrib/sb-rotate-byte/compiler.lisp b/contrib/sb-rotate-byte/compiler.lisp index 8dd45e42d..eddb8f2f1 100644 --- a/contrib/sb-rotate-byte/compiler.lisp +++ b/contrib/sb-rotate-byte/compiler.lisp @@ -69,7 +69,7 @@ ;; Generic implementation for platforms that don't supply VOPs for 32-bit ;; rotate. -#-(or x86 x86-64 ppc arm arm64 riscv) +#-(or x86 x86-64 ppc arm arm64 riscv loongarch64) (deftransform %unsigned-32-rotate-byte ((.count. .integer.) ((integer -31 31) (unsigned-byte 32)) *) diff --git a/contrib/sb-rotate-byte/loongarch64-vm.lisp b/contrib/sb-rotate-byte/loongarch64-vm.lisp new file mode 100644 index 000000000..c37eeacbe --- /dev/null +++ b/contrib/sb-rotate-byte/loongarch64-vm.lisp @@ -0,0 +1,92 @@ +(in-package "SB-ROTATE-BYTE") + +;;; 32-bit +(define-vop (%32bit-rotate-byte/c) + (:policy :fast-safe) + (:translate %unsigned-32-rotate-byte) + (:note "inline 32-bit constant rotation") + (:args (integer :scs (sb-vm::unsigned-reg) :target result)) + (:info count) + (:arg-types (:constant (integer -31 31)) sb-vm::unsigned-num) + (:temporary (:sc sb-vm::unsigned-reg) temp) + (:results (result :scs (sb-vm::unsigned-reg))) + (:result-types sb-vm::unsigned-num) + (:generator 5 + (aver (/= count 0)) + (let ((count (if (plusp count) + count + (+ 32 count)))) + (inst slli.d temp integer count) + (inst srli.d result integer (- 32 count)) + (inst or result result temp) + #+64-bit + (progn + (inst slli.d result result 32) + (inst srli.d result result 32))))) + +(define-vop (%32bit-rotate-byte) + (:policy :fast-safe) + (:translate %unsigned-32-rotate-byte) + (:note "inline 32-bit rotation") + (:args (count :scs (sb-vm::signed-reg)) + (integer :scs (sb-vm::unsigned-reg))) + (:arg-types sb-vm::tagged-num sb-vm::unsigned-num) + (:temporary (:sc sb-vm::signed-reg) temp) + (:temporary (:sc sb-vm::signed-reg) count-temp) + (:results (result :scs (sb-vm::unsigned-reg))) + (:result-types sb-vm::unsigned-num) + (:generator 10 + (inst slti count-temp count 0) + (inst slli.d count-temp count-temp 5) + (inst add.d count-temp count-temp count) + (inst sll.d temp integer count-temp) + (inst subi count-temp count-temp 32) + (inst sub.d count-temp sb-vm::zero-tn count-temp) + (inst srl.d result integer count-temp) + (inst or result result temp) + #+64-bit + (progn + (inst slli.d result result 32) + (inst srli.d result result 32)))) + +;;; 64-bit +(define-vop (%64bit-rotate-byte/c) + (:policy :fast-safe) + (:translate %unsigned-64-rotate-byte) + (:note "inline 64-bit constant rotation") + (:args (integer :scs (sb-vm::unsigned-reg) :target result)) + (:info count) + (:arg-types (:constant (integer -63 63)) sb-vm::unsigned-num) + (:temporary (:sc sb-vm::unsigned-reg) temp) + (:results (result :scs (sb-vm::unsigned-reg))) + (:result-types sb-vm::unsigned-num) + (:generator 5 + (aver (not (= count 0))) + (let ((count (if (plusp count) + count + (+ 64 count)))) + (inst slli.d temp integer count) + (inst srli.d result integer (- 64 count)) + (inst or result result temp)))) + +(define-vop (%64bit-rotate-byte) + (:policy :fast-safe) + (:translate %unsigned-64-rotate-byte) + (:note "inline 64-bit rotation") + (:args (count :scs (sb-vm::signed-reg)) + (integer :scs (sb-vm::unsigned-reg))) + (:arg-types sb-vm::tagged-num sb-vm::unsigned-num) + (:temporary (:sc sb-vm::unsigned-reg) temp) + (:temporary (:sc sb-vm::signed-reg) count-temp) + (:results (result :scs (sb-vm::unsigned-reg))) + (:result-types sb-vm::unsigned-num) + (:generator 10 + (inst slti count-temp count 0) + (inst slli.d count-temp count-temp 6) + (inst add.d count-temp count-temp count) + (inst sll.d temp integer count-temp) + (inst subi count-temp count-temp 64) + (inst sub.d count-temp sb-vm::zero-tn count-temp) + (inst srl.d result integer count-temp) + (inst or result result temp))) + diff --git a/contrib/sb-rotate-byte/sb-rotate-byte.asd b/contrib/sb-rotate-byte/sb-rotate-byte.asd index 055cb81af..a9ba12992 100644 --- a/contrib/sb-rotate-byte/sb-rotate-byte.asd +++ b/contrib/sb-rotate-byte/sb-rotate-byte.asd @@ -17,5 +17,6 @@ (:file "x86-64-vm" :if-feature :x86-64) (:file "riscv-vm" :if-feature :riscv) (:file "ppc-vm" :if-feature :ppc) - (:file "ppc64-vm" :if-feature :ppc64))) + (:file "ppc64-vm" :if-feature :ppc64) + (:file "loongarch64-vm" :if-feature :loongarch64))) (:file "rotate-byte" :depends-on ("vm")))) -- 2.20.1