Text file src/runtime/cgo/asm_ppc64x.s

     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.
     4  
     5  //go:build ppc64 || ppc64le
     6  // +build ppc64 ppc64le
     7  
     8  #include "textflag.h"
     9  #include "asm_ppc64x.h"
    10  
    11  // Called by C code generated by cmd/cgo.
    12  // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
    13  // Saves C callee-saved registers and calls cgocallback with three arguments.
    14  // fn is the PC of a func(a unsafe.Pointer) function.
    15  // The value of R2 is saved on the new stack frame, and not
    16  // the caller's frame due to issue #43228.
    17  TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
    18  	// Start with standard C stack frame layout and linkage
    19  	MOVD	LR, R0
    20  	MOVD	R0, 16(R1)	// Save LR in caller's frame
    21  	MOVW	CR, R0		// Save CR in caller's frame
    22  	MOVW	R0, 8(R1)
    23  
    24  	BL	saveregs2<>(SB)
    25  
    26  	MOVDU	R1, (-288-3*8-FIXED_FRAME)(R1)
    27  	// Save the caller's R2
    28  	MOVD	R2, 24(R1)
    29  
    30  	// Initialize Go ABI environment
    31  	BL	runtime·reginit(SB)
    32  	BL	runtime·load_g(SB)
    33  
    34  #ifdef GOARCH_ppc64
    35  	// ppc64 use elf ABI v1. we must get the real entry address from
    36  	// first slot of the function descriptor before call.
    37  	// Same for AIX.
    38  	MOVD	8(R3), R2
    39  	MOVD	(R3), R3
    40  #endif
    41  	MOVD	R3, FIXED_FRAME+0(R1)	// fn unsafe.Pointer
    42  	MOVD	R4, FIXED_FRAME+8(R1)	// a unsafe.Pointer
    43  	// Skip R5 = n uint32
    44  	MOVD	R6, FIXED_FRAME+16(R1)	// ctxt uintptr
    45  	BL	runtime·cgocallback(SB)
    46  
    47  	// Restore the caller's R2
    48  	MOVD	24(R1), R2
    49  	ADD	$(288+3*8+FIXED_FRAME), R1
    50  
    51  	BL	restoreregs2<>(SB)
    52  
    53  	MOVW	8(R1), R0
    54  	MOVFL	R0, $0xff
    55  	MOVD	16(R1), R0
    56  	MOVD	R0, LR
    57  	RET
    58  
    59  TEXT saveregs2<>(SB),NOSPLIT|NOFRAME,$0
    60  	// 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
    61  	MOVD	R14, -288(R1)
    62  	MOVD	R15, -280(R1)
    63  	MOVD	R16, -272(R1)
    64  	MOVD	R17, -264(R1)
    65  	MOVD	R18, -256(R1)
    66  	MOVD	R19, -248(R1)
    67  	MOVD	R20, -240(R1)
    68  	MOVD	R21, -232(R1)
    69  	MOVD	R22, -224(R1)
    70  	MOVD	R23, -216(R1)
    71  	MOVD	R24, -208(R1)
    72  	MOVD	R25, -200(R1)
    73  	MOVD	R26, -192(R1)
    74  	MOVD	R27, -184(R1)
    75  	MOVD	R28, -176(R1)
    76  	MOVD	R29, -168(R1)
    77  	MOVD	g, -160(R1)
    78  	MOVD	R31, -152(R1)
    79  	FMOVD	F14, -144(R1)
    80  	FMOVD	F15, -136(R1)
    81  	FMOVD	F16, -128(R1)
    82  	FMOVD	F17, -120(R1)
    83  	FMOVD	F18, -112(R1)
    84  	FMOVD	F19, -104(R1)
    85  	FMOVD	F20, -96(R1)
    86  	FMOVD	F21, -88(R1)
    87  	FMOVD	F22, -80(R1)
    88  	FMOVD	F23, -72(R1)
    89  	FMOVD	F24, -64(R1)
    90  	FMOVD	F25, -56(R1)
    91  	FMOVD	F26, -48(R1)
    92  	FMOVD	F27, -40(R1)
    93  	FMOVD	F28, -32(R1)
    94  	FMOVD	F29, -24(R1)
    95  	FMOVD	F30, -16(R1)
    96  	FMOVD	F31, -8(R1)
    97  
    98  	RET
    99  
   100  TEXT restoreregs2<>(SB),NOSPLIT|NOFRAME,$0
   101  	// 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
   102  	MOVD	-288(R1), R14
   103  	MOVD	-280(R1), R15
   104  	MOVD	-272(R1), R16
   105  	MOVD	-264(R1), R17
   106  	MOVD	-256(R1), R18
   107  	MOVD	-248(R1), R19
   108  	MOVD	-240(R1), R20
   109  	MOVD	-232(R1), R21
   110  	MOVD	-224(R1), R22
   111  	MOVD	-216(R1), R23
   112  	MOVD	-208(R1), R24
   113  	MOVD	-200(R1), R25
   114  	MOVD	-192(R1), R26
   115  	MOVD	-184(R1), R27
   116  	MOVD	-176(R1), R28
   117  	MOVD	-168(R1), R29
   118  	MOVD	-160(R1), g
   119  	MOVD	-152(R1), R31
   120  	FMOVD	-144(R1), F14
   121  	FMOVD	-136(R1), F15
   122  	FMOVD	-128(R1), F16
   123  	FMOVD	-120(R1), F17
   124  	FMOVD	-112(R1), F18
   125  	FMOVD	-104(R1), F19
   126  	FMOVD	-96(R1), F20
   127  	FMOVD	-88(R1), F21
   128  	FMOVD	-80(R1), F22
   129  	FMOVD	-72(R1), F23
   130  	FMOVD	-64(R1), F24
   131  	FMOVD	-56(R1), F25
   132  	FMOVD	-48(R1), F26
   133  	FMOVD	-40(R1), F27
   134  	FMOVD	-32(R1), F28
   135  	FMOVD	-24(R1), F29
   136  	FMOVD	-16(R1), F30
   137  	FMOVD	-8(R1), F31
   138  
   139  	RET
   140  

View as plain text