Commit | Line | Data |
---|---|---|
299d901c AC |
1 | ; Hitachi SHmedia instruction set description. -*- Scheme -*- |
2 | ; | |
3 | ; Copyright 2000, 2001 Free Software Foundation, Inc. | |
4 | ; | |
5 | ; Contributed by Red Hat Inc; developed under contract from Hitachi | |
6 | ; Semiconductor (America) Inc. | |
7 | ; | |
8 | ; This file is part of the GNU Binutils. | |
9 | ; | |
10 | ; This program is free software; you can redistribute it and/or modify | |
11 | ; it under the terms of the GNU General Public License as published by | |
12 | ; the Free Software Foundation; either version 2 of the License, or | |
13 | ; (at your option) any later version. | |
14 | ; | |
15 | ; This program is distributed in the hope that it will be useful, | |
16 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | ; GNU General Public License for more details. | |
19 | ; | |
20 | ; You should have received a copy of the GNU General Public License | |
21 | ; along with this program; if not, write to the Free Software | |
22 | ; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
23 | ||
24 | \f | |
25 | ; dshmf -- define-normal-sh-media-field | |
26 | ||
27 | (define-pmacro (dshmf xname xcomment ignored xstart xlength) | |
28 | (dnf xname xcomment ((ISA media)) xstart xlength)) | |
29 | ||
30 | ; dshmop -- define-normal-sh-media-operand | |
31 | ||
32 | (define-pmacro (dshmop xname xcomment ignored xhardware xfield) | |
33 | (dnop xname xcomment ((ISA media)) xhardware xfield)) | |
34 | ||
35 | ; dnshmi -- define-normal-sh-media-insn | |
36 | ||
37 | (define-pmacro (dshmi xname xcomment xattrs xsyntax xformat xsemantics) | |
38 | (define-insn | |
39 | (name xname) | |
40 | (comment xcomment) | |
41 | (.splice attrs (.unsplice xattrs) (ISA media)) | |
42 | (syntax xsyntax) | |
43 | (format xformat) | |
44 | (semantics xsemantics))) | |
45 | ||
46 | ; Saturation functions. | |
47 | ; Force a value `i' into words `n' bits wide. | |
48 | ; See Hitachi SH-5 CPU core, volume 2, p. 25 for details. | |
49 | ||
50 | ; saturate -- signed saturatation function | |
51 | ||
52 | (define-pmacro (saturate mode n i) | |
53 | (if mode (lt i (neg mode (sll mode 1 (sub n 1)))) | |
54 | (neg (sll mode 1 (sub n 1))) | |
55 | (if mode (lt i (sll mode 1 (sub n 1))) | |
56 | i | |
57 | (sub mode (sll mode 1 (sub n 1)) 1)))) | |
58 | ||
59 | ; usaturate -- unsigned saturation function | |
60 | ||
61 | (define-pmacro (usaturate mode n i) | |
62 | (if mode (lt i (const mode 0)) | |
63 | (const mode 0) | |
64 | (if mode (lt i (sll mode 1 n)) | |
65 | i | |
66 | (sub mode (sll mode 1 n) 1)))) | |
67 | ||
68 | \f | |
69 | ; Ifields. | |
70 | ||
71 | (dshmf f-op "Opcode" () 31 6) | |
72 | (dshmf f-ext "Extension opcode" () 19 4) | |
73 | (dshmf f-rsvd "Reserved" (RESERVED) 3 4) | |
74 | ||
75 | (dshmf f-left "Left register" () 25 6) | |
76 | (dshmf f-right "Right register" () 15 6) | |
77 | (dshmf f-dest "Destination register" () 9 6) | |
78 | ||
79 | (define-multi-ifield | |
80 | (name f-left-right) | |
81 | (comment "Left and right matched register pair") | |
82 | (attrs (ISA media)) | |
83 | (mode UINT) | |
84 | (subfields f-left f-right) | |
85 | (insert (sequence () | |
86 | (set (ifield f-left) | |
87 | (and (ifield f-left-right) 63)) | |
88 | (set (ifield f-right) | |
89 | (and (ifield f-left-right) 63)))) | |
90 | (extract (set (ifield f-left-right) (ifield f-left))) | |
91 | ) | |
92 | ||
93 | (dshmf f-tra "Target register" () 6 3) | |
94 | (dshmf f-trb "Target register" () 22 3) | |
95 | (dshmf f-likely "Likely bit" () 9 1) | |
96 | (dshmf f-25 "Three unused bits at bit 25" () 25 3) | |
97 | (dshmf f-8-2 "Two unused bits at bit 8" () 8 2) | |
98 | ||
99 | (df f-imm6 "Immediate value (6 bits)" ((ISA media)) 15 6 INT #f #f) | |
100 | (df f-imm10 "Immediate value (10 bits)" ((ISA media)) 19 10 INT #f #f) | |
101 | (df f-imm16 "Immediate value (16 bits)" ((ISA media)) 25 16 INT #f #f) | |
102 | ||
103 | (dshmf f-uimm6 "Immediate value (6 bits)" () 15 6) | |
104 | (dshmf f-uimm16 "Immediate value (16 bits)" () 25 16) | |
105 | ||
106 | ; Various displacement fields. | |
107 | ; The 10 bit field, for example, has different scaling for displacements. | |
108 | ||
109 | (df f-disp6 "Displacement (6 bits)" ((ISA media)) 15 6 INT #f #f) | |
110 | ||
111 | (df f-disp6x32 "Displacement (6 bits)" ((ISA media)) 15 6 INT | |
112 | ((value pc) (sra SI value 5)) | |
113 | ((value pc) (sll SI value 5))) | |
114 | ||
115 | (df f-disp10 "Displacement (10 bits)" ((ISA media)) 19 10 INT #f #f) | |
116 | ||
117 | (df f-disp10x8 "Displacement (10 bits)" ((ISA media)) 19 10 INT | |
118 | ((value pc) (sra SI value 3)) | |
119 | ((value pc) (sll SI value 3))) | |
120 | ||
121 | (df f-disp10x4 "Displacement (10 bits)" ((ISA media)) 19 10 INT | |
122 | ((value pc) (sra SI value 2)) | |
123 | ((value pc) (sll SI value 2))) | |
124 | ||
125 | (df f-disp10x2 "Displacement (10 bits)" ((ISA media)) 19 10 INT | |
126 | ((value pc) (sra SI value 1)) | |
127 | ((value pc) (sll SI value 1))) | |
128 | ||
129 | (df f-disp16 "Displacement (16 bits)" ((ISA media) PCREL-ADDR) 25 16 INT | |
130 | ((value pc) (sra DI value 2)) | |
131 | ((value pc) (add DI (sll DI value 2) pc))) | |
132 | ||
133 | \f | |
134 | ; Operands. | |
135 | ||
136 | (dshmop rm "Left general purpose reg" () h-gr f-left) | |
137 | (dshmop rn "Right general purpose reg" () h-gr f-right) | |
138 | (dshmop rd "Destination general purpose reg" () h-gr f-dest) | |
139 | ||
140 | (dshmop frg "Left single precision register" () h-fr f-left) | |
141 | (dshmop frh "Right single precision register" () h-fr f-right) | |
142 | (dshmop frf "Destination single precision reg" () h-fr f-dest) | |
143 | (dshmop frgh "Single precision register pair" () h-fr f-left-right) | |
144 | ||
145 | (dshmop fpf "Pair of single precision registers" () h-fp f-dest) | |
146 | ||
147 | (dshmop fvg "Left single precision vector" () h-fv f-left) | |
148 | (dshmop fvh "Right single precision vector" () h-fv f-right) | |
149 | (dshmop fvf "Destination single precision vector" () h-fv f-dest) | |
150 | (dshmop mtrxg "Left single precision matrix" () h-fmtx f-left) | |
151 | ||
152 | (dshmop drg "Left double precision register" () h-dr f-left) | |
153 | (dshmop drh "Right double precision register" () h-dr f-right) | |
154 | (dshmop drf "Destination double precision reg" () h-dr f-dest) | |
155 | (dshmop drgh "Double precision register pair" () h-dr f-left-right) | |
156 | ||
157 | (dshmop fpscr "Floating point status register" () h-fpscr f-nil) | |
158 | (dshmop crj "Control register j" () h-cr f-dest) | |
159 | (dshmop crk "Control register k" () h-cr f-left) | |
160 | ||
161 | (dshmop tra "Target register a" () h-tr f-tra) | |
162 | (dshmop trb "Target register b" () h-tr f-trb) | |
163 | ||
164 | (dshmop disp6 "Displacement (6 bits)" () h-sint f-disp6) | |
165 | (dshmop disp6x32 "Displacement (6 bits, scale 32)" () h-sint f-disp6x32) | |
166 | (dshmop disp10 "Displacement (10 bits)" () h-sint f-disp10) | |
167 | (dshmop disp10x2 "Displacement (10 bits, scale 2)" () h-sint f-disp10x2) | |
168 | (dshmop disp10x4 "Displacement (10 bits, scale 4)" () h-sint f-disp10x4) | |
169 | (dshmop disp10x8 "Displacement (10 bits, scale 8)" () h-sint f-disp10x8) | |
170 | (dshmop disp16 "Displacement (16 bits)" () h-sint f-disp16) | |
171 | ||
172 | (dshmop imm6 "Immediate (6 bits)" () h-sint f-imm6) | |
173 | (dshmop imm10 "Immediate (10 bits)" () h-sint f-imm10) | |
174 | (dshmop imm16 "Immediate (16 bits)" () h-sint f-imm16) | |
175 | (dshmop uimm6 "Immediate (6 bits)" () h-uint f-uimm6) | |
176 | (dshmop uimm16 "Unsigned immediate (16 bits)" () h-uint f-uimm16) | |
177 | ||
178 | ; FIXME: provide these parse/print functions in `sh-media.opc'. | |
179 | ||
180 | (define-operand (name likely) (comment "Likely branch?") (attrs (ISA media)) | |
181 | (type h-uint) (index f-likely) (handlers (parse "likely") (print "likely"))) | |
182 | ||
183 | \f | |
184 | ; Instructions. | |
185 | ||
186 | (dshmi add "Add" | |
187 | () | |
188 | "add $rm, $rn, $rd" | |
189 | (+ (f-op 0) rm (f-ext 9) rn rd (f-rsvd 0)) | |
190 | (set rd (add rm rn))) | |
191 | ||
192 | (dshmi addl "Add long" | |
193 | () | |
194 | "add.l $rm, $rn, $rd" | |
195 | (+ (f-op 0) rm (f-ext 8) rn rd (f-rsvd 0)) | |
196 | (set rd (add (subword SI rm 1) (subword SI rn 1)))) | |
197 | ||
198 | (dshmi addi "Add immediate" | |
199 | () | |
200 | "addi $rm, $disp10, $rd" | |
201 | (+ (f-op 52) rm disp10 rd (f-rsvd 0)) | |
202 | (set rd (add rm (ext DI disp10)))) | |
203 | ||
204 | (dshmi addil "Add immediate long" | |
205 | () | |
206 | "addi.l $rm, $disp10, $rd" | |
207 | (+ (f-op 53) rm disp10 rd (f-rsvd 0)) | |
208 | (set rd (ext DI (add (ext SI disp10) (subword SI rm 1))))) | |
209 | ||
210 | (dshmi addzl "Add zero extended long" | |
211 | () | |
212 | "addz.l $rm, $rn, $rd" | |
213 | (+ (f-op 0) rm (f-ext 12) rn rd (f-rsvd 0)) | |
214 | (set rd (zext DI (add (subword SI rm 1) (subword SI rn 1))))) | |
215 | ||
216 | (dshmi alloco "Allocate operand cache block" | |
217 | () | |
218 | "alloco $rm, $disp6x32" | |
219 | (+ (f-op 56) rm (f-ext 4) disp6x32 (f-dest 63) (f-rsvd 0)) | |
220 | (unimp "alloco")) | |
221 | ||
222 | (dshmi and "AND" | |
223 | () | |
224 | "and $rm, $rn, $rd" | |
225 | (+ (f-op 1) rm (f-ext 11) rn rd (f-rsvd 0)) | |
226 | (set rd (and rm rn))) | |
227 | ||
228 | (dshmi andc "AND complement" | |
229 | () | |
230 | "andc $rm, $rn, $rd" | |
231 | (+ (f-op 1) rm (f-ext 15) rn rd (f-rsvd 0)) | |
232 | (set rd (and rm (inv rn)))) | |
233 | ||
234 | (dshmi andi "AND immediate" | |
235 | () | |
236 | "andi $rm, $disp10, $rd" | |
237 | (+ (f-op 54) rm disp10 rd (f-rsvd 0)) | |
238 | (set rd (and rm (ext DI disp10)))) | |
239 | ||
240 | (dshmi beq "Branch if equal" | |
241 | () | |
242 | "beq$likely $rm, $rn, $tra" | |
243 | (+ (f-op 25) rm (f-ext 1) rn likely (f-8-2 0) tra (f-rsvd 0)) | |
244 | (if (eq rm rn) | |
245 | (set pc tra))) | |
246 | ||
247 | (dshmi beqi "Branch if equal immediate" | |
248 | () | |
249 | "beqi$likely $rm, $imm6, $tra" | |
250 | (+ (f-op 57) rm (f-ext 1) imm6 likely (f-8-2 0) tra (f-rsvd 0)) | |
251 | (if (eq rm (ext DI imm6)) | |
252 | (set pc tra))) | |
253 | ||
254 | (dshmi bge "Branch if greater than or equal" | |
255 | () | |
256 | "bge$likely $rm, $rn, $tra" | |
257 | (+ (f-op 25) rm (f-ext 3) rn likely (f-8-2 0) tra (f-rsvd 0)) | |
258 | (if (ge rm rn) | |
259 | (set pc tra))) | |
260 | ||
261 | (dshmi bgeu "Branch if greater than or equal (unsigned comparison)" | |
262 | () | |
263 | "bgeu$likely $rm, $rn, $tra" | |
264 | (+ (f-op 25) rm (f-ext 11) rn likely (f-8-2 0) tra (f-rsvd 0)) | |
265 | (if (geu rm rn) | |
266 | (set pc tra))) | |
267 | ||
268 | (dshmi bgt "Branch greater than" | |
269 | () | |
270 | "bgt$likely $rm, $rn, $tra" | |
271 | (+ (f-op 25) rm (f-ext 7) rn likely (f-8-2 0) tra (f-rsvd 0)) | |
272 | (if (gt rm rn) | |
273 | (set pc tra))) | |
274 | ||
275 | (dshmi bgtu "Branch greater than (unsigned comparison)" | |
276 | () | |
277 | "bgtu$likely $rm, $rn, $tra" | |
278 | (+ (f-op 25) rm (f-ext 15) rn likely (f-8-2 0) tra (f-rsvd 0)) | |
279 | (if (gtu rm rn) | |
280 | (set pc tra))) | |
281 | ||
282 | (dshmi blink "Branch and link" | |
283 | () | |
284 | "blink $trb, $rd" | |
285 | (+ (f-op 17) (f-25 0) trb (f-ext 1) (f-right 63) rd (f-rsvd 0)) | |
286 | (sequence () | |
287 | (set rd (or (add pc 4) 1)) | |
288 | (set pc trb))) | |
289 | ||
290 | (dshmi bne "Branch if not equal" | |
291 | () | |
292 | "bne$likely $rm, $rn, $tra" | |
293 | (+ (f-op 25) rm (f-ext 5) rn likely (f-8-2 0) tra (f-rsvd 0)) | |
294 | (if (ne rm rn) | |
295 | (set pc tra))) | |
296 | ||
297 | (dshmi bnei "Branch if not equal immediate" | |
298 | () | |
299 | "bnei$likely $rm, $imm6, $tra" | |
300 | (+ (f-op 57) rm (f-ext 5) rn likely (f-8-2 0) tra (f-rsvd 0)) | |
301 | (if (ne rm (ext DI imm6)) | |
302 | (set pc tra))) | |
303 | ||
304 | (dshmi brk "Breakpoint instruction" | |
305 | () | |
306 | "brk" | |
307 | (+ (f-op 27) (f-left 63) (f-ext 5) (f-right 63) (f-dest 63) (f-rsvd 0)) | |
308 | (c-call "sh64_break" pc)) | |
309 | ||
310 | (define-pmacro (-byterev-step) | |
311 | (sequence () | |
312 | (set result (or (sll result 8) (and source 255))) | |
313 | (set source (srl source 8))) | |
314 | ) | |
315 | ||
316 | (dshmi byterev "Byte reverse" | |
317 | () | |
318 | "byterev $rm, $rd" | |
319 | (+ (f-op 0) rm (f-ext 15) (f-right 63) rd (f-rsvd 0)) | |
320 | (sequence ((DI source) (DI result)) | |
321 | (set source rm) | |
322 | (set result 0) | |
323 | (-byterev-step) | |
324 | (-byterev-step) | |
325 | (-byterev-step) | |
326 | (-byterev-step) | |
327 | (-byterev-step) | |
328 | (-byterev-step) | |
329 | (-byterev-step) | |
330 | (-byterev-step) | |
331 | (set rd result))) | |
332 | ||
333 | (dshmi cmpeq "Compare equal" | |
334 | () | |
335 | "cmpeq $rm, $rn, $rd" | |
336 | (+ (f-op 0) rm (f-ext 1) rn rd (f-rsvd 0)) | |
337 | (set rd (if DI (eq rm rn) 1 0))) | |
338 | ||
339 | (dshmi cmpgt "Compare greater than" | |
340 | () | |
341 | "cmpgt $rm, $rn, $rd" | |
342 | (+ (f-op 0) rm (f-ext 3) rn rd (f-rsvd 0)) | |
343 | (set rd (if DI (gt rm rn) 1 0))) | |
344 | ||
345 | (dshmi cmpgtu "Compare greater than (unsigned comparison)" | |
346 | () | |
347 | "cmpgtu $rm,$rn, $rd" | |
348 | (+ (f-op 0) rm (f-ext 7) rn rd (f-rsvd 0)) | |
349 | (set rd (if DI (gtu rm rn) 1 0))) | |
350 | ||
351 | (dshmi cmveq "Conditional move if equal to zero" | |
352 | () | |
353 | "cmveq $rm, $rn, $rd" | |
354 | (+ (f-op 8) rm (f-ext 1) rn rd (f-rsvd 0)) | |
355 | (if (eq rm 0) | |
356 | (set rd rn))) | |
357 | ||
358 | (dshmi cmvne "Conditional move if not equal to zero" | |
359 | () | |
360 | "cmvne $rm, $rn, $rd" | |
361 | (+ (f-op 8) rm (f-ext 5) rn rd (f-rsvd 0)) | |
362 | (if (ne rm 0) | |
363 | (set rd rn))) | |
364 | ||
365 | (dshmi fabsd "Floating point absolute (double)" | |
366 | () | |
367 | "fabs.d $drgh, $drf" | |
368 | (+ (f-op 6) drgh (f-ext 1) drf (f-rsvd 0)) | |
369 | (set drf (c-call DF "sh64_fabsd" drgh))) | |
370 | ||
371 | (dshmi fabss "Floating point absolute (single)" | |
372 | () | |
373 | "fabs.s $frgh, $frf" | |
374 | (+ (f-op 6) frgh (f-ext 0) frf (f-rsvd 0)) | |
375 | (set frf (c-call SF "sh64_fabss" frgh))) | |
376 | ||
377 | (dshmi faddd "Floating point add (double)" | |
378 | () | |
379 | "fadd.d $drg, $drh, $drf" | |
380 | (+ (f-op 13) drg (f-ext 1) drh drf (f-rsvd 0)) | |
381 | (set drf (c-call DF "sh64_faddd" drg drh))) | |
382 | ||
383 | (dshmi fadds "Floating point add (single)" | |
384 | () | |
385 | "fadd.s $frg, $frh, $frf" | |
386 | (+ (f-op 13) frg (f-ext 0) frh frf (f-rsvd 0)) | |
387 | (set frf (c-call SF "sh64_fadds" frg frh))) | |
388 | ||
389 | (dshmi fcmpeqd "Floating point compare if equal (double)" | |
390 | () | |
391 | "fcmpeq.d $drg, $drh, $rd" | |
392 | (+ (f-op 12) drg (f-ext 9) drh rd (f-rsvd 0)) | |
393 | (set rd (zext DI (c-call BI "sh64_fcmpeqd" drg drh)))) | |
394 | ||
395 | (dshmi fcmpeqs "Floating point compare if equal (single)" | |
396 | () | |
397 | "fcmpeq.s $frg, $frh, $rd" | |
398 | (+ (f-op 12) frg (f-ext 8) frh rd (f-rsvd 0)) | |
399 | (set rd (zext DI (c-call BI "sh64_fcmpeqs" frg frh)))) | |
400 | ||
401 | (dshmi fcmpged "Floating compare compare if greater than or equal (double)" | |
402 | () | |
403 | "fcmpge.d $drg, $drh, $rd" | |
404 | (+ (f-op 12) drg (f-ext 15) drh rd (f-rsvd 0)) | |
405 | (set rd (zext DI (c-call BI "sh64_fcmpged" drg drh)))) | |
406 | ||
407 | (dshmi fcmpges "Floating point compare if greater than or equal (single)" | |
408 | () | |
409 | "fcmpge.s $frg, $frh, $rd" | |
410 | (+ (f-op 12) frg (f-ext 14) frh rd (f-rsvd 0)) | |
411 | (set rd (zext DI (c-call BI "sh64_fcmpges" frg frh)))) | |
412 | ||
413 | (dshmi fcmpgtd "Floating point compare if greater than (double)" | |
414 | () | |
415 | "fcmpgt.d $drg, $drh, $rd" | |
416 | (+ (f-op 12) drg (f-ext 13) drh rd (f-rsvd 0)) | |
417 | (set rd (zext DI (c-call BI "sh64_fcmpgtd" drg drh)))) | |
418 | ||
419 | (dshmi fcmpgts "Floating point compare if greater than (single)" | |
420 | () | |
421 | "fcmpgt.s $frg, $frh, $rd" | |
422 | (+ (f-op 12) frg (f-ext 12) frh rd (f-rsvd 0)) | |
423 | (set rd (zext DI (c-call BI "sh64_fcmpgts" frg frh)))) | |
424 | ||
425 | (dshmi fcmpund "Floating point unordered comparison (double)" | |
426 | () | |
427 | "fcmpun.d $drg, $drh, $rd" | |
428 | (+ (f-op 12) drg (f-ext 11) drh rd (f-rsvd 0)) | |
429 | (set rd (zext DI (c-call BI "sh64_fcmpund" drg drh)))) | |
430 | ||
431 | (dshmi fcmpuns "Floating point unordered comparison (single)" | |
432 | () | |
433 | "fcmpun.s $frg, $frh, $rd" | |
434 | (+ (f-op 12) frg (f-ext 10) frh rd (f-rsvd 0)) | |
435 | (set rd (zext DI (c-call BI "sh64_fcmpuns" frg frh)))) | |
436 | ||
437 | (dshmi fcnvds "Floating point coversion (double to single)" | |
438 | () | |
439 | "fcnv.ds $drgh, $frf" | |
440 | (+ (f-op 14) drgh (f-ext 7) frf (f-rsvd 0)) | |
441 | (set frf (c-call SF "sh64_fcnvds" drgh))) | |
442 | ||
443 | (dshmi fcnvsd "Floating point conversion (single to double)" | |
444 | () | |
445 | "fcnv.sd $frgh, $drf" | |
446 | (+ (f-op 14) frgh (f-ext 6) drf (f-rsvd 0)) | |
447 | (set drf (c-call DF "sh64_fcnvsd" frgh))) | |
448 | ||
449 | (dshmi fdivd "Floating point divide (double)" | |
450 | () | |
451 | "fdiv.d $drg, $drh, $drf" | |
452 | (+ (f-op 13) drg (f-ext 5) drh drf (f-rsvd 0)) | |
453 | (set drf (c-call DF "sh64_fdivd" drg drh))) | |
454 | ||
455 | (dshmi fdivs "Floating point divide (single)" | |
456 | () | |
457 | "fdiv.s $frg, $frh, $frf" | |
458 | (+ (f-op 13) frg (f-ext 4) frh frf (f-rsvd 0)) | |
459 | (set frf (c-call SF "sh64_fdivs" frg frh))) | |
460 | ||
461 | (dshmi fgetscr "Floating point get from FPSCR" | |
462 | () | |
463 | "fgetscr $frf" | |
464 | (+ (f-op 7) (f-left 63) (f-ext 2) (f-right 63) frf (f-rsvd 0)) | |
465 | (unimp "fputscr")) | |
466 | ; FIXME: this should work! | |
467 | ; (set frf fpscr)) | |
468 | ||
469 | (dshmi fiprs "Floating point inner product (single)" | |
470 | () | |
471 | "fipr.s $fvg, $fvh, $frf" | |
472 | (+ (f-op 5) fvg (f-ext 6) fvh frf (f-rsvd 0)) | |
473 | (sequence ((UQI g) (UQI h) (SF temp)) | |
474 | (set g (index-of fvg)) | |
475 | (set h (index-of fvh)) | |
476 | (set temp (c-call SF "sh64_fmuls" (reg h-fr g) (reg h-fr h))) | |
477 | (set temp (c-call SF "sh64_fadds" temp | |
478 | (c-call SF "sh64_fmuls" (reg h-fr (add g 1)) (reg h-fr (add h 1))))) | |
479 | (set temp (c-call SF "sh64_fadds" temp | |
480 | (c-call SF "sh64_fmuls" (reg h-fr (add g 2)) (reg h-fr (add h 2))))) | |
481 | (set temp (c-call SF "sh64_fadds" temp | |
482 | (c-call SF "sh64_fmuls" (reg h-fr (add g 3)) (reg h-fr (add h 3))))) | |
483 | (set frf temp))) | |
484 | ||
485 | (dshmi fldd "Floating point load (double)" | |
486 | () | |
487 | "fld.d $rm, $disp10x8, $drf" | |
488 | (+ (f-op 39) rm disp10x8 drf (f-rsvd 0)) | |
489 | (set drf (mem DF (add rm disp10x8)))) | |
490 | ||
491 | (dshmi fldp "Floating point load (pair of singles)" | |
492 | () | |
493 | "fld.p $rm, $disp10x8, $fpf" | |
494 | (+ (f-op 38) rm disp10x8 fpf (f-rsvd 0)) | |
495 | (sequence ((QI f)) | |
496 | (set f (index-of fpf)) | |
497 | (set (reg h-fr f) (mem SF (add rm disp10x8))) | |
498 | (set (reg h-fr (add f 1)) (mem SF (add rm (add disp10x8 4)))))) | |
499 | ||
500 | (dshmi flds "Floating point load (single)" | |
501 | () | |
502 | "fld.s $rm, $disp10x4, $frf" | |
503 | (+ (f-op 37) rm disp10x4 frf (f-rsvd 0)) | |
504 | (set frf (mem SF (add rm disp10x4)))) | |
505 | ||
506 | (dshmi fldxd "Floating point extended load (double)" | |
507 | () | |
508 | "fldx.d $rm, $rn, $drf" | |
509 | (+ (f-op 7) rm (f-ext 9) rn frf (f-rsvd 0)) | |
510 | (set drf (mem DF (add rm rn)))) | |
511 | ||
512 | (dshmi fldxp "Floating point extended load (pair of singles)" | |
513 | () | |
514 | "fldx.p $rm, $rn, $fpf" | |
515 | (+ (f-op 7) rm (f-ext 13) rn fpf (f-rsvd 0)) | |
516 | (sequence ((QI f)) | |
517 | (set f (index-of fpf)) | |
518 | (set (reg h-fr f) (mem SF (add rm rn))) | |
519 | (set (reg h-fr (add f 1)) (mem SF (add rm (add rn 4)))))) | |
520 | ||
521 | (dshmi fldxs "Floating point extended load (single)" | |
522 | () | |
523 | "fldx.s $rm, $rn, $frf" | |
524 | (+ (f-op 7) rm (f-ext 8) rn frf (f-rsvd 0)) | |
525 | (set frf (mem SF (add rm rn)))) | |
526 | ||
527 | (dshmi floatld "Floating point conversion (long to double)" | |
528 | () | |
529 | "float.ld $frgh, $drf" | |
530 | (+ (f-op 14) frgh (f-ext 14) drf (f-rsvd 0)) | |
531 | (set drf (c-call DF "sh64_floatld" frgh))) | |
532 | ||
533 | (dshmi floatls "Floating point conversion (long to single)" | |
534 | () | |
535 | "float.ls $frgh, $frf" | |
536 | (+ (f-op 14) frgh (f-ext 12) frf (f-rsvd 0)) | |
537 | (set frf (c-call SF "sh64_floatls" frgh))) | |
538 | ||
539 | (dshmi floatqd "Floating point conversion (quad to double)" | |
540 | () | |
541 | "float.qd $drgh, $drf" | |
542 | (+ (f-op 14) drgh (f-ext 13) drf (f-rsvd 0)) | |
543 | (set drf (c-call DF "sh64_floatqd" drgh))) | |
544 | ||
545 | (dshmi floatqs "Floating point conversion (quad to single)" | |
546 | () | |
547 | "float.qs $drgh, $frf" | |
548 | (+ (f-op 14) drgh (f-ext 15) frf (f-rsvd 0)) | |
549 | (set frf (c-call SF "sh64_floatqs" drgh))) | |
550 | ||
551 | (dshmi fmacs "Floating point multiply and accumulate (single)" | |
552 | () | |
553 | "fmac.s $frg, $frh, $frf" | |
554 | (+ (f-op 13) frg (f-ext 14) frh frf (f-rsvd 0)) | |
555 | (set frf (c-call SF "sh64_fadds" frf (c-call SF "sh64_fmuls" frg frh)))) | |
556 | ||
557 | (dshmi fmovd "Floating point move double" | |
558 | () | |
559 | "fmov.d $drgh, $drf" | |
560 | (+ (f-op 14) drgh (f-ext 1) drf (f-rsvd 0)) | |
561 | (set drf drgh)) | |
562 | ||
563 | (dshmi fmovdq "Floating point move (double to quad integer)" | |
564 | () | |
565 | "fmov.dq $drgh, $rd" | |
566 | (+ (f-op 12) drgh (f-ext 1) rd (f-rsvd 0)) | |
567 | (set rd (subword DI drgh 0))) | |
568 | ||
569 | (dshmi fmovls "Floating point move (lower to single)" | |
570 | () | |
571 | "fmov.ls $rm, $frf" | |
572 | (+ (f-op 7) rm (f-ext 0) (f-right 63) frf (f-rsvd 0)) | |
573 | (set frf (subword SF (subword SI rm 1) 0))) | |
574 | ||
575 | (dshmi fmovqd "Floating point move (quad to double)" | |
576 | () | |
577 | "fmov.qd $rm, $drf" | |
578 | (+ (f-op 7) rm (f-ext 1) (f-right 63) frf (f-rsvd 0)) | |
579 | (set drf (subword DF rm 0))) | |
580 | ||
581 | (dshmi fmovs "Floating point move (single)" | |
582 | () | |
583 | "fmov.s $frgh, $frf" | |
584 | (+ (f-op 14) frgh (f-ext 0) frf (f-rsvd 0)) | |
585 | (set frf frgh)) | |
586 | ||
587 | (dshmi fmovsl "Floating point move (single to lower)" | |
588 | () | |
589 | "fmov.sl $frgh, $rd" | |
590 | (+ (f-op 12) frgh (f-ext 0) rd (f-rsvd 0)) | |
591 | (set rd (ext DI (subword SI frgh 1)))) | |
592 | ||
593 | (dshmi fmuld "Floating point multiply (double)" | |
594 | () | |
595 | "fmul.d $drg, $drh, $drf" | |
596 | (+ (f-op 13) drg (f-ext 7) drh drf (f-rsvd 0)) | |
597 | (set drf (c-call DF "sh64_fmuld" drg drh))) | |
598 | ||
599 | (dshmi fmuls "Floating point multiply (single)" | |
600 | () | |
601 | "fmul.s $frg, $frh, $frf" | |
602 | (+ (f-op 13) frg (f-ext 6) frh frf (f-rsvd 0)) | |
603 | (set frf (c-call SF "sh64_fmuls" frg frh))) | |
604 | ||
605 | (dshmi fnegd "Floating point negate (double)" | |
606 | () | |
607 | "fneg.d $drgh, $drf" | |
608 | (+ (f-op 6) drgh (f-ext 3) drf (f-rsvd 0)) | |
609 | (set drf (c-call DF "sh64_fnegd" drgh))) | |
610 | ||
611 | (dshmi fnegs "Floating point negate (single)" | |
612 | () | |
613 | "fneg.s $frgh, $frf" | |
614 | (+ (f-op 6) frgh (f-ext 2) frf (f-rsvd 0)) | |
615 | (set frf (c-call SF "sh64_fnegs" frgh))) | |
616 | ||
617 | (dshmi fputscr "Floating point put to FPSCR" | |
618 | () | |
619 | "fputscr $frgh" | |
620 | (+ (f-op 12) frgh (f-ext 2) (f-dest 63) (f-rsvd 0)) | |
621 | (unimp "fputscr")) | |
622 | ; FIXME: this should work! | |
623 | ; (set fpscr (subword SI frgh 0))) | |
624 | ||
625 | (dshmi fsqrtd "Floating point square root (double)" | |
626 | () | |
627 | "fsqrt.d $drgh, $drf" | |
628 | (+ (f-op 14) drgh (f-ext 5) drf (f-rsvd 0)) | |
629 | (set drf (c-call DF "sh64_fsqrtd" drgh))) | |
630 | ||
631 | (dshmi fsqrts "Floating point squart root (single)" | |
632 | () | |
633 | "fsqrt.s $frgh, $frf" | |
634 | (+ (f-op 14) frgh (f-ext 4) frf (f-rsvd 0)) | |
635 | (set frf (c-call SF "sh64_fsqrts" frgh))) | |
636 | ||
637 | (dshmi fstd "Floating point store (double)" | |
638 | () | |
639 | "fst.d $rm, $disp10x8, $drf" | |
640 | (+ (f-op 47) rm disp10x8 drf (f-rsvd 0)) | |
641 | (set (mem DF (add rm disp10x8)) drf)) | |
642 | ||
643 | (dshmi fstp "Floating point store (pair of singles)" | |
644 | () | |
645 | "fst.p $rm, $disp10x8, $fpf" | |
646 | (+ (f-op 46) rm disp10x8 fpf (f-rsvd 0)) | |
647 | (sequence ((QI f)) | |
648 | (set f (index-of fpf)) | |
649 | (set (mem SF (add rm disp10x8)) (reg h-fr f)) | |
650 | (set (mem SF (add rm (add disp10x8 4))) (reg h-fr (add f 1))))) | |
651 | ||
652 | (dshmi fsts "Floating point store (single)" | |
653 | () | |
654 | "fst.s $rm, $disp10x4, $frf" | |
655 | (+ (f-op 45) rm disp10x4 frf (f-rsvd 0)) | |
656 | (set (mem SF (add rm disp10x4)) frf)) | |
657 | ||
658 | (dshmi fstxd "Floating point extended store (double)" | |
659 | () | |
660 | "fstx.d $rm, $rn, $drf" | |
661 | (+ (f-op 15) rm (f-ext 9) rn drf (f-rsvd 0)) | |
662 | (set (mem DF (add rm rn)) drf)) | |
663 | ||
664 | (dshmi fstxp "Floating point extended store (pair of singles)" | |
665 | () | |
666 | "fstx.p $rm, $rn, $fpf" | |
667 | (+ (f-op 15) rm (f-ext 13) rn fpf (f-rsvd 0)) | |
668 | (sequence ((QI f)) | |
669 | (set f (index-of fpf)) | |
670 | (set (mem SF (add rm rn)) (reg h-fr f)) | |
671 | (set (mem SF (add rm (add rn 4))) (reg h-fr (add f 1))))) | |
672 | ||
673 | (dshmi fstxs "Floating point extended store (single)" | |
674 | () | |
675 | "fstx.s $rm, $rn, $frf" | |
676 | (+ (f-op 15) rm (f-ext 8) rn frf (f-rsvd 0)) | |
677 | (set (mem SF (add rm rn)) frf)) | |
678 | ||
679 | (dshmi fsubd "Floating point subtract (double)" | |
680 | () | |
681 | "fsub.d $drg, $drh, $drf" | |
682 | (+ (f-op 13) frg (f-ext 3) frh frf (f-rsvd 0)) | |
683 | (set drf (c-call DF "sh64_fsubd" drg drh))) | |
684 | ||
685 | (dshmi fsubs "Floating point subtract (single)" | |
686 | () | |
687 | "fsub.s $frg, $frh, $frf" | |
688 | (+ (f-op 13) frg (f-ext 2) frh frf (f-rsvd 0)) | |
689 | (set frf (c-call SF "sh64_fsubs" frg frh))) | |
690 | ||
691 | (dshmi ftrcdl "Floating point conversion (double to long)" | |
692 | () | |
693 | "ftrc.dl $drgh, $frf" | |
694 | (+ (f-op 14) drgh (f-ext 11) frf (f-rsvd 0)) | |
695 | (set frf (c-call SF "sh64_ftrcdl" drgh))) | |
696 | ||
697 | (dshmi ftrcsl "Floating point conversion (single to long)" | |
698 | () | |
699 | "ftrc.sl $frgh, $frf" | |
700 | (+ (f-op 14) frgh (f-ext 8) frf (f-rsvd 0)) | |
701 | (set frf (c-call SF "sh64_ftrcsl" frgh))) | |
702 | ||
703 | (dshmi ftrcdq "Floating point conversion (double to quad)" | |
704 | () | |
705 | "ftrc.dq $drgh, $drf" | |
706 | (+ (f-op 14) drgh (f-ext 9) frf (f-rsvd 0)) | |
707 | (set drf (c-call DF "sh64_ftrcdq" drgh))) | |
708 | ||
709 | (dshmi ftrcsq "Floating point conversion (single to quad)" | |
710 | () | |
711 | "ftrc.sq $frgh, $drf" | |
712 | (+ (f-op 14) frgh (f-ext 10) drf (f-rsvd 0)) | |
713 | (set drf (c-call DF "sh64_ftrcsq" frgh))) | |
714 | ||
715 | (dshmi ftrvs "Floating point matrix multiply" | |
716 | () | |
717 | "ftrv.s $mtrxg, $fvh, $fvf" | |
718 | (+ (f-op 5) mtrxg (f-ext 14) fvh fvf (f-rsvd 0)) | |
719 | (c-call "sh64_ftrvs" (index-of mtrxg) (index-of fvh) (index-of fvf))) | |
720 | ||
721 | (dshmi getcfg "Get configuration register" | |
722 | () | |
723 | "getcfg $rm, $disp6, $rd" | |
724 | (+ (f-op 48) rm (f-ext 15) disp6 rd (f-rsvd 0)) | |
725 | (unimp "getcfg")) | |
726 | ||
727 | (dshmi getcon "Get control register" | |
728 | () | |
729 | "getcon $crk, $rd" | |
730 | (+ (f-op 9) crk (f-ext 15) (f-right 63) rd (f-rsvd 0)) | |
731 | (set rd crk)) | |
732 | ||
733 | (dshmi gettr "Get target register" | |
734 | () | |
735 | "gettr $trb, $rd" | |
736 | (+ (f-op 17) (f-25 0) trb (f-ext 5) (f-right 63) rd (f-rsvd 0)) | |
737 | (set rd trb)) | |
738 | ||
739 | (dshmi icbi "Invalidate instruction cache block" | |
740 | () | |
741 | "icbi $rm, $disp6x32" | |
742 | (+ (f-op 56) rm (f-ext 5) disp6x32 (f-dest 63) (f-rsvd 0)) | |
743 | (unimp "icbi")) | |
744 | ||
745 | (dshmi ldb "Load byte" | |
746 | () | |
747 | "ld.b $rm, $disp10, $rd" | |
748 | (+ (f-op 32) rm disp10 rd (f-rsvd 0)) | |
749 | (set rd (ext DI (mem QI (add rm (ext DI disp10)))))) | |
750 | ||
751 | (dshmi ldl "Load long word" | |
752 | () | |
753 | "ld.l $rm, $disp10x4, $rd" | |
754 | (+ (f-op 34) rm disp10x4 rd (f-rsvd 0)) | |
755 | (set rd (ext DI (mem SI (add rm (ext DI disp10x4)))))) | |
756 | ||
757 | (dshmi ldq "Load quad word" | |
758 | () | |
759 | "ld.q $rm, $disp10x8, $rd" | |
760 | (+ (f-op 35) rm disp10x8 rd (f-rsvd 0)) | |
761 | (set rd (mem DI (add rm (ext DI disp10x8))))) | |
762 | ||
763 | (dshmi ldub "Load unsigned byte" | |
764 | () | |
765 | "ld.ub $rm, $disp10, $rd" | |
766 | (+ (f-op 36) rm disp10 rd (f-rsvd 0)) | |
767 | (set rd (zext DI (mem QI (add rm (ext DI disp10)))))) | |
768 | ||
769 | (dshmi lduw "Load unsigned word" | |
770 | () | |
771 | "ld.uw $rm, $disp10x2, $rd" | |
772 | (+ (f-op 44) rm disp10 rd (f-rsvd 0)) | |
773 | (set rd (zext DI (mem HI (add rm (ext DI disp10x2)))))) | |
774 | ||
775 | (dshmi ldw "Load word" | |
776 | () | |
777 | "ld.w $rm, $disp10x2, $rd" | |
778 | (+ (f-op 33) rm disp10 rd (f-rsvd 0)) | |
779 | (set rd (ext DI (mem HI (add rm (ext DI disp10x2)))))) | |
780 | ||
781 | (dshmi ldhil "Load high part (long word)" | |
782 | () | |
783 | "ldhi.l $rm, $disp6, $rd" | |
784 | (+ (f-op 48) rm (f-ext 6) disp6 rd (f-rsvd 0)) | |
785 | ; FIXME. | |
786 | (unimp "ldhil")) | |
787 | ||
788 | (dshmi ldhiq "Load high part (quad word)" | |
789 | () | |
790 | "ldhi.q $rm, $disp6, $rd" | |
791 | (+ (f-op 48) rm (f-ext 7) disp6 rd (f-rsvd 0)) | |
792 | ; FIXME. | |
793 | (unimp "ldhiq")) | |
794 | ||
795 | (dshmi ldlol "Load low part (long word)" | |
796 | () | |
797 | "ldlo.l $rm, $disp6, $rd" | |
798 | (+ (f-op 48) rm (f-ext 2) disp6 rd (f-rsvd 0)) | |
799 | ; FIXME. | |
800 | (unimp "ldlol")) | |
801 | ||
802 | (dshmi ldloq "Load low part (quad word)" | |
803 | () | |
804 | "ldlo.q $rm, $disp6, $rd" | |
805 | (+ (f-op 48) rm (f-ext 3) disp6 rd (f-rsvd 0)) | |
806 | ; FIXME; | |
807 | (unimp "ldloq")) | |
808 | ||
809 | (dshmi ldxb "Load byte (extended displacement)" | |
810 | () | |
811 | "ldx.b $rm, $rn, $rd" | |
812 | (+ (f-op 16) rm (f-ext 0) rn rd (f-rsvd 0)) | |
813 | (set rd (ext DI (mem QI (add rm rn))))) | |
814 | ||
815 | (dshmi ldxl "Load long word (extended displacement)" | |
816 | () | |
817 | "ldx.l $rm, $rn, $rd" | |
818 | (+ (f-op 16) rm (f-ext 2) rn rd (f-rsvd 0)) | |
819 | (set rd (ext DI (mem SI (add rm rn))))) | |
820 | ||
821 | (dshmi ldxq "Load quad word (extended displacement)" | |
822 | () | |
823 | "ldx.q $rm, $rn, $rd" | |
824 | (+ (f-op 16) rm (f-ext 3) rn rd (f-rsvd 0)) | |
825 | (set rd (mem DI (add rm rn)))) | |
826 | ||
827 | (dshmi ldxub "Load unsigned byte (extended displacement)" | |
828 | () | |
829 | "ldx.ub $rm, $rn, $rd" | |
830 | (+ (f-op 16) rm (f-ext 4) rn rd (f-rsvd 0)) | |
831 | (set rd (zext DI (mem UQI (add rm rn))))) | |
832 | ||
833 | (dshmi ldxuw "Load unsigned word (extended displacement)" | |
834 | () | |
835 | "ldx.uw $rm, $rn, $rd" | |
836 | (+ (f-op 16) rm (f-ext 5) rn rd (f-rsvd 0)) | |
837 | (set rd (zext DI (mem UHI (add rm rn))))) | |
838 | ||
839 | (dshmi ldxw "Load word (extended displacement)" | |
840 | () | |
841 | "ldx.w $rm, $rn, $rd" | |
842 | (+ (f-op 16) rm (f-ext 1) rn rd (f-rsvd 0)) | |
843 | (set rd (ext DI (mem HI (add rm rn))))) | |
844 | ||
845 | \f | |
846 | ; Macros to facilitate multimedia instructions. | |
847 | ||
848 | (define-pmacro (slice-byte expr) | |
849 | (sequence ((QI result7) (QI result6) (QI result5) (QI result4) | |
850 | (QI result3) (QI result2) (QI result1) (QI result0)) | |
851 | (set result0 (expr (subword QI rm 7) (subword QI rn 7))) | |
852 | (set result1 (expr (subword QI rm 6) (subword QI rn 6))) | |
853 | (set result2 (expr (subword QI rm 5) (subword QI rn 5))) | |
854 | (set result3 (expr (subword QI rm 4) (subword QI rn 4))) | |
855 | (set result4 (expr (subword QI rm 3) (subword QI rn 3))) | |
856 | (set result5 (expr (subword QI rm 2) (subword QI rn 2))) | |
857 | (set result6 (expr (subword QI rm 1) (subword QI rn 1))) | |
858 | (set result7 (expr (subword QI rm 0) (subword QI rn 0))) | |
859 | (set rd (-join-qi result7 result6 result5 result4 result3 result2 | |
860 | result1 result0)))) | |
861 | ||
862 | (define-pmacro (slice-word expr) | |
863 | (sequence ((HI result3) (HI result2) (HI result1) (HI result0)) | |
864 | (set result0 (expr (subword HI rm 3) (subword HI rn 3))) | |
865 | (set result1 (expr (subword HI rm 2) (subword HI rn 2))) | |
866 | (set result2 (expr (subword HI rm 1) (subword HI rn 1))) | |
867 | (set result3 (expr (subword HI rm 0) (subword HI rn 0))) | |
868 | (set rd (-join-hi result3 result2 result1 result0)))) | |
869 | ||
870 | (define-pmacro (slice-word-unop expr) | |
871 | (sequence ((HI result3) (HI result2) (HI result1) (HI result0)) | |
872 | (set result0 (expr (subword HI rm 3))) | |
873 | (set result1 (expr (subword HI rm 2))) | |
874 | (set result2 (expr (subword HI rm 1))) | |
875 | (set result3 (expr (subword HI rm 0))) | |
876 | (set rd (-join-hi result3 result2 result1 result0)))) | |
877 | ||
878 | (define-pmacro (slice-long expr) | |
879 | (sequence ((SI result1) (SI result0)) | |
880 | (set result0 (expr (subword SI rm 1) (subword SI rn 1))) | |
881 | (set result1 (expr (subword SI rm 0) (subword SI rn 0))) | |
882 | (set rd (-join-si result1 result0)))) | |
883 | ||
884 | (define-pmacro (slice-long-unop expr) | |
885 | (sequence ((SI result1) (SI result0)) | |
886 | (set result0 (expr (subword SI rm 1))) | |
887 | (set result1 (expr (subword SI rm 0))) | |
888 | (set rd (-join-si result1 result0)))) | |
889 | ||
890 | ; Multimedia instructions. | |
891 | ||
892 | (dshmi mabsl "Multimedia absolute value (long word)" | |
893 | () | |
894 | "mabs.l $rm, $rd" | |
895 | (+ (f-op 10) rm (f-ext 10) (f-right 63) rd (f-rsvd 0)) | |
896 | (slice-long-unop abs)) | |
897 | ||
898 | (dshmi mabsw "Multimedia absolute value (word)" | |
899 | () | |
900 | "mabs.w $rm, $rd" | |
901 | (+ (f-op 10) rm (f-ext 9) (f-right 63) rd (f-rsvd 0)) | |
902 | (slice-word-unop abs)) | |
903 | ||
904 | (dshmi maddl "Multimedia add (long word)" | |
905 | () | |
906 | "madd.l $rm, $rn, $rd" | |
907 | (+ (f-op 2) rm (f-ext 2) rn rd (f-rsvd 0)) | |
908 | (slice-long add)) | |
909 | ||
910 | (dshmi maddw "Multimedia add (word)" | |
911 | () | |
912 | "madd.w $rm, $rn, $rd" | |
913 | (+ (f-op 2) rm (f-ext 1) rn rd (f-rsvd 0)) | |
914 | (slice-word add)) | |
915 | ||
916 | (define-pmacro (-maddsl arg1 arg2) (saturate SI 32 (add arg1 arg2))) | |
917 | (dshmi maddsl "Multimedia add (saturating, long word)" | |
918 | () | |
919 | "madds.l $rm, $rn, $rd" | |
920 | (+ (f-op 2) rm (f-ext 6) rn rd (f-rsvd 0)) | |
921 | (slice-long -maddsl)) | |
922 | ||
923 | (define-pmacro (-maddsub arg1 arg2) (usaturate QI 8 (add arg1 arg2))) | |
924 | (dshmi maddsub "Multimedia add (saturating, unsigned byte)" | |
925 | () | |
926 | "madds.ub $rm, $rn, $rd" | |
927 | (+ (f-op 2) rm (f-ext 4) rn rd (f-rsvd 0)) | |
928 | (slice-byte -maddsub)) | |
929 | ||
930 | (define-pmacro (-maddsw arg1 arg2) (saturate HI 16 (add arg1 arg2))) | |
931 | (dshmi maddsw "Multimedia add (saturating, word)" | |
932 | () | |
933 | "madds.w $rm, $rn, $rd" | |
934 | (+ (f-op 2) rm (f-ext 5) rn rd (f-rsvd 0)) | |
935 | (slice-word -maddsw)) | |
936 | ||
937 | (define-pmacro (-mcmpeq mode arg1 arg2) | |
938 | (if mode (eq arg1 arg2) (inv mode 0) (const mode 0))) | |
939 | ||
940 | (define-pmacro (-mcmpeqb arg1 arg2) (-mcmpeq QI arg1 arg2)) | |
941 | (dshmi mcmpeqb "Multimedia compare equal (byte)" | |
942 | () | |
943 | "mcmpeq.b $rm, $rn, $rd" | |
944 | (+ (f-op 10) rm (f-ext 0) rn rd (f-rsvd 0)) | |
945 | (slice-byte -mcmpeqb)) | |
946 | ||
947 | (define-pmacro (-mcmpeql arg1 arg2) (-mcmpeq SI arg1 arg2)) | |
948 | (dshmi mcmpeql "Multimedia compare equal (long word)" | |
949 | () | |
950 | "mcmpeq.l $rm, $rn, $rd" | |
951 | (+ (f-op 10) rm (f-ext 2) rn rd (f-rsvd 0)) | |
952 | (slice-long -mcmpeql)) | |
953 | ||
954 | (define-pmacro (-mcmpeqw arg1 arg2) (-mcmpeq HI arg1 arg2)) | |
955 | (dshmi mcmpeqw "Multimedia compare equal (word)" | |
956 | () | |
957 | "mcmpeq.w $rm, $rn, $rd" | |
958 | (+ (f-op 10) rm (f-ext 1) rn rd (f-rsvd 0)) | |
959 | (slice-word -mcmpeqw)) | |
960 | ||
961 | (define-pmacro (-mcmpgt mode arg1 arg2) | |
962 | (if mode (gt arg1 arg2) (inv mode 0) (const mode 0))) | |
963 | (define-pmacro (-mcmpgtu mode arg1 arg2) | |
964 | (if mode (gtu arg1 arg2) (inv mode 0) (const mode 0))) | |
965 | ||
966 | (define-pmacro (-mcmpgtl arg1 arg2) (-mcmpgt SI arg1 arg2)) | |
967 | (dshmi mcmpgtl "Multimedia compare greater than (long word)" | |
968 | () | |
969 | "mcmpgt.l $rm, $rn, $rd" | |
970 | (+ (f-op 10) rm (f-ext 6) rn rd (f-rsvd 0)) | |
971 | (slice-long -mcmpgtl)) | |
972 | ||
973 | (define-pmacro (-mcmpgtub arg1 arg2) (-mcmpgtu QI arg1 arg2)) | |
974 | (dshmi mcmpgtub "Multimediate compare unsigned greater than (byte)" | |
975 | () | |
976 | "mcmpgt.ub $rm, $rn, $rd" | |
977 | (+ (f-op 10) rm (f-ext 4) rn rd (f-rsvd 0)) | |
978 | (slice-byte -mcmpgtub)) | |
979 | ||
980 | (define-pmacro (-mcmpgtw arg1 arg2) (-mcmpgt HI arg1 arg2)) | |
981 | (dshmi mcmpgtw "Multimedia compare greater than (word)" | |
982 | () | |
983 | "mcmpgt.w $rm, $rn, $rd" | |
984 | (+ (f-op 10) rm (f-ext 5) rn rd (f-rsvd 0)) | |
985 | (slice-word -mcmpgtw)) | |
986 | ||
987 | (dshmi mcmv "Multimedia conditional move" | |
988 | () | |
989 | "mcmv $rm, $rn, $rd" | |
990 | (+ (f-op 18) rm (f-ext 3) rn rd (f-rsvd 0)) | |
991 | (set rd (or (and rm rn) (and rd (inv rn))))) | |
992 | ||
993 | (dshmi mcnvslw "Multimedia convert/saturate (long to word)" | |
994 | () | |
995 | "mcnvs.lw $rm, $rn, $rd" | |
996 | (+ (f-op 19) rm (f-ext 13) rn rd (f-rsvd 0)) | |
997 | (sequence ((HI result3) (HI result2) (HI result1) (HI result0)) | |
998 | (set result0 (saturate HI 16 (subword SI rm 0))) | |
999 | (set result1 (saturate HI 16 (subword SI rm 1))) | |
1000 | (set result2 (saturate HI 16 (subword SI rn 0))) | |
1001 | (set result3 (saturate HI 16 (subword SI rn 1))) | |
1002 | (set rd (-join-hi result3 result2 result1 result0)))) | |
1003 | ||
1004 | (dshmi mcnvswb "Multimedia convert/saturate (word to byte)" | |
1005 | () | |
1006 | "mcnvs.wb $rm, $rn, $rd" | |
1007 | (+ (f-op 19) rm (f-ext 8) rn rd (f-rsvd 0)) | |
1008 | (sequence ((QI result7) (QI result6) (QI result5) (QI result4) | |
1009 | (QI result3) (QI result2) (QI result1) (QI result0)) | |
1010 | (set result0 (saturate QI 8 (subword HI rm 0))) | |
1011 | (set result1 (saturate QI 8 (subword HI rm 1))) | |
1012 | (set result2 (saturate QI 8 (subword HI rm 2))) | |
1013 | (set result3 (saturate QI 8 (subword HI rm 3))) | |
1014 | (set result4 (saturate QI 8 (subword HI rn 0))) | |
1015 | (set result5 (saturate QI 8 (subword HI rn 1))) | |
1016 | (set result6 (saturate QI 8 (subword HI rn 2))) | |
1017 | (set result7 (saturate QI 8 (subword HI rn 3))) | |
1018 | (set rd (-join-qi result7 result6 result5 result4 | |
1019 | result3 result2 result1 result0)))) | |
1020 | ||
1021 | (dshmi mcnvswub "Multimedia convert/saturate (word to unsigned byte)" | |
1022 | () | |
1023 | "mcnvs.wub $rm, $rn, $rd" | |
1024 | (+ (f-op 19) rm (f-ext 12) rn rd (f-rsvd 0)) | |
1025 | (sequence ((QI result7) (QI result6) (QI result5) (QI result4) | |
1026 | (QI result3) (QI result2) (QI result1) (QI result0)) | |
1027 | (set result0 (usaturate QI 8 (subword HI rm 0))) | |
1028 | (set result1 (usaturate QI 8 (subword HI rm 1))) | |
1029 | (set result2 (usaturate QI 8 (subword HI rm 2))) | |
1030 | (set result3 (usaturate QI 8 (subword HI rm 3))) | |
1031 | (set result4 (usaturate QI 8 (subword HI rn 0))) | |
1032 | (set result5 (usaturate QI 8 (subword HI rn 1))) | |
1033 | (set result6 (usaturate QI 8 (subword HI rn 2))) | |
1034 | (set result7 (usaturate QI 8 (subword HI rn 3))) | |
1035 | (set rd (-join-qi result7 result6 result5 result4 result3 | |
1036 | result2 result1 result0)))) | |
1037 | ||
1038 | ; mexter -- generate an mexterN instruction, where: | |
1039 | ; op = primary opcode | |
1040 | ; extop = extended opcode | |
1041 | ||
1042 | (define-pmacro (make-mextr n op extop) | |
1043 | (dshmi (.sym mextr n) | |
1044 | (.str "Multimedia extract 64-bit slice (from byte " n ")") | |
1045 | () | |
1046 | (.str "mextr" n " $rm, $rn, $rd") | |
1047 | (+ (f-op op) rm (f-ext extop) rn rd (f-rsvd 0)) | |
1048 | (sequence ((QI count) (DI mask) (DI rhs)) | |
1049 | (set count (mul QI 8 (sub QI 8 n))) | |
1050 | (set mask (sll DI (inv 0) count)) | |
1051 | (set rhs (srl (and rm mask) count)) | |
1052 | (set count (mul QI 8 n)) | |
1053 | (set mask (srl DI (inv 0) count)) | |
1054 | (set rd (or DI rhs (sll DI (and rn mask) count)))))) | |
1055 | ||
1056 | (make-mextr 1 10 7) | |
1057 | (make-mextr 2 10 11) | |
1058 | (make-mextr 3 10 15) | |
1059 | (make-mextr 4 11 3) | |
1060 | (make-mextr 5 11 7) | |
1061 | (make-mextr 6 11 11) | |
1062 | (make-mextr 7 11 15) | |
1063 | ||
1064 | (dshmi mmacfxwl "Multimedia fractional multiply (word to long)" | |
1065 | () | |
1066 | "mmacfx.wl $rm, $rn, $rd" | |
1067 | (+ (f-op 18) rm (f-ext 1) rn rd (f-rsvd 0)) | |
1068 | (sequence ((SI temp) (SI result1) (SI result0)) | |
1069 | (set result0 (subword SI rd 0)) | |
1070 | (set result1 (subword SI rd 1)) | |
1071 | (set temp (mul (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0)))) | |
1072 | (set temp (saturate SI 32 (sll temp 1))) | |
1073 | (set result0 (saturate SI 32 (add result0 temp))) | |
1074 | (set temp (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1)))) | |
1075 | (set temp (saturate SI 32 (sll temp 1))) | |
1076 | (set result1 (saturate SI 32 (add result1 temp))) | |
1077 | (set rd (-join-si result1 result0)))) | |
1078 | ||
1079 | (dshmi mmacnfx.wl "Multimedia fractional multiple (word to long)" | |
1080 | () | |
1081 | "mmacnfx.wl $rm, $rn, $rd" | |
1082 | (+ (f-op 18) rn (f-ext 5) rn rd (f-rsvd 0)) | |
1083 | (sequence ((SI temp) (SI result1) (SI result0)) | |
1084 | (set result0 (subword SI rd 0)) | |
1085 | (set result1 (subword SI rd 1)) | |
1086 | (set temp (mul (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0)))) | |
1087 | (set temp (saturate SI 32 (sll temp 1))) | |
1088 | (set result0 (saturate SI 32 (sub result0 temp))) | |
1089 | (set temp (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1)))) | |
1090 | (set temp (saturate SI 32 (sll temp 1))) | |
1091 | (set result1 (saturate SI 32 (sub result1 temp))) | |
1092 | (set rd (-join-si result1 result0)))) | |
1093 | ||
1094 | (dshmi mmull "Multimedia multiply (long word)" | |
1095 | () | |
1096 | "mmul.l $rm, $rn, $rd" | |
1097 | (+ (f-op 19) rm (f-ext 2) rn rd (f-rsvd 0)) | |
1098 | (slice-long mul)) | |
1099 | ||
1100 | (dshmi mmulw "Multimedia multiply (word)" | |
1101 | () | |
1102 | "mmul.w $rm, $rn, $rd" | |
1103 | (+ (f-op 19) rm (f-ext 1) rn rd (f-rsvd 0)) | |
1104 | (slice-word mul)) | |
1105 | ||
1106 | (dshmi mmulfxl "Multimedia fractional multiply (long word)" | |
1107 | () | |
1108 | "mmulfx.l $rm, $rn, $rd" | |
1109 | (+ (f-op 19) rm (f-ext 6) rn rd (f-rsvd 0)) | |
1110 | (sequence ((DI temp) (SI result0) (SI result1)) | |
1111 | (set temp (mul (zext DI (subword SI rm 0)) (zext DI (subword SI rn 0)))) | |
1112 | (set result0 (saturate SI 32 (sra temp 31))) | |
1113 | (set temp (mul (zext DI (subword SI rm 1)) (zext DI (subword SI rn 1)))) | |
1114 | (set result1 (saturate SI 32 (sra temp 31))) | |
1115 | (set rd (-join-si result1 result0)))) | |
1116 | ||
1117 | (dshmi mmulfxw "Multimedia fractional multiply (word)" | |
1118 | () | |
1119 | "mmulfx.w $rm, $rn, $rd" | |
1120 | (+ (f-op 19) rm (f-ext 5) rn rd (f-rsvd 0)) | |
1121 | (sequence ((SI temp) (HI result0) (HI result1) (HI result2) (HI result3)) | |
1122 | (set temp (mul (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0)))) | |
1123 | (set result0 (saturate HI 16 (sra temp 15))) | |
1124 | (set temp (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1)))) | |
1125 | (set result1 (saturate HI 16 (sra temp 15))) | |
1126 | (set temp (mul (zext SI (subword HI rm 2)) (zext SI (subword HI rn 2)))) | |
1127 | (set result2 (saturate HI 16 (sra temp 15))) | |
1128 | (set temp (mul (zext SI (subword HI rm 3)) (zext SI (subword HI rn 3)))) | |
1129 | (set result3 (saturate HI 16 (sra temp 15))) | |
1130 | (set rd (-join-hi result3 result2 result1 result0)))) | |
1131 | ||
1132 | (dshmi mmulfxrpw "Multimedia fractional multiply round positive (word op)" | |
1133 | () | |
1134 | "mmulfxrp.w $rm, $rn, $rd" | |
1135 | (+ (f-op 19) rm (f-ext 9) rn rd (f-rsvd 0)) | |
1136 | (sequence ((SI temp) (HI result0) (HI result1) (HI result2) (HI result3) (HI c)) | |
1137 | (set c (sll 1 14)) | |
1138 | (set temp (mul (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0)))) | |
1139 | (set result0 (saturate HI 16 (sra (add temp c) 15))) | |
1140 | (set temp (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1)))) | |
1141 | (set result1 (saturate HI 16 (sra (add temp c) 15))) | |
1142 | (set temp (mul (zext SI (subword HI rm 2)) (zext SI (subword HI rn 2)))) | |
1143 | (set result2 (saturate HI 16 (sra (add temp c) 15))) | |
1144 | (set temp (mul (zext SI (subword HI rm 3)) (zext SI (subword HI rn 3)))) | |
1145 | (set result3 (saturate HI 16 (sra (add temp c) 15))) | |
1146 | (set rd (-join-hi result3 result2 result1 result0)))) | |
1147 | ||
1148 | (dshmi mmulhiwl "Multimedia multiply higher halves (word to long)" | |
1149 | () | |
1150 | "mmulhi.wl $rm, $rn, $rd" | |
1151 | (+ (f-op 19) rm (f-ext 14) rn rd (f-rsvd 0)) | |
1152 | (sequence ((SI result1) (SI result0)) | |
1153 | (set result0 (mul (zext SI (subword HI rm 2)) (zext SI (subword HI rn 2)))) | |
1154 | (set result1 (mul (zext SI (subword HI rm 3)) (zext SI (subword HI rn 3)))) | |
1155 | (set rd (-join-si result1 result0)))) | |
1156 | ||
1157 | (dshmi mmullowl "Multimedia multiply lower halves (word to long)" | |
1158 | () | |
1159 | "mmullo.wl $rm, $rn, $rd" | |
1160 | (+ (f-op 19) rm (f-ext 10) rn rd (f-rsvd 0)) | |
1161 | (sequence ((SI result1) (SI result0)) | |
1162 | (set result0 (mul (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0)))) | |
1163 | (set result1 (mul (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1)))) | |
1164 | (set rd (-join-si result1 result0)))) | |
1165 | ||
1166 | (dshmi mmulsumwq "Multimedia multiply and accumulate (word to quad)" | |
1167 | () | |
1168 | "mmulsum.wq $rm, $rn, $rd" | |
1169 | (+ (f-op 18) rm (f-ext 9) rn rd (f-rsvd 0)) | |
1170 | (sequence ((DI acc)) | |
1171 | (set acc (mul SI (zext SI (subword HI rm 0)) (zext SI (subword HI rn 0)))) | |
1172 | (set acc (add acc (mul SI (zext SI (subword HI rm 1)) (zext SI (subword HI rn 1))))) | |
1173 | (set acc (add acc (mul SI (zext SI (subword HI rm 2)) (zext SI (subword HI rn 2))))) | |
1174 | (set acc (add acc (mul SI (zext SI (subword HI rm 3)) (zext SI (subword HI rn 3))))) | |
1175 | (set rd (add rd acc)))) | |
1176 | ||
1177 | (dshmi movi "Move immediate" | |
1178 | () | |
1179 | "movi $imm16, $rd" | |
1180 | (+ (f-op 51) imm16 rd (f-rsvd 0)) | |
1181 | (set rd (ext DI imm16))) | |
1182 | ||
1183 | (dshmi mpermw "Multimedia permutate word" | |
1184 | () | |
1185 | "mperm.w $rm, $rn, $rd" | |
1186 | (+ (f-op 10) rm (f-ext 13) rn rd (f-rsvd 0)) | |
1187 | (sequence ((QI control) (HI result3) (HI result2) (HI result1) (HI result0)) | |
1188 | (set control (and QI rn #x3f)) | |
1189 | (set result0 (subword HI rm (sub 3 (and control 3)))) | |
1190 | (set result1 (subword HI rm (sub 3 (and (srl control 2) 3)))) | |
1191 | (set result2 (subword HI rm (sub 3 (and (srl control 4) 3)))) | |
1192 | (set result3 (subword HI rm (sub 3 (and (srl control 6) 3)))) | |
1193 | (set rd (-join-hi result3 result2 result1 result0)))) | |
1194 | ||
1195 | (dshmi msadubq "Multimedia absolute difference (byte)" | |
1196 | () | |
1197 | "msad.ubq $rm, $rn, $rd" | |
1198 | (+ (f-op 18) rm (f-ext 0) rn rd (f-rsvd 0)) | |
1199 | (sequence ((DI acc)) | |
1200 | (set acc (abs DI (sub (subword QI rm 0) (subword QI rn 1)))) | |
1201 | (set acc (add DI acc (abs (sub (subword QI rm 1) (subword QI rn 1))))) | |
1202 | (set acc (add DI acc (abs (sub (subword QI rm 2) (subword QI rn 2))))) | |
1203 | (set acc (add DI acc (abs (sub (subword QI rm 3) (subword QI rn 3))))) | |
1204 | (set acc (add DI acc (abs (sub (subword QI rm 4) (subword QI rn 4))))) | |
1205 | (set acc (add DI acc (abs (sub (subword QI rm 5) (subword QI rn 5))))) | |
1206 | (set acc (add DI acc (abs (sub (subword QI rm 6) (subword QI rn 6))))) | |
1207 | (set acc (add DI acc (abs (sub (subword QI rm 7) (subword QI rn 7))))) | |
1208 | (set rd (add rd acc)))) | |
1209 | ||
1210 | (define-pmacro (-mshaldsl arg) (saturate SI 32 (sll arg (and rn 31)))) | |
1211 | (dshmi mshaldsl "Multimedia saturating arithmetic left shift (long word)" | |
1212 | () | |
1213 | "mshalds.l $rm, $rn, $rd" | |
1214 | (+ (f-op 3) rm (f-ext 6) rn rd (f-rsvd 0)) | |
1215 | (slice-long-unop -mshaldsl)) | |
1216 | ||
1217 | (define-pmacro (-mshaldsw arg) (saturate HI 16 (sll arg (and rn 15)))) | |
1218 | (dshmi mshaldsw "Multimedia saturating arithmetic left shift (word)" | |
1219 | () | |
1220 | "mshalds.w $rm, $rn, $rd" | |
1221 | (+ (f-op 3) rm (f-ext 5) rn rd (f-rsvd 0)) | |
1222 | (slice-word-unop -mshaldsw)) | |
1223 | ||
1224 | (define-pmacro (-mshardl arg) (sra arg (and rn 31))) | |
1225 | (dshmi mshardl "Multimedia arithmetic right shift (long)" | |
1226 | () | |
1227 | "mshard.l $rm, $rn, $rd" | |
1228 | (+ (f-op 3) rm (f-ext 10) rn rd (f-rsvd 0)) | |
1229 | (slice-long-unop -mshardl)) | |
1230 | ||
1231 | (define-pmacro (-mshardw arg) (sra arg (and rn 15))) | |
1232 | (dshmi mshardw "Multimedia arithmetic right shift (word)" | |
1233 | () | |
1234 | "mshard.w $rm, $rn, $rd" | |
1235 | (+ (f-op 3) rm (f-ext 9) rn rd (f-rsvd 0)) | |
1236 | (slice-word-unop -mshardw)) | |
1237 | ||
1238 | (dshmi mshardsq "Multimedia saturating arithmetic right shift (quad word)" | |
1239 | () | |
1240 | "mshards.q $rm, $rn, $rd" | |
1241 | (+ (f-op 3) rm (f-ext 11) rn rd (f-rsvd 0)) | |
1242 | (set rd (saturate DI 16 (sra rm (and rn 63))))) | |
1243 | ||
1244 | (dshmi mshfhib "Multimedia shuffle higher-half (byte)" | |
1245 | () | |
1246 | "mshfhi.b $rm, $rn, $rd" | |
1247 | (+ (f-op 11) rm (f-ext 4) rn rd (f-rsvd 0)) | |
1248 | (sequence ((QI result7) (QI result6) (QI result5) (QI result4) | |
1249 | (QI result3) (QI result2) (QI result1) (QI result0)) | |
1250 | (set result0 (subword QI rm 4)) | |
1251 | (set result1 (subword QI rn 4)) | |
1252 | (set result2 (subword QI rm 5)) | |
1253 | (set result3 (subword QI rn 5)) | |
1254 | (set result4 (subword QI rm 6)) | |
1255 | (set result5 (subword QI rn 6)) | |
1256 | (set result6 (subword QI rm 7)) | |
1257 | (set result7 (subword QI rn 7)) | |
1258 | (set rd (-join-qi result7 result6 result5 result4 result3 | |
1259 | result2 result1 result0)))) | |
1260 | ||
1261 | (dshmi mshfhil "Multimedia shuffle higher-half (long)" | |
1262 | () | |
1263 | "mshfhi.l $rm, $rn, $rd" | |
1264 | (+ (f-op 11) rm (f-ext 6) rn rd (f-rsvd 0)) | |
1265 | (sequence ((SI result1) (SI result0)) | |
1266 | (set result0 (subword SI rm 1)) | |
1267 | (set result1 (subword SI rn 1)) | |
1268 | (set rd (-join-si result1 result0)))) | |
1269 | ||
1270 | (dshmi mshfhiw "Multimedia shuffle higher-half (word)" | |
1271 | () | |
1272 | "mshfhi.w $rm, $rn, $rd" | |
1273 | (+ (f-op 11) rm (f-ext 5) rn rd (f-rsvd 0)) | |
1274 | (sequence ((HI result3) (HI result2) (HI result1) (HI result0)) | |
1275 | (set result0 (subword HI rm 2)) | |
1276 | (set result1 (subword HI rn 2)) | |
1277 | (set result2 (subword HI rm 3)) | |
1278 | (set result3 (subword HI rn 3)) | |
1279 | (set rd (-join-hi result3 result2 result1 result0)))) | |
1280 | ||
1281 | (dshmi mshflob "Multimedia shuffle lower-half (byte)" | |
1282 | () | |
1283 | "mshflo.b $rm, $rn, $rd" | |
1284 | (+ (f-op 11) rm (f-ext 0) rn rd (f-rsvd 0)) | |
1285 | (sequence ((QI result7) (QI result6) (QI result5) (QI result4) | |
1286 | (QI result3) (QI result2) (QI result1) (QI result0)) | |
1287 | (set result0 (subword QI rm 0)) | |
1288 | (set result1 (subword QI rn 0)) | |
1289 | (set result2 (subword QI rm 1)) | |
1290 | (set result3 (subword QI rn 1)) | |
1291 | (set result4 (subword QI rm 2)) | |
1292 | (set result5 (subword QI rn 2)) | |
1293 | (set result6 (subword QI rm 3)) | |
1294 | (set result7 (subword QI rn 3)) | |
1295 | (set rd (-join-qi result7 result6 result5 result4 result3 | |
1296 | result2 result1 result0)))) | |
1297 | ||
1298 | (dshmi mshflol "Multimedia shuffle lower-half (long)" | |
1299 | () | |
1300 | "mshflo.l $rm, $rn, $rd" | |
1301 | (+ (f-op 11) rm (f-ext 2) rn rd (f-rsvd 0)) | |
1302 | (sequence ((SI result1) (SI result0)) | |
1303 | (set result0 (subword SI rm 0)) | |
1304 | (set result1 (subword SI rn 0)) | |
1305 | (set rd (-join-si result1 result0)))) | |
1306 | ||
1307 | (dshmi mshflow "Multimedia shuffle lower-half (word)" | |
1308 | () | |
1309 | "mshflo.w $rm, $rn, $rd" | |
1310 | (+ (f-op 11) rm (f-ext 1) rn rd (f-rsvd 0)) | |
1311 | (sequence ((HI result3) (HI result2) (HI result1) (HI result0)) | |
1312 | (set result0 (subword HI rm 0)) | |
1313 | (set result1 (subword HI rn 0)) | |
1314 | (set result2 (subword HI rm 1)) | |
1315 | (set result3 (subword HI rn 1)) | |
1316 | (set rd (-join-hi result3 result2 result1 result0)))) | |
1317 | ||
1318 | (define-pmacro (-mshlldl arg) (sll arg (and rn 31))) | |
1319 | (dshmi mshlldl "Multimedia logical left shift (long word)" | |
1320 | () | |
1321 | "mshlld.l $rm, $rn, $rd" | |
1322 | (+ (f-op 3) rm (f-ext 2) rn rd (f-rsvd 0)) | |
1323 | (slice-long-unop -mshlldl)) | |
1324 | ||
1325 | (define-pmacro (-mshlldw arg) (sll arg (and rn 15))) | |
1326 | (dshmi mshlldw "Multimedia logical left shift (word)" | |
1327 | () | |
1328 | "mshlld.w $rm, $rn, $rd" | |
1329 | (+ (f-op 3) rm (f-ext 1) rn rd (f-rsvd 0)) | |
1330 | (slice-word-unop -mshlldw)) | |
1331 | ||
1332 | (define-pmacro (-mshlrdl arg) (srl arg (and rn 31))) | |
1333 | (dshmi mshlrdl "Multimedia logical right shift (long word)" | |
1334 | () | |
1335 | "mshlrd.l $rm, $rn, $rd" | |
1336 | (+ (f-op 3) rm (f-ext 14) rn rd (f-rsvd 0)) | |
1337 | (slice-long-unop -mshlrdl)) | |
1338 | ||
1339 | (define-pmacro (-mshlrdw arg) (srl arg (and rn 15))) | |
1340 | (dshmi mshlrdw "Multimedia logical right shift (word)" | |
1341 | () | |
1342 | "mshlrd.w $rm, $rn, $rd" | |
1343 | (+ (f-op 3) rm (f-ext 13) rn rd (f-rsvd 0)) | |
1344 | (slice-word-unop -mshlrdw)) | |
1345 | ||
1346 | (dshmi msubl "Multimedia subtract (long word)" | |
1347 | () | |
1348 | "msub.l $rm, $rn, $rd" | |
1349 | (+ (f-op 2) rm (f-ext 10) rn rd (f-rsvd 0)) | |
1350 | (slice-long sub)) | |
1351 | ||
1352 | (dshmi msubw "Multimedia add (word)" | |
1353 | () | |
1354 | "msub.w $rm, $rn, $rd" | |
1355 | (+ (f-op 2) rm (f-ext 9) rn rd (f-rsvd 0)) | |
1356 | (slice-word sub)) | |
1357 | ||
1358 | (define-pmacro (-msubsl arg1 arg2) (saturate SI 32 (sub arg1 arg2))) | |
1359 | (dshmi msubsl "Multimedia subtract (saturating long)" | |
1360 | () | |
1361 | "msubs.l $rm, $rn, $rd" | |
1362 | (+ (f-op 2) rm (f-ext 14) rn rd (f-rsvd 0)) | |
1363 | (slice-long -msubsl)) | |
1364 | ||
1365 | (define-pmacro (-msubsub arg1 arg2) (usaturate QI 8 (sub arg1 arg2))) | |
1366 | (dshmi msubsub "Multimedia subtract (saturating byte)" | |
1367 | () | |
1368 | "msubs.ub $rm, $rn, $rd" | |
1369 | (+ (f-op 2) rm (f-ext 12) rn rd (f-rsvd 0)) | |
1370 | (slice-byte -msubsub)) | |
1371 | ||
1372 | (define-pmacro (-msubsw arg1 arg2) (saturate HI 16 (sub arg1 arg2))) | |
1373 | (dshmi msubsw "Multimedia subtract (saturating word)" | |
1374 | () | |
1375 | "msubs.w $rm, $rn, $rd" | |
1376 | (+ (f-op 2) rm (f-ext 13) rn rd (f-rsvd 0)) | |
1377 | (slice-byte -msubsw)) | |
1378 | ||
1379 | (dshmi mulsl "Multiply signed long" | |
1380 | () | |
1381 | "muls.l $rm, $rn, $rd" | |
1382 | (+ (f-op 1) rm (f-ext 14) rn rd (f-rsvd 0)) | |
1383 | (set rd (mul (ext DI (subword SI rm 1)) (ext DI (subword SI rn 1))))) | |
1384 | ||
1385 | (dshmi mulul "Multiply unsigned long" | |
1386 | () | |
1387 | "mulu.l $rm, $rn, $rd" | |
1388 | (+ (f-op 0) rm (f-ext 14) rn rd (f-rsvd 0)) | |
1389 | (set rd (mul (zext DI (subword SI rm 1)) (zext DI (subword SI rn 1))))) | |
1390 | ||
1391 | (dshmi nop "No operation" | |
1392 | () | |
1393 | "nop" | |
1394 | (+ (f-op 27) (f-left 63) (f-ext 0) (f-right 63) (f-dest 63) (f-rsvd 0)) | |
1395 | (nop)) | |
1396 | ||
1397 | (dshmi nsb "Number of consecutive sign bits" | |
1398 | () | |
1399 | "nsb $rm, $rd" | |
1400 | (+ (f-op 0) rm (f-ext 13) (f-right 63) rd (f-rsvd 0)) | |
1401 | ; Semantics requires a loop construct, so punt to C. | |
1402 | (set rd (c-call DI "sh64_nsb" rm))) | |
1403 | ||
1404 | (dshmi ocbi "Invalidate operand cache block" | |
1405 | () | |
1406 | "ocbi $rm, $disp6x32" | |
1407 | (+ (f-op 56) rm (f-ext 9) disp6x32 (f-dest 63) (f-rsvd 0)) | |
1408 | (unimp "ocbi")) | |
1409 | ||
1410 | (dshmi ocbp "Purge operand cache block" | |
1411 | () | |
1412 | "ocbp $rm, $disp6x32" | |
1413 | (+ (f-op 56) rm (f-ext 8) disp6x32 (f-dest 63) (f-rsvd 0)) | |
1414 | (unimp "ocbp")) | |
1415 | ||
1416 | (dshmi ocbwb "Write-back operand cache block" | |
1417 | () | |
1418 | "ocbwb $rm, $disp6x32" | |
1419 | (+ (f-op 56) rm (f-ext 12) disp6x32 (f-dest 63) (f-rsvd 0)) | |
1420 | (unimp "ocbwb")) | |
1421 | ||
1422 | (dshmi or "OR" | |
1423 | () | |
1424 | "or $rm, $rn, $rd" | |
1425 | (+ (f-op 1) rm (f-ext 9) rn rd (f-rsvd 0)) | |
1426 | (set rd (or rm rn))) | |
1427 | ||
1428 | (dshmi ori "OR immediate" | |
1429 | () | |
1430 | "ori $rm, $imm10, $rd" | |
1431 | (+ (f-op 55) rm imm10 rd (f-rsvd 0)) | |
1432 | (set rd (or rm (ext DI imm10)))) | |
1433 | ||
1434 | (dshmi prefi "Prefetch instruction" | |
1435 | () | |
1436 | "prefi $rm, $disp6x32" | |
1437 | (+ (f-op 56) rm (f-ext 1) disp6x32 (f-right 63) (f-rsvd 0)) | |
1438 | (unimp "prefi")) | |
1439 | ||
1440 | (dshmi pta "Prepare target register for SHmedia target" | |
1441 | () | |
1442 | "pta$likely $disp16, $tra" | |
1443 | (+ (f-op 58) disp16 likely (f-8-2 0) tra (f-rsvd 0)) | |
1444 | (set tra (add disp16 1))) | |
1445 | ||
1446 | (dshmi ptabs "Prepare target register with absolute value from register" | |
1447 | () | |
1448 | "ptabs$likely $rn, $tra" | |
1449 | (+ (f-op 26) (f-left 63) (f-ext 1) rn likely (f-8-2 0) tra (f-rsvd 0)) | |
1450 | (set tra rn)) | |
1451 | ||
1452 | (dshmi ptb "Prepare target register for SHcompact target" | |
1453 | () | |
1454 | "ptb$likely $disp16, $tra" | |
1455 | (+ (f-op 59) disp16 likely (f-8-2 0) tra (f-rsvd 0)) | |
1456 | (set tra disp16)) | |
1457 | ||
1458 | (dshmi ptrel "Prepare target register with relative value from register" | |
1459 | () | |
1460 | "ptrel$likely $rn, $tra" | |
1461 | (+ (f-op 26) (f-left 63) (f-ext 5) rn likely (f-8-2 0) tra (f-rsvd 0)) | |
1462 | (set tra (add pc rn))) | |
1463 | ||
1464 | (dshmi putcfg "Put configuration register" | |
1465 | () | |
1466 | "putcfg $rm, $disp6, $rd" | |
1467 | (+ (f-op 56) rm (f-ext 15) disp6 rd (f-rsvd 0)) | |
1468 | (unimp "putcfg")) | |
1469 | ||
1470 | (dshmi putcon "Put control register" | |
1471 | () | |
1472 | "putcon $rm, $crj" | |
1473 | (+ (f-op 27) rm (f-ext 15) (f-right 63) crj (f-rsvd 0)) | |
1474 | (set crj rm)) | |
1475 | ||
1476 | (dshmi rte "Return from exception" | |
1477 | () | |
1478 | "rte" | |
1479 | (+ (f-op 27) (f-left 63) (f-ext 3) (f-right 63) (f-dest 63) (f-rsvd 0)) | |
1480 | (unimp "rte")) | |
1481 | ||
1482 | (dshmi shard "Arithmetic right shift" | |
1483 | () | |
1484 | "shard $rm, $rn, $rd" | |
1485 | (+ (f-op 1) rm (f-ext 7) rn rd (f-rsvd 0)) | |
1486 | (set rd (sra rm (and rn 63)))) | |
1487 | ||
1488 | (dshmi shardl "Arithmetic right shift (long word)" | |
1489 | () | |
1490 | "shard.l $rm, $rn, $rd" | |
1491 | (+ (f-op 1) rm (f-ext 6) rn rd (f-rsvd 0)) | |
1492 | (set rd (ext DI (sra (subword SI rm 1) (and rn 63))))) | |
1493 | ||
1494 | (dshmi shari "Arithmetic right shift (immediate count)" | |
1495 | () | |
1496 | "shari $rm, $uimm6, $rd" | |
1497 | (+ (f-op 49) rm (f-ext 7) uimm6 rd (f-rsvd 0)) | |
1498 | (set rd (sra rm uimm6))) | |
1499 | ||
1500 | (dshmi sharil "Arithmetic right shift (long word, immediate count)" | |
1501 | () | |
1502 | "shari.l $rm, $uimm6, $rd" | |
1503 | (+ (f-op 49) rm (f-ext 6) uimm6 rd (f-rsvd 0)) | |
1504 | (set rd (ext DI (sra (subword SI rm 1) (and uimm6 63))))) | |
1505 | ||
1506 | (dshmi shlld "Logical left shift" | |
1507 | () | |
1508 | "shlld $rm, $rn, $rd" | |
1509 | (+ (f-op 1) rm (f-ext 1) rn rd (f-rsvd 0)) | |
1510 | (set rd (sll rm (and rn 63)))) | |
1511 | ||
1512 | (dshmi shlldl "Logical left shift (long word)" | |
1513 | () | |
1514 | "shlld.l $rm, $rn, $rd" | |
1515 | (+ (f-op 1) rm (f-ext 0) rn rd (f-rsvd 0)) | |
1516 | (set rd (ext DI (sll (subword SI rm 1) (and rn 63))))) | |
1517 | ||
1518 | (dshmi shlli "Logical left shift (immediate count)" | |
1519 | () | |
1520 | "shlli $rm, $uimm6, $rd" | |
1521 | (+ (f-op 49) rm (f-ext 1) uimm6 rd (f-rsvd 0)) | |
1522 | (set rd (sll rm uimm6))) | |
1523 | ||
1524 | (dshmi shllil "Logical left shift (long word, immediate count)" | |
1525 | () | |
1526 | "shlli.l $rm, $uimm6, $rd" | |
1527 | (+ (f-op 49) rm (f-ext 0) uimm6 rd (f-rsvd 0)) | |
1528 | (set rd (ext DI (sll (subword SI rm 1) (and uimm6 63))))) | |
1529 | ||
1530 | (dshmi shlrd "Logical right shift" | |
1531 | () | |
1532 | "shlrd $rm, $rn, $rd" | |
1533 | (+ (f-op 1) rm (f-ext 3) rn rd (f-rsvd 0)) | |
1534 | (set rd (srl rm (and rn 63)))) | |
1535 | ||
1536 | (dshmi shlrdl "Logical right shift (long word)" | |
1537 | () | |
1538 | "shlrd.l $rm, $rn, $rd" | |
1539 | (+ (f-op 1) rm (f-ext 2) rn rd (f-rsvd 0)) | |
1540 | (set rd (ext DI (srl (subword SI rm 1) (and rn 63))))) | |
1541 | ||
1542 | (dshmi shlri "Logical right shift (immediate count)" | |
1543 | () | |
1544 | "shlri $rm, $uimm6, $rd" | |
1545 | (+ (f-op 49) rm (f-ext 3) uimm6 rd (f-rsvd 0)) | |
1546 | (set rd (srl rm uimm6))) | |
1547 | ||
1548 | (dshmi shlril "Logical right shift (long word, immediate count)" | |
1549 | () | |
1550 | "shlri.l $rm, $uimm6, $rd" | |
1551 | (+ (f-op 49) rm (f-ext 2) uimm6 rd (f-rsvd 0)) | |
1552 | (set rd (ext DI (srl (subword SI rm 1) (and uimm6 63))))) | |
1553 | ||
1554 | (dshmi shori "Shift-or immediate" | |
1555 | () | |
1556 | "shori $uimm16, $rd" | |
1557 | (+ (f-op 50) uimm16 rd (f-rsvd 0)) | |
1558 | (set rd (or (sll rd 16) (zext DI uimm16)))) | |
1559 | ||
1560 | (dshmi sleep "Sleep" | |
1561 | () | |
1562 | "sleep" | |
1563 | (+ (f-op 27) (f-left 63) (f-ext 7) (f-right 63) (f-dest 63) (f-rsvd 0)) | |
1564 | (unimp "sleep")) | |
1565 | ||
1566 | (dshmi stb "Store byte" | |
1567 | () | |
1568 | "st.b $rm, $disp10, $rd" | |
1569 | (+ (f-op 40) rm disp10 rd (f-rsvd 0)) | |
1570 | (set (mem UQI (add rm (ext DI disp10))) (and QI rd #xff))) | |
1571 | ||
1572 | (dshmi stl "Store long word" | |
1573 | () | |
1574 | "st.l $rm, $disp10x4, $rd" | |
1575 | (+ (f-op 42) rm disp10x4 rd (f-rsvd 0)) | |
1576 | (set (mem SI (add rm (ext DI disp10x4))) (and SI rd #xffffffff))) | |
1577 | ||
1578 | (dshmi stq "Store quad word" | |
1579 | () | |
1580 | "st.q $rm, $disp10x8, $rd" | |
1581 | (+ (f-op 43) rm disp10x8 rd (f-rsvd 0)) | |
1582 | (set (mem DI (add rm (ext DI disp10x8))) rd)) | |
1583 | ||
1584 | (dshmi stw "Store word" | |
1585 | () | |
1586 | "st.w $rm, $disp10x2, $rd" | |
1587 | (+ (f-op 41) rm disp10x2 rd (f-rsvd 0)) | |
1588 | (set (mem HI (add rm (ext DI disp10x2))) (and HI rd #xffff))) | |
1589 | ||
1590 | (define-pmacro (-sthi-byte) | |
1591 | (sequence () | |
1592 | (set (mem UQI addr) (and QI val #xff)) | |
1593 | (set val (srl val 8)) | |
1594 | (set addr (add addr 1)))) | |
1595 | ||
1596 | (dshmi sthil "Store high part (long word)" | |
1597 | () | |
1598 | "sthi.l $rm, $disp6, $rd" | |
1599 | (+ (f-op 56) rm (f-ext 6) disp6 rd (f-rsvd 0)) | |
1600 | (sequence ((DI addr) (QI bytecount) (DI val)) | |
1601 | (set addr (add rm disp6)) | |
1602 | (set bytecount (add (and addr 3) 1)) | |
1603 | (if endian | |
1604 | (set val rd) | |
1605 | (set val (srl rd (sub 32 (mul 8 bytecount))))) | |
1606 | (set addr (add (sub addr bytecount) 1)) | |
1607 | (if (gt bytecount 3) | |
1608 | (-sthi-byte)) | |
1609 | (if (gt bytecount 2) | |
1610 | (-sthi-byte)) | |
1611 | (if (gt bytecount 1) | |
1612 | (-sthi-byte)) | |
1613 | (if (gt bytecount 0) | |
1614 | (-sthi-byte)))) | |
1615 | ||
1616 | (dshmi sthiq "Store high part (quad word)" | |
1617 | () | |
1618 | "sthi.q $rm, $disp6, $rd" | |
1619 | (+ (f-op 56) rm (f-ext 7) disp6 rd (f-rsvd 0)) | |
1620 | (sequence ((DI addr) (QI bytecount) (DI val)) | |
1621 | (set addr (add rm disp6)) | |
1622 | (set bytecount (add (and addr 7) 1)) | |
1623 | (if endian | |
1624 | (set val rd) | |
1625 | (set val (srl rd (sub 64 (mul 8 bytecount))))) | |
1626 | (set addr (add (sub addr bytecount) 1)) | |
1627 | (if (gt bytecount 7) | |
1628 | (-sthi-byte)) | |
1629 | (if (gt bytecount 6) | |
1630 | (-sthi-byte)) | |
1631 | (if (gt bytecount 5) | |
1632 | (-sthi-byte)) | |
1633 | (if (gt bytecount 4) | |
1634 | (-sthi-byte)) | |
1635 | (if (gt bytecount 3) | |
1636 | (-sthi-byte)) | |
1637 | (if (gt bytecount 2) | |
1638 | (-sthi-byte)) | |
1639 | (if (gt bytecount 1) | |
1640 | (-sthi-byte)) | |
1641 | (if (gt bytecount 0) | |
1642 | (-sthi-byte)))) | |
1643 | ||
1644 | (dshmi stlol "Store low part (long word)" | |
1645 | () | |
1646 | "stlo.l $rm, $disp6, $rd" | |
1647 | (+ (f-op 56) rm (f-ext 2) disp6 rd (f-rsvd 0)) | |
1648 | ; FIXME. | |
1649 | (unimp "stlol")) | |
1650 | ||
1651 | (dshmi stloq "Store low part (quad word)" | |
1652 | () | |
1653 | "stlo.q $rm, $disp6, $rd" | |
1654 | (+ (f-op 56) rm (f-ext 3) disp6 rd (f-rsvd 0)) | |
1655 | ; FIXME. | |
1656 | (unimp "stloq")) | |
1657 | ||
1658 | (dshmi stxb "Store byte (extended displacement)" | |
1659 | () | |
1660 | "stx.b $rm, $rn, $rd" | |
1661 | (+ (f-op 24) rm (f-ext 0) rn rd (f-rsvd 0)) | |
1662 | (set (mem UQI (add rm rn)) (subword QI rd 7))) | |
1663 | ||
1664 | (dshmi stxl "Store long (extended displacement)" | |
1665 | () | |
1666 | "stx.l $rm, $rn, $rd" | |
1667 | (+ (f-op 24) rm (f-ext 2) rn rd (f-rsvd 0)) | |
1668 | (set (mem SI (add rm rn)) (subword SI rd 1))) | |
1669 | ||
1670 | (dshmi stxq "Store quad word (extended displacement)" | |
1671 | () | |
1672 | "stx.q $rm, $rn, $rd" | |
1673 | (+ (f-op 24) rm (f-ext 3) rn rd (f-rsvd 0)) | |
1674 | (set (mem DI (add rm rn)) rd)) | |
1675 | ||
1676 | (dshmi stxw "Store word (extended displacement)" | |
1677 | () | |
1678 | "stx.w $rm, $rn, $rd" | |
1679 | (+ (f-op 24) rm (f-ext 1) rn rd (f-rsvd 0)) | |
1680 | (set (mem HI (add rm rn)) (subword HI rd 3))) | |
1681 | ||
1682 | (dshmi sub "Subtract" | |
1683 | () | |
1684 | "sub $rm, $rn, $rd" | |
1685 | (+ (f-op 0) rm (f-ext 11) rn rd (f-rsvd 0)) | |
1686 | (set rd (sub rm rn))) | |
1687 | ||
1688 | (dshmi subl "Subtract long" | |
1689 | () | |
1690 | "sub.l $rm, $rn, $rd" | |
1691 | (+ (f-op 0) rm (f-ext 10) rn rd (f-rsvd 0)) | |
1692 | (set rd (ext DI (sub (subword SI rm 1) (subword SI rn 1))))) | |
1693 | ||
1694 | (dshmi swapq "Swap quad words" | |
1695 | () | |
1696 | "swap.q $rm, $rn, $rd" | |
1697 | (+ (f-op 8) rm (f-ext 3) rn rd (f-rsvd 0)) | |
1698 | (sequence ((DI addr) (DI temp)) | |
1699 | (set addr (add rm rn)) | |
1700 | (set temp (mem DI addr)) | |
1701 | (set (mem DI addr) rd) | |
1702 | (set rd temp))) | |
1703 | ||
1704 | (dshmi synci "Synchronise instruction fetch" | |
1705 | () | |
1706 | "synci" | |
1707 | (+ (f-op 27) (f-left 63) (f-ext 2) (f-right 63) (f-dest 63) (f-rsvd 0)) | |
1708 | (unimp "synci")) | |
1709 | ||
1710 | (dshmi synco "Synchronise data operations" | |
1711 | () | |
1712 | "synco" | |
1713 | (+ (f-op 27) (f-left 63) (f-ext 6) (f-right 63) (f-dest 63) (f-rsvd 0)) | |
1714 | (unimp "synco")) | |
1715 | ||
1716 | (dshmi trapa "Trap" | |
1717 | () | |
1718 | "trapa $rm" | |
1719 | (+ (f-op 27) rm (f-ext 1) (f-right 63) (f-dest 63) (f-rsvd 0)) | |
1720 | (c-call "sh64_trapa" rm pc)) | |
1721 | ||
1722 | (dshmi xor "Exclusive OR" | |
1723 | () | |
1724 | "xor $rm, $rn, $rd" | |
1725 | (+ (f-op 1) rm (f-ext 13) rn rd (f-rsvd 0)) | |
1726 | (set rd (xor rm rn))) | |
1727 | ||
1728 | (dshmi xori "Exclusive OR immediate" | |
1729 | () | |
1730 | "xori $rm, $imm6, $rd" | |
1731 | (+ (f-op 49) rm (f-ext 13) rn rd (f-rsvd 0)) | |
1732 | (set rd (xor rm (ext DI imm6)))) |