Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2143 lines
67 KiB

  1. // ******************************
  2. // Intel Confidential
  3. // ******************************
  4. // ******************************
  5. // asm mappings to instructions
  6. // ******************************
  7. // MACH
  8. #include "ki.h"
  9. #ifndef _STDIO_H
  10. #include <stdio.h>
  11. #endif
  12. #include "fepublic.h"
  13. #include "fehelper.h"
  14. #include "festate.h"
  15. #include "feinstr.h"
  16. // ******************************************************************
  17. // Public functions
  18. // ******************************************************************
  19. // ******************************************************************
  20. // fma: Floating point multiply add
  21. // ******************************************************************
  22. void
  23. fp82_fma(EM_state_type *ps,
  24. EM_opcode_pc_type pc,
  25. EM_opcode_sf_type sf,
  26. EM_pred_reg_specifier qp,
  27. EM_fp_reg_specifier f1,
  28. EM_fp_reg_specifier f3,
  29. EM_fp_reg_specifier f4,
  30. EM_fp_reg_specifier f2)
  31. {
  32. GETSTATE_F1(qp,f1,f3,f4,f2);
  33. _fma(ps, pc, sf, qp, f1, f3, f4, f2);
  34. PUTSTATE_F1(f1);
  35. }
  36. // ******************************************************************
  37. // fpma: Floating point parallel multiply add
  38. // ******************************************************************
  39. void
  40. fp82_fpma(EM_state_type *ps,
  41. EM_opcode_sf_type sf,
  42. EM_pred_reg_specifier qp,
  43. EM_fp_reg_specifier f1,
  44. EM_fp_reg_specifier f3,
  45. EM_fp_reg_specifier f4,
  46. EM_fp_reg_specifier f2)
  47. {
  48. GETSTATE_F1(qp,f1,f3,f4,f2);
  49. _fpma(ps, sf, qp, f1, f3, f4, f2);
  50. PUTSTATE_F1(f1);
  51. }
  52. // ******************************************************************
  53. // Floating-point Multiply Subtract
  54. // ******************************************************************
  55. void
  56. fp82_fms(EM_state_type *ps,
  57. EM_opcode_pc_type pc,
  58. EM_opcode_sf_type sf,
  59. EM_pred_reg_specifier qp,
  60. EM_fp_reg_specifier f1,
  61. EM_fp_reg_specifier f3,
  62. EM_fp_reg_specifier f4,
  63. EM_fp_reg_specifier f2)
  64. {
  65. GETSTATE_F1(qp,f1,f3,f4,f2);
  66. _fms(ps, pc, sf, qp, f1, f3, f4, f2);
  67. PUTSTATE_F1(f1);
  68. }
  69. // ******************************************************************
  70. // Floating-point Parallel Multiply Subtract
  71. // ******************************************************************
  72. void
  73. fp82_fpms(EM_state_type *ps,
  74. EM_opcode_sf_type sf,
  75. EM_pred_reg_specifier qp,
  76. EM_fp_reg_specifier f1,
  77. EM_fp_reg_specifier f3,
  78. EM_fp_reg_specifier f4,
  79. EM_fp_reg_specifier f2)
  80. {
  81. GETSTATE_F1(qp,f1,f3,f4,f2);
  82. _fpms(ps, sf, qp, f1, f3, f4, f2);
  83. PUTSTATE_F1(f1);
  84. }
  85. // ******************************************************************
  86. // Floating-point Negative Multiply Add
  87. // ******************************************************************
  88. void
  89. fp82_fnma(EM_state_type *ps,
  90. EM_opcode_pc_type pc,
  91. EM_opcode_sf_type sf,
  92. EM_pred_reg_specifier qp,
  93. EM_fp_reg_specifier f1,
  94. EM_fp_reg_specifier f3,
  95. EM_fp_reg_specifier f4,
  96. EM_fp_reg_specifier f2)
  97. {
  98. GETSTATE_F1(qp,f1,f3,f4,f2);
  99. _fnma(ps, pc, sf, qp, f1, f3, f4, f2);
  100. PUTSTATE_F1(f1);
  101. }
  102. // ******************************************************************
  103. // Floating-point Parallel Negative Multiply Add
  104. // ******************************************************************
  105. void
  106. fp82_fpnma(EM_state_type *ps,
  107. EM_opcode_sf_type sf,
  108. EM_pred_reg_specifier qp,
  109. EM_fp_reg_specifier f1,
  110. EM_fp_reg_specifier f3,
  111. EM_fp_reg_specifier f4,
  112. EM_fp_reg_specifier f2)
  113. {
  114. GETSTATE_F1(qp,f1,f3,f4,f2);
  115. _fpnma(ps, sf, qp, f1, f3, f4, f2);
  116. PUTSTATE_F1(f1);
  117. }
  118. // ******************************************************************
  119. // Floating-point Compare
  120. // ******************************************************************
  121. void
  122. fp82_fcmp_eq(EM_state_type *ps,
  123. EM_opcode_ctype_type fctype,
  124. EM_opcode_sf_type sf,
  125. EM_pred_reg_specifier qp,
  126. EM_pred_reg_specifier p1,
  127. EM_pred_reg_specifier p2,
  128. EM_fp_reg_specifier f2,
  129. EM_fp_reg_specifier f3)
  130. {
  131. GETSTATE_F4(qp,p1,p2,f2,f3);
  132. _fcmp(ps, frelEQ, fctype, sf, (EM_uint_t)qp,
  133. (EM_uint_t)p1, (EM_uint_t)p2, (EM_uint_t)f2, (EM_uint_t)f3);
  134. PUTSTATE_F4(p1,p2);
  135. }
  136. void
  137. fp82_fcmp_lt(EM_state_type *ps,
  138. EM_opcode_ctype_type fctype,
  139. EM_opcode_sf_type sf,
  140. EM_pred_reg_specifier qp,
  141. EM_pred_reg_specifier p1,
  142. EM_pred_reg_specifier p2,
  143. EM_fp_reg_specifier f2,
  144. EM_fp_reg_specifier f3)
  145. {
  146. GETSTATE_F4(qp,p1,p2,f2,f3);
  147. _fcmp(ps, frelLT, fctype, sf, (EM_uint_t)qp,
  148. (EM_uint_t)p1, (EM_uint_t)p2, (EM_uint_t)f2, (EM_uint_t)f3);
  149. PUTSTATE_F4(p1,p2);
  150. }
  151. void
  152. fp82_fcmp_le(EM_state_type *ps,
  153. EM_opcode_ctype_type fctype,
  154. EM_opcode_sf_type sf,
  155. EM_pred_reg_specifier qp,
  156. EM_pred_reg_specifier p1,
  157. EM_pred_reg_specifier p2,
  158. EM_fp_reg_specifier f2,
  159. EM_fp_reg_specifier f3)
  160. {
  161. GETSTATE_F4(qp,p1,p2,f2,f3);
  162. _fcmp(ps, frelLE, fctype, sf, (EM_uint_t)qp,
  163. (EM_uint_t)p1, (EM_uint_t)p2, (EM_uint_t)f2, (EM_uint_t)f3);
  164. PUTSTATE_F4(p1,p2);
  165. }
  166. void
  167. fp82_fcmp_unord(EM_state_type *ps,
  168. EM_opcode_ctype_type fctype,
  169. EM_opcode_sf_type sf,
  170. EM_pred_reg_specifier qp,
  171. EM_pred_reg_specifier p1,
  172. EM_pred_reg_specifier p2,
  173. EM_fp_reg_specifier f2,
  174. EM_fp_reg_specifier f3)
  175. {
  176. GETSTATE_F4(qp,p1,p2,f2,f3);
  177. _fcmp(ps, frelUNORD, fctype, sf, (EM_uint_t)qp,
  178. (EM_uint_t)p1, (EM_uint_t)p2, (EM_uint_t)f2, (EM_uint_t)f3);
  179. PUTSTATE_F4(p1,p2);
  180. }
  181. // ******************************************************************
  182. // Floating-point Reciprocal Approximation
  183. // ******************************************************************
  184. void
  185. fp82_frcpa(EM_state_type *ps,
  186. EM_opcode_sf_type sf,
  187. EM_pred_reg_specifier qp,
  188. EM_fp_reg_specifier f1,
  189. EM_pred_reg_specifier p2,
  190. EM_fp_reg_specifier f2,
  191. EM_fp_reg_specifier f3)
  192. {
  193. GETSTATE_F6(qp,f1,p2,f2,f3);
  194. _frcpa(ps, sf, qp, f1, p2, f2, f3);
  195. PUTSTATE_F6(f1,p2);
  196. }
  197. // ******************************************************************
  198. // Floating-point Parallel Reciprocal Approximation
  199. // ******************************************************************
  200. void
  201. fp82_fprcpa(EM_state_type *ps,
  202. EM_opcode_sf_type sf,
  203. EM_pred_reg_specifier qp,
  204. EM_fp_reg_specifier f1,
  205. EM_pred_reg_specifier p2,
  206. EM_fp_reg_specifier f2,
  207. EM_fp_reg_specifier f3)
  208. {
  209. GETSTATE_F6(qp,f1,p2,f2,f3);
  210. _fprcpa(ps, sf, qp, f1, p2, f2, f3);
  211. PUTSTATE_F6(f1,p2);
  212. }
  213. // ******************************************************************
  214. // Floating-point Reciprocal Square Root Approximation
  215. // ******************************************************************
  216. void
  217. fp82_frsqrta(EM_state_type *ps,
  218. EM_opcode_sf_type sf,
  219. EM_pred_reg_specifier qp,
  220. EM_fp_reg_specifier f1,
  221. EM_pred_reg_specifier p2,
  222. EM_fp_reg_specifier f3)
  223. {
  224. GETSTATE_F7(qp,f1,p2,f3);
  225. _frsqrta(ps, sf, qp, f1, p2, f3);
  226. PUTSTATE_F7(f1,p2);
  227. }
  228. // ******************************************************************
  229. // Floating-point Parallel Reciprocal Square Root Approximation
  230. // ******************************************************************
  231. void
  232. fp82_fprsqrta(EM_state_type *ps,
  233. EM_opcode_sf_type sf,
  234. EM_pred_reg_specifier qp,
  235. EM_fp_reg_specifier f1,
  236. EM_pred_reg_specifier p2,
  237. EM_fp_reg_specifier f3)
  238. {
  239. GETSTATE_F7(qp,f1,p2,f3);
  240. _fprsqrta(ps, sf, qp, f1, p2, f3);
  241. PUTSTATE_F7(f1,p2);
  242. }
  243. // ******************************************************************
  244. // Floating-point Minimum
  245. // ******************************************************************
  246. void
  247. fp82_fmin(EM_state_type *ps,
  248. EM_opcode_sf_type sf,
  249. EM_pred_reg_specifier qp,
  250. EM_fp_reg_specifier f1,
  251. EM_fp_reg_specifier f2,
  252. EM_fp_reg_specifier f3)
  253. {
  254. GETSTATE_F8(qp,f1,f2,f3);
  255. _fmin(ps, sf, qp, f1, f2, f3);
  256. PUTSTATE_F8(f1);
  257. }
  258. // ******************************************************************
  259. // Floating-point Maximum
  260. // ******************************************************************
  261. void
  262. fp82_fmax(EM_state_type *ps,
  263. EM_opcode_sf_type sf,
  264. EM_pred_reg_specifier qp,
  265. EM_fp_reg_specifier f1,
  266. EM_fp_reg_specifier f2,
  267. EM_fp_reg_specifier f3)
  268. {
  269. GETSTATE_F8(qp,f1,f2,f3);
  270. _fmax(ps, sf, qp, f1, f2, f3);
  271. PUTSTATE_F8(f1);
  272. }
  273. // ******************************************************************
  274. // Floating-point Absolute Minimum
  275. // ******************************************************************
  276. void
  277. fp82_famin(EM_state_type *ps,
  278. EM_opcode_sf_type sf,
  279. EM_pred_reg_specifier qp,
  280. EM_fp_reg_specifier f1,
  281. EM_fp_reg_specifier f2,
  282. EM_fp_reg_specifier f3)
  283. {
  284. GETSTATE_F8(qp,f1,f2,f3);
  285. _famin(ps, sf, (EM_uint_t)qp, (EM_uint_t)f1, (EM_uint_t)f2, (EM_uint_t)f3);
  286. PUTSTATE_F8(f1);
  287. }
  288. // ******************************************************************
  289. // Floating-point Absolute Maximum
  290. // ******************************************************************
  291. void
  292. fp82_famax(EM_state_type *ps,
  293. EM_opcode_sf_type sf,
  294. EM_pred_reg_specifier qp,
  295. EM_fp_reg_specifier f1,
  296. EM_fp_reg_specifier f2,
  297. EM_fp_reg_specifier f3)
  298. {
  299. GETSTATE_F8(qp,f1,f2,f3);
  300. _famax(ps, sf, (EM_uint_t)qp, (EM_uint_t)f1, (EM_uint_t)f2, (EM_uint_t)f3);
  301. PUTSTATE_F8(f1);
  302. }
  303. // ******************************************************************
  304. // Floating-point Parallel Minimum
  305. // ******************************************************************
  306. void
  307. fp82_fpmin(EM_state_type *ps,
  308. EM_opcode_sf_type sf,
  309. EM_pred_reg_specifier qp,
  310. EM_fp_reg_specifier f1,
  311. EM_fp_reg_specifier f2,
  312. EM_fp_reg_specifier f3)
  313. {
  314. GETSTATE_F8(qp,f1,f2,f3);
  315. _fpmin(ps, sf, qp, f1, f2, f3);
  316. PUTSTATE_F8(f1);
  317. }
  318. // ******************************************************************
  319. // Floating-point Parallel Maximum
  320. // ******************************************************************
  321. void
  322. fp82_fpmax(EM_state_type *ps,
  323. EM_opcode_sf_type sf,
  324. EM_pred_reg_specifier qp,
  325. EM_fp_reg_specifier f1,
  326. EM_fp_reg_specifier f2,
  327. EM_fp_reg_specifier f3)
  328. {
  329. GETSTATE_F8(qp,f1,f2,f3);
  330. _fpmax(ps, sf, qp, f1, f2, f3);
  331. PUTSTATE_F8(f1);
  332. }
  333. // ******************************************************************
  334. // Floating-point Parallel Absolute Minimum
  335. // ******************************************************************
  336. void
  337. fp82_fpamin(EM_state_type *ps,
  338. EM_opcode_sf_type sf,
  339. EM_pred_reg_specifier qp,
  340. EM_fp_reg_specifier f1,
  341. EM_fp_reg_specifier f2,
  342. EM_fp_reg_specifier f3)
  343. {
  344. GETSTATE_F8(qp,f1,f2,f3);
  345. _fpamin(ps, sf, (EM_uint_t)qp, (EM_uint_t)f1, (EM_uint_t)f2, (EM_uint_t)f3);
  346. PUTSTATE_F8(f1);
  347. }
  348. // ******************************************************************
  349. // Floating-point Parallel Absolute Maximum
  350. // ******************************************************************
  351. void
  352. fp82_fpamax(EM_state_type *ps,
  353. EM_opcode_sf_type sf,
  354. EM_pred_reg_specifier qp,
  355. EM_fp_reg_specifier f1,
  356. EM_fp_reg_specifier f2,
  357. EM_fp_reg_specifier f3)
  358. {
  359. GETSTATE_F8(qp,f1,f2,f3);
  360. _fpamax(ps, sf, (EM_uint_t)qp, (EM_uint_t)f1, (EM_uint_t)f2, (EM_uint_t)f3);
  361. PUTSTATE_F8(f1);
  362. }
  363. // ******************************************************************
  364. // Floating-point Parallel Compare
  365. // ******************************************************************
  366. void
  367. fp82_fpcmp_eq(EM_state_type *ps,
  368. EM_opcode_sf_type sf,
  369. EM_pred_reg_specifier qp,
  370. EM_fp_reg_specifier f1,
  371. EM_fp_reg_specifier f2,
  372. EM_fp_reg_specifier f3)
  373. {
  374. GETSTATE_F8(qp,f1,f2,f3);
  375. _fpcmp(ps, frelEQ, sf, (EM_uint_t)qp,
  376. (EM_uint_t)f1, (EM_uint_t)f2, (EM_uint_t)f3);
  377. PUTSTATE_F8(f1);
  378. }
  379. void
  380. fp82_fpcmp_lt(EM_state_type *ps,
  381. EM_opcode_sf_type sf,
  382. EM_pred_reg_specifier qp,
  383. EM_fp_reg_specifier f1,
  384. EM_fp_reg_specifier f2,
  385. EM_fp_reg_specifier f3)
  386. {
  387. GETSTATE_F8(qp,f1,f2,f3);
  388. _fpcmp(ps, frelLT, sf, (EM_uint_t)qp,
  389. (EM_uint_t)f1, (EM_uint_t)f2, (EM_uint_t)f3);
  390. PUTSTATE_F8(f1);
  391. }
  392. void
  393. fp82_fpcmp_le(EM_state_type *ps,
  394. EM_opcode_sf_type sf,
  395. EM_pred_reg_specifier qp,
  396. EM_fp_reg_specifier f1,
  397. EM_fp_reg_specifier f2,
  398. EM_fp_reg_specifier f3)
  399. {
  400. GETSTATE_F8(qp,f1,f2,f3);
  401. _fpcmp(ps, frelLE, sf, (EM_uint_t)qp,
  402. (EM_uint_t)f1, (EM_uint_t)f2, (EM_uint_t)f3);
  403. PUTSTATE_F8(f1);
  404. }
  405. void
  406. fp82_fpcmp_unord(EM_state_type *ps,
  407. EM_opcode_sf_type sf,
  408. EM_pred_reg_specifier qp,
  409. EM_fp_reg_specifier f1,
  410. EM_fp_reg_specifier f2,
  411. EM_fp_reg_specifier f3)
  412. {
  413. GETSTATE_F8(qp,f1,f2,f3);
  414. _fpcmp(ps, frelUNORD, sf, (EM_uint_t)qp,
  415. (EM_uint_t)f1, (EM_uint_t)f2, (EM_uint_t)f3);
  416. PUTSTATE_F8(f1);
  417. }
  418. void
  419. fp82_fpcmp_neq(EM_state_type *ps,
  420. EM_opcode_sf_type sf,
  421. EM_pred_reg_specifier qp,
  422. EM_fp_reg_specifier f1,
  423. EM_fp_reg_specifier f2,
  424. EM_fp_reg_specifier f3)
  425. {
  426. GETSTATE_F8(qp,f1,f2,f3);
  427. _fpcmp(ps,
  428. frelNEQ, sf, (EM_uint_t)qp,
  429. (EM_uint_t)f1, (EM_uint_t)f2, (EM_uint_t)f3);
  430. PUTSTATE_F8(f1);
  431. }
  432. void
  433. fp82_fpcmp_nlt(EM_state_type *ps,
  434. EM_opcode_sf_type sf,
  435. EM_pred_reg_specifier qp,
  436. EM_fp_reg_specifier f1,
  437. EM_fp_reg_specifier f2,
  438. EM_fp_reg_specifier f3)
  439. {
  440. GETSTATE_F8(qp,f1,f2,f3);
  441. _fpcmp(ps, frelNLT, sf, (EM_uint_t)qp,
  442. (EM_uint_t)f1, (EM_uint_t)f2, (EM_uint_t)f3);
  443. PUTSTATE_F8(f1);
  444. }
  445. void
  446. fp82_fpcmp_nle(EM_state_type *ps,
  447. EM_opcode_sf_type sf,
  448. EM_pred_reg_specifier qp,
  449. EM_fp_reg_specifier f1,
  450. EM_fp_reg_specifier f2,
  451. EM_fp_reg_specifier f3)
  452. {
  453. GETSTATE_F8(qp,f1,f2,f3);
  454. _fpcmp(ps, frelNLE, sf, (EM_uint_t)qp,
  455. (EM_uint_t)f1, (EM_uint_t)f2, (EM_uint_t)f3);
  456. PUTSTATE_F8(f1);
  457. }
  458. void
  459. fp82_fpcmp_ord(EM_state_type *ps,
  460. EM_opcode_sf_type sf,
  461. EM_pred_reg_specifier qp,
  462. EM_fp_reg_specifier f1,
  463. EM_fp_reg_specifier f2,
  464. EM_fp_reg_specifier f3)
  465. {
  466. GETSTATE_F8(qp,f1,f2,f3);
  467. _fpcmp(ps, frelORD, sf, (EM_uint_t)qp,
  468. (EM_uint_t)f1, (EM_uint_t)f2, (EM_uint_t)f3);
  469. PUTSTATE_F8(f1);
  470. }
  471. // ******************************************************************
  472. // Convert Floating-point to Integer
  473. // ******************************************************************
  474. void
  475. fp82_fcvt_fx(EM_state_type *ps,
  476. EM_opcode_sf_type sf,
  477. EM_pred_reg_specifier qp,
  478. EM_fp_reg_specifier f1,
  479. EM_fp_reg_specifier f2)
  480. {
  481. GETSTATE_F10(qp,f1,f2);
  482. SIGNED_FORM = 1;
  483. _fcvt_fx(ps, sf, (EM_uint_t)qp, (EM_uint_t)f1, (EM_uint_t)f2);
  484. PUTSTATE_F10(f1);
  485. }
  486. void
  487. fp82_fcvt_fxu(EM_state_type *ps,
  488. EM_opcode_sf_type sf,
  489. EM_pred_reg_specifier qp,
  490. EM_fp_reg_specifier f1,
  491. EM_fp_reg_specifier f2)
  492. {
  493. GETSTATE_F10(qp,f1,f2);
  494. UNSIGNED_FORM = 1;
  495. _fcvt_fx(ps, sf, (EM_uint_t)qp, (EM_uint_t)f1, (EM_uint_t)f2);
  496. PUTSTATE_F10(f1);
  497. }
  498. void
  499. fp82_fcvt_fx_trunc(EM_state_type *ps,
  500. EM_opcode_sf_type sf,
  501. EM_pred_reg_specifier qp,
  502. EM_fp_reg_specifier f1,
  503. EM_fp_reg_specifier f2)
  504. {
  505. GETSTATE_F10(qp,f1,f2);
  506. SIGNED_FORM = 1;
  507. TRUNC_FORM = 1;
  508. _fcvt_fx(ps, sf, (EM_uint_t)qp, (EM_uint_t)f1, (EM_uint_t)f2);
  509. PUTSTATE_F10(f1);
  510. }
  511. void
  512. fp82_fcvt_fxu_trunc(EM_state_type *ps,
  513. EM_opcode_sf_type sf,
  514. EM_pred_reg_specifier qp,
  515. EM_fp_reg_specifier f1,
  516. EM_fp_reg_specifier f2)
  517. {
  518. GETSTATE_F10(qp,f1,f2);
  519. TRUNC_FORM = 1;
  520. UNSIGNED_FORM = 1;
  521. _fcvt_fx(ps, sf, (EM_uint_t)qp, (EM_uint_t)f1, (EM_uint_t)f2);
  522. PUTSTATE_F10(f1);
  523. }
  524. // ******************************************************************
  525. // Parallel Convert Floating-point to Integer
  526. // ******************************************************************
  527. void
  528. fp82_fpcvt_fx(EM_state_type *ps,
  529. EM_opcode_sf_type sf,
  530. EM_pred_reg_specifier qp,
  531. EM_fp_reg_specifier f1,
  532. EM_fp_reg_specifier f2)
  533. {
  534. GETSTATE_F10(qp,f1,f2);
  535. SIGNED_FORM = 1;
  536. _fpcvt_fx(ps, sf, (EM_uint_t)qp, (EM_uint_t)f1, (EM_uint_t)f2);
  537. PUTSTATE_F10(f1);
  538. }
  539. void
  540. fp82_fpcvt_fxu(EM_state_type *ps,
  541. EM_opcode_sf_type sf,
  542. EM_pred_reg_specifier qp,
  543. EM_fp_reg_specifier f1,
  544. EM_fp_reg_specifier f2)
  545. {
  546. GETSTATE_F10(qp,f1,f2);
  547. UNSIGNED_FORM = 1;
  548. _fpcvt_fx(ps, sf, (EM_uint_t)qp, (EM_uint_t)f1, (EM_uint_t)f2);
  549. PUTSTATE_F10(f1);
  550. }
  551. void
  552. fp82_fpcvt_fx_trunc(EM_state_type *ps,
  553. EM_opcode_sf_type sf,
  554. EM_pred_reg_specifier qp,
  555. EM_fp_reg_specifier f1,
  556. EM_fp_reg_specifier f2)
  557. {
  558. GETSTATE_F10(qp,f1,f2);
  559. SIGNED_FORM = 1;
  560. TRUNC_FORM = 1;
  561. _fpcvt_fx(ps, sf, (EM_uint_t)qp, (EM_uint_t)f1, (EM_uint_t)f2);
  562. PUTSTATE_F10(f1);
  563. }
  564. void
  565. fp82_fpcvt_fxu_trunc(EM_state_type *ps,
  566. EM_opcode_sf_type sf,
  567. EM_pred_reg_specifier qp,
  568. EM_fp_reg_specifier f1,
  569. EM_fp_reg_specifier f2)
  570. {
  571. GETSTATE_F10(qp,f1,f2);
  572. TRUNC_FORM = 1;
  573. UNSIGNED_FORM = 1;
  574. _fpcvt_fx(ps, sf, (EM_uint_t)qp, (EM_uint_t)f1, (EM_uint_t)f2);
  575. PUTSTATE_F10(f1);
  576. }
  577. //***************************************************************
  578. // Instruction pages: The Underbar Routines
  579. //***************************************************************
  580. // ******************************************************************
  581. // _fma
  582. // ******************************************************************
  583. static INLINE void
  584. _fma(EM_state_type *ps,
  585. EM_opcode_pc_type pc,
  586. EM_opcode_sf_type sf,
  587. EM_uint_t qp,
  588. EM_uint_t f1,
  589. EM_uint_t f3,
  590. EM_uint_t f4,
  591. EM_uint_t f2)
  592. {
  593. EM_uint_t tmp_isrcode;
  594. EM_fp_reg_type tmp_default_result;
  595. EM_tmp_fp_env_type tmp_fp_env;
  596. EM_fp_dp_type tmp_res;
  597. /* EAS START */
  598. if (PR[qp]) {
  599. fp_check_target_register(f1);
  600. if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, f4))
  601. disabled_fp_register_fault(tmp_isrcode,0);
  602. if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3]) || fp_is_natval(FR[f4])) {
  603. FR[f1] = NATVAL;
  604. fp_update_psr(f1);
  605. } else {
  606. tmp_default_result = fma_exception_fault_check(f2, f3, f4,
  607. pc, sf, &tmp_fp_env);
  608. if (fp_raise_fault(tmp_fp_env)) {
  609. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  610. return; // MACH
  611. }
  612. if (fp_is_nan_or_inf(tmp_default_result)) {
  613. FR[f1] = tmp_default_result;
  614. } else {
  615. tmp_res = fp_mul(fp_reg_read(FR[f3]),
  616. fp_reg_read(FR[f4]));
  617. if (f2 != 0)
  618. tmp_res = fp_add(tmp_res, fp_reg_read(FR[f2]), tmp_fp_env);
  619. FR[f1] = fp_ieee_round(tmp_res, &tmp_fp_env);
  620. }
  621. fp_update_fpsr(sf, tmp_fp_env);
  622. fp_update_psr(f1);
  623. if (fp_raise_traps(tmp_fp_env))
  624. fp_exception_trap(fp_decode_trap(tmp_fp_env));
  625. }
  626. }
  627. /* EAS END */
  628. }
  629. // ******************************************************************
  630. // _fpma
  631. // ******************************************************************
  632. static INLINE void
  633. _fpma(EM_state_type *ps,
  634. EM_opcode_sf_type sf,
  635. EM_uint_t qp,
  636. EM_uint_t f1,
  637. EM_uint_t f3,
  638. EM_uint_t f4,
  639. EM_uint_t f2)
  640. {
  641. EM_uint_t tmp_isrcode, tmp_res_hi, tmp_res_lo;
  642. EM_pair_fp_reg_type tmp_default_result_pair;
  643. EM_tmp_fp_env_type tmp_fp_env;
  644. EM_fp_dp_type tmp_res;
  645. /* EAS START */
  646. if (PR[qp]) {
  647. fp_check_target_register(f1);
  648. if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, f4))
  649. disabled_fp_register_fault(tmp_isrcode,0);
  650. if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3]) || fp_is_natval(FR[f4])) {
  651. FR[f1] = NATVAL;
  652. fp_update_psr(f1);
  653. } else {
  654. tmp_default_result_pair = fpma_exception_fault_check(f2,
  655. f3, f4, sf, &tmp_fp_env);
  656. if (fp_raise_fault(tmp_fp_env)) {
  657. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  658. return; // MACH
  659. }
  660. if (fp_is_nan_or_inf(tmp_default_result_pair.hi)) {
  661. tmp_res_hi = fp_single(tmp_default_result_pair.hi);
  662. } else {
  663. tmp_res = fp_mul(fp_reg_read_hi(f3), fp_reg_read_hi(f4));
  664. if (f2 != 0)
  665. tmp_res = fp_add(tmp_res, fp_reg_read_hi(f2), tmp_fp_env);
  666. tmp_res_hi = fp_ieee_round_sp(tmp_res, high, &tmp_fp_env);
  667. }
  668. if (fp_is_nan_or_inf(tmp_default_result_pair.lo)) {
  669. tmp_res_lo = fp_single(tmp_default_result_pair.lo);
  670. } else {
  671. tmp_res = fp_mul(fp_reg_read_lo(f3), fp_reg_read_lo(f4));
  672. if (f2 != 0)
  673. tmp_res = fp_add(tmp_res, fp_reg_read_lo(f2), tmp_fp_env);
  674. tmp_res_lo = fp_ieee_round_sp(tmp_res, low, &tmp_fp_env);
  675. }
  676. FR[f1].significand = fp_concatenate(tmp_res_hi, tmp_res_lo);
  677. FR[f1].exponent = FP_INTEGER_EXP;
  678. FR[f1].sign = FP_SIGN_POSITIVE;
  679. fp_update_fpsr(sf, tmp_fp_env);
  680. fp_update_psr(f1);
  681. if (fp_raise_traps(tmp_fp_env))
  682. fp_exception_trap(fp_decode_trap(tmp_fp_env));
  683. }
  684. }
  685. /* EAS END */
  686. }
  687. // ******************************************************************
  688. // _fms
  689. // ******************************************************************
  690. static INLINE void
  691. _fms(EM_state_type *ps,
  692. EM_opcode_pc_type pc,
  693. EM_opcode_sf_type sf,
  694. EM_uint_t qp,
  695. EM_uint_t f1,
  696. EM_uint_t f3,
  697. EM_uint_t f4,
  698. EM_uint_t f2)
  699. {
  700. EM_uint_t tmp_isrcode;
  701. EM_fp_reg_type tmp_fr2, tmp_default_result;
  702. EM_fp_dp_type tmp_res;
  703. EM_tmp_fp_env_type tmp_fp_env;
  704. /* EAS START */
  705. if (PR[qp]) {
  706. fp_check_target_register(f1);
  707. if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, f4))
  708. disabled_fp_register_fault(tmp_isrcode,0);
  709. if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3]) || fp_is_natval(FR[f4])) {
  710. FR[f1] = NATVAL;
  711. fp_update_psr(f1);
  712. } else {
  713. tmp_default_result = fms_fnma_exception_fault_check(f2, f3, f4,
  714. pc, sf, &tmp_fp_env);
  715. if (fp_raise_fault(tmp_fp_env)) {
  716. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  717. return; // MACH
  718. }
  719. if (fp_is_nan_or_inf(tmp_default_result)) {
  720. FR[f1] = tmp_default_result;
  721. } else {
  722. tmp_res = fp_mul(fp_reg_read(FR[f3]), fp_reg_read(FR[f4]));
  723. tmp_fr2 = fp_reg_read(FR[f2]);
  724. tmp_fr2.sign = !tmp_fr2.sign;
  725. if (f2 != 0)
  726. tmp_res = fp_add(tmp_res, tmp_fr2, tmp_fp_env);
  727. FR[f1] = fp_ieee_round(tmp_res, &tmp_fp_env);
  728. }
  729. fp_update_fpsr(sf, tmp_fp_env);
  730. fp_update_psr(f1);
  731. if (fp_raise_traps(tmp_fp_env))
  732. fp_exception_trap(fp_decode_trap(tmp_fp_env));
  733. }
  734. }
  735. /* EAS END */
  736. }
  737. // ******************************************************************
  738. // _fpms
  739. // ******************************************************************
  740. static INLINE void
  741. _fpms(EM_state_type *ps,
  742. EM_opcode_sf_type sf,
  743. EM_uint_t qp,
  744. EM_uint_t f1,
  745. EM_uint_t f3,
  746. EM_uint_t f4,
  747. EM_uint_t f2)
  748. {
  749. EM_uint_t tmp_isrcode, tmp_res_hi, tmp_res_lo;
  750. EM_pair_fp_reg_type tmp_default_result_pair;
  751. EM_fp_reg_type tmp_sub;
  752. EM_fp_dp_type tmp_res;
  753. EM_tmp_fp_env_type tmp_fp_env;
  754. /* EAS START */
  755. if (PR[qp]) {
  756. fp_check_target_register(f1);
  757. if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, f4))
  758. disabled_fp_register_fault(tmp_isrcode,0);
  759. if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3]) || fp_is_natval(FR[f4])) {
  760. FR[f1] = NATVAL;
  761. fp_update_psr(f1);
  762. } else {
  763. tmp_default_result_pair = fpms_fpnma_exception_fault_check(f2, f3, f4,
  764. sf, &tmp_fp_env);
  765. if (fp_raise_fault(tmp_fp_env)) {
  766. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  767. return; // MACH
  768. }
  769. if (fp_is_nan_or_inf(tmp_default_result_pair.hi)) {
  770. tmp_res_hi = fp_single(tmp_default_result_pair.hi);
  771. } else {
  772. tmp_res = fp_mul(fp_reg_read_hi(f3), fp_reg_read_hi(f4));
  773. if (f2 != 0) {
  774. tmp_sub = fp_reg_read_hi(f2);
  775. tmp_sub.sign = !tmp_sub.sign;
  776. tmp_res = fp_add(tmp_res, tmp_sub, tmp_fp_env);
  777. }
  778. tmp_res_hi = fp_ieee_round_sp(tmp_res, high, &tmp_fp_env);
  779. }
  780. if (fp_is_nan_or_inf(tmp_default_result_pair.lo)) {
  781. tmp_res_lo = fp_single(tmp_default_result_pair.lo);
  782. } else {
  783. tmp_res = fp_mul(fp_reg_read_lo(f3), fp_reg_read_lo(f4));
  784. if (f2 != 0) {
  785. tmp_sub = fp_reg_read_lo(f2);
  786. tmp_sub.sign = !tmp_sub.sign;
  787. tmp_res = fp_add(tmp_res, tmp_sub, tmp_fp_env);
  788. }
  789. tmp_res_lo = fp_ieee_round_sp(tmp_res, low, &tmp_fp_env);
  790. }
  791. FR[f1].significand = fp_concatenate(tmp_res_hi, tmp_res_lo);
  792. FR[f1].exponent = FP_INTEGER_EXP;
  793. FR[f1].sign = FP_SIGN_POSITIVE;
  794. fp_update_fpsr(sf, tmp_fp_env);
  795. fp_update_psr(f1);
  796. if (fp_raise_traps(tmp_fp_env))
  797. fp_exception_trap(fp_decode_trap(tmp_fp_env));
  798. }
  799. }
  800. /* EAS END */
  801. }
  802. // ******************************************************************
  803. // _fnma
  804. // ******************************************************************
  805. static INLINE void
  806. _fnma(EM_state_type *ps,
  807. EM_opcode_pc_type pc,
  808. EM_opcode_sf_type sf,
  809. EM_uint_t qp,
  810. EM_uint_t f1,
  811. EM_uint_t f3,
  812. EM_uint_t f4,
  813. EM_uint_t f2)
  814. {
  815. EM_uint_t tmp_isrcode;
  816. EM_fp_reg_type tmp_default_result;
  817. EM_tmp_fp_env_type tmp_fp_env;
  818. EM_fp_dp_type tmp_res;
  819. /* EAS START */
  820. if (PR[qp]) {
  821. fp_check_target_register(f1);
  822. if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, f4))
  823. disabled_fp_register_fault(tmp_isrcode,0);
  824. if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3]) || fp_is_natval(FR[f4])) {
  825. FR[f1] = NATVAL;
  826. fp_update_psr(f1);
  827. } else {
  828. tmp_default_result = fms_fnma_exception_fault_check(f2, f3, f4,
  829. pc, sf, &tmp_fp_env);
  830. if (fp_raise_fault(tmp_fp_env)) {
  831. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  832. return; // MACH
  833. }
  834. if (fp_is_nan_or_inf(tmp_default_result)) {
  835. FR[f1] = tmp_default_result;
  836. } else {
  837. tmp_res = fp_mul(fp_reg_read(FR[f3]), fp_reg_read(FR[f4]));
  838. tmp_res.sign = !tmp_res.sign;
  839. if (f2 != 0)
  840. tmp_res = fp_add(tmp_res, fp_reg_read(FR[f2]), tmp_fp_env);
  841. FR[f1] = fp_ieee_round(tmp_res, &tmp_fp_env);
  842. }
  843. fp_update_fpsr(sf, tmp_fp_env);
  844. fp_update_psr(f1);
  845. if (fp_raise_traps(tmp_fp_env))
  846. fp_exception_trap(fp_decode_trap(tmp_fp_env));
  847. }
  848. }
  849. /* EAS END */
  850. }
  851. // ******************************************************************
  852. // _fpnma
  853. // ******************************************************************
  854. static INLINE void
  855. _fpnma(EM_state_type *ps,
  856. EM_opcode_sf_type sf,
  857. EM_uint_t qp,
  858. EM_uint_t f1,
  859. EM_uint_t f3,
  860. EM_uint_t f4,
  861. EM_uint_t f2)
  862. {
  863. EM_uint_t tmp_isrcode, tmp_res_hi, tmp_res_lo;
  864. EM_pair_fp_reg_type tmp_default_result_pair;
  865. EM_tmp_fp_env_type tmp_fp_env;
  866. EM_fp_dp_type tmp_res;
  867. /* EAS START */
  868. if (PR[qp]) {
  869. fp_check_target_register(f1);
  870. if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, f4))
  871. disabled_fp_register_fault(tmp_isrcode,0);
  872. if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3]) || fp_is_natval(FR[f4])) {
  873. FR[f1] = NATVAL;
  874. fp_update_psr(f1);
  875. } else {
  876. tmp_default_result_pair = fpms_fpnma_exception_fault_check(f2, f3, f4,
  877. sf, &tmp_fp_env);
  878. if (fp_raise_fault(tmp_fp_env)) {
  879. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  880. return; // MACH
  881. }
  882. if (fp_is_nan_or_inf(tmp_default_result_pair.hi)) {
  883. tmp_res_hi = fp_single(tmp_default_result_pair.hi);
  884. } else {
  885. tmp_res = fp_mul(fp_reg_read_hi(f3), fp_reg_read_hi(f4));
  886. tmp_res.sign = !tmp_res.sign;
  887. if (f2 != 0)
  888. tmp_res = fp_add(tmp_res, fp_reg_read_hi(f2), tmp_fp_env);
  889. tmp_res_hi = fp_ieee_round_sp(tmp_res, high, &tmp_fp_env);
  890. }
  891. if (fp_is_nan_or_inf(tmp_default_result_pair.lo)) {
  892. tmp_res_lo = fp_single(tmp_default_result_pair.lo);
  893. } else {
  894. tmp_res = fp_mul(fp_reg_read_lo(f3), fp_reg_read_lo(f4));
  895. tmp_res.sign = !tmp_res.sign;
  896. if (f2 != 0)
  897. tmp_res = fp_add(tmp_res, fp_reg_read_lo(f2), tmp_fp_env);
  898. tmp_res_lo = fp_ieee_round_sp(tmp_res, low, &tmp_fp_env);
  899. }
  900. FR[f1].significand = fp_concatenate(tmp_res_hi, tmp_res_lo);
  901. FR[f1].exponent = FP_INTEGER_EXP;
  902. FR[f1].sign = FP_SIGN_POSITIVE;
  903. fp_update_fpsr(sf, tmp_fp_env);
  904. fp_update_psr(f1);
  905. if (fp_raise_traps(tmp_fp_env))
  906. fp_exception_trap(fp_decode_trap(tmp_fp_env));
  907. }
  908. }
  909. /* EAS END */
  910. }
  911. // ******************************************************************
  912. // _fcmp
  913. // ******************************************************************
  914. static INLINE void
  915. _fcmp(EM_state_type *ps,
  916. EM_opcode_frel_type frel,
  917. EM_opcode_ctype_type fctype,
  918. EM_opcode_sf_type sf,
  919. EM_uint_t qp,
  920. EM_uint_t p1,
  921. EM_uint_t p2,
  922. EM_uint_t f2,
  923. EM_uint_t f3)
  924. {
  925. EM_uint_t tmp_isrcode;
  926. EM_fp_reg_type tmp_fr2, tmp_fr3;
  927. EM_tmp_fp_env_type tmp_fp_env;
  928. EM_boolean_t tmp_rel;
  929. /* EAS START */
  930. if (PR[qp]) {
  931. if(p1==p2)
  932. illegal_operation_fault(0);
  933. if (tmp_isrcode = fp_reg_disabled(f2, f3, 0, 0))
  934. disabled_fp_register_fault(tmp_isrcode,0);
  935. if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
  936. PR[p1] = 0;
  937. PR[p2] = 0;
  938. } else {
  939. fcmp_exception_fault_check(f2, f3, frel, sf, &tmp_fp_env);
  940. if (fp_raise_fault(tmp_fp_env)) {
  941. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  942. return; // MACH
  943. }
  944. tmp_fr2 = fp_reg_read(FR[f2]);
  945. tmp_fr3 = fp_reg_read(FR[f3]);
  946. if (frel == frelEQ) tmp_rel = fp_equal(tmp_fr2, tmp_fr3);
  947. else if (frel == frelLT) tmp_rel = fp_less_than(tmp_fr2, tmp_fr3);
  948. else if (frel == frelLE) tmp_rel = fp_lesser_or_equal(tmp_fr2, tmp_fr3);
  949. else if (frel == frelGT) tmp_rel = fp_less_than(tmp_fr3, tmp_fr2);
  950. else if (frel == frelGE) tmp_rel = fp_lesser_or_equal(tmp_fr3, tmp_fr2);
  951. else if (frel == frelUNORD) tmp_rel = fp_unordered(tmp_fr2, tmp_fr3);
  952. else if (frel == frelNEQ) tmp_rel = !fp_equal(tmp_fr2, tmp_fr3);
  953. else if (frel == frelNLT) tmp_rel = !fp_less_than(tmp_fr2, tmp_fr3);
  954. else if (frel == frelNLE) tmp_rel = !fp_lesser_or_equal(tmp_fr2, tmp_fr3);
  955. else if (frel == frelNGT) tmp_rel = !fp_less_than(tmp_fr3, tmp_fr2);
  956. else if (frel == frelNGE) tmp_rel = !fp_lesser_or_equal(tmp_fr3, tmp_fr2);
  957. else tmp_rel = !fp_unordered(tmp_fr2, tmp_fr3);
  958. PR[p1] = tmp_rel;
  959. PR[p2] = !tmp_rel;
  960. fp_update_fpsr(sf, tmp_fp_env);
  961. }
  962. } else {
  963. if (fctype == fctypeUNC) {
  964. if(p1==p2)
  965. illegal_operation_fault(0);
  966. PR[p1] = 0;
  967. PR[p2] = 0;
  968. }
  969. }
  970. /* EAS END */
  971. }
  972. // ******************************************************************
  973. // _frcpa
  974. // ******************************************************************
  975. static INLINE void
  976. _frcpa(EM_state_type *ps,
  977. EM_opcode_sf_type sf,
  978. EM_uint_t qp,
  979. EM_uint_t f1,
  980. EM_uint_t p2,
  981. EM_uint_t f2,
  982. EM_uint_t f3)
  983. {
  984. EM_uint_t tmp_isrcode;
  985. EM_fp_reg_type tmp_default_result, num, den;
  986. EM_tmp_fp_env_type tmp_fp_env;
  987. /* EAS START */
  988. if (PR[qp]) {
  989. fp_check_target_register(f1);
  990. if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
  991. disabled_fp_register_fault(tmp_isrcode,0);
  992. if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
  993. FR[f1] = NATVAL;
  994. PR[p2] = 0;
  995. } else {
  996. tmp_default_result = frcpa_exception_fault_check(f2, f3, sf, &tmp_fp_env);
  997. if (fp_raise_fault(tmp_fp_env)) {
  998. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  999. return; // MACH
  1000. }
  1001. if (fp_is_nan_or_inf(tmp_default_result)) {
  1002. FR[f1] = tmp_default_result;
  1003. PR[p2] = 0;
  1004. } else {
  1005. num = fp_normalize(fp_reg_read(FR[f2]));
  1006. den = fp_normalize(fp_reg_read(FR[f3]));
  1007. if (fp_is_inf(num) && fp_is_finite(den)) {
  1008. FR[f1] = FP_INFINITY;
  1009. FR[f1].sign = num.sign ^ den.sign;
  1010. PR[p2] = 0;
  1011. } else if (fp_is_finite(num) && fp_is_inf(den)) {
  1012. FR[f1] = FP_ZERO;
  1013. FR[f1].sign = num.sign ^ den.sign;
  1014. PR[p2] = 0;
  1015. } else if (fp_is_zero(num) && fp_is_finite(den)) {
  1016. FR[f1] = FP_ZERO;
  1017. FR[f1].sign = num.sign ^ den.sign;
  1018. PR[p2] = 0;
  1019. } else {
  1020. FR[f1] = fp_ieee_recip(den);
  1021. PR[p2] = 1;
  1022. }
  1023. }
  1024. fp_update_fpsr(sf, tmp_fp_env);
  1025. }
  1026. fp_update_psr(f1);
  1027. } else {
  1028. PR[p2] = 0;
  1029. }
  1030. /* EAS END */
  1031. }
  1032. // ******************************************************************
  1033. // _fprcpa
  1034. // ******************************************************************
  1035. static INLINE void
  1036. _fprcpa(EM_state_type *ps,
  1037. EM_opcode_sf_type sf,
  1038. EM_uint_t qp,
  1039. EM_uint_t f1,
  1040. EM_uint_t p2,
  1041. EM_uint_t f2,
  1042. EM_uint_t f3)
  1043. {
  1044. EM_uint_t tmp_isrcode, tmp_res_hi, tmp_res_lo;
  1045. EM_pair_fp_reg_type tmp_default_result_pair;
  1046. EM_fp_reg_type tmp_res, num, den;
  1047. EM_boolean_t tmp_pred_hi, tmp_pred_lo;
  1048. EM_tmp_fp_env_type tmp_fp_env;
  1049. EM_limits_check_fprcpa limits_check = {0,0,0,0};
  1050. /* EAS START */
  1051. if (PR[qp]) {
  1052. fp_check_target_register(f1);
  1053. if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
  1054. disabled_fp_register_fault(tmp_isrcode,0);
  1055. if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
  1056. FR[f1] = NATVAL;
  1057. PR[p2] = 0;
  1058. } else {
  1059. tmp_default_result_pair = fprcpa_exception_fault_check(f2, f3, sf,
  1060. &tmp_fp_env, &limits_check);
  1061. if (fp_raise_fault(tmp_fp_env)) {
  1062. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  1063. return; // MACH
  1064. }
  1065. if (fp_is_nan_or_inf(tmp_default_result_pair.hi) || limits_check.hi_fr3) {
  1066. tmp_res_hi = fp_single(tmp_default_result_pair.hi);
  1067. tmp_pred_hi = 0;
  1068. } else {
  1069. num = fp_normalize(fp_reg_read_hi(f2));
  1070. den = fp_normalize(fp_reg_read_hi(f3));
  1071. if (fp_is_inf(num) && fp_is_finite(den)) {
  1072. tmp_res = FP_INFINITY;
  1073. tmp_res.sign = num.sign ^ den.sign;
  1074. tmp_pred_hi = 0;
  1075. } else if (fp_is_finite(num) && fp_is_inf(den)) {
  1076. tmp_res = FP_ZERO;
  1077. tmp_res.sign = num.sign ^ den.sign;
  1078. tmp_pred_hi = 0;
  1079. } else if (fp_is_zero(num) && fp_is_finite(den)) {
  1080. tmp_res = FP_ZERO;
  1081. tmp_res.sign = num.sign ^ den.sign;
  1082. tmp_pred_hi = 0;
  1083. } else {
  1084. tmp_res = fp_ieee_recip(den);
  1085. if (limits_check.hi_fr2_or_quot) {
  1086. tmp_pred_hi = 0;
  1087. } else {
  1088. tmp_pred_hi = 1;
  1089. }
  1090. }
  1091. tmp_res_hi = fp_single(tmp_res);
  1092. }
  1093. if (fp_is_nan_or_inf(tmp_default_result_pair.lo) || limits_check.lo_fr3) {
  1094. tmp_res_lo = fp_single(tmp_default_result_pair.lo);
  1095. tmp_pred_lo = 0;
  1096. } else {
  1097. num = fp_normalize(fp_reg_read_lo(f2));
  1098. den = fp_normalize(fp_reg_read_lo(f3));
  1099. if (fp_is_inf(num) && fp_is_finite(den)) {
  1100. tmp_res = FP_INFINITY;
  1101. tmp_res.sign = num.sign ^ den.sign;
  1102. tmp_pred_lo = 0;
  1103. } else if (fp_is_finite(num) && fp_is_inf(den)) {
  1104. tmp_res = FP_ZERO;
  1105. tmp_res.sign = num.sign ^ den.sign;
  1106. tmp_pred_lo = 0;
  1107. } else if (fp_is_zero(num) && fp_is_finite(den)) {
  1108. tmp_res = FP_ZERO;
  1109. tmp_res.sign = num.sign ^ den.sign;
  1110. tmp_pred_lo = 0;
  1111. } else {
  1112. tmp_res = fp_ieee_recip(den);
  1113. if (limits_check.lo_fr2_or_quot) {
  1114. tmp_pred_lo = 0;
  1115. } else {
  1116. tmp_pred_lo = 1;
  1117. }
  1118. }
  1119. tmp_res_lo = fp_single(tmp_res);
  1120. }
  1121. FR[f1].significand = fp_concatenate(tmp_res_hi, tmp_res_lo);
  1122. FR[f1].exponent = FP_INTEGER_EXP;
  1123. FR[f1].sign = FP_SIGN_POSITIVE;
  1124. PR[p2] = tmp_pred_hi && tmp_pred_lo;
  1125. fp_update_fpsr(sf, tmp_fp_env);
  1126. }
  1127. fp_update_psr(f1);
  1128. } else {
  1129. PR[p2] = 0; /* unconditional semantics */
  1130. }
  1131. /* EAS END */
  1132. }
  1133. // ******************************************************************
  1134. // _frsqrta
  1135. // ******************************************************************
  1136. static INLINE void
  1137. _frsqrta(EM_state_type *ps,
  1138. EM_opcode_sf_type sf,
  1139. EM_uint_t qp,
  1140. EM_uint_t f1,
  1141. EM_uint_t p2,
  1142. EM_uint_t f3)
  1143. {
  1144. EM_uint_t tmp_isrcode;
  1145. EM_fp_reg_type tmp_default_result, tmp_fr3;
  1146. EM_tmp_fp_env_type tmp_fp_env;
  1147. /* EAS START */
  1148. if (PR[qp]) {
  1149. fp_check_target_register(f1);
  1150. if (tmp_isrcode = fp_reg_disabled(f1, f3, 0, 0))
  1151. disabled_fp_register_fault(tmp_isrcode,0);
  1152. if (fp_is_natval(FR[f3])) {
  1153. FR[f1] = NATVAL;
  1154. PR[p2] = 0;
  1155. } else {
  1156. tmp_default_result = frsqrta_exception_fault_check(f3, sf, &tmp_fp_env);
  1157. if (fp_raise_fault(tmp_fp_env)) {
  1158. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  1159. return; // MACH
  1160. }
  1161. if (fp_is_nan_or_inf(tmp_default_result)) {
  1162. FR[f1] = tmp_default_result;
  1163. PR[p2] = 0;
  1164. } else {
  1165. tmp_fr3 = fp_normalize(fp_reg_read(FR[f3]));
  1166. if (fp_is_zero(tmp_fr3)) {
  1167. FR[f1] = tmp_fr3;
  1168. PR[p2] = 0;
  1169. } else if (fp_is_pos_inf(tmp_fr3)) {
  1170. FR[f1] = tmp_fr3;
  1171. PR[p2] = 0;
  1172. } else {
  1173. FR[f1] = fp_ieee_recip_sqrt(tmp_fr3);
  1174. PR[p2] = 1;
  1175. }
  1176. }
  1177. fp_update_fpsr(sf, tmp_fp_env);
  1178. }
  1179. fp_update_psr(f1);
  1180. } else {
  1181. PR[p2] = 0;
  1182. }
  1183. /* EAS END */
  1184. }
  1185. // ******************************************************************
  1186. // _fprsqrta
  1187. // ******************************************************************
  1188. static INLINE void
  1189. _fprsqrta(EM_state_type *ps,
  1190. EM_opcode_sf_type sf,
  1191. EM_uint_t qp,
  1192. EM_uint_t f1,
  1193. EM_uint_t p2,
  1194. EM_uint_t f3)
  1195. {
  1196. EM_uint_t tmp_isrcode, tmp_res_hi, tmp_res_lo;
  1197. EM_pair_fp_reg_type tmp_default_result_pair;
  1198. EM_fp_reg_type tmp_res, tmp_fr3;
  1199. EM_boolean_t tmp_pred_hi, tmp_pred_lo;
  1200. EM_tmp_fp_env_type tmp_fp_env;
  1201. EM_limits_check_fprsqrta limits_check = {0, 0};
  1202. /* EAS START */
  1203. if (PR[qp]) {
  1204. fp_check_target_register(f1);
  1205. if (tmp_isrcode = fp_reg_disabled(f1, f3, 0, 0))
  1206. disabled_fp_register_fault(tmp_isrcode,0);
  1207. if( fp_is_natval(FR[f3])) {
  1208. PR[p2] = 0;
  1209. FR[f1] = NATVAL;
  1210. } else {
  1211. tmp_default_result_pair = fprsqrta_exception_fault_check(f3, sf,
  1212. &tmp_fp_env, &limits_check);
  1213. if(fp_raise_fault(tmp_fp_env)) {
  1214. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  1215. return; // MACH
  1216. }
  1217. if (fp_is_nan(tmp_default_result_pair.hi) ) {
  1218. tmp_res_hi = fp_single(tmp_default_result_pair.hi);
  1219. tmp_pred_hi = 0;
  1220. } else {
  1221. tmp_fr3 = fp_normalize(fp_reg_read_hi(f3));
  1222. if (fp_is_zero(tmp_fr3)) {
  1223. tmp_res = FP_INFINITY;
  1224. tmp_res.sign = tmp_fr3.sign;
  1225. tmp_pred_hi = 0;
  1226. } else if (fp_is_pos_inf(tmp_fr3)) {
  1227. tmp_res = FP_ZERO;
  1228. tmp_pred_hi = 0;
  1229. } else {
  1230. tmp_res = fp_ieee_recip_sqrt(tmp_fr3);
  1231. if (limits_check.hi)
  1232. tmp_pred_hi = 0;
  1233. else
  1234. tmp_pred_hi = 1;
  1235. }
  1236. tmp_res_hi = fp_single(tmp_res);
  1237. }
  1238. if (fp_is_nan(tmp_default_result_pair.lo) ) {
  1239. tmp_res_lo = fp_single(tmp_default_result_pair.lo);
  1240. tmp_pred_lo = 0;
  1241. } else {
  1242. tmp_fr3 = fp_normalize(fp_reg_read_lo(f3));
  1243. if (fp_is_zero(tmp_fr3)) {
  1244. tmp_res = FP_INFINITY;
  1245. tmp_res.sign = tmp_fr3.sign;
  1246. tmp_pred_lo = 0;
  1247. } else if (fp_is_pos_inf(tmp_fr3)) {
  1248. tmp_res = FP_ZERO;
  1249. tmp_pred_lo = 0;
  1250. } else {
  1251. tmp_res = fp_ieee_recip_sqrt(tmp_fr3);
  1252. if (limits_check.lo)
  1253. tmp_pred_lo = 0;
  1254. else
  1255. tmp_pred_lo = 1;
  1256. }
  1257. tmp_res_lo = fp_single(tmp_res);
  1258. }
  1259. FR[f1].significand = fp_concatenate(tmp_res_hi,tmp_res_lo);
  1260. FR[f1].exponent = FP_INTEGER_EXP;
  1261. FR[f1].sign = FP_SIGN_POSITIVE;
  1262. PR[p2] = tmp_pred_hi & tmp_pred_lo;
  1263. fp_update_fpsr(sf, tmp_fp_env);
  1264. }
  1265. fp_update_psr(f1);
  1266. } else {
  1267. PR[p2] = 0;
  1268. }
  1269. /* EAS END */
  1270. }
  1271. // ******************************************************************
  1272. // _fmin
  1273. // ******************************************************************
  1274. static INLINE void
  1275. _fmin(EM_state_type *ps,
  1276. EM_opcode_sf_type sf,
  1277. EM_uint_t qp,
  1278. EM_uint_t f1,
  1279. EM_uint_t f2,
  1280. EM_uint_t f3)
  1281. {
  1282. EM_uint_t tmp_isrcode;
  1283. EM_tmp_fp_env_type tmp_fp_env;
  1284. EM_boolean_t tmp_bool_res;
  1285. /* EAS START */
  1286. if (PR[qp]) {
  1287. fp_check_target_register(f1);
  1288. if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
  1289. disabled_fp_register_fault(tmp_isrcode,0);
  1290. if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
  1291. FR[f1] = NATVAL;
  1292. } else {
  1293. fminmax_exception_fault_check(f2, f3, sf, &tmp_fp_env);
  1294. if (fp_raise_fault(tmp_fp_env)) {
  1295. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  1296. return; // MACH
  1297. }
  1298. tmp_bool_res = fp_less_than(fp_reg_read(FR[f2]), fp_reg_read(FR[f3]));
  1299. FR[f1] = tmp_bool_res ? FR[f2] : FR[f3];
  1300. fp_update_fpsr(sf, tmp_fp_env);
  1301. }
  1302. fp_update_psr(f1);
  1303. }
  1304. /* EAS END */
  1305. }
  1306. // ******************************************************************
  1307. // _fmax
  1308. // ******************************************************************
  1309. static INLINE void
  1310. _fmax(EM_state_type *ps,
  1311. EM_opcode_sf_type sf,
  1312. EM_uint_t qp,
  1313. EM_uint_t f1,
  1314. EM_uint_t f2,
  1315. EM_uint_t f3)
  1316. {
  1317. EM_uint_t tmp_isrcode;
  1318. EM_tmp_fp_env_type tmp_fp_env;
  1319. EM_boolean_t tmp_bool_res;
  1320. /* EAS START */
  1321. if (PR[qp]) {
  1322. fp_check_target_register(f1);
  1323. if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
  1324. disabled_fp_register_fault(tmp_isrcode,0);
  1325. if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
  1326. FR[f1] = NATVAL;
  1327. } else {
  1328. fminmax_exception_fault_check(f2, f3, sf, &tmp_fp_env);
  1329. if (fp_raise_fault(tmp_fp_env)) {
  1330. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  1331. return; // MACH
  1332. }
  1333. tmp_bool_res = fp_less_than(fp_reg_read(FR[f3]), fp_reg_read(FR[f2]));
  1334. FR[f1] = (tmp_bool_res ? FR[f2] : FR[f3]);
  1335. fp_update_fpsr(sf, tmp_fp_env);
  1336. }
  1337. fp_update_psr(f1);
  1338. }
  1339. /* EAS END */
  1340. }
  1341. // ******************************************************************
  1342. // _famin
  1343. // ******************************************************************
  1344. static INLINE void
  1345. _famin(EM_state_type *ps,
  1346. EM_opcode_sf_type sf,
  1347. EM_uint_t qp,
  1348. EM_uint_t f1,
  1349. EM_uint_t f2,
  1350. EM_uint_t f3)
  1351. {
  1352. EM_uint_t tmp_isrcode;
  1353. EM_fp_reg_type tmp_right, tmp_left;
  1354. EM_tmp_fp_env_type tmp_fp_env;
  1355. EM_boolean_t tmp_bool_res;
  1356. /* EAS START */
  1357. if (PR[qp]) {
  1358. fp_check_target_register(f1);
  1359. if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
  1360. disabled_fp_register_fault(tmp_isrcode,0);
  1361. if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
  1362. FR[f1] = NATVAL;
  1363. } else {
  1364. fminmax_exception_fault_check(f2, f3, sf, &tmp_fp_env);
  1365. if (fp_raise_fault(tmp_fp_env)) {
  1366. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  1367. return; // MACH
  1368. }
  1369. tmp_left = fp_reg_read(FR[f2]);
  1370. tmp_right = fp_reg_read(FR[f3]);
  1371. tmp_left.sign = FP_SIGN_POSITIVE;
  1372. tmp_right.sign = FP_SIGN_POSITIVE;
  1373. tmp_bool_res = fp_less_than(tmp_left, tmp_right);
  1374. FR[f1] = tmp_bool_res ? FR[f2] : FR[f3];
  1375. fp_update_fpsr(sf, tmp_fp_env);
  1376. }
  1377. fp_update_psr(f1);
  1378. }
  1379. /* EAS END */
  1380. }
  1381. // ******************************************************************
  1382. // _famax
  1383. // ******************************************************************
  1384. static INLINE void
  1385. _famax(EM_state_type *ps,
  1386. EM_opcode_sf_type sf,
  1387. EM_uint_t qp,
  1388. EM_uint_t f1,
  1389. EM_uint_t f2,
  1390. EM_uint_t f3)
  1391. {
  1392. EM_uint_t tmp_isrcode;
  1393. EM_fp_reg_type tmp_right, tmp_left;
  1394. EM_tmp_fp_env_type tmp_fp_env;
  1395. EM_boolean_t tmp_bool_res;
  1396. /* EAS START */
  1397. if (PR[qp]) {
  1398. fp_check_target_register(f1);
  1399. if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0) )
  1400. disabled_fp_register_fault(tmp_isrcode,0);
  1401. if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3])) {
  1402. FR[f1] = NATVAL;
  1403. } else {
  1404. fminmax_exception_fault_check(f2, f3, sf, &tmp_fp_env);
  1405. if (fp_raise_fault(tmp_fp_env)) {
  1406. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  1407. return; // MACH
  1408. }
  1409. tmp_right = fp_reg_read(FR[f2]);
  1410. tmp_left = fp_reg_read(FR[f3]);
  1411. tmp_right.sign = FP_SIGN_POSITIVE;
  1412. tmp_left.sign = FP_SIGN_POSITIVE;
  1413. tmp_bool_res = fp_less_than(tmp_left, tmp_right);
  1414. FR[f1] = tmp_bool_res ? FR[f2] : FR[f3];
  1415. fp_update_fpsr(sf, tmp_fp_env);
  1416. }
  1417. fp_update_psr(f1);
  1418. }
  1419. /* EAS END */
  1420. }
  1421. // ******************************************************************
  1422. // _fpmin
  1423. // ******************************************************************
  1424. static INLINE void
  1425. _fpmin(EM_state_type *ps,
  1426. EM_opcode_sf_type sf,
  1427. EM_uint_t qp,
  1428. EM_uint_t f1,
  1429. EM_uint_t f2,
  1430. EM_uint_t f3)
  1431. {
  1432. EM_uint_t tmp_isrcode, tmp_res_hi, tmp_res_lo;
  1433. EM_fp_reg_type tmp_right, tmp_left, tmp_fr2, tmp_fr3;
  1434. EM_tmp_fp_env_type tmp_fp_env;
  1435. EM_boolean_t tmp_bool_res;
  1436. /* EAS START */
  1437. if (PR[qp]) {
  1438. fp_check_target_register(f1);
  1439. if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
  1440. disabled_fp_register_fault(tmp_isrcode,0);
  1441. if (fp_is_natval(FR[f2] ) || fp_is_natval(FR[f3]) ) {
  1442. FR[f1] = NATVAL;
  1443. } else {
  1444. fpminmax_exception_fault_check(f2, f3, sf, &tmp_fp_env);
  1445. if (fp_raise_fault(tmp_fp_env)) {
  1446. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  1447. return; // MACH
  1448. }
  1449. tmp_fr2 = tmp_left = fp_reg_read_hi(f2);
  1450. tmp_fr3 = tmp_right = fp_reg_read_hi(f3);
  1451. tmp_bool_res = fp_less_than(tmp_left, tmp_right);
  1452. tmp_res_hi = fp_single(tmp_bool_res ? tmp_fr2: tmp_fr3);
  1453. tmp_fr2 = tmp_left = fp_reg_read_lo(f2);
  1454. tmp_fr3 = tmp_right = fp_reg_read_lo(f3);
  1455. tmp_bool_res = fp_less_than(tmp_left, tmp_right);
  1456. tmp_res_lo = fp_single(tmp_bool_res ? tmp_fr2: tmp_fr3);
  1457. FR[f1].significand = fp_concatenate(tmp_res_hi, tmp_res_lo);
  1458. FR[f1].exponent = FP_INTEGER_EXP;
  1459. FR[f1].sign = FP_SIGN_POSITIVE;
  1460. fp_update_fpsr(sf, tmp_fp_env);
  1461. }
  1462. fp_update_psr(f1);
  1463. }
  1464. /* EAS END */
  1465. }
  1466. // ******************************************************************
  1467. // _fpmax
  1468. // ******************************************************************
  1469. static INLINE void
  1470. _fpmax(EM_state_type *ps,
  1471. EM_opcode_sf_type sf,
  1472. EM_uint_t qp,
  1473. EM_uint_t f1,
  1474. EM_uint_t f2,
  1475. EM_uint_t f3)
  1476. {
  1477. EM_uint_t tmp_isrcode, tmp_res_hi, tmp_res_lo;
  1478. EM_fp_reg_type tmp_right, tmp_left, tmp_fr2, tmp_fr3;
  1479. EM_tmp_fp_env_type tmp_fp_env;
  1480. EM_boolean_t tmp_bool_res;
  1481. /* EAS START */
  1482. if (PR[qp]) {
  1483. fp_check_target_register(f1);
  1484. if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
  1485. disabled_fp_register_fault(tmp_isrcode,0);
  1486. if (fp_is_natval(FR[f2] ) || fp_is_natval(FR[f3]) ) {
  1487. FR[f1] = NATVAL;
  1488. } else {
  1489. fpminmax_exception_fault_check(f2, f3, sf, &tmp_fp_env);
  1490. if (fp_raise_fault(tmp_fp_env)) {
  1491. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  1492. return; // MACH
  1493. }
  1494. tmp_fr2 = tmp_right = fp_reg_read_hi(f2);
  1495. tmp_fr3 = tmp_left = fp_reg_read_hi(f3);
  1496. tmp_bool_res = fp_less_than(tmp_left, tmp_right);
  1497. tmp_res_hi = fp_single(tmp_bool_res ? tmp_fr2 : tmp_fr3);
  1498. tmp_fr2 = tmp_right = fp_reg_read_lo(f2);
  1499. tmp_fr3 = tmp_left = fp_reg_read_lo(f3);
  1500. tmp_bool_res = fp_less_than(tmp_left, tmp_right);
  1501. tmp_res_lo = fp_single(tmp_bool_res ? tmp_fr2: tmp_fr3);
  1502. FR[f1].significand = fp_concatenate(tmp_res_hi, tmp_res_lo);
  1503. FR[f1].exponent = FP_INTEGER_EXP;
  1504. FR[f1].sign = FP_SIGN_POSITIVE;
  1505. fp_update_fpsr(sf, tmp_fp_env);
  1506. }
  1507. fp_update_psr(f1);
  1508. }
  1509. /* EAS END */
  1510. }
  1511. // ******************************************************************
  1512. // _fpamin
  1513. // ******************************************************************
  1514. static INLINE void
  1515. _fpamin(EM_state_type *ps,
  1516. EM_opcode_sf_type sf,
  1517. EM_uint_t qp,
  1518. EM_uint_t f1,
  1519. EM_uint_t f2,
  1520. EM_uint_t f3)
  1521. {
  1522. EM_uint_t tmp_isrcode, tmp_res_hi, tmp_res_lo;
  1523. EM_fp_reg_type tmp_right, tmp_left, tmp_fr2, tmp_fr3;
  1524. EM_tmp_fp_env_type tmp_fp_env;
  1525. EM_boolean_t tmp_bool_res;
  1526. /* EAS START */
  1527. if (PR[qp]) {
  1528. fp_check_target_register(f1);
  1529. if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
  1530. disabled_fp_register_fault(tmp_isrcode,0);
  1531. if (fp_is_natval(FR[f2] ) || fp_is_natval(FR[f3]) ) {
  1532. FR[f1] = NATVAL;
  1533. } else {
  1534. fpminmax_exception_fault_check(f2,f3, sf, &tmp_fp_env);
  1535. if(fp_raise_fault(tmp_fp_env)) {
  1536. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  1537. return; // MACH
  1538. }
  1539. tmp_fr2 = tmp_left = fp_reg_read_hi(f2);
  1540. tmp_fr3 = tmp_right = fp_reg_read_hi(f3);
  1541. tmp_left.sign = FP_SIGN_POSITIVE;
  1542. tmp_right.sign = FP_SIGN_POSITIVE;
  1543. tmp_bool_res = fp_less_than(tmp_left, tmp_right);
  1544. tmp_res_hi = fp_single(tmp_bool_res ? tmp_fr2 : tmp_fr3);
  1545. tmp_fr2 = tmp_left = fp_reg_read_lo(f2);
  1546. tmp_fr3 = tmp_right = fp_reg_read_lo(f3);
  1547. tmp_left.sign = FP_SIGN_POSITIVE;
  1548. tmp_right.sign = FP_SIGN_POSITIVE;
  1549. tmp_bool_res = fp_less_than(tmp_left, tmp_right);
  1550. tmp_res_lo = fp_single(tmp_bool_res ? tmp_fr2: tmp_fr3);
  1551. FR[f1].significand = fp_concatenate(tmp_res_hi, tmp_res_lo);
  1552. FR[f1].exponent = FP_INTEGER_EXP;
  1553. FR[f1].sign = FP_SIGN_POSITIVE;
  1554. fp_update_fpsr(sf, tmp_fp_env);
  1555. }
  1556. fp_update_psr(f1);
  1557. }
  1558. /* EAS END */
  1559. }
  1560. // ******************************************************************
  1561. // _fpamax
  1562. // ******************************************************************
  1563. static INLINE void
  1564. _fpamax(EM_state_type *ps,
  1565. EM_opcode_sf_type sf,
  1566. EM_uint_t qp,
  1567. EM_uint_t f1,
  1568. EM_uint_t f2,
  1569. EM_uint_t f3)
  1570. {
  1571. EM_uint_t tmp_isrcode, tmp_res_hi, tmp_res_lo;
  1572. EM_fp_reg_type tmp_right, tmp_left, tmp_fr2, tmp_fr3;
  1573. EM_tmp_fp_env_type tmp_fp_env;
  1574. EM_boolean_t tmp_bool_res;
  1575. /* EAS START */
  1576. if (PR[qp]) {
  1577. fp_check_target_register(f1);
  1578. if (tmp_isrcode = fp_reg_disabled(f1, f2, f3, 0))
  1579. disabled_fp_register_fault(tmp_isrcode,0);
  1580. if (fp_is_natval(FR[f2] ) || fp_is_natval(FR[f3]) ) {
  1581. FR[f1] = NATVAL;
  1582. } else {
  1583. fpminmax_exception_fault_check(f2, f3, sf, &tmp_fp_env);
  1584. if (fp_raise_fault(tmp_fp_env)) {
  1585. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  1586. return; // MACH
  1587. }
  1588. tmp_fr2 = tmp_right = fp_reg_read_hi(f2);
  1589. tmp_fr3 = tmp_left = fp_reg_read_hi(f3);
  1590. tmp_right.sign = FP_SIGN_POSITIVE;
  1591. tmp_left.sign = FP_SIGN_POSITIVE;
  1592. tmp_bool_res = fp_less_than(tmp_left, tmp_right);
  1593. tmp_res_hi = fp_single(tmp_bool_res ? tmp_fr2: tmp_fr3);
  1594. tmp_fr2 = tmp_right = fp_reg_read_lo(f2);
  1595. tmp_fr3 = tmp_left = fp_reg_read_lo(f3);
  1596. tmp_right.sign = FP_SIGN_POSITIVE;
  1597. tmp_left.sign = FP_SIGN_POSITIVE;
  1598. tmp_bool_res = fp_less_than(tmp_left, tmp_right);
  1599. tmp_res_lo = fp_single(tmp_bool_res ? tmp_fr2: tmp_fr3);
  1600. FR[f1].significand = fp_concatenate(tmp_res_hi, tmp_res_lo);
  1601. FR[f1].exponent = FP_INTEGER_EXP;
  1602. FR[f1].sign = FP_SIGN_POSITIVE;
  1603. fp_update_fpsr(sf, tmp_fp_env);
  1604. }
  1605. fp_update_psr(f1);
  1606. }
  1607. /* EAS END */
  1608. }
  1609. // ******************************************************************
  1610. // _fpcmp
  1611. // ******************************************************************
  1612. static INLINE void
  1613. _fpcmp(EM_state_type *ps,
  1614. EM_opcode_frel_type frel,
  1615. EM_opcode_sf_type sf,
  1616. EM_uint_t qp,
  1617. EM_uint_t f1,
  1618. EM_uint_t f2,
  1619. EM_uint_t f3)
  1620. {
  1621. EM_uint_t tmp_isrcode, tmp_res_hi, tmp_res_lo;
  1622. EM_fp_reg_type tmp_fr2, tmp_fr3;
  1623. EM_tmp_fp_env_type tmp_fp_env;
  1624. EM_boolean_t tmp_rel;
  1625. /* EAS START */
  1626. if (PR[qp]) {
  1627. fp_check_target_register(f1);
  1628. if(tmp_isrcode = fp_reg_disabled(f1, f2,f3, 0))
  1629. disabled_fp_register_fault(tmp_isrcode,0);
  1630. if (fp_is_natval(FR[f2]) || fp_is_natval(FR[f3]) ) {
  1631. FR[f1] = NATVAL;
  1632. } else {
  1633. fpcmp_exception_fault_check(f2, f3, frel, sf, &tmp_fp_env);
  1634. if (fp_raise_fault(tmp_fp_env)) {
  1635. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  1636. return; // MACH
  1637. }
  1638. tmp_fr2 = fp_reg_read_hi(f2);
  1639. tmp_fr3 = fp_reg_read_hi(f3);
  1640. if (frel == frelEQ) tmp_rel = fp_equal(tmp_fr2, tmp_fr3);
  1641. else if (frel == frelLT) tmp_rel = fp_less_than(tmp_fr2, tmp_fr3);
  1642. else if (frel == frelLE) tmp_rel = fp_lesser_or_equal(tmp_fr2, tmp_fr3);
  1643. else if (frel == frelGT) tmp_rel = fp_less_than(tmp_fr3, tmp_fr2);
  1644. else if (frel == frelGE) tmp_rel = fp_lesser_or_equal(tmp_fr3, tmp_fr2);
  1645. else if (frel == frelUNORD) tmp_rel = fp_unordered(tmp_fr2, tmp_fr3);
  1646. else if (frel == frelNEQ) tmp_rel = !fp_equal(tmp_fr2, tmp_fr3);
  1647. else if (frel == frelNLT) tmp_rel = !fp_less_than(tmp_fr2, tmp_fr3);
  1648. else if (frel == frelNLE) tmp_rel = !fp_lesser_or_equal(tmp_fr2, tmp_fr3);
  1649. else if (frel == frelNGT) tmp_rel = !fp_less_than(tmp_fr3, tmp_fr2);
  1650. else if (frel == frelNGE) tmp_rel = !fp_lesser_or_equal(tmp_fr3, tmp_fr2);
  1651. else tmp_rel = !fp_unordered(tmp_fr2, tmp_fr3);
  1652. tmp_res_hi = (tmp_rel ? 0xFFFFFFFF : 0x00000000);
  1653. tmp_fr2 = fp_reg_read_lo(f2);
  1654. tmp_fr3 = fp_reg_read_lo(f3);
  1655. if (frel == frelEQ) tmp_rel = fp_equal(tmp_fr2, tmp_fr3);
  1656. else if (frel == frelLT) tmp_rel = fp_less_than(tmp_fr2, tmp_fr3);
  1657. else if (frel == frelLE) tmp_rel = fp_lesser_or_equal(tmp_fr2, tmp_fr3);
  1658. else if (frel == frelGT) tmp_rel = fp_less_than(tmp_fr3, tmp_fr2);
  1659. else if (frel == frelGE) tmp_rel = fp_lesser_or_equal(tmp_fr3, tmp_fr2);
  1660. else if (frel == frelUNORD) tmp_rel = fp_unordered(tmp_fr2, tmp_fr3);
  1661. else if (frel == frelNEQ) tmp_rel = !fp_equal(tmp_fr2, tmp_fr3);
  1662. else if (frel == frelNLT) tmp_rel = !fp_less_than(tmp_fr2, tmp_fr3);
  1663. else if (frel == frelNLE) tmp_rel = !fp_lesser_or_equal(tmp_fr2, tmp_fr3);
  1664. else if (frel == frelNGT) tmp_rel = !fp_less_than(tmp_fr3, tmp_fr2);
  1665. else if (frel == frelNGE) tmp_rel = !fp_lesser_or_equal(tmp_fr3, tmp_fr2);
  1666. else tmp_rel = !fp_unordered(tmp_fr2, tmp_fr3);
  1667. tmp_res_lo = (tmp_rel ? 0xFFFFFFFF : 0x00000000);
  1668. FR[f1].significand = fp_concatenate(tmp_res_hi, tmp_res_lo);
  1669. FR[f1].exponent = FP_INTEGER_EXP;
  1670. FR[f1].sign = FP_SIGN_POSITIVE;
  1671. fp_update_fpsr(sf, tmp_fp_env);
  1672. }
  1673. fp_update_psr(f1);
  1674. }
  1675. /* EAS END */
  1676. }
  1677. // ******************************************************************
  1678. // _fcvt_fx
  1679. // ******************************************************************
  1680. static INLINE void
  1681. _fcvt_fx(EM_state_type *ps,
  1682. EM_opcode_sf_type sf,
  1683. EM_uint_t qp,
  1684. EM_uint_t f1,
  1685. EM_uint_t f2)
  1686. {
  1687. EM_uint_t tmp_isrcode;
  1688. EM_fp_reg_type tmp_default_result, tmp_res;
  1689. EM_tmp_fp_env_type tmp_fp_env;
  1690. /* EAS START */
  1691. if (PR[qp]) {
  1692. fp_check_target_register(f1);
  1693. if (tmp_isrcode = fp_reg_disabled(f1, f2, 0, 0))
  1694. disabled_fp_register_fault(tmp_isrcode,0);
  1695. if (fp_is_natval(FR[f2])) {
  1696. FR[f1] = NATVAL;
  1697. fp_update_psr(f1);
  1698. } else {
  1699. tmp_default_result = fcvt_exception_fault_check(f2, sf,
  1700. SIGNED_FORM, TRUNC_FORM, &tmp_fp_env);
  1701. if (fp_raise_fault(tmp_fp_env)) {
  1702. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  1703. return; // MACH
  1704. }
  1705. if (fp_is_nan(tmp_default_result)) {
  1706. FR[f1].significand = INTEGER_INDEFINITE;
  1707. FR[f1].exponent = FP_INTEGER_EXP;
  1708. FR[f1].sign = FP_SIGN_POSITIVE;
  1709. } else {
  1710. tmp_res = fp_ieee_rnd_to_int(fp_reg_read(FR[f2]), &tmp_fp_env);
  1711. if (tmp_res.exponent)
  1712. tmp_res.significand = fp_U64_rsh(
  1713. tmp_res.significand, FP_INTEGER_EXP - (EM_int_t)tmp_res.exponent);
  1714. if (SIGNED_FORM && tmp_res.sign)
  1715. tmp_res.significand = (~tmp_res.significand) + 1;
  1716. FR[f1].significand = tmp_res.significand;
  1717. FR[f1].exponent = FP_INTEGER_EXP;
  1718. FR[f1].sign = FP_SIGN_POSITIVE;
  1719. }
  1720. fp_update_fpsr(sf, tmp_fp_env);
  1721. fp_update_psr(f1);
  1722. if (fp_raise_traps(tmp_fp_env))
  1723. fp_exception_trap(fp_decode_trap(tmp_fp_env));
  1724. }
  1725. }
  1726. /* EAS END */
  1727. }
  1728. // ******************************************************************
  1729. // _fpcvt_fx
  1730. // ******************************************************************
  1731. static INLINE void
  1732. _fpcvt_fx(EM_state_type *ps,
  1733. EM_opcode_sf_type sf,
  1734. EM_uint_t qp,
  1735. EM_uint_t f1,
  1736. EM_uint_t f2)
  1737. {
  1738. EM_uint_t tmp_isrcode, tmp_res_lo, tmp_res_hi;
  1739. EM_pair_fp_reg_type tmp_default_result_pair;
  1740. EM_fp_reg_type tmp_res;
  1741. EM_tmp_fp_env_type tmp_fp_env;
  1742. /* EAS START */
  1743. if (PR[qp]) {
  1744. fp_check_target_register(f1);
  1745. if (tmp_isrcode = fp_reg_disabled(f1, f2, 0, 0))
  1746. disabled_fp_register_fault(tmp_isrcode,0);
  1747. if (fp_is_natval(FR[f2]) ) {
  1748. FR[f1] = NATVAL;
  1749. fp_update_psr(f1);
  1750. } else {
  1751. tmp_default_result_pair = fpcvt_exception_fault_check(f2, sf,
  1752. SIGNED_FORM, TRUNC_FORM, &tmp_fp_env);
  1753. if (fp_raise_fault(tmp_fp_env)) {
  1754. fp_exception_fault(fp_decode_fault(tmp_fp_env));
  1755. return; // MACH
  1756. }
  1757. if (fp_is_nan(tmp_default_result_pair.hi)) {
  1758. tmp_res_hi = INTEGER_INDEFINITE_32_BIT;
  1759. } else {
  1760. tmp_res = fp_ieee_rnd_to_int_sp(fp_reg_read_hi(f2), high, &tmp_fp_env);
  1761. if (tmp_res.exponent)
  1762. tmp_res.significand = fp_U64_rsh(
  1763. tmp_res.significand, (FP_INTEGER_EXP - tmp_res.exponent));
  1764. if (SIGNED_FORM && tmp_res.sign)
  1765. tmp_res.significand = (~tmp_res.significand) + 1;
  1766. tmp_res_hi = fp_extract_bits(tmp_res.significand, 31, 0);
  1767. }
  1768. if (fp_is_nan(tmp_default_result_pair.lo)) {
  1769. tmp_res_lo = INTEGER_INDEFINITE_32_BIT;
  1770. } else {
  1771. tmp_res = fp_ieee_rnd_to_int_sp(fp_reg_read_lo(f2), low, &tmp_fp_env);
  1772. if (tmp_res.exponent)
  1773. tmp_res.significand = fp_U64_rsh(
  1774. tmp_res.significand,(FP_INTEGER_EXP - tmp_res.exponent));
  1775. if (SIGNED_FORM && tmp_res.sign)
  1776. tmp_res.significand = (~tmp_res.significand) + 1;
  1777. tmp_res_lo = fp_extract_bits(tmp_res.significand, 31, 0);
  1778. }
  1779. FR[f1].significand = fp_concatenate(tmp_res_hi, tmp_res_lo);
  1780. FR[f1].exponent = FP_INTEGER_EXP;
  1781. FR[f1].sign = FP_SIGN_POSITIVE;
  1782. fp_update_fpsr(sf, tmp_fp_env);
  1783. fp_update_psr(f1);
  1784. if (fp_raise_traps(tmp_fp_env))
  1785. fp_exception_trap(fp_decode_trap(tmp_fp_env));
  1786. }
  1787. }
  1788. /* EAS END */
  1789. }
  1790. /********** fp_ieee_recip **********/
  1791. static EM_fp_reg_type
  1792. fp_ieee_recip(
  1793. EM_fp_reg_type den)
  1794. {
  1795. EM_uint_t tmp_index;
  1796. EM_fp_reg_type tmp_res;
  1797. /* EAS START */
  1798. const EM_uint_t RECIP_TABLE[256] = {
  1799. 0x3fc, 0x3f4, 0x3ec, 0x3e4, 0x3dd, 0x3d5, 0x3cd, 0x3c6,
  1800. 0x3be, 0x3b7, 0x3af, 0x3a8, 0x3a1, 0x399, 0x392, 0x38b,
  1801. 0x384, 0x37d, 0x376, 0x36f, 0x368, 0x361, 0x35b, 0x354,
  1802. 0x34d, 0x346, 0x340, 0x339, 0x333, 0x32c, 0x326, 0x320,
  1803. 0x319, 0x313, 0x30d, 0x307, 0x300, 0x2fa, 0x2f4, 0x2ee,
  1804. 0x2e8, 0x2e2, 0x2dc, 0x2d7, 0x2d1, 0x2cb, 0x2c5, 0x2bf,
  1805. 0x2ba, 0x2b4, 0x2af, 0x2a9, 0x2a3, 0x29e, 0x299, 0x293,
  1806. 0x28e, 0x288, 0x283, 0x27e, 0x279, 0x273, 0x26e, 0x269,
  1807. 0x264, 0x25f, 0x25a, 0x255, 0x250, 0x24b, 0x246, 0x241,
  1808. 0x23c, 0x237, 0x232, 0x22e, 0x229, 0x224, 0x21f, 0x21b,
  1809. 0x216, 0x211, 0x20d, 0x208, 0x204, 0x1ff, 0x1fb, 0x1f6,
  1810. 0x1f2, 0x1ed, 0x1e9, 0x1e5, 0x1e0, 0x1dc, 0x1d8, 0x1d4,
  1811. 0x1cf, 0x1cb, 0x1c7, 0x1c3, 0x1bf, 0x1bb, 0x1b6, 0x1b2,
  1812. 0x1ae, 0x1aa, 0x1a6, 0x1a2, 0x19e, 0x19a, 0x197, 0x193,
  1813. 0x18f, 0x18b, 0x187, 0x183, 0x17f, 0x17c, 0x178, 0x174,
  1814. 0x171, 0x16d, 0x169, 0x166, 0x162, 0x15e, 0x15b, 0x157,
  1815. 0x154, 0x150, 0x14d, 0x149, 0x146, 0x142, 0x13f, 0x13b,
  1816. 0x138, 0x134, 0x131, 0x12e, 0x12a, 0x127, 0x124, 0x120,
  1817. 0x11d, 0x11a, 0x117, 0x113, 0x110, 0x10d, 0x10a, 0x107,
  1818. 0x103, 0x100, 0x0fd, 0x0fa, 0x0f7, 0x0f4, 0x0f1, 0x0ee,
  1819. 0x0eb, 0x0e8, 0x0e5, 0x0e2, 0x0df, 0x0dc, 0x0d9, 0x0d6,
  1820. 0x0d3, 0x0d0, 0x0cd, 0x0ca, 0x0c8, 0x0c5, 0x0c2, 0x0bf,
  1821. 0x0bc, 0x0b9, 0x0b7, 0x0b4, 0x0b1, 0x0ae, 0x0ac, 0x0a9,
  1822. 0x0a6, 0x0a4, 0x0a1, 0x09e, 0x09c, 0x099, 0x096, 0x094,
  1823. 0x091, 0x08e, 0x08c, 0x089, 0x087, 0x084, 0x082, 0x07f,
  1824. 0x07c, 0x07a, 0x077, 0x075, 0x073, 0x070, 0x06e, 0x06b,
  1825. 0x069, 0x066, 0x064, 0x061, 0x05f, 0x05d, 0x05a, 0x058,
  1826. 0x056, 0x053, 0x051, 0x04f, 0x04c, 0x04a, 0x048, 0x045,
  1827. 0x043, 0x041, 0x03f, 0x03c, 0x03a, 0x038, 0x036, 0x033,
  1828. 0x031, 0x02f, 0x02d, 0x02b, 0x029, 0x026, 0x024, 0x022,
  1829. 0x020, 0x01e, 0x01c, 0x01a, 0x018, 0x015, 0x013, 0x011,
  1830. 0x00f, 0x00d, 0x00b, 0x009, 0x007, 0x005, 0x003, 0x001,
  1831. };
  1832. tmp_index = fp_extract_bits(den.significand,62,55);
  1833. tmp_res.significand = ((EM_uint64_t)1 << 63) | ((EM_uint64_t)RECIP_TABLE[tmp_index] << 53);
  1834. tmp_res.exponent = (EM_int_t)FP_REG_EXP_ONES - 2 - (EM_int_t)den.exponent;
  1835. tmp_res.sign = den.sign;
  1836. return (tmp_res);
  1837. /* EAS END */
  1838. }
  1839. /********** fp_ieee_recip_sqrt **********/
  1840. static EM_fp_reg_type
  1841. fp_ieee_recip_sqrt(
  1842. EM_fp_reg_type root)
  1843. {
  1844. EM_uint_t tmp_index;
  1845. EM_fp_reg_type tmp_res;
  1846. /* EAS START */
  1847. const EM_uint_t RECIP_SQRT_TABLE[256] = {
  1848. 0x1a5, 0x1a0, 0x19a, 0x195, 0x18f, 0x18a, 0x185, 0x180,
  1849. 0x17a, 0x175, 0x170, 0x16b, 0x166, 0x161, 0x15d, 0x158,
  1850. 0x153, 0x14e, 0x14a, 0x145, 0x140, 0x13c, 0x138, 0x133,
  1851. 0x12f, 0x12a, 0x126, 0x122, 0x11e, 0x11a, 0x115, 0x111,
  1852. 0x10d, 0x109, 0x105, 0x101, 0x0fd, 0x0fa, 0x0f6, 0x0f2,
  1853. 0x0ee, 0x0ea, 0x0e7, 0x0e3, 0x0df, 0x0dc, 0x0d8, 0x0d5,
  1854. 0x0d1, 0x0ce, 0x0ca, 0x0c7, 0x0c3, 0x0c0, 0x0bd, 0x0b9,
  1855. 0x0b6, 0x0b3, 0x0b0, 0x0ad, 0x0a9, 0x0a6, 0x0a3, 0x0a0,
  1856. 0x09d, 0x09a, 0x097, 0x094, 0x091, 0x08e, 0x08b, 0x088,
  1857. 0x085, 0x082, 0x07f, 0x07d, 0x07a, 0x077, 0x074, 0x071,
  1858. 0x06f, 0x06c, 0x069, 0x067, 0x064, 0x061, 0x05f, 0x05c,
  1859. 0x05a, 0x057, 0x054, 0x052, 0x04f, 0x04d, 0x04a, 0x048,
  1860. 0x045, 0x043, 0x041, 0x03e, 0x03c, 0x03a, 0x037, 0x035,
  1861. 0x033, 0x030, 0x02e, 0x02c, 0x029, 0x027, 0x025, 0x023,
  1862. 0x020, 0x01e, 0x01c, 0x01a, 0x018, 0x016, 0x014, 0x011,
  1863. 0x00f, 0x00d, 0x00b, 0x009, 0x007, 0x005, 0x003, 0x001,
  1864. 0x3fc, 0x3f4, 0x3ec, 0x3e5, 0x3dd, 0x3d5, 0x3ce, 0x3c7,
  1865. 0x3bf, 0x3b8, 0x3b1, 0x3aa, 0x3a3, 0x39c, 0x395, 0x38e,
  1866. 0x388, 0x381, 0x37a, 0x374, 0x36d, 0x367, 0x361, 0x35a,
  1867. 0x354, 0x34e, 0x348, 0x342, 0x33c, 0x336, 0x330, 0x32b,
  1868. 0x325, 0x31f, 0x31a, 0x314, 0x30f, 0x309, 0x304, 0x2fe,
  1869. 0x2f9, 0x2f4, 0x2ee, 0x2e9, 0x2e4, 0x2df, 0x2da, 0x2d5,
  1870. 0x2d0, 0x2cb, 0x2c6, 0x2c1, 0x2bd, 0x2b8, 0x2b3, 0x2ae,
  1871. 0x2aa, 0x2a5, 0x2a1, 0x29c, 0x298, 0x293, 0x28f, 0x28a,
  1872. 0x286, 0x282, 0x27d, 0x279, 0x275, 0x271, 0x26d, 0x268,
  1873. 0x264, 0x260, 0x25c, 0x258, 0x254, 0x250, 0x24c, 0x249,
  1874. 0x245, 0x241, 0x23d, 0x239, 0x235, 0x232, 0x22e, 0x22a,
  1875. 0x227, 0x223, 0x220, 0x21c, 0x218, 0x215, 0x211, 0x20e,
  1876. 0x20a, 0x207, 0x204, 0x200, 0x1fd, 0x1f9, 0x1f6, 0x1f3,
  1877. 0x1f0, 0x1ec, 0x1e9, 0x1e6, 0x1e3, 0x1df, 0x1dc, 0x1d9,
  1878. 0x1d6, 0x1d3, 0x1d0, 0x1cd, 0x1ca, 0x1c7, 0x1c4, 0x1c1,
  1879. 0x1be, 0x1bb, 0x1b8, 0x1b5, 0x1b2, 0x1af, 0x1ac, 0x1aa,
  1880. };
  1881. tmp_index = (fp_extract_bits((EM_uint64_t)root.exponent,0,0) << 7) |
  1882. fp_extract_bits(root.significand,62,56);
  1883. tmp_res.significand = ((EM_uint64_t)1 << 63) |((EM_uint64_t)RECIP_SQRT_TABLE[tmp_index] << 53);
  1884. tmp_res.exponent = ((EM_int_t)FP_REG_EXP_HALF) - ((((EM_int_t)root.exponent) - ((EM_int_t)FP_REG_BIAS)) >> 1);
  1885. tmp_res.sign = FP_SIGN_POSITIVE;
  1886. return(tmp_res);
  1887. /* EAS END */
  1888. }