[PATCH 8/13]Recognize loongarch64 path in src/compiler

[email protected]
Newsgroups gmane.lisp.steel-bank.devel
Message-ID <[email protected]>
This patch updates src/compiler to correctly recognize LoongArch64 paths.

_______________________________________________
Sbcl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sbcl-devel
0008-recognize-loongarch64-path-in-src-compiler.patch (application/octet-stream, 8.1 KB)
From dbca987b5b3c5b64e9095ecbc71d8df2f09244cf Mon Sep 17 00:00:00 2001
From: ZiLong Wang <[email protected]>
Date: Sat, 17 Jan 2026 10:24:03 +0800
Subject: [PATCH 08/13] recognize loongarch path in src/compiler

---
 src/compiler/generic/early-objdef.lisp | 4 ++--
 src/compiler/generic/genesis.lisp      | 2 +-
 src/compiler/generic/late-objdef.lisp  | 2 +-
 src/compiler/generic/objdef.lisp       | 4 ++--
 src/compiler/generic/parms.lisp        | 2 +-
 src/compiler/generic/type-vops.lisp    | 2 +-
 src/compiler/generic/vm-fndb.lisp      | 4 ++--
 src/compiler/generic/vm-ir2tran.lisp   | 2 +-
 src/compiler/srctran.lisp              | 4 ++--
 src/compiler/target-disassem.lisp      | 4 ++--
 10 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/compiler/generic/early-objdef.lisp b/src/compiler/generic/early-objdef.lisp
index 8662d6f50..a83668917 100644
--- a/src/compiler/generic/early-objdef.lisp
+++ b/src/compiler/generic/early-objdef.lisp
@@ -209,8 +209,8 @@
   simple-fun-widetag                              ;  3A   41
   closure-widetag                                 ;  3E   45
 
-  #-(or x86 x86-64 arm64 riscv) return-pc-widetag ;  42   49
-  #+(or x86 x86-64 arm64 riscv) lra-widetag-notused
+  #-(or x86 x86-64 arm64 riscv loongarch64) return-pc-widetag ;  42   49
+  #+(or x86 x86-64 arm64 riscv loongarch64) lra-widetag-notused
 
   value-cell-widetag                              ;  46   4D
   character-widetag                               ;  4A   51
