asm_s390x.s raw

   1  // Copyright 2016 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  #include "textflag.h"
   6  
   7  // Called by C code generated by cmd/cgo.
   8  // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
   9  // Saves C callee-saved registers and calls cgocallback with three arguments.
  10  // fn is the PC of a func(a unsafe.Pointer) function.
  11  TEXT crosscall2(SB), NOSPLIT|NOFRAME, $0
  12  	// Start with standard C stack frame layout and linkage.
  13  
  14  	// Save R6-R15 in the register save area of the calling function.
  15  	STMG R6, R15, 48(R15)
  16  
  17  	// Allocate 96 bytes on the stack.
  18  	MOVD $-96(R15), R15
  19  
  20  	// Save F8-F15 in our stack frame.
  21  	FMOVD F8, 32(R15)
  22  	FMOVD F9, 40(R15)
  23  	FMOVD F10, 48(R15)
  24  	FMOVD F11, 56(R15)
  25  	FMOVD F12, 64(R15)
  26  	FMOVD F13, 72(R15)
  27  	FMOVD F14, 80(R15)
  28  	FMOVD F15, 88(R15)
  29  
  30  	// Initialize Go ABI environment.
  31  	BL runtimeĀ·load_g(SB)
  32  
  33  	MOVD R2, 8(R15)  // fn unsafe.Pointer
  34  	MOVD R3, 16(R15) // a unsafe.Pointer
  35  
  36  	// Skip R4 = n uint32
  37  	MOVD R5, 24(R15)             // ctxt uintptr
  38  	BL   runtimeĀ·cgocallback(SB)
  39  
  40  	FMOVD 32(R15), F8
  41  	FMOVD 40(R15), F9
  42  	FMOVD 48(R15), F10
  43  	FMOVD 56(R15), F11
  44  	FMOVD 64(R15), F12
  45  	FMOVD 72(R15), F13
  46  	FMOVD 80(R15), F14
  47  	FMOVD 88(R15), F15
  48  
  49  	// De-allocate stack frame.
  50  	MOVD $96(R15), R15
  51  
  52  	// Restore R6-R15.
  53  	LMG 48(R15), R6, R15
  54  
  55  	RET
  56