1 // Copyright 2014 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.
5 //go:build ppc64 || ppc64le
8 #include "asm_ppc64x.h"
10 // Called by C code generated by cmd/cgo.
11 // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
12 // Saves C callee-saved registers and calls cgocallback with three arguments.
13 // fn is the PC of a func(a unsafe.Pointer) function.
14 // The value of R2 is saved on the new stack frame, and not
15 // the caller's frame due to issue #43228.
16 TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
17 // Start with standard C stack frame layout and linkage
19 MOVD R0, 16(R1) // Save LR in caller's frame
20 MOVW CR, R0 // Save CR in caller's frame
25 MOVDU R1, (-288-3*8-FIXED_FRAME)(R1)
26 // Save the caller's R2
29 // Initialize Go ABI environment
30 BL runtime·reginit(SB)
33 #ifdef GO_PPC64X_HAS_FUNCDESC
34 // Load the real entry address from the first slot of the function descriptor.
38 MOVD R3, FIXED_FRAME+0(R1) // fn unsafe.Pointer
39 MOVD R4, FIXED_FRAME+8(R1) // a unsafe.Pointer
41 MOVD R6, FIXED_FRAME+16(R1) // ctxt uintptr
42 BL runtime·cgocallback(SB)
44 // Restore the caller's R2
46 ADD $(288+3*8+FIXED_FRAME), R1
56 TEXT saveregs2<>(SB),NOSPLIT|NOFRAME,$0
57 // O=-288; for R in R{14..31}; do echo "\tMOVD\t$R, $O(R1)"|sed s/R30/g/; ((O+=8)); done; for F in F{14..31}; do echo "\tFMOVD\t$F, $O(R1)"; ((O+=8)); done
97 TEXT restoreregs2<>(SB),NOSPLIT|NOFRAME,$0
98 // O=-288; for R in R{14..31}; do echo "\tMOVD\t$O(R1), $R"|sed s/R30/g/; ((O+=8)); done; for F in F{14..31}; do echo "\tFMOVD\t$O(R1), $F"; ((O+=8)); done