blob: 36dab286aecb3df8f26811bb93c72f2cf37682e6 [file] [log] [blame]
Brad Fitzpatrick51947442016-03-01 22:57:46 +00001// Copyright 2012 The Go Authors. All rights reserved.
Russ Coxd17506e2013-02-28 22:14:55 -08002// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
Russ Coxe8fc3622014-09-06 15:27:39 -04005#include "textflag.h"
Keith Randall8b789e12013-08-12 10:25:36 -07006
Ian Lance Taylor5f9a8702016-04-27 14:18:29 -07007// Called by C code generated by cmd/cgo.
8// func crosscall2(fn func(a unsafe.Pointer, n int32, ctxt uintptr), a unsafe.Pointer, n int32, ctxt uintptr)
9// Saves C callee-saved registers and calls fn with three arguments.
Austin Clementsa046caa2018-01-25 12:15:23 -050010TEXT crosscall2(SB),NOSPLIT|NOFRAME,$0
Russ Coxd17506e2013-02-28 22:14:55 -080011 /*
12 * We still need to save all callee save register as before, and then
Ian Lance Taylor5f9a8702016-04-27 14:18:29 -070013 * push 3 args for fn (R1, R2, R3).
Aaron Jacobs86286882015-06-24 09:50:12 +100014 * Also note that at procedure entry in gc world, 4(R13) will be the
Russ Coxd17506e2013-02-28 22:14:55 -080015 * first arg, so we must push another dummy reg (R0) for 0(R13).
Russ Cox89f185f2014-06-26 11:54:39 -040016 * Additionally, runtime·load_g will clobber R0, so we need to save R0
Russ Coxd17506e2013-02-28 22:14:55 -080017 * nevertheless.
18 */
Elias Naur72eb46c2016-05-16 15:51:07 +020019 SUB $(8*9), R13 // Reserve space for the floating point registers.
Ian Lance Taylor5f9a8702016-04-27 14:18:29 -070020 MOVM.WP [R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, g, R11, R12, R14], (R13)
Elias Naur72eb46c2016-05-16 15:51:07 +020021
22 // Skip floating point registers on GOARM < 6.
23 MOVB runtime·goarm(SB), R11
24 CMP $6, R11
25 BLT skipfpsave
26 MOVD F8, (14*4+8*1)(R13)
27 MOVD F9, (14*4+8*2)(R13)
28 MOVD F10, (14*4+8*3)(R13)
29 MOVD F11, (14*4+8*4)(R13)
30 MOVD F12, (14*4+8*5)(R13)
31 MOVD F13, (14*4+8*6)(R13)
32 MOVD F14, (14*4+8*7)(R13)
33 MOVD F15, (14*4+8*8)(R13)
34
35skipfpsave:
Russ Cox89f185f2014-06-26 11:54:39 -040036 BL runtime·load_g(SB)
Rob Pike0f3f2c42015-02-17 09:49:57 -080037 MOVW R15, R14 // R15 is PC.
38 MOVW 0(R13), R15
Elias Naur72eb46c2016-05-16 15:51:07 +020039
40 MOVB runtime·goarm(SB), R11
41 CMP $6, R11
42 BLT skipfprest
43 MOVD (14*4+8*1)(R13), F8
44 MOVD (14*4+8*2)(R13), F9
45 MOVD (14*4+8*3)(R13), F10
46 MOVD (14*4+8*4)(R13), F11
47 MOVD (14*4+8*5)(R13), F12
48 MOVD (14*4+8*6)(R13), F13
49 MOVD (14*4+8*7)(R13), F14
50 MOVD (14*4+8*8)(R13), F15
51
52skipfprest:
53 MOVM.IAW (R13), [R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, g, R11, R12, R14]
54 ADD $(8*9), R13
55 MOVW R14, R15