abi_arm64.h raw

   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  #define RESTORE_R19_TO_R28(offset) \
  25  	LDP	((offset)+0*8)(RSP), (R19, R20) \
  26  	LDP	((offset)+2*8)(RSP), (R21, R22) \
  27  	LDP	((offset)+4*8)(RSP), (R23, R24) \
  28  	LDP	((offset)+6*8)(RSP), (R25, R26) \
  29  	LDP	((offset)+8*8)(RSP), (R27, g) /* R28 */
  30  #define SAVE_F8_TO_F15(offset) \
  31  	FSTPD	(F8, F9), ((offset)+0*8)(RSP) \
  32  	FSTPD	(F10, F11), ((offset)+2*8)(RSP) \
  33  	FSTPD	(F12, F13), ((offset)+4*8)(RSP) \
  34  	FSTPD	(F14, F15), ((offset)+6*8)(RSP)
  35  #define RESTORE_F8_TO_F15(offset) \
  36  	FLDPD	((offset)+0*8)(RSP), (F8, F9) \
  37  	FLDPD	((offset)+2*8)(RSP), (F10, F11) \
  38  	FLDPD	((offset)+4*8)(RSP), (F12, F13) \
  39  	FLDPD	((offset)+6*8)(RSP), (F14, F15)
  40