Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / cpu / sparc / ultra / impldis.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: impldis.fth
4\
5\ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6\
7\ - Do no alter or remove copyright notices
8\
9\ - Redistribution and use of this software in source and binary forms, with
10\ or without modification, are permitted provided that the following
11\ conditions are met:
12\
13\ - Redistribution of source code must retain the above copyright notice,
14\ this list of conditions and the following disclaimer.
15\
16\ - Redistribution in binary form must reproduce the above copyright notice,
17\ this list of conditions and the following disclaimer in the
18\ documentation and/or other materials provided with the distribution.
19\
20\ Neither the name of Sun Microsystems, Inc. or the names of contributors
21\ may be used to endorse or promote products derived from this software
22\ without specific prior written permission.
23\
24\ This software is provided "AS IS," without a warranty of any kind.
25\ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
26\ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
27\ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
28\ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
29\ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
30\ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
31\ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
32\ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
33\ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
34\ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
35\ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
36\
37\ You acknowledge that this software is not designed, licensed or
38\ intended for use in the design, construction, operation or maintenance of
39\ any nuclear facility.
40\
41\ ========== Copyright Header End ============================================
42id: @(#)impldis.fth 1.4 06/04/21
43purpose: Implementation-dependent disassembler extensions for SpitFire
44copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved
45copyright: Use is subject to license terms.
46
47also disassembler also definitions
48
49headerless
50
51string-array spit-gx-logical-ops \ Op-field - 0x60
52( 0 ) ," fzero" ," fzeros" ," fnor" ," fnors"
53( 4 ) ," fandnot2" ," fandnot2s" ," fnot2" ," fnot2s"
54( 8 ) ," fandnot1" ," fandnot1s" ," fnot1" ," fnot1s"
55( c ) ," fxor" ," fxors" ," fnand" ," fnands"
56( 10 ) ," fand" ," fands" ," fxnor" ," fxnors"
57( 14 ) ," fsrc1" ," fsrc1s" ," fornot2" ," fornot2s"
58( 18 ) ," fsrc2" ," fsrc2s" ," fornot1" ," fornot1s"
59( 1c ) ," for" ," fors" ," fone" ," fones"
60end-string-array
61
62string-array spit-gx-addsub-ops \ Op-field - 0x50
63( 0 ) ," fpadd16" ," fpadd16s" ," fpadd32" ," fpadd32s"
64( 4 ) ," fpsub16" ," fpsub16s" ," fpsub32" ," fpsub32s"
65end-string-array
66
67string-array spit-gx-other-ops
68( 0 ) ," edge8" ," ???" ," edge8l" ," ???"
69( 4 ) ," edge16" ," ???" ," edge16l" ," ???"
70( 8 ) ," edge32" ," ???" ," edge32l" ," ???"
71( c ) ," ???" ," ???" ," ???" ," ???"
72( 10 ) ," array8" ," ???" ," array16" ," ???"
73( 14 ) ," array32" ," ???" ," array16" ," ???"
74( 18 ) ," alignaddr" ," ???" ," alignaddrl" ," ???"
75( 1c ) ," ???" ," ???" ," ???" ," ???"
76( 20 ) ," fcmple16" ," ???" ," fcmpne16" ," ???"
77( 24 ) ," fcmple32" ," ???" ," fcmpne32" ," ???"
78( 28 ) ," fcmpgt16" ," ???" ," fcmpeq16" ," ???"
79( 2c ) ," fcmpgt32" ," ???" ," fcmpeq32" ," ???"
80( 30 ) ," ???" ," fmul8x16" ," ???" ," fmul8x16au"
81( 34 ) ," ???" ," fmul8x16al" ," fmul8sux16" ," fmul8ulx16"
82( 38 ) ," fmuld8sux16" ," fmuld8ulx16" ," fpack32" ," fpack16"
83( 3c ) ," ???" ," fpackfix" ," pdist" ," ???"
84( 40 ) ," ???" ," ???" ," ???" ," ???"
85( 44 ) ," ???" ," ???" ," ???" ," ???"
86( 48 ) ," faligndata" ," ???" ," ???" ," fpmerge"
87( 4c ) ," ???" ," fexpand"
88end-string-array
89
90string-array spit-rd/wr-asrs \ Reg-field - 0x10
91( 0 ) ," %pcr" ," %pic" ," %dcr" ," %gsr"
92( 4 ) ," %set_softint" ," %clear_softint" ," %softint" ," %tick_cmpr"
93( 8 ) ," %stick" ," %stick_cmpr"
94end-string-array
95
96: .spit-rdasr ( -- )
97 rs1 h# 10 -
98 dup 0 3 between ( indx good1? )
99 over 6 9 between or ( indx good? )
100 if
101 ." rdasr" op-col spit-rd/wr-asrs ". ., .rd
102 else
103 drop .illegal
104 then
105;
106: .spit-wrasr ( -- )
107 rd h# 10 -
108 dup 0 9 between ( indx good? )
109 if
110 ." wrasr" op-col .src ., spit-rd/wr-asrs ".
111 else
112 drop .illegal
113 then
114;
115
116: spit-opf ( -- n ) 5 9 bits ;
117: .frd ( -- ) rd .freg ;
118: .frd-double ( -- ) rd .freg-double ;
119
120\ Print both the given reg and rd as floating-doubles
121 : .f(reg+rd)-double ( reg -- )
122 .freg-double ., .frd-double
123;
124: .f(rs2+rd)-double ( -- )
125 rs2 .f(reg+rd)-double
126;
127: .frs1.frd ( -- )
128 rs1 .freg ., .frd
129;
130: .2fregs+frd-double ( -- )
131 .frs1rs2 ., .frd-double
132;
133
134\ For cases where Bit 0 of opcode distinguishes between
135\ single and double op:
136 : .3fregs?double ( spit-opf -- )
137 1 and if \ bit 0 of opcode is 0 then double op
138 ( ) .3fregs
139 else ( )
140 ( ) .3fregs-double
141 then ( )
142;
143
144\ Already tested whether spit-opf h# 60 h# 7f between
145: .spit-gx-logical ( spit-opf -- )
146 h# 60 -
147 dup spit-gx-logical-ops ". op-col
148 case
149 0 of .frd-double endof \ fzero
150 1 of .frd endof \ fzeros
151 6 of .f(rs2+rd)-double endof \ fnot2
152 7 of .frsrd endof \ fnot2s
153 h# a of rs1 .f(reg+rd)-double endof \ fnot1
154 h# b of .frs1.frd endof \ fnot1s
155 h# 14 of rs1 .f(reg+rd)-double endof \ fsrc1
156 h# 15 of .frs1.frd endof \ fsrc1s
157 h# 18 of .f(rs2+rd)-double endof \ fsrc2
158 h# 19 of .frsrd endof \ fsrc2s
159 h# 1e of .frd-double endof \ fone
160 h# 1f of .frd endof \ fones
161 dup .3fregs?double
162 endcase
163;
164
165\ Already tested whether spit-opf h# 50 h# 57 between
166: .spit-gx-addsub ( spit-opf -- )
167 h# 50 -
168 dup spit-gx-addsub-ops ". op-col
169 .3fregs?double
170;
171
172 \ Support routines: Common-special cases in the .spit-gx-others group
173 : .spit-gx-others+op ( spit-opf -- )
174 spit-gx-other-ops ". op-col
175 ;
176 : .spit-gx-fpack ( spit-opf -- )
177 .spit-gx-others+op rs2 .freg-double ., .frd
178 ;
179
180\ Group routines: Collect identically-treated "opf" values
181\ and handle appropriately.
182
183\ Each of the following four support routines compares the given
184\ SpitFire-Floating-OP code value against a known set.
185\ If found, the routine prints the corresponding string from the
186\ .spit-gx-others array, "does the right thing" with the rest
187\ of field, and returns a true , telling the caller that it's done.
188\ Otherwise, the routine leaves the "OPF" on the stack with a false
189\ and the caller can then proceed to try the next set.
190
191 \ Value: String:
192 \ 0 edge8
193 \ 2 edge8l
194 \ 4 edge16
195 \ 6 edge16l
196 \ 8 edge32
197 \ h# a edge32l
198 \ h# 10 array8
199 \ h# 12 array16
200 \ h# 14 array32
201 \ h# 18 alignaddr
202 \ h# 1a alignaddrl
203: ?spit-gx-edge/array? ( spit-opf -- spit-opf false | true )
204 dup " "( 00 02 04 06 08 0a 10 12 14 18 1a)"
205 rot scantochar <> nip if
206 .spit-gx-others+op .src ., .rd
207 true exit
208 then false
209;
210
211 \ Value: String:
212 \ h# 20 fcmple16
213 \ h# 22 fcmpne16
214 \ h# 24 fcmple32
215 \ h# 26 fcmpne32
216 \ h# 28 fcmpgt16
217 \ h# 2a fcmpeq16
218 \ h# 2c fcmpgt32
219 \ h# 2e fcmpeq32
220: ?spit-gx-fcmp? ( spit-opf -- spit-opf false | true )
221 dup " "( 20 22 24 26 28 2a 2c 2e)"
222 rot scantochar <> nip if
223 .spit-gx-others+op .frs1rs2-double ., .rd
224 true exit
225 then false
226;
227
228 \ Value: String:
229 \ h# 33 fmul8x16au
230 \ h# 35 fmul8x16al
231 \ h# 38 fmuld8sux16
232 \ h# 39 fmuld8ulx16
233 \ h# 4b fpmerge
234: ?spit-gx-2fregs+frd-double? ( spit-opf -- spit-opf false | true )
235 dup " "( 33 35 38 39 4b)"
236 rot scantochar <> nip if
237 .spit-gx-others+op .2fregs+frd-double
238 true exit
239 then false
240;
241
242 \ Value: String:
243 \ h# 36 fmul8sux16
244 \ h# 37 fmul8ulx16
245 \ h# 3a fpack32
246 \ h# 3e pdist
247 \ h# 48 faligndata
248: ?spit-gx-others+3fregs-double? ( spit-opf -- spit-opf false | true )
249 dup " "( 36 37 3a 3e 48)"
250 rot scantochar <> nip if
251 .spit-gx-others+op .3fregs-double
252 true exit
253 then false
254;
255
256: .spit-gx-others ( spit-opf -- )
257 ?spit-gx-edge/array? if exit then
258 ?spit-gx-fcmp? if exit then
259 ?spit-gx-2fregs+frd-double? if exit then
260 ?spit-gx-others+3fregs-double? if exit then
261 dup
262 case
263 h# 31 of .spit-gx-others+op
264 rs1 .freg ., .f(rs2+rd)-double endof \ fmul8x16
265 h# 3b of .spit-gx-fpack endof \ fpack16
266 h# 3d of .spit-gx-fpack endof \ fpackfix
267 h# 4d of .spit-gx-others+op \ fexpand
268 rs2 .freg ., .frd-double endof
269 .illegal drop
270 endcase
271;
272
273: .spit-impdep1 ( -- )
274 spit-opf
275 dup h# 60 h# 7f between if
276 .spit-gx-logical
277 else
278 dup h# 50 h# 57 between if
279 .spit-gx-addsub
280 else
281 dup 0 h# 4d between if
282 .spit-gx-others
283 else
284 h# 80 = if
285 ." shutdown"
286 else
287 .illegal
288 then
289 then
290 then
291 then
292;
293
294: .spit-impdep2 ( -- )
295 .illegal
296;
297
298: .spit-asi-ea ( -- )
299 immasi dup h# c0 h# c5 between
300 swap h# c8 h# cd between or
301 opcode h# 37 =
302 and if
303 ." [" .rs1 ." ]" .rs2 ., 5 8 bits (u.) type
304 else
305 .ea-sparc
306 then
307;
308
309' .spit-wrasr is .impl-wrasr
310' .spit-rdasr is .impl-rdasr
311' .spit-impdep1 is .impdep1
312' .spit-impdep2 is .impdep2
313' .spit-asi-ea is .impl-asi-ea
314
315previous previous definitions
316
317headers