Text file src/runtime/cgo/abi_arm64.h

     1  // Copyright 2021 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_R19_TO_R28(offset) saves R19 ~ R28 to the stack space
    11  // of ((offset)+0*8)(RSP) ~ ((offset)+9*8)(RSP).
    12  //
    13  // SAVE_F8_TO_F15(offset) saves F8 ~ F15 to the stack space
    14  // of ((offset)+0*8)(RSP) ~ ((offset)+7*8)(RSP).
    15  //
    16  // R29 is not saved because Go will save and restore it.
    17  
    18  #define SAVE_R19_TO_R28(offset) \
    19  	STP	(R19, R20), ((offset)+0*8)(RSP) \
    20  	STP	(R21, R22), ((offset)+2*8)(RSP) \
    21  	STP	(R23, R24), ((offset)+4*8)(RSP) \
    22  	STP	(R25, R26), ((offset)+6*8)(RSP) \
    23  	STP	(R27, g), ((offset)+8*8)(RSP)
    24  
    25  #define RESTORE_R19_TO_R28(offset) \
    26  	LDP	((offset)+0*8)(RSP), (R19, R20) \
    27  	LDP	((offset)+2*8)(RSP), (R21, R22) \
    28  	LDP	((offset)+4*8)(RSP), (R23, R24) \
    29  	LDP	((offset)+6*8)(RSP), (R25, R26) \
    30  	LDP	((offset)+8*8)(RSP), (R27, g) /* R28 */
    31  
    32  #define SAVE_F8_TO_F15(offset) \
    33  	FSTPD	(F8, F9), ((offset)+0*8)(RSP) \
    34  	FSTPD	(F10, F11), ((offset)+2*8)(RSP) \
    35  	FSTPD	(F12, F13), ((offset)+4*8)(RSP) \
    36  	FSTPD	(F14, F15), ((offset)+6*8)(RSP)
    37  
    38  #define RESTORE_F8_TO_F15(offset) \
    39  	FLDPD	((offset)+0*8)(RSP), (F8, F9) \
    40  	FLDPD	((offset)+2*8)(RSP), (F10, F11) \
    41  	FLDPD	((offset)+4*8)(RSP), (F12, F13) \
    42  	FLDPD	((offset)+6*8)(RSP), (F14, F15)
    43  
    44  

View as plain text