github.com/primecitizens/pcz/std@v0.2.1/core/reflect/call_arm.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 && arm 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 // Caution: ugly multiline assembly macros in your future! 18 19 #define DISPATCH(NAME,MAXSIZE) \ 20 CMP $MAXSIZE, R0; \ 21 B.HI 3(PC); \ 22 MOVW $NAME(SB), R1; \ 23 B (R1) 24 25 TEXT ·Call(SB),NOSPLIT|NOFRAME,$0-28 26 MOVW frameSize+20(FP), R0 27 DISPATCH(·call16, 16) 28 DISPATCH(·call32, 32) 29 DISPATCH(·call64, 64) 30 DISPATCH(·call128, 128) 31 DISPATCH(·call256, 256) 32 DISPATCH(·call512, 512) 33 DISPATCH(·call1024, 1024) 34 DISPATCH(·call2048, 2048) 35 DISPATCH(·call4096, 4096) 36 DISPATCH(·call8192, 8192) 37 DISPATCH(·call16384, 16384) 38 DISPATCH(·call32768, 32768) 39 DISPATCH(·call65536, 65536) 40 DISPATCH(·call131072, 131072) 41 DISPATCH(·call262144, 262144) 42 DISPATCH(·call524288, 524288) 43 DISPATCH(·call1048576, 1048576) 44 DISPATCH(·call2097152, 2097152) 45 DISPATCH(·call4194304, 4194304) 46 DISPATCH(·call8388608, 8388608) 47 DISPATCH(·call16777216, 16777216) 48 DISPATCH(·call33554432, 33554432) 49 DISPATCH(·call67108864, 67108864) 50 DISPATCH(·call134217728, 134217728) 51 DISPATCH(·call268435456, 268435456) 52 DISPATCH(·call536870912, 536870912) 53 DISPATCH(·call1073741824, 1073741824) 54 MOVW $·badreflectcall(SB), R1 55 B (R1) 56 57 #define CALLFN(NAME,MAXSIZE) \ 58 TEXT NAME(SB), WRAPPER, $MAXSIZE-28; \ 59 NO_LOCAL_POINTERS; \ 60 /* copy arguments to stack */ \ 61 MOVW stackArgs+8(FP), R0; \ 62 MOVW stackArgsSize+12(FP), R2; \ 63 ADD $4, R13, R1; \ 64 CMP $0, R2; \ 65 B.EQ 5(PC); \ 66 MOVBU.P 1(R0), R5; \ 67 MOVBU.P R5, 1(R1); \ 68 SUB $1, R2, R2; \ 69 B -5(PC); \ 70 /* call function */ \ 71 MOVW f+4(FP), R7; \ 72 MOVW (R7), R0; \ 73 PCDATA $PCDATA_StackMapIndex, $0; \ 74 BL (R0); \ 75 /* copy return values back */ \ 76 MOVW stackArgsType+0(FP), R4; \ 77 MOVW stackArgs+8(FP), R0; \ 78 MOVW stackArgsSize+12(FP), R2; \ 79 MOVW stackArgsRetOffset+16(FP), R3; \ 80 ADD $4, R13, R1; \ 81 ADD R3, R1; \ 82 ADD R3, R0; \ 83 SUB R3, R2; \ 84 BL callRet<>(SB); \ 85 RET 86 87 // callRet copies return values back at the end of call*. This is a 88 // separate function so it can allocate stack space for the arguments 89 // to reflectcallmove. It does not follow the Go ABI; it expects its 90 // arguments in registers. 91 TEXT callRet<>(SB), NOSPLIT, $20-0 92 MOVW R4, 4(R13) 93 MOVW R0, 8(R13) 94 MOVW R1, 12(R13) 95 MOVW R2, 16(R13) 96 MOVW $0, R7 97 MOVW R7, 20(R13) 98 BL ·reflectcallmove(SB) 99 RET 100 101 CALLFN(·call16, 16) 102 CALLFN(·call32, 32) 103 CALLFN(·call64, 64) 104 CALLFN(·call128, 128) 105 CALLFN(·call256, 256) 106 CALLFN(·call512, 512) 107 CALLFN(·call1024, 1024) 108 CALLFN(·call2048, 2048) 109 CALLFN(·call4096, 4096) 110 CALLFN(·call8192, 8192) 111 CALLFN(·call16384, 16384) 112 CALLFN(·call32768, 32768) 113 CALLFN(·call65536, 65536) 114 CALLFN(·call131072, 131072) 115 CALLFN(·call262144, 262144) 116 CALLFN(·call524288, 524288) 117 CALLFN(·call1048576, 1048576) 118 CALLFN(·call2097152, 2097152) 119 CALLFN(·call4194304, 4194304) 120 CALLFN(·call8388608, 8388608) 121 CALLFN(·call16777216, 16777216) 122 CALLFN(·call33554432, 33554432) 123 CALLFN(·call67108864, 67108864) 124 CALLFN(·call134217728, 134217728) 125 CALLFN(·call268435456, 268435456) 126 CALLFN(·call536870912, 536870912) 127 CALLFN(·call1073741824, 1073741824)