...

Text file src/runtime/cgo/abi_loong64.h

Documentation: runtime/cgo

     1// Copyright 2022 The Go Authors. All rights reserved.
     2// Use of this source code is governed by a BSD-style
     3// license that can be found in the LICENSE file.
     4
     5// Macros for transitioning from the host ABI to Go ABI0.
     6//
     7// These macros save and restore the callee-saved registers
     8// from the stack, but they don't adjust stack pointer, so
     9// the user should prepare stack space in advance.
    10// SAVE_R22_TO_R31(offset) saves R22 ~ R31 to the stack space
    11// of ((offset)+0*8)(R3) ~ ((offset)+9*8)(R3).
    12//
    13// SAVE_F24_TO_F31(offset) saves F24 ~ F31 to the stack space
    14// of ((offset)+0*8)(R3) ~ ((offset)+7*8)(R3).
    15//
    16// Note: g is R22
    17
    18#define SAVE_R22_TO_R31(offset)	\
    19	MOVV	g,   ((offset)+(0*8))(R3)	\
    20	MOVV	R23, ((offset)+(1*8))(R3)	\
    21	MOVV	R24, ((offset)+(2*8))(R3)	\
    22	MOVV	R25, ((offset)+(3*8))(R3)	\
    23	MOVV	R26, ((offset)+(4*8))(R3)	\
    24	MOVV	R27, ((offset)+(5*8))(R3)	\
    25	MOVV	R28, ((offset)+(6*8))(R3)	\
    26	MOVV	R29, ((offset)+(7*8))(R3)	\
    27	MOVV	R30, ((offset)+(8*8))(R3)	\
    28	MOVV	R31, ((offset)+(9*8))(R3)
    29
    30#define SAVE_F24_TO_F31(offset)	\
    31	MOVD	F24, ((offset)+(0*8))(R3)	\
    32	MOVD	F25, ((offset)+(1*8))(R3)	\
    33	MOVD	F26, ((offset)+(2*8))(R3)	\
    34	MOVD	F27, ((offset)+(3*8))(R3)	\
    35	MOVD	F28, ((offset)+(4*8))(R3)	\
    36	MOVD	F29, ((offset)+(5*8))(R3)	\
    37	MOVD	F30, ((offset)+(6*8))(R3)	\
    38	MOVD	F31, ((offset)+(7*8))(R3)
    39
    40#define RESTORE_R22_TO_R31(offset)	\
    41	MOVV	((offset)+(0*8))(R3),  g	\
    42	MOVV	((offset)+(1*8))(R3), R23	\
    43	MOVV	((offset)+(2*8))(R3), R24	\
    44	MOVV	((offset)+(3*8))(R3), R25	\
    45	MOVV	((offset)+(4*8))(R3), R26	\
    46	MOVV	((offset)+(5*8))(R3), R27	\
    47	MOVV	((offset)+(6*8))(R3), R28	\
    48	MOVV	((offset)+(7*8))(R3), R29	\
    49	MOVV	((offset)+(8*8))(R3), R30	\
    50	MOVV	((offset)+(9*8))(R3), R31
    51
    52#define RESTORE_F24_TO_F31(offset)	\
    53	MOVD	((offset)+(0*8))(R3), F24	\
    54	MOVD	((offset)+(1*8))(R3), F25	\
    55	MOVD	((offset)+(2*8))(R3), F26	\
    56	MOVD	((offset)+(3*8))(R3), F27	\
    57	MOVD	((offset)+(4*8))(R3), F28	\
    58	MOVD	((offset)+(5*8))(R3), F29	\
    59	MOVD	((offset)+(6*8))(R3), F30	\
    60	MOVD	((offset)+(7*8))(R3), F31

View as plain text