diff --git a/src/compiler/generic/genesis.lisp b/src/compiler/generic/genesis.lisp
index bea32ebd7..0c4bc406d 100644
--- a/src/compiler/generic/genesis.lisp
+++ b/src/compiler/generic/genesis.lisp
@@ -2202,7 +2202,7 @@ core and return a descriptor to it."
     (write-wordindexed fdefn sb-vm:fdefn-fun-slot function)
     (write-wordindexed/raw
      fdefn sb-vm:fdefn-raw-addr-slot
-     (or #+(or sparc arm riscv) ; raw addr is the function descriptor
+     (or #+(or sparc arm riscv loongarch64) ; raw addr is the function descriptor
          (descriptor-bits function)
          ;; For all others raw addr is the starting address
          (+ (descriptor-base-address function)
diff --git a/src/compiler/generic/late-objdef.lisp b/src/compiler/generic/late-objdef.lisp
index 2d4130bae..d8cdb9dcb 100644
--- a/src/compiler/generic/late-objdef.lisp
+++ b/src/compiler/generic/late-objdef.lisp
@@ -61,7 +61,7 @@
     ;; Like closure, but these can also have a layout pointer in the high header bytes.
     (funcallable-instance "funinstance" "lose" "short_boxed")
     ;; These have a scav and trans function, but no size function.
-    #-(or x86 x86-64 arm64 riscv)
+    #-(or x86 x86-64 arm64 riscv loongarch64)
     (return-pc "return_pc_header" "return_pc_header" "lose")
 
     (value-cell "boxed")
diff --git a/src/compiler/generic/objdef.lisp b/src/compiler/generic/objdef.lisp
index ea991e683..91ff3d9cc 100644
--- a/src/compiler/generic/objdef.lisp
+++ b/src/compiler/generic/objdef.lisp
@@ -254,7 +254,7 @@ during backtrace.
 (defconstant simple-fun-source-slot  2) ; form and/or docstring
 (defconstant simple-fun-info-slot    3) ; type and possibly xref
 
-#-(or x86 x86-64 arm64 riscv)
+#-(or x86 x86-64 arm64 riscv loongarch64)
 (define-primitive-object (return-pc :lowtag other-pointer-lowtag :widetag t)
   (return-point :c-type "unsigned char" :rest-p t))
 
@@ -488,7 +488,7 @@ during backtrace.
   (binding-stack-pointer :c-type "lispobj *" :pointer t
                          :special *binding-stack-pointer*)
   ;; next two not used in C, but this wires the TLS offsets to small values
-  #+(or x86-64 (and (or riscv arm64) sb-thread))
+  #+(or x86-64 (and (or riscv arm64 loongarch64) sb-thread))
   #((current-catch-block :special *current-catch-block*)
     (current-unwind-protect-block :special *current-unwind-protect-block*))
   ;; BUG: fundamentally a pseudo-atomic code sequence does not use these bits
diff --git a/src/compiler/generic/parms.lisp b/src/compiler/generic/parms.lisp
index d88ffd042..60748e8e4 100644
--- a/src/compiler/generic/parms.lisp
+++ b/src/compiler/generic/parms.lisp
@@ -211,7 +211,7 @@
     ;; NLX variables are thread slots on x86-64 and RISC-V.  A static sym is needed
     ;; for arm64, ppc, and x86 because we haven't implemented TLS index fixups,
     ;; so must lookup the TLS index given the symbol.
-    #+(and sb-thread (not x86-64) (not riscv))
+    #+(and sb-thread (not x86-64) (not riscv) (not loongarch64))
     ,@'(*current-catch-block*
         *current-unwind-protect-block*)
 
diff --git a/src/compiler/generic/type-vops.lisp b/src/compiler/generic/type-vops.lisp
index ef4fae31d..4e6334d1b 100644
--- a/src/compiler/generic/type-vops.lisp
+++ b/src/compiler/generic/type-vops.lisp
@@ -113,7 +113,7 @@
 
 (define-type-vop code-component-p (code-header-widetag))
 
-#-(or x86 x86-64 arm64 riscv)
+#-(or x86 x86-64 arm64 riscv loongarch64)
 (define-type-vop lra-p (return-pc-widetag))
 
 (define-type-vop fdefn-p (fdefn-widetag))
diff --git a/src/compiler/generic/vm-fndb.lisp b/src/compiler/generic/vm-fndb.lisp
index 3564e8ed3..d4c99c7fc 100644
--- a/src/compiler/generic/vm-fndb.lisp
+++ b/src/compiler/generic/vm-fndb.lisp
@@ -243,10 +243,10 @@
 (defknown %instance-set (instance index t) (values) (always-translatable))
 (defknown update-object-layout (t) layout)
 
-#+(or arm64 ppc ppc64 riscv x86 x86-64)
+#+(or arm64 loongarch64 ppc ppc64 riscv x86 x86-64)
 (defknown %raw-instance-cas/word (instance index sb-vm:word sb-vm:word)
   sb-vm:word ())
-#+(or arm64 riscv x86 x86-64)
+#+(or arm64 loongarch64 riscv x86 x86-64)
 (defknown %raw-instance-cas/signed-word (instance index sb-vm:signed-word sb-vm:signed-word)
   sb-vm:signed-word ())
 (defknown %raw-instance-xchg/word (instance index sb-vm:word) sb-vm:word ())
diff --git a/src/compiler/generic/vm-ir2tran.lisp b/src/compiler/generic/vm-ir2tran.lisp
index b1e8132a9..c7bdac51e 100644
--- a/src/compiler/generic/vm-ir2tran.lisp
+++ b/src/compiler/generic/vm-ir2tran.lisp
@@ -510,7 +510,7 @@
 ;;; This vop is safe even if the user calls ALIEN-SAP by hand - the compiler will assert
 ;;; the arg to be of type SB-ALIEN-INTERNALS:ALIEN-VALUE (unless checking is dsabled).
 ;;; *** produces a bad build on ppc and ppc64 - why? ***
-#+(or arm64 riscv x86 x86-64)
+#+(or arm64 loongarch64 riscv x86 x86-64)
 (define-vop (alien-sap)
   (:translate alien-sap)
   (:policy :fast-safe)
diff --git a/src/compiler/srctran.lisp b/src/compiler/srctran.lisp
index 70d9a4666..4fcb795dc 100644
--- a/src/compiler/srctran.lisp
+++ b/src/compiler/srctran.lisp
@@ -749,7 +749,7 @@
 (declaim (inline bad-float-p))
 (defun bad-float-p (value)
   (declare (ignorable value))
-  #+(or arm (and arm64 (not darwin)) riscv sb-xc-host)
+  #+(or arm (and arm64 (not darwin)) riscv loongarch64 sb-xc-host)
   (or (and (floatp value)
            (float-infinity-or-nan-p value))
       (and (complex-float-p value)
@@ -7494,7 +7494,7 @@
   (source-transform-transitive 'logxor args 0 'integer))
 (define-source-transform logand (&rest args)
   (source-transform-transitive 'logand args -1 'integer))
-#-(or arm arm64 mips x86 x86-64 riscv) ; defined in compiler/{arch}/arith.lisp
+#-(or arm arm64 mips x86 x86-64 riscv loongarch64) ; defined in compiler/{arch}/arith.lisp
 (define-source-transform logeqv (&rest args)
   (source-transform-transitive 'logeqv args -1 'integer))
 (define-source-transform gcd (&rest args)
diff --git a/src/compiler/target-disassem.lisp b/src/compiler/target-disassem.lisp
index 15f10216d..4d47956df 100644
--- a/src/compiler/target-disassem.lisp
+++ b/src/compiler/target-disassem.lisp
@@ -355,7 +355,7 @@
            (type alignment size))
   (zerop (logand (1- size) address)))
 
-#-(or x86 x86-64 arm64 riscv)
+#-(or x86 x86-64 arm64 riscv loongarch64)
 (progn
 (defconstant lra-size (words-to-bytes 1))
 (defun lra-hook (chunk stream dstate)
@@ -1381,7 +1381,7 @@
       (format stream "#X~2,'0x" (sap-ref-8 sap (+ offs start-offs))))))
 
 (defvar *default-dstate-hooks*
-  (list* #-(or x86 x86-64 arm64 riscv) #'lra-hook nil))
+  (list* #-(or x86 x86-64 arm64 riscv loongarch64) #'lra-hook nil))
 
 ;;; Make a disassembler-state object.
 (defun make-dstate (&optional (fun-hooks *default-dstate-hooks*))
-- 
2.20.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.