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