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