1; QuickThreads -- Threads-building toolkit. 2; Copyright (c) 1993 by David Keppel 3 4; Permission to use, copy, modify and distribute this software and 5; its documentation for any purpose and without fee is hereby 6; granted, provided that the above copyright notice and this notice 7; appear in all copies. This software is provided as a 8; proof-of-concept and for demonstration purposes; there is no 9; representation about the suitability of this software for any 10; purpose. 11 12; This file (pa-risc_b.s) is part of the port of QuickThreads for 13; PA-RISC 1.1 architecture. It contains assembly-level support for 14; raw processor performance measurement. It was written in 1994 by 15; Uwe Reder (`uereder@cip.informatik.uni-erlangen.de') 16; for the Operating Systems Department (IMMD4) at the 17; University of Erlangen/Nuernberg Germany. 18 19 20; Note that the number of instructions in the measurement-loops, differ 21; from implementation to implementation. I took eight instructions in a loop 22; for every test (execute eight instructions and loop to the start). 23 24 .CODE 25 26 .IMPORT $global$,DATA 27 .IMPORT $$dyncall,MILLICODE 28 .EXPORT b_call_reg 29 .EXPORT b_call_imm 30 .EXPORT b_add 31 .EXPORT b_load 32 33; Just do nothing, only return to caller. This procedure is called by 34; `b_call_reg' and `b_call_imm'. 35 36b_null 37 .PROC 38 .CALLINFO NO_CALLS, FRAME=0 39 .ENTRY 40 41 bv,n %r0(%rp) ; just return 42 43 .EXIT 44 .PROCEND 45 46; Call the procedure `b_null' with function pointer in a register. 47 48b_call_reg 49 .PROC 50 .CALLINFO CALLER, FRAME=0 51 .ENTRY 52 53 stwm %r3,64(%sp) ; store r3 (may be used by caller) 54 stw %rp,-20(%sp) ; save return-pointer to frame-marker 55 56 addil LR'to_call-$global$,%r27 57 ldw RR'to_call-$global$(%r1),%r3 58 59_loop0 60 copy %r3,%r22 ; copy the procedure label to r22, ... 61 .CALL ; ...this is the input to $$dyncall 62 bl $$dyncall,%mrp ; call $$dyncall (millicode function) 63 copy %mrp,%rp ; remember the return-pointer 64 65 copy %r3,%r22 66 .CALL 67 bl $$dyncall,%mrp 68 copy %mrp,%rp 69 70 copy %r3,%r22 71 .CALL 72 bl $$dyncall,%mrp 73 copy %mrp,%rp 74 75 copy %r3,%r22 76 .CALL 77 bl $$dyncall,%mrp 78 copy %mrp,%rp 79 80 copy %r3,%r22 81 .CALL 82 bl $$dyncall,%mrp 83 copy %mrp,%rp 84 85 copy %r3,%r22 86 .CALL 87 bl $$dyncall,%mrp 88 copy %mrp,%rp 89 90 copy %r3,%r22 91 .CALL 92 bl $$dyncall,%mrp 93 copy %mrp,%rp 94 95 copy %r3,%r22 96 .CALL 97 bl $$dyncall,%mrp 98 copy %mrp,%rp 99 100 addibf,<= -8,%arg0,_loop0 ; decrement counter by 8 and loop 101 nop 102 103 ldw -20(%sp),%rp ; restore return-pointer 104 bv %r0(%rp) ; return to caller 105 ldwm -64(%sp),%r3 ; resore r3 and remove stack frame 106 107 .EXIT 108 .PROCEND 109 110; Call the procedure `b_null' immediate. 111 112b_call_imm 113 .PROC 114 .CALLINFO CALLER, FRAME=0, SAVE_RP 115 .ENTRY 116 117 ldo 64(%sp),%sp ; caller needs a stack-frame 118 stw %rp,-20(%sp) ; save return-pointer to frame-marker 119 120_loop1 121 bl b_null,%rp ; call `b_null' immediate (8 times) 122 nop 123 bl b_null,%rp 124 nop 125 bl b_null,%rp 126 nop 127 bl b_null,%rp 128 nop 129 bl b_null,%rp 130 nop 131 bl b_null,%rp 132 nop 133 bl b_null,%rp 134 nop 135 bl b_null,%rp 136 nop 137 138 addibf,<= -8,%arg0,_loop1 ; decrement counter by 8 and loop 139 nop 140 141 ldw -20(%sp),%rp ; restore return-pointer 142 bv %r0(%rp) ; return to caller 143 ldo -64(%sp),%sp ; remove stack-frame 144 145 .EXIT 146 .PROCEND 147 148; Copy register-to-register. 149; On PA-RISC this is implemented with an `or'. 150; The `or' is hidden by a pseudo-operation called `copy'. 151 152b_add 153 .PROC 154 .CALLINFO NO_CALLS, FRAME=0 155 .ENTRY 156 157_loop2 158 copy %r19,%r20 ; copy register-to-register 159 copy %r20,%r21 ; use caller-saves registers 160 copy %r21,%r22 161 copy %r22,%r21 162 copy %r21,%r20 163 copy %r20,%r19 164 copy %r19,%r20 165 copy %r20,%r21 166 167 addibf,<= -8,%arg0,_loop2 ; decrement counter by 8 and loop 168 nop 169 170 bv,n %r0(%rp) 171 172 .EXIT 173 .PROCEND 174 175; Load memory to a register. 176 177b_load 178 .PROC 179 .CALLINFO NO_CALLS, FRAME=0 180 .ENTRY 181 182_loop3 183 ldw -4(%sp),%r22 ; load data from frame-marker 184 ldw -8(%sp),%r22 ; use a caller-saves register 185 ldw -12(%sp),%r22 186 ldw -16(%sp),%r22 187 ldw -20(%sp),%r22 188 ldw -24(%sp),%r22 189 ldw -28(%sp),%r22 190 ldw -32(%sp),%r22 191 192 addibf,<= -8,%arg0,_loop3 ; decrement counter by 8 and loop 193 nop 194 195 bv,n %r0(%rp) 196 197 .EXIT 198 .PROCEND 199 200 201 .ALIGN 8 202to_call 203 .WORD b_null 204