3 // Simulator definition for the MIPS MDMX ASE.
4 // Copyright (C) 2002 Free Software Foundation, Inc.
5 // Contributed by Ed Satterthwaite and Chris Demetriou, of Broadcom
6 // Corporation (SiByte).
8 // This file is part of GDB, the GNU debugger.
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, or (at your option)
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.
20 // You should have received a copy of the GNU General Public License along
21 // with this program; if not, write to the Free Software Foundation, Inc.,
22 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 // Reference: MIPS64 Architecture Volume IV-b:
25 // The MDMX Application-Specific Extension
27 // Notes on "format selectors" (FMTSEL):
29 // A selector with final bit 0 indicates OB format.
30 // A selector with final bits 01 indicates QH format.
31 // A selector with final bits 11 has UNPREDICTABLE result per the spec.
33 // Similarly, for the single-bit fields which differentiate between
34 // formats (FMTOP), 0 is OB format and 1 is QH format.
36 // If you change this file to add instructions, please make sure that model
37 // "sb1" configurations still build, and that you've added no new
38 // instructions to the "sb1" model.
43 // Check whether MDMX is usable, and if not signal an appropriate exception.
46 :function:::void:check_mdmx:instruction_word insn
50 SignalExceptionCoProcessorUnusable (1);
51 if ((SR & (status_MX|status_FR)) != (status_MX|status_FR))
52 SignalExceptionMDMX ();
53 check_u64 (SD_, insn);
59 // Check whether a given MDMX format selector indicates a valid and usable
60 // format, and if not signal an appropriate exception.
63 :function:::int:check_mdmx_fmtsel:instruction_word insn, int fmtsel
66 switch (fmtsel & 0x03)
72 case 0x03: /* UNPREDICTABLE */
73 SignalException (ReservedInstruction, insn);
82 // Check whether a given MDMX format bit indicates a valid and usable
83 // format, and if not signal an appropriate exception.
86 :function:::int:check_mdmx_fmtop:instruction_word insn, int fmtop
99 :%s::::FMTSEL:int fmtsel
103 if ((fmtsel & 0x1) == 0)
105 else if ((fmtsel & 0x3) == 1)
112 :%s::::FMTOP:int fmtop
129 if ((shop & 0x11) == 0x00)
130 switch ((shop >> 1) & 0x07)
132 case 3: return "upsl.ob";
133 case 4: return "pach.ob";
134 case 6: return "mixh.ob";
135 case 7: return "mixl.ob";
138 else if ((shop & 0x03) == 0x01)
139 switch ((shop >> 2) & 0x07)
141 case 0: return "mixh.qh";
142 case 1: return "mixl.qh";
143 case 2: return "pach.qh";
144 case 4: return "bfla.qh";
145 case 6: return "repa.qh";
146 case 7: return "repb.qh";
154 011110,5.FMTSEL,5.VT,5.VS,5.VD,001011:MDMX:64::ADD.fmt
155 "add.%s<FMTSEL> v<VD>, v<VS>, v<VT>"
159 check_mdmx (SD_, instruction_0);
160 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
161 StoreFPR(VD,fmt_mdmx,MX_Add(ValueFPR(VS,fmt_mdmx),VT,FMTSEL));
165 011110,5.FMTSEL,5.VT,5.VS,0,0000,110111:MDMX:64::ADDA.fmt
166 "adda.%s<FMTSEL> v<VS>, v<VT>"
170 check_mdmx (SD_, instruction_0);
171 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
172 MX_AddA(ValueFPR(VS,fmt_mdmx),VT,FMTSEL);
176 011110,5.FMTSEL,5.VT,5.VS,1,0000,110111:MDMX:64::ADDL.fmt
177 "addl.%s<FMTSEL> v<VS>, v<VT>"
181 check_mdmx (SD_, instruction_0);
182 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
183 MX_AddL(ValueFPR(VS,fmt_mdmx),VT,FMTSEL);
187 011110,00,3.IMM,5.VT,5.VS,5.VD,0110,1.FMTOP,0:MDMX:64::ALNI.fmt
188 "alni.%s<FMTOP> v<VD>, v<VS>, v<VT>, <IMM>"
194 check_mdmx (SD_, instruction_0);
195 check_mdmx_fmtop (SD_, instruction_0, FMTOP);
197 result = ValueFPR(VS,fmt_mdmx) << s;
198 if (s != 0) // x86 gcc treats >> 64 as >> 0
199 result |= ValueFPR(VT,fmt_mdmx) >> (64 - s);
200 StoreFPR(VD,fmt_mdmx,result);
204 011110,5.RS,5.VT,5.VS,5.VD,0110,1.FMTOP,1:MDMX:64::ALNV.fmt
205 "alnv.%s<FMTOP> v<VD>, v<VS>, v<VT>, r<RS>"
211 check_mdmx (SD_, instruction_0);
212 check_mdmx_fmtop (SD_, instruction_0, FMTOP);
213 s = ((GPR[RS] & 0x7) << 3);
214 result = ValueFPR(VS,fmt_mdmx) << s;
215 if (s != 0) // x86 gcc treats >> 64 as >> 0
216 result |= ValueFPR(VT,fmt_mdmx) >> (64 - s);
217 StoreFPR(VD,fmt_mdmx,result);
221 011110,5.FMTSEL,5.VT,5.VS,5.VD,001100:MDMX:64::AND.fmt
222 "and.%s<FMTSEL> v<VD>, v<VS>, v<VT>"
226 check_mdmx (SD_, instruction_0);
227 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
228 StoreFPR(VD,fmt_mdmx,MX_And(ValueFPR(VS,fmt_mdmx),VT,FMTSEL));
232 011110,5.FMTSEL,5.VT,5.VS,00000,000001:MDMX:64::C.EQ.fmt
233 "c.eq.%s<FMTSEL> v<VS>, v<VT>"
237 check_mdmx (SD_, instruction_0);
238 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
239 MX_Comp(ValueFPR(VS,fmt_mdmx),MX_C_EQ,VT,FMTSEL);
243 011110,5.FMTSEL,5.VT,5.VS,00000,000101:MDMX:64::C.LE.fmt
244 "c.le.%s<FMTSEL> v<VS>, v<VT>"
248 check_mdmx (SD_, instruction_0);
249 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
250 MX_Comp(ValueFPR(VS,fmt_mdmx),MX_C_LT|MX_C_EQ,VT,FMTSEL);
254 011110,5.FMTSEL,5.VT,5.VS,00000,000100:MDMX:64::C.LT.fmt
255 "c.lt.%s<FMTSEL> v<VS>, v<VT>"
259 check_mdmx (SD_, instruction_0);
260 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
261 MX_Comp(ValueFPR(VS,fmt_mdmx),MX_C_LT,VT,FMTSEL);
265 011110,5.FMTSEL,5.VT,5.VS,5.VD,000111:MDMX:64::MAX.fmt
266 "max.%s<FMTSEL> v<VD>, v<VS>, v<VT>"
270 check_mdmx (SD_, instruction_0);
271 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
272 StoreFPR(VD,fmt_mdmx,MX_Max(ValueFPR(VS,fmt_mdmx),VT,FMTSEL));
276 011110,5.FMTSEL,5.VT,5.VS,5.VD,000110:MDMX:64::MIN.fmt
277 "min.%s<FMTSEL> v<VD>, v<VS>, v<VT>"
281 check_mdmx (SD_, instruction_0);
282 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
283 StoreFPR(VD,fmt_mdmx,MX_Min(ValueFPR(VS,fmt_mdmx),VT,FMTSEL));
287 011110,3.SEL,01,5.VT,5.VS,5.VD,000000:MDMX:64::MSGN.QH
288 "msgn.qh v<VD>, v<VS>, v<VT>"
291 check_mdmx (SD_, instruction_0);
292 StoreFPR(VD,fmt_mdmx,MX_Msgn(ValueFPR(VS,fmt_mdmx),VT,qh_fmtsel(SEL)));
296 011110,5.FMTSEL,5.VT,5.VS,5.VD,110000:MDMX:64::MUL.fmt
297 "mul.%s<FMTSEL> v<VD>, v<VS>, v<VT>"
301 check_mdmx (SD_, instruction_0);
302 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
303 StoreFPR(VD,fmt_mdmx,MX_Mul(ValueFPR(VS,fmt_mdmx),VT,FMTSEL));
307 011110,5.FMTSEL,5.VT,5.VS,0,0000,110011:MDMX:64::MULA.fmt
308 "mula.%s<FMTSEL> v<VS>, v<VT>"
312 check_mdmx (SD_, instruction_0);
313 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
314 MX_MulA(ValueFPR(VS,fmt_mdmx),VT,FMTSEL);
318 011110,5.FMTSEL,5.VT,5.VS,1,0000,110011:MDMX:64::MULL.fmt
319 "mull.%s<FMTSEL> v<VS>, v<VT>"
323 check_mdmx (SD_, instruction_0);
324 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
325 MX_MulL(ValueFPR(VS,fmt_mdmx),VT,FMTSEL);
329 011110,5.FMTSEL,5.VT,5.VS,0,0000,110010:MDMX:64::MULS.fmt
330 "muls.%s<FMTSEL> v<VS>, v<VT>"
334 check_mdmx (SD_, instruction_0);
335 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
336 MX_MulS(ValueFPR(VS,fmt_mdmx),VT,FMTSEL);
340 011110,5.FMTSEL,5.VT,5.VS,1,0000,110010:MDMX:64::MULSL.fmt
341 "mulsl.%s<FMTSEL> v<VS>, v<VT>"
345 check_mdmx (SD_, instruction_0);
346 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
347 MX_MulSL(ValueFPR(VS,fmt_mdmx),VT,FMTSEL);
351 011110,5.FMTSEL,5.VT,5.VS,5.VD,001111:MDMX:64::NOR.fmt
352 "nor.%s<FMTSEL> v<VD>, v<VS>, v<VT>"
356 check_mdmx (SD_, instruction_0);
357 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
358 StoreFPR(VD,fmt_mdmx,MX_Nor(ValueFPR(VS,fmt_mdmx),VT,FMTSEL));
362 011110,5.FMTSEL,5.VT,5.VS,5.VD,001110:MDMX:64::OR.fmt
363 "or.%s<FMTSEL> v<VD>, v<VS>, v<VT>"
367 check_mdmx (SD_, instruction_0);
368 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
369 StoreFPR(VD,fmt_mdmx,MX_Or(ValueFPR(VS,fmt_mdmx),VT,FMTSEL));
373 011110,5.FMTSEL,5.VT,5.VS,5.VD,000010:MDMX:64::PICKF.fmt
374 "pickf.%s<FMTSEL> v<VD>, v<VS>, v<VT>"
378 check_mdmx (SD_, instruction_0);
379 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
380 StoreFPR(VD,fmt_mdmx,MX_Pick(0,ValueFPR(VS,fmt_mdmx),VT,FMTSEL));
384 011110,5.FMTSEL,5.VT,5.VS,5.VD,000011:MDMX:64::PICKT.fmt
385 "pickt.%s<FMTSEL> v<VD>, v<VS>, v<VT>"
389 check_mdmx (SD_, instruction_0);
390 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
391 StoreFPR(VD,fmt_mdmx,MX_Pick(1,ValueFPR(VS,fmt_mdmx),VT,FMTSEL));
395 011110,1000,1.FMTOP,00000,00000,5.VD,111111:MDMX:64::RACH.fmt
396 "rach.%s<FMTOP> v<VD>"
400 check_mdmx (SD_, instruction_0);
401 check_mdmx_fmtop (SD_, instruction_0, FMTOP);
402 StoreFPR(VD,fmt_mdmx,MX_RAC(MX_RAC_H,FMTOP));
406 011110,0000,1.FMTOP,00000,00000,5.VD,111111:MDMX:64::RACL.fmt
407 "racl.%s<FMTOP> v<VD>"
411 check_mdmx (SD_, instruction_0);
412 check_mdmx_fmtop (SD_, instruction_0, FMTOP);
413 StoreFPR(VD,fmt_mdmx,MX_RAC(MX_RAC_L,FMTOP));
417 011110,0100,1.FMTOP,00000,00000,5.VD,111111:MDMX:64::RACM.fmt
418 "racm.%s<FMTOP> v<VD>"
422 check_mdmx (SD_, instruction_0);
423 check_mdmx_fmtop (SD_, instruction_0, FMTOP);
424 StoreFPR(VD,fmt_mdmx,MX_RAC(MX_RAC_M,FMTOP));
428 011110,3.SEL,01,5.VT,00000,5.VD,100101:MDMX:64::RNAS.QH
429 "rnas.qh v<VD>, v<VT>"
432 check_mdmx (SD_, instruction_0);
433 StoreFPR(VD,fmt_mdmx,MX_RNAS(VT,qh_fmtsel(SEL)));
437 011110,5.FMTSEL,5.VT,00000,5.VD,100001:MDMX:64::RNAU.fmt
438 "rnau.%s<FMTSEL> v<VD>, v<VT>"
442 check_mdmx (SD_, instruction_0);
443 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
444 StoreFPR(VD,fmt_mdmx,MX_RNAU(VT,FMTSEL));
448 011110,3.SEL,01,5.VT,00000,5.VD,100110:MDMX:64::RNES.QH
449 "rnes.qh v<VD>, v<VT>"
452 check_mdmx (SD_, instruction_0);
453 StoreFPR(VD,fmt_mdmx,MX_RNES(VT,qh_fmtsel(SEL)));
457 011110,5.FMTSEL,5.VT,00000,5.VD,100010:MDMX:64::RNEU.fmt
458 "rneu.%s<FMTSEL> v<VD>, v<VT>"
462 check_mdmx (SD_, instruction_0);
463 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
464 StoreFPR(VD,fmt_mdmx,MX_RNEU(VT,FMTSEL));
468 011110,3.SEL,01,5.VT,00000,5.VD,100100:MDMX:64::RZS.QH
469 "rzs.qh v<VD>, v<VT>"
472 check_mdmx (SD_, instruction_0);
473 StoreFPR(VD,fmt_mdmx,MX_RZS(VT,qh_fmtsel(SEL)));
477 011110,5.FMTSEL,5.VT,00000,5.VD,100000:MDMX:64::RZU.fmt
478 "rzu.%s<FMTSEL> v<VD>, v<VT>"
482 check_mdmx (SD_, instruction_0);
483 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
484 StoreFPR(VD,fmt_mdmx,MX_RZU(VT,FMTSEL));
488 011110,5.SHOP,5.VT,5.VS,5.VD,011111:MDMX:64::SHFL.op.fmt
489 "shfl.%s<SHOP> v<VD>, v<VS>, v<VT>"
493 check_mdmx (SD_, instruction_0);
494 if (check_mdmx_fmtsel (SD_, instruction_0, SHOP))
495 StoreFPR(VD,fmt_mdmx,MX_SHFL(SHOP,ValueFPR(VS,fmt_mdmx),ValueFPR(VT,fmt_mdmx)));
499 011110,5.FMTSEL,5.VT,5.VS,5.VD,010000:MDMX:64::SLL.fmt
500 "sll.%s<FMTSEL> v<VD>, v<VS>, v<VT>"
504 check_mdmx (SD_, instruction_0);
505 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
506 StoreFPR(VD,fmt_mdmx,MX_ShiftLeftLogical(ValueFPR(VS,fmt_mdmx),VT,FMTSEL));
510 011110,3.SEL,01,5.VT,5.VS,5.VD,010011:MDMX:64::SRA.QH
511 "sra.qh v<VD>, v<VS>, v<VT>"
514 check_mdmx (SD_, instruction_0);
515 StoreFPR(VD,fmt_mdmx,MX_ShiftRightArith(ValueFPR(VS,fmt_mdmx),VT,qh_fmtsel(SEL)));
519 011110,5.FMTSEL,5.VT,5.VS,5.VD,010010:MDMX:64::SRL.fmt
520 "srl.%s<FMTSEL> v<VD>, v<VS>, v<VT>"
524 check_mdmx (SD_, instruction_0);
525 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
526 StoreFPR(VD,fmt_mdmx,MX_ShiftRightLogical(ValueFPR(VS,fmt_mdmx),VT,FMTSEL));
530 011110,5.FMTSEL,5.VT,5.VS,5.VD,001010:MDMX:64::SUB.fmt
531 "sub.%s<FMTSEL> v<VD>, v<VS>, v<VT>"
535 check_mdmx (SD_, instruction_0);
536 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
537 StoreFPR(VD,fmt_mdmx,MX_Sub(ValueFPR(VS,fmt_mdmx),VT,FMTSEL));
541 011110,5.FMTSEL,5.VT,5.VS,0,0000,110110:MDMX:64::SUBA.fmt
542 "suba.%s<FMTSEL> v<VS>, v<VT>"
546 check_mdmx (SD_, instruction_0);
547 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
548 MX_SubA(ValueFPR(VS,fmt_mdmx),VT,FMTSEL);
552 011110,5.FMTSEL,5.VT,5.VS,1,0000,110110:MDMX:64::SUBL.fmt
553 "subl.%s<FMTSEL> v<VS>, v<VT>"
557 check_mdmx (SD_, instruction_0);
558 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
559 MX_SubL(ValueFPR(VS,fmt_mdmx),VT,FMTSEL);
563 011110,1000,1.FMTOP,00000,5.VS,00000,111110:MDMX:64::WACH.fmt
564 "wach.%s<FMTOP> v<VS>"
568 check_mdmx (SD_, instruction_0);
569 check_mdmx_fmtop (SD_, instruction_0, FMTOP);
570 MX_WACH(FMTOP,ValueFPR(VS,fmt_mdmx));
574 011110,0000,1.FMTOP,5.VT,5.VS,00000,111110:MDMX:64::WACL.fmt
575 "wacl.%s<FMTOP> v<VS>, v<VT>"
579 check_mdmx (SD_, instruction_0);
580 check_mdmx_fmtop (SD_, instruction_0, FMTOP);
581 MX_WACL(FMTOP,ValueFPR(VS,fmt_mdmx),ValueFPR(VT,fmt_mdmx));
585 011110,5.FMTSEL,5.VT,5.VS,5.VD,001101:MDMX:64::XOR.fmt
586 "xor.%s<FMTSEL> v<VD>, v<VS>, v<VT>"
590 check_mdmx (SD_, instruction_0);
591 if (check_mdmx_fmtsel (SD_, instruction_0, FMTSEL))
592 StoreFPR(VD,fmt_mdmx,MX_Xor(ValueFPR(VS,fmt_mdmx),VT,FMTSEL));