github.com/aloncn/graphics-go@v0.0.1/src/runtime/cgo/asm_ppc64x.s (about)

     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  // +build ppc64 ppc64le
     6  
     7  #include "textflag.h"
     8  #include "asm_ppc64x.h"
     9  
    10  /*
    11   * void crosscall2(void (*fn)(void*, int32), void*, int32)
    12   * Save registers and call fn with two arguments.
    13   * crosscall2 obeys the C ABI; fn obeys the Go ABI.
    14   */
    15  TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
    16  	// TODO(austin): ABI v1 (fn is probably a function descriptor)
    17  
    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  	MOVD	R2, 24(R1)	// Save TOC in caller's frame
    22  
    23  	BL	saveregs2<>(SB)
    24  
    25  	MOVDU	R1, (-288-2*8-FIXED_FRAME)(R1)
    26  
    27  	// Initialize Go ABI environment
    28  	BL	runtimeĀ·reginit(SB)
    29  	BL	runtimeĀ·load_g(SB)
    30  
    31  	MOVD	R3, R12
    32  	MOVD	R3, CTR
    33  	MOVD	R4, FIXED_FRAME+0(R1)
    34  	MOVD	R5, FIXED_FRAME+8(R1)
    35  	BL	(CTR)
    36  
    37  	ADD	$(288+2*8+FIXED_FRAME), R1
    38  
    39  	BL	restoreregs2<>(SB)
    40  
    41  	MOVD	24(R1), R2
    42  	MOVD	16(R1), R0
    43  	MOVD	R0, LR
    44  	RET
    45  
    46  TEXT saveregs2<>(SB),NOSPLIT|NOFRAME,$0
    47  	// 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
    48  	MOVD	R14, -288(R1)
    49  	MOVD	R15, -280(R1)
    50  	MOVD	R16, -272(R1)
    51  	MOVD	R17, -264(R1)
    52  	MOVD	R18, -256(R1)
    53  	MOVD	R19, -248(R1)
    54  	MOVD	R20, -240(R1)
    55  	MOVD	R21, -232(R1)
    56  	MOVD	R22, -224(R1)
    57  	MOVD	R23, -216(R1)
    58  	MOVD	R24, -208(R1)
    59  	MOVD	R25, -200(R1)
    60  	MOVD	R26, -192(R1)
    61  	MOVD	R27, -184(R1)
    62  	MOVD	R28, -176(R1)
    63  	MOVD	R29, -168(R1)
    64  	MOVD	g, -160(R1)
    65  	MOVD	R31, -152(R1)
    66  	FMOVD	F14, -144(R1)
    67  	FMOVD	F15, -136(R1)
    68  	FMOVD	F16, -128(R1)
    69  	FMOVD	F17, -120(R1)
    70  	FMOVD	F18, -112(R1)
    71  	FMOVD	F19, -104(R1)
    72  	FMOVD	F20, -96(R1)
    73  	FMOVD	F21, -88(R1)
    74  	FMOVD	F22, -80(R1)
    75  	FMOVD	F23, -72(R1)
    76  	FMOVD	F24, -64(R1)
    77  	FMOVD	F25, -56(R1)
    78  	FMOVD	F26, -48(R1)
    79  	FMOVD	F27, -40(R1)
    80  	FMOVD	F28, -32(R1)
    81  	FMOVD	F29, -24(R1)
    82  	FMOVD	F30, -16(R1)
    83  	FMOVD	F31, -8(R1)
    84  
    85  	RET
    86  
    87  TEXT restoreregs2<>(SB),NOSPLIT|NOFRAME,$0
    88  	// 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
    89  	MOVD	-288(R1), R14
    90  	MOVD	-280(R1), R15
    91  	MOVD	-272(R1), R16
    92  	MOVD	-264(R1), R17
    93  	MOVD	-256(R1), R18
    94  	MOVD	-248(R1), R19
    95  	MOVD	-240(R1), R20
    96  	MOVD	-232(R1), R21
    97  	MOVD	-224(R1), R22
    98  	MOVD	-216(R1), R23
    99  	MOVD	-208(R1), R24
   100  	MOVD	-200(R1), R25
   101  	MOVD	-192(R1), R26
   102  	MOVD	-184(R1), R27
   103  	MOVD	-176(R1), R28
   104  	MOVD	-168(R1), R29
   105  	MOVD	-160(R1), g
   106  	MOVD	-152(R1), R31
   107  	FMOVD	-144(R1), F14
   108  	FMOVD	-136(R1), F15
   109  	FMOVD	-128(R1), F16
   110  	FMOVD	-120(R1), F17
   111  	FMOVD	-112(R1), F18
   112  	FMOVD	-104(R1), F19
   113  	FMOVD	-96(R1), F20
   114  	FMOVD	-88(R1), F21
   115  	FMOVD	-80(R1), F22
   116  	FMOVD	-72(R1), F23
   117  	FMOVD	-64(R1), F24
   118  	FMOVD	-56(R1), F25
   119  	FMOVD	-48(R1), F26
   120  	FMOVD	-40(R1), F27
   121  	FMOVD	-32(R1), F28
   122  	FMOVD	-24(R1), F29
   123  	FMOVD	-16(R1), F30
   124  	FMOVD	-8(R1), F31
   125  
   126  	RET