@@ -633,6 +633,56 @@ modifying or saving the FPCR.
633633Functions are allowed to modify it between calls (as long as they
634634restore it), but as of this writing Go code never does.
635635
636+ ### loong64 architecture
637+
638+ The loong64 architecture uses R4 – R19 for integer arguments and integer results.
639+
640+ It uses F0 – F15 for floating-point arguments and results.
641+
642+ Registers R20 - R21, R23 – R28, R30 - R31, F16 – F31 are permanent scratch registers.
643+
644+ Register R2 is reserved and never used.
645+
646+ Register R20, R21 is Used by runtime.duffcopy, runtime.duffzero.
647+
648+ Special-purpose registers used within Go generated code and Go assembly code
649+ are as follows:
650+
651+ | Register | Call meaning | Return meaning | Body meaning |
652+ | --- | --- | --- | --- |
653+ | R0 | Zero value | Same | Same |
654+ | R1 | Link register | Link register | Scratch |
655+ | R3 | Stack pointer | Same | Same |
656+ | R20,R21 | Scratch | Scratch | Used by duffcopy, duffzero |
657+ | R22 | Current goroutine | Same | Same |
658+ | R29 | Closure context pointer | Same | Same |
659+ | R30, R31 | used by the assembler | Same | Same |
660+
661+ * Rationale* : These register meanings are compatible with Go’s stack-based
662+ calling convention.
663+
664+ #### Stack layout
665+
666+ The stack pointer, R3, grows down and is aligned to 8 bytes.
667+
668+ A function's stack frame, after the frame is created, is laid out as
669+ follows:
670+
671+ +------------------------------+
672+ | ... locals ... |
673+ | ... outgoing arguments ... |
674+ | return PC | ← R3 points to
675+ +------------------------------+ ↓ lower addresses
676+
677+ This stack layout is used by both register-based (ABIInternal) and
678+ stack-based (ABI0) calling conventions.
679+
680+ The "return PC" is loaded to the link register, R1, as part of the
681+ loong64 ` JAL ` operation.
682+
683+ #### Flags
684+ All bits in CSR are system flags and are not modified by Go.
685+
636686### ppc64 architecture
637687
638688The ppc64 architecture uses R3 – R10 and R14 – R17 for integer arguments
0 commit comments