aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal
diff options
context:
space:
mode:
authorlimeidan <limeidan@loongson.cn>2025-12-03 10:25:15 +0800
committerabner chenc <chenguoqi@loongson.cn>2026-03-18 18:08:52 -0700
commit1e994e0a486afc976116e2d7a6ca7517fe150304 (patch)
tree7c39b6354369d35f3177a116d92ad663ea5f5811 /src/cmd/internal
parent9def4acb06bf9167441caa8af37e27b3cdbf8cf0 (diff)
downloadgo-1e994e0a486afc976116e2d7a6ca7517fe150304.tar.xz
cmd/link: modify the register used in trampoline
R30 is the callee's saved register; using it requires saving and then restoring. Therefore, we replace it with a register saved by the caller. R4~R19 are argument registers on loong64, and R20 is the only remaining usable caller saved register. To use R20 in trampoline, we modified the registers used by the LoweredMove/LoweredMoveLoop operations (originally using r20 and r21, now changed to R23 and R24). Change-Id: Ie7bba0caa30a764a45bcb47635c35c829036c5a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/726140 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: abner chenc <chenguoqi@loongson.cn> Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/cmd/internal')
-rw-r--r--src/cmd/internal/obj/loong64/doc.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cmd/internal/obj/loong64/doc.go b/src/cmd/internal/obj/loong64/doc.go
index 19c9e05590..1cf83223f1 100644
--- a/src/cmd/internal/obj/loong64/doc.go
+++ b/src/cmd/internal/obj/loong64/doc.go
@@ -6,6 +6,18 @@
Package loong64 implements an LoongArch64 assembler. Go assembly syntax is different from
GNU LoongArch64 syntax, but we can still follow the general rules to map between them.
+# Register Convention
+
+ Name | Alias | Meaning
+ -----------------------------------------------------------------------------------------------------------------------
+ R0 | REGZERO | Constant zero
+ R1 | REGLINK | Return address
+ R3 | REGSP | Stack pointer
+ R12,R13,R14,R15,R20 | | For plt and trampoline, use with caution in assembly code, save before calling function
+ R22 | REGG | Goroutine pointer
+ R29 | REGCTXT | Context for closures
+ R30 | REGTMP | Tmp register used by assembler
+
# Instructions mnemonics mapping rules
1. Bit widths represented by various instruction suffixes and prefixes