github.com/lovishpuri/go-40569/src@v0.0.0-20230519171745-f8623e7c56cf/runtime/cgo/asm_arm.s (about)

     1  // Copyright 2012 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  #include "textflag.h"
     6  
     7  // Set the x_crosscall2_ptr C function pointer variable point to crosscall2.
     8  // It's such a pointer chain: _crosscall2_ptr -> x_crosscall2_ptr -> crosscall2
     9  TEXT ·set_crosscall2(SB),NOSPLIT,$0-0
    10  	MOVW	_crosscall2_ptr(SB), R1
    11  	MOVW	$crosscall2(SB), R2
    12  	MOVW	R2, (R1)
    13  	RET
    14  
    15  // Called by C code generated by cmd/cgo.
    16  // func crosscall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)
    17  // Saves C callee-saved registers and calls cgocallback with three arguments.
    18  // fn is the PC of a func(a unsafe.Pointer) function.
    19  TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
    20  	SUB	$(8*9), R13 // Reserve space for the floating point registers.
    21  	// The C arguments arrive in R0, R1, R2, and R3. We want to
    22  	// pass R0, R1, and R3 to Go, so we push those on the stack.
    23  	// Also, save C callee-save registers R4-R12.
    24  	MOVM.WP	[R0, R1, R3, R4, R5, R6, R7, R8, R9, g, R11, R12], (R13)
    25  	// Finally, save the link register R14. This also puts the
    26  	// arguments we pushed for cgocallback where they need to be,
    27  	// starting at 4(R13).
    28  	MOVW.W	R14, -4(R13)
    29  
    30  	// Skip floating point registers on GOARM < 6.
    31  	MOVB    runtime·goarm(SB), R11
    32  	CMP $6, R11
    33  	BLT skipfpsave
    34  	MOVD	F8, (13*4+8*1)(R13)
    35  	MOVD	F9, (13*4+8*2)(R13)
    36  	MOVD	F10, (13*4+8*3)(R13)
    37  	MOVD	F11, (13*4+8*4)(R13)
    38  	MOVD	F12, (13*4+8*5)(R13)
    39  	MOVD	F13, (13*4+8*6)(R13)
    40  	MOVD	F14, (13*4+8*7)(R13)
    41  	MOVD	F15, (13*4+8*8)(R13)
    42  
    43  skipfpsave:
    44  	BL	runtime·load_g(SB)
    45  	// We set up the arguments to cgocallback when saving registers above.
    46  	BL	runtime·cgocallback(SB)
    47  
    48  	MOVB    runtime·goarm(SB), R11
    49  	CMP $6, R11
    50  	BLT skipfprest
    51  	MOVD	(13*4+8*1)(R13), F8
    52  	MOVD	(13*4+8*2)(R13), F9
    53  	MOVD	(13*4+8*3)(R13), F10
    54  	MOVD	(13*4+8*4)(R13), F11
    55  	MOVD	(13*4+8*5)(R13), F12
    56  	MOVD	(13*4+8*6)(R13), F13
    57  	MOVD	(13*4+8*7)(R13), F14
    58  	MOVD	(13*4+8*8)(R13), F15
    59  
    60  skipfprest:
    61  	MOVW.P	4(R13), R14
    62  	MOVM.IAW	(R13), [R0, R1, R3, R4, R5, R6, R7, R8, R9, g, R11, R12]
    63  	ADD	$(8*9), R13
    64  	MOVW	R14, R15