...

Text file src/pkg/runtime/cgo/gcc_aix_ppc64.S

     1	// Copyright 2019 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
     6	// +build aix
     7	
     8	/*
     9	 * void crosscall_ppc64(void (*fn)(void), void *g)
    10	 *
    11	 * Calling into the gc tool chain, where all registers are caller save.
    12	 * Called from standard ppc64 C ABI, where r2, r14-r31, f14-f31 are
    13	 * callee-save, so they must be saved explicitly.
    14	 * AIX has a special assembly syntax and keywords that can be mixed with
    15	 * Linux assembly.
    16	 */
    17	  .toc
    18	  .csect .text[PR]
    19	  .globl crosscall_ppc64
    20	  .globl .crosscall_ppc64
    21	  .csect crosscall_ppc64[DS]
    22	crosscall_ppc64:
    23	  .llong .crosscall_ppc64, TOC[tc0], 0
    24	  .csect .text[PR]
    25	.crosscall_ppc64:
    26		// Start with standard C stack frame layout and linkage
    27		mflr	0
    28		std	0, 16(1)	// Save LR in caller's frame
    29		std	2, 40(1)	// Save TOC in caller's frame
    30		bl	saveregs
    31		stdu	1, -296(1)
    32	
    33		// Set up Go ABI constant registers
    34		// Must match _cgo_reginit in runtime package.
    35		xor 0, 0, 0
    36	
    37		// Restore g pointer (r30 in Go ABI, which may have been clobbered by C)
    38		mr	30, 4
    39	
    40		// Call fn
    41		mr	12, 3
    42		mtctr	12
    43		bctrl
    44	
    45		addi	1, 1, 296
    46		bl	restoreregs
    47		ld	2, 40(1)
    48		ld	0, 16(1)
    49		mtlr	0
    50		blr
    51	
    52	saveregs:
    53		// Save callee-save registers
    54		// O=-288; for R in {14..31}; do echo "\tstd\t$R, $O(1)"; ((O+=8)); done; for F in f{14..31}; do echo "\tstfd\t$F, $O(1)"; ((O+=8)); done
    55		std	14, -288(1)
    56		std	15, -280(1)
    57		std	16, -272(1)
    58		std	17, -264(1)
    59		std	18, -256(1)
    60		std	19, -248(1)
    61		std	20, -240(1)
    62		std	21, -232(1)
    63		std	22, -224(1)
    64		std	23, -216(1)
    65		std	24, -208(1)
    66		std	25, -200(1)
    67		std	26, -192(1)
    68		std	27, -184(1)
    69		std	28, -176(1)
    70		std	29, -168(1)
    71		std	30, -160(1)
    72		std	31, -152(1)
    73		stfd	14, -144(1)
    74		stfd	15, -136(1)
    75		stfd	16, -128(1)
    76		stfd	17, -120(1)
    77		stfd	18, -112(1)
    78		stfd	19, -104(1)
    79		stfd	20, -96(1)
    80		stfd	21, -88(1)
    81		stfd	22, -80(1)
    82		stfd	23, -72(1)
    83		stfd	24, -64(1)
    84		stfd	25, -56(1)
    85		stfd	26, -48(1)
    86		stfd	27, -40(1)
    87		stfd	28, -32(1)
    88		stfd	29, -24(1)
    89		stfd	30, -16(1)
    90		stfd	31, -8(1)
    91	
    92		blr
    93	
    94	restoreregs:
    95		// O=-288; for R in {14..31}; do echo "\tld\t$R, $O(1)"; ((O+=8)); done; for F in {14..31}; do echo "\tlfd\t$F, $O(1)"; ((O+=8)); done
    96		ld	14, -288(1)
    97		ld	15, -280(1)
    98		ld	16, -272(1)
    99		ld	17, -264(1)
   100		ld	18, -256(1)
   101		ld	19, -248(1)
   102		ld	20, -240(1)
   103		ld	21, -232(1)
   104		ld	22, -224(1)
   105		ld	23, -216(1)
   106		ld	24, -208(1)
   107		ld	25, -200(1)
   108		ld	26, -192(1)
   109		ld	27, -184(1)
   110		ld	28, -176(1)
   111		ld	29, -168(1)
   112		ld	30, -160(1)
   113		ld	31, -152(1)
   114		lfd	14, -144(1)
   115		lfd	15, -136(1)
   116		lfd	16, -128(1)
   117		lfd	17, -120(1)
   118		lfd	18, -112(1)
   119		lfd	19, -104(1)
   120		lfd	20, -96(1)
   121		lfd	21, -88(1)
   122		lfd	22, -80(1)
   123		lfd	23, -72(1)
   124		lfd	24, -64(1)
   125		lfd	25, -56(1)
   126		lfd	26, -48(1)
   127		lfd	27, -40(1)
   128		lfd	28, -32(1)
   129		lfd	29, -24(1)
   130		lfd	30, -16(1)
   131		lfd	31, -8(1)
   132	
   133		blr

View as plain text