github.com/primecitizens/pcz/std@v0.2.1/core/reflect/call_mipsx.s (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 // 4 // Copyright 2018 The Go Authors. All rights reserved. 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file. 7 8 //go:build pcz && (mips || mipsle) 9 10 #include "textflag.h" 11 #include "funcdata.h" // for NO_LOCAL_POINTERS 12 13 // reflectcall: call a function with the given argument list 14 // func call(stackArgsType *_type, f *FuncVal, stackArgs *byte, stackArgsSize, stackRetOffset, frameSize uint32, regArgs *abi.RegArgs). 15 // we don't have variable-sized frames, so we use a small number 16 // of constant-sized-frame functions to encode a few bits of size in the pc. 17 18 #define DISPATCH(NAME,MAXSIZE) \ 19 MOVW $MAXSIZE, R23; \ 20 SGTU R1, R23, R23; \ 21 BNE R23, 3(PC); \ 22 MOVW $NAME(SB), R4; \ 23 JMP (R4) 24 25 TEXT ·Call(SB),NOSPLIT|NOFRAME,$0-28 26 MOVW frameSize+20(FP), R1 27 28 DISPATCH(·call16, 16) 29 DISPATCH(·call32, 32) 30 DISPATCH(·call64, 64) 31 DISPATCH(·call128, 128) 32 DISPATCH(·call256, 256) 33 DISPATCH(·call512, 512) 34 DISPATCH(·call1024, 1024) 35 DISPATCH(·call2048, 2048) 36 DISPATCH(·call4096, 4096) 37 DISPATCH(·call8192, 8192) 38 DISPATCH(·call16384, 16384) 39 DISPATCH(·call32768, 32768) 40 DISPATCH(·call65536, 65536) 41 DISPATCH(·call131072, 131072) 42 DISPATCH(·call262144, 262144) 43 DISPATCH(·call524288, 524288) 44 DISPATCH(·call1048576, 1048576) 45 DISPATCH(·call2097152, 2097152) 46 DISPATCH(·call4194304, 4194304) 47 DISPATCH(·call8388608, 8388608) 48 DISPATCH(·call16777216, 16777216) 49 DISPATCH(·call33554432, 33554432) 50 DISPATCH(·call67108864, 67108864) 51 DISPATCH(·call134217728, 134217728) 52 DISPATCH(·call268435456, 268435456) 53 DISPATCH(·call536870912, 536870912) 54 DISPATCH(·call1073741824, 1073741824) 55 MOVW $·badreflectcall(SB), R4 56 JMP (R4) 57 58 #define CALLFN(NAME,MAXSIZE) \ 59 TEXT NAME(SB),WRAPPER,$MAXSIZE-28; \ 60 NO_LOCAL_POINTERS; \ 61 /* copy arguments to stack */ \ 62 MOVW stackArgs+8(FP), R1; \ 63 MOVW stackArgsSize+12(FP), R2; \ 64 MOVW R29, R3; \ 65 ADDU $4, R3; \ 66 ADDU R3, R2; \ 67 BEQ R3, R2, 6(PC); \ 68 MOVBU (R1), R4; \ 69 ADDU $1, R1; \ 70 MOVBU R4, (R3); \ 71 ADDU $1, R3; \ 72 JMP -5(PC); \ 73 /* call function */ \ 74 MOVW f+4(FP), REGCTXT; \ 75 MOVW (REGCTXT), R4; \ 76 PCDATA $PCDATA_StackMapIndex, $0; \ 77 JAL (R4); \ 78 /* copy return values back */ \ 79 MOVW stackArgsType+0(FP), R5; \ 80 MOVW stackArgs+8(FP), R1; \ 81 MOVW stackArgsSize+12(FP), R2; \ 82 MOVW stackRetOffset+16(FP), R4; \ 83 ADDU $4, R29, R3; \ 84 ADDU R4, R3; \ 85 ADDU R4, R1; \ 86 SUBU R4, R2; \ 87 JAL callRet<>(SB); \ 88 RET 89 90 // callRet copies return values back at the end of call*. This is a 91 // separate function so it can allocate stack space for the arguments 92 // to reflectcallmove. It does not follow the Go ABI; it expects its 93 // arguments in registers. 94 TEXT callRet<>(SB), NOSPLIT, $20-0 95 MOVW R5, 4(R29) 96 MOVW R1, 8(R29) 97 MOVW R3, 12(R29) 98 MOVW R2, 16(R29) 99 MOVW $0, 20(R29) 100 JAL ·reflectcallmove(SB) 101 RET 102 103 CALLFN(·call16, 16) 104 CALLFN(·call32, 32) 105 CALLFN(·call64, 64) 106 CALLFN(·call128, 128) 107 CALLFN(·call256, 256) 108 CALLFN(·call512, 512) 109 CALLFN(·call1024, 1024) 110 CALLFN(·call2048, 2048) 111 CALLFN(·call4096, 4096) 112 CALLFN(·call8192, 8192) 113 CALLFN(·call16384, 16384) 114 CALLFN(·call32768, 32768) 115 CALLFN(·call65536, 65536) 116 CALLFN(·call131072, 131072) 117 CALLFN(·call262144, 262144) 118 CALLFN(·call524288, 524288) 119 CALLFN(·call1048576, 1048576) 120 CALLFN(·call2097152, 2097152) 121 CALLFN(·call4194304, 4194304) 122 CALLFN(·call8388608, 8388608) 123 CALLFN(·call16777216, 16777216) 124 CALLFN(·call33554432, 33554432) 125 CALLFN(·call67108864, 67108864) 126 CALLFN(·call134217728, 134217728) 127 CALLFN(·call268435456, 268435456) 128 CALLFN(·call536870912, 536870912) 129 CALLFN(·call1073741824, 1073741824)