summaryrefslogtreecommitdiff
path: root/ext/systemc/src/sysc/qt/md/hppa_b.s
blob: 1b1e8264eb89103babf5e23c2254dafbe78aa067 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
; QuickThreads -- Threads-building toolkit.
; Copyright (c) 1993 by David Keppel

; Permission to use, copy, modify and distribute this software and
; its documentation for any purpose and without fee is hereby
; granted, provided that the above copyright notice and this notice
; appear in all copies.  This software is provided as a
; proof-of-concept and for demonstration purposes; there is no
; representation about the suitability of this software for any
; purpose.

; This file (pa-risc_b.s) is part of the port of QuickThreads for
; PA-RISC 1.1 architecture.  It contains assembly-level support for
; raw processor performance measurement.  It was written in 1994 by
; Uwe Reder (`uereder@cip.informatik.uni-erlangen.de')
; for the Operating Systems Department (IMMD4) at the
; University of Erlangen/Nuernberg Germany.


; Note that the number of instructions in the measurement-loops, differ
; from implementation to implementation. I took eight instructions in a loop
; for every test (execute eight instructions and loop to the start).

            .CODE

            .IMPORT $global$,DATA
            .IMPORT $$dyncall,MILLICODE
            .EXPORT b_call_reg
            .EXPORT b_call_imm
            .EXPORT b_add
            .EXPORT b_load

; Just do nothing, only return to caller. This procedure is called by
; `b_call_reg' and `b_call_imm'.

b_null
            .PROC
            .CALLINFO   NO_CALLS, FRAME=0
            .ENTRY

            bv,n        %r0(%rp)        ; just return

            .EXIT
            .PROCEND

; Call the procedure `b_null' with function pointer in a register.

b_call_reg
            .PROC
            .CALLINFO   CALLER, FRAME=0
            .ENTRY
    
            stwm        %r3,64(%sp)     ; store r3 (may be used by caller)
            stw         %rp,-20(%sp)    ; save return-pointer to frame-marker

            addil       LR'to_call-$global$,%r27
            ldw         RR'to_call-$global$(%r1),%r3

_loop0
            copy        %r3,%r22        ; copy the procedure label to r22, ...
            .CALL                       ; ...this is the input to $$dyncall
            bl          $$dyncall,%mrp  ; call $$dyncall (millicode function)
            copy        %mrp,%rp        ; remember the return-pointer

            copy        %r3,%r22
            .CALL
            bl          $$dyncall,%mrp
            copy        %mrp,%rp

            copy        %r3,%r22
            .CALL
            bl          $$dyncall,%mrp
            copy        %mrp,%rp

            copy        %r3,%r22
            .CALL
            bl          $$dyncall,%mrp
            copy        %mrp,%rp

            copy        %r3,%r22
            .CALL
            bl          $$dyncall,%mrp
            copy        %mrp,%rp

            copy        %r3,%r22
            .CALL
            bl          $$dyncall,%mrp
            copy        %mrp,%rp

            copy        %r3,%r22
            .CALL
            bl          $$dyncall,%mrp
            copy        %mrp,%rp

            copy        %r3,%r22
            .CALL
            bl          $$dyncall,%mrp
            copy        %mrp,%rp

            addibf,<=   -8,%arg0,_loop0 ; decrement counter by 8 and loop
            nop

            ldw         -20(%sp),%rp    ; restore return-pointer
            bv          %r0(%rp)        ; return to caller
            ldwm        -64(%sp),%r3    ; resore r3 and remove stack frame

            .EXIT
            .PROCEND

; Call the procedure `b_null' immediate.

b_call_imm
            .PROC
            .CALLINFO   CALLER, FRAME=0, SAVE_RP
            .ENTRY

            ldo         64(%sp),%sp     ; caller needs a stack-frame
            stw         %rp,-20(%sp)    ; save return-pointer to frame-marker

_loop1
            bl          b_null,%rp      ; call `b_null' immediate (8 times)
            nop 
            bl          b_null,%rp
            nop
            bl          b_null,%rp
            nop
            bl          b_null,%rp
            nop
            bl          b_null,%rp
            nop
            bl          b_null,%rp
            nop
            bl          b_null,%rp
            nop
            bl          b_null,%rp
            nop

            addibf,<=   -8,%arg0,_loop1 ; decrement counter by 8 and loop
            nop
            
            ldw         -20(%sp),%rp    ; restore return-pointer
            bv          %r0(%rp)        ; return to caller
            ldo         -64(%sp),%sp    ; remove stack-frame

            .EXIT
            .PROCEND

; Copy register-to-register.
; On PA-RISC this is implemented with an `or'.
; The `or' is hidden by a pseudo-operation called `copy'.

b_add
            .PROC
            .CALLINFO   NO_CALLS, FRAME=0
            .ENTRY

_loop2
            copy        %r19,%r20       ; copy register-to-register
            copy        %r20,%r21       ; use caller-saves registers
            copy        %r21,%r22
            copy        %r22,%r21
            copy        %r21,%r20
            copy        %r20,%r19
            copy        %r19,%r20
            copy        %r20,%r21

            addibf,<=   -8,%arg0,_loop2 ; decrement counter by 8 and loop
            nop

            bv,n        %r0(%rp)

            .EXIT
            .PROCEND

; Load memory to a register.

b_load
            .PROC
            .CALLINFO   NO_CALLS, FRAME=0
            .ENTRY

_loop3
            ldw         -4(%sp),%r22    ; load data from frame-marker
            ldw         -8(%sp),%r22    ; use a caller-saves register
            ldw         -12(%sp),%r22
            ldw         -16(%sp),%r22
            ldw         -20(%sp),%r22
            ldw         -24(%sp),%r22
            ldw         -28(%sp),%r22
            ldw         -32(%sp),%r22

            addibf,<=   -8,%arg0,_loop3 ; decrement counter by 8 and loop
            nop

            bv,n        %r0(%rp)

            .EXIT
            .PROCEND


            .ALIGN 8
to_call
            .WORD       b_null