...
Run Format

Text file src/runtime/cgo/asm_ppc64x.s

Documentation: runtime/cgo

     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	// Called by C code generated by cmd/cgo.
    11	// func crosscall2(fn func(a unsafe.Pointer, n int32, ctxt uintptr), a unsafe.Pointer, n int32, ctxt uintptr)
    12	// Saves C callee-saved registers and calls fn with three arguments.
    13	TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
    14		// TODO(austin): ABI v1 (fn is probably a function descriptor)
    15	
    16		// Start with standard C stack frame layout and linkage
    17		MOVD	LR, R0
    18		MOVD	R0, 16(R1)	// Save LR in caller's frame
    19		MOVW	CR, R0		// Save CR in caller's frame
    20		MOVD	R0, 8(R1)
    21		MOVD	R2, 24(R1)	// Save TOC in caller's frame
    22	
    23		BL	saveregs2<>(SB)
    24	
    25		MOVDU	R1, (-288-3*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		MOVD	R6, FIXED_FRAME+16(R1)
    36		BL	(CTR)
    37	
    38		ADD	$(288+3*8+FIXED_FRAME), R1
    39	
    40		BL	restoreregs2<>(SB)
    41	
    42		MOVD	24(R1), R2
    43		MOVD	8(R1), R0
    44		MOVFL	R0, $0xff
    45		MOVD	16(R1), R0
    46		MOVD	R0, LR
    47		RET
    48	
    49	TEXT saveregs2<>(SB),NOSPLIT|NOFRAME,$0
    50		// 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
    51		MOVD	R14, -288(R1)
    52		MOVD	R15, -280(R1)
    53		MOVD	R16, -272(R1)
    54		MOVD	R17, -264(R1)
    55		MOVD	R18, -256(R1)
    56		MOVD	R19, -248(R1)
    57		MOVD	R20, -240(R1)
    58		MOVD	R21, -232(R1)
    59		MOVD	R22, -224(R1)
    60		MOVD	R23, -216(R1)
    61		MOVD	R24, -208(R1)
    62		MOVD	R25, -200(R1)
    63		MOVD	R26, -192(R1)
    64		MOVD	R27, -184(R1)
    65		MOVD	R28, -176(R1)
    66		MOVD	R29, -168(R1)
    67		MOVD	g, -160(R1)
    68		MOVD	R31, -152(R1)
    69		FMOVD	F14, -144(R1)
    70		FMOVD	F15, -136(R1)
    71		FMOVD	F16, -128(R1)
    72		FMOVD	F17, -120(R1)
    73		FMOVD	F18, -112(R1)
    74		FMOVD	F19, -104(R1)
    75		FMOVD	F20, -96(R1)
    76		FMOVD	F21, -88(R1)
    77		FMOVD	F22, -80(R1)
    78		FMOVD	F23, -72(R1)
    79		FMOVD	F24, -64(R1)
    80		FMOVD	F25, -56(R1)
    81		FMOVD	F26, -48(R1)
    82		FMOVD	F27, -40(R1)
    83		FMOVD	F28, -32(R1)
    84		FMOVD	F29, -24(R1)
    85		FMOVD	F30, -16(R1)
    86		FMOVD	F31, -8(R1)
    87	
    88		RET
    89	
    90	TEXT restoreregs2<>(SB),NOSPLIT|NOFRAME,$0
    91		// 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
    92		MOVD	-288(R1), R14
    93		MOVD	-280(R1), R15
    94		MOVD	-272(R1), R16
    95		MOVD	-264(R1), R17
    96		MOVD	-256(R1), R18
    97		MOVD	-248(R1), R19
    98		MOVD	-240(R1), R20
    99		MOVD	-232(R1), R21
   100		MOVD	-224(R1), R22
   101		MOVD	-216(R1), R23
   102		MOVD	-208(R1), R24
   103		MOVD	-200(R1), R25
   104		MOVD	-192(R1), R26
   105		MOVD	-184(R1), R27
   106		MOVD	-176(R1), R28
   107		MOVD	-168(R1), R29
   108		MOVD	-160(R1), g
   109		MOVD	-152(R1), R31
   110		FMOVD	-144(R1), F14
   111		FMOVD	-136(R1), F15
   112		FMOVD	-128(R1), F16
   113		FMOVD	-120(R1), F17
   114		FMOVD	-112(R1), F18
   115		FMOVD	-104(R1), F19
   116		FMOVD	-96(R1), F20
   117		FMOVD	-88(R1), F21
   118		FMOVD	-80(R1), F22
   119		FMOVD	-72(R1), F23
   120		FMOVD	-64(R1), F24
   121		FMOVD	-56(R1), F25
   122		FMOVD	-48(R1), F26
   123		FMOVD	-40(R1), F27
   124		FMOVD	-32(R1), F28
   125		FMOVD	-24(R1), F29
   126		FMOVD	-16(R1), F30
   127		FMOVD	-8(R1), F31
   128	
   129		RET

View as plain text