sb1.igen 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. // -*- C -*-
  2. // Simulator definition for the Broadcom SiByte SB-1 CPU extensions.
  3. // Copyright (C) 2002-2022 Free Software Foundation, Inc.
  4. // Contributed by Ed Satterthwaite and Chris Demetriou, of Broadcom
  5. // Corporation (SiByte).
  6. //
  7. // This file is part of GDB, the GNU debugger.
  8. //
  9. // This program is free software; you can redistribute it and/or modify
  10. // it under the terms of the GNU General Public License as published by
  11. // the Free Software Foundation; either version 3 of the License, or
  12. // (at your option) any later version.
  13. //
  14. // This program is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. // GNU General Public License for more details.
  18. //
  19. // You should have received a copy of the GNU General Public License
  20. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. // Helper:
  22. //
  23. // Check that the SB-1 extension instruction can currently be used, and
  24. // signal a ReservedInstruction exception if not.
  25. //
  26. :function:::void:check_sbx:instruction_word insn
  27. *sb1:
  28. {
  29. if ((SR & status_SBX) == 0)
  30. SignalException(ReservedInstruction, insn);
  31. }
  32. // MDMX ASE Instructions
  33. // ---------------------
  34. //
  35. // The SB-1 implements the format OB subset of MDMX
  36. // and has three additions (pavg, pabsdiff, pabsdifc).
  37. // In addition, there are a couple of partial-decoding
  38. // issues for the read/write accumulator instructions.
  39. //
  40. // This code is structured so that mdmx.igen can be used by
  41. // selecting the allowed instructions either via model, or by
  42. // using check_mdmx_fmtsel and check_mdmx_fmtop to cause an
  43. // exception if the instruction is not allowed.
  44. :function:::void:check_mdmx:instruction_word insn
  45. *sb1:
  46. {
  47. if (!COP_Usable(1))
  48. SignalExceptionCoProcessorUnusable(1);
  49. if ((SR & status_MX) == 0)
  50. SignalExceptionMDMX();
  51. check_u64 (SD_, insn);
  52. }
  53. :function:::int:check_mdmx_fmtsel:instruction_word insn, int fmtsel
  54. *sb1:
  55. {
  56. switch (fmtsel & 0x03)
  57. {
  58. case 0x00: /* ob */
  59. case 0x02:
  60. return 1;
  61. case 0x01: /* qh */
  62. case 0x03: /* UNPREDICTABLE */
  63. SignalException (ReservedInstruction, insn);
  64. return 0;
  65. }
  66. return 0;
  67. }
  68. :function:::int:check_mdmx_fmtop:instruction_word insn, int fmtop
  69. *sb1:
  70. {
  71. switch (fmtop & 0x01)
  72. {
  73. case 0x00: /* ob */
  74. return 1;
  75. case 0x01: /* qh */
  76. SignalException (ReservedInstruction, insn);
  77. return 0;
  78. }
  79. return 0;
  80. }
  81. 011110,10,2.X!0,1.FMTOP,00000,00000,5.VD,111111:MDMX:64::RACH.sb1.fmt
  82. "rach.?<X>.%s<FMTOP> v<VD>"
  83. *sb1:
  84. {
  85. check_mdmx (SD_, instruction_0);
  86. check_mdmx_fmtop (SD_, instruction_0, FMTOP);
  87. /* No op. */
  88. }
  89. 011110,00,2.X!0,1.FMTOP,00000,00000,5.VD,111111:MDMX:64::RACL.sb1.fmt
  90. "racl.?<X>.%s<FMTOP> v<VD>"
  91. *sb1:
  92. {
  93. check_mdmx (SD_, instruction_0);
  94. check_mdmx_fmtop (SD_, instruction_0, FMTOP);
  95. /* No op. */
  96. }
  97. 011110,01,2.X!0,1.FMTOP,00000,00000,5.VD,111111:MDMX:64::RACM.sb1.fmt
  98. "racm.?<X>.%s<FMTOP> v<VD>"
  99. *sb1:
  100. {
  101. check_mdmx (SD_, instruction_0);
  102. check_mdmx_fmtop (SD_, instruction_0, FMTOP);
  103. /* No op. */
  104. }
  105. 011110,2.X1!0!1!2,2.X2,1.FMTOP,00000,00000,5.VD,111111:MDMX:64::RAC.sb1.fmt
  106. "rac?<X1>.?<X2> v<VD>"
  107. *sb1:
  108. {
  109. check_mdmx (SD_, instruction_0);
  110. check_mdmx_fmtop (SD_, instruction_0, FMTOP);
  111. /* No op. */
  112. }
  113. 011110,10,2.X!0,1.FMTOP,00000,5.VS,00000,111110:MDMX:64::WACH.sb1.fmt
  114. "wach.?<X>.%s<FMTOP> v<VS>"
  115. *sb1:
  116. {
  117. check_mdmx (SD_, instruction_0);
  118. check_mdmx_fmtop (SD_, instruction_0, FMTOP);
  119. /* No op. */
  120. }
  121. 011110,00,2.X!0,1.FMTOP,5.VT,5.VS,00000,111110:MDMX:64::WACL.sb1.fmt
  122. "wacl.?<X>.%s<FMTOP> v<VS>,v<VT>"
  123. *sb1:
  124. {
  125. check_mdmx (SD_, instruction_0);
  126. check_mdmx_fmtop (SD_, instruction_0, FMTOP);
  127. /* No op. */
  128. }
  129. 011110,2.X1!0!2,2.X2,1.FMTOP,5.VT,5.VS,00000,111110:MDMX:64::WAC.sb1.fmt
  130. "wacl?<X1>.?<X2>.%s<FMTOP> v<VS>,v<VT>"
  131. *sb1:
  132. {
  133. check_mdmx (SD_, instruction_0);
  134. check_mdmx_fmtop (SD_, instruction_0, FMTOP);
  135. /* No op. */
  136. }
  137. 011110,5.FMTSEL,5.VT,5.VS,5.VD,001001:MDMX:64::PABSDIFF.fmt
  138. "pabsdiff.%s<FMTSEL> v<VD>,v<VS>,v<VT>"
  139. *sb1:
  140. {
  141. check_mdmx (SD_, instruction_0);
  142. check_sbx (SD_, instruction_0);
  143. check_mdmx_fmtsel (SD_, instruction_0, FMTSEL);
  144. StoreFPR(VD,fmt_mdmx,MX_AbsDiff(ValueFPR(VS,fmt_mdmx),VT,FMTSEL));
  145. }
  146. 011110,5.FMTSEL,5.VT,5.VS,00000,110101:MDMX:64::PABSDIFC.fmt
  147. "pabsdifc.%<FMTSEL> v<VS>,v<VT>"
  148. *sb1:
  149. {
  150. check_mdmx (SD_, instruction_0);
  151. check_sbx (SD_, instruction_0);
  152. check_mdmx_fmtsel (SD_, instruction_0, FMTSEL);
  153. MX_AbsDiffC(ValueFPR(VS,fmt_mdmx),VT,FMTSEL);
  154. }
  155. 011110,5.FMTSEL,5.VT,5.VS,5.VD,001000:MDMX:64::PAVG.fmt
  156. "pavg.%s<FMTSEL> v<VD>,v<VS>,v<VT>"
  157. *sb1:
  158. {
  159. check_mdmx (SD_, instruction_0);
  160. check_sbx (SD_, instruction_0);
  161. check_mdmx_fmtsel (SD_, instruction_0, FMTSEL);
  162. StoreFPR(VD,fmt_mdmx,MX_Avg(ValueFPR(VS,fmt_mdmx),VT,FMTSEL));
  163. }
  164. // Paired-Single Extension Instructions
  165. // ------------------------------------
  166. //
  167. // The SB-1 implements several .PS format instructions that are
  168. // extensions to the MIPS64 architecture.
  169. 010001,10,3.FMT=6,5.FT,5.FS,5.FD,000011:COP1:32,f::DIV.PS
  170. "div.%s<FMT> f<FD>, f<FS>, f<FT>"
  171. *sb1:
  172. {
  173. int fmt = FMT;
  174. check_fpu (SD_);
  175. check_sbx (SD_, instruction_0);
  176. StoreFPR (FD, fmt, Divide (ValueFPR (FS, fmt), ValueFPR (FT, fmt), fmt));
  177. }
  178. 010001,10,3.FMT=6,00000,5.FS,5.FD,010101:COP1:32,f::RECIP.PS
  179. "recip.%s<FMT> f<FD>, f<FS>"
  180. *sb1:
  181. {
  182. int fmt = FMT;
  183. check_fpu (SD_);
  184. check_sbx (SD_, instruction_0);
  185. StoreFPR (FD, fmt, Recip (ValueFPR (FS, fmt), fmt));
  186. }
  187. 010001,10,3.FMT=6,00000,5.FS,5.FD,010110:COP1:32,f::RSQRT.PS
  188. "rsqrt.%s<FMT> f<FD>, f<FS>"
  189. *sb1:
  190. {
  191. int fmt = FMT;
  192. check_fpu (SD_);
  193. check_sbx (SD_, instruction_0);
  194. StoreFPR (FD, fmt, RSquareRoot (ValueFPR (FS, fmt), fmt));
  195. }
  196. 010001,10,3.FMT=6,00000,5.FS,5.FD,000100:COP1:32,f::SQRT.PS
  197. "sqrt.%s<FMT> f<FD>, f<FS>"
  198. *sb1:
  199. {
  200. int fmt = FMT;
  201. check_fpu (SD_);
  202. check_sbx (SD_, instruction_0);
  203. StoreFPR (FD, fmt, (SquareRoot (ValueFPR (FS, fmt), fmt)));
  204. }