1// Copyright 2016 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//go:build mips64 || mips64le
6
7.file "gcc_mips64x.S"
8
9/*
10 * void crosscall1(void (*fn)(void), void (*setg_gcc)(void *g), void *g)
11 *
12 * Calling into the gc tool chain, where all registers are caller save.
13 * Called from standard MIPS N64 ABI, where $16-$23, $28, $30, and $f24-$f31
14 * are callee-save, so they must be saved explicitly, along with $31 (LR).
15 */
16.globl crosscall1
17.set noat
18crosscall1:
19#ifndef __mips_soft_float
20 daddiu $29, $29, -160
21#else
22 daddiu $29, $29, -96 // For soft-float, no need to make room for FP registers
23#endif
24 sd $31, 0($29)
25 sd $16, 8($29)
26 sd $17, 16($29)
27 sd $18, 24($29)
28 sd $19, 32($29)
29 sd $20, 40($29)
30 sd $21, 48($29)
31 sd $22, 56($29)
32 sd $23, 64($29)
33 sd $28, 72($29)
34 sd $30, 80($29)
35#ifndef __mips_soft_float
36 sdc1 $f24, 88($29)
37 sdc1 $f25, 96($29)
38 sdc1 $f26, 104($29)
39 sdc1 $f27, 112($29)
40 sdc1 $f28, 120($29)
41 sdc1 $f29, 128($29)
42 sdc1 $f30, 136($29)
43 sdc1 $f31, 144($29)
44#endif
45
46 // prepare SB register = pc & 0xffffffff00000000
47 bal 1f
481:
49 dsrl $28, $31, 32
50 dsll $28, $28, 32
51
52 move $20, $4 // save R4
53 move $1, $6
54 jalr $5 // call setg_gcc (clobbers R4)
55 jalr $20 // call fn
56
57 ld $16, 8($29)
58 ld $17, 16($29)
59 ld $18, 24($29)
60 ld $19, 32($29)
61 ld $20, 40($29)
62 ld $21, 48($29)
63 ld $22, 56($29)
64 ld $23, 64($29)
65 ld $28, 72($29)
66 ld $30, 80($29)
67#ifndef __mips_soft_float
68 ldc1 $f24, 88($29)
69 ldc1 $f25, 96($29)
70 ldc1 $f26, 104($29)
71 ldc1 $f27, 112($29)
72 ldc1 $f28, 120($29)
73 ldc1 $f29, 128($29)
74 ldc1 $f30, 136($29)
75 ldc1 $f31, 144($29)
76#endif
77 ld $31, 0($29)
78#ifndef __mips_soft_float
79 daddiu $29, $29, 160
80#else
81 daddiu $29, $29, 96
82#endif
83 jr $31
84
85.set at
86
87#ifdef __ELF__
88.section .note.GNU-stack,"",%progbits
89#endif
View as plain text