dfp-impl.c.inc 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /*** Decimal Floating Point ***/
  2. static inline TCGv_ptr gen_fprp_ptr(int reg)
  3. {
  4. TCGv_ptr r = tcg_temp_new_ptr();
  5. tcg_gen_addi_ptr(r, cpu_env, offsetof(CPUPPCState, vsr[reg].u64[0]));
  6. return r;
  7. }
  8. #define GEN_DFP_T_A_B_Rc(name) \
  9. static void gen_##name(DisasContext *ctx) \
  10. { \
  11. TCGv_ptr rd, ra, rb; \
  12. if (unlikely(!ctx->fpu_enabled)) { \
  13. gen_exception(ctx, POWERPC_EXCP_FPU); \
  14. return; \
  15. } \
  16. gen_update_nip(ctx, ctx->base.pc_next - 4); \
  17. rd = gen_fprp_ptr(rD(ctx->opcode)); \
  18. ra = gen_fprp_ptr(rA(ctx->opcode)); \
  19. rb = gen_fprp_ptr(rB(ctx->opcode)); \
  20. gen_helper_##name(cpu_env, rd, ra, rb); \
  21. if (unlikely(Rc(ctx->opcode) != 0)) { \
  22. gen_set_cr1_from_fpscr(ctx); \
  23. } \
  24. tcg_temp_free_ptr(rd); \
  25. tcg_temp_free_ptr(ra); \
  26. tcg_temp_free_ptr(rb); \
  27. }
  28. #define GEN_DFP_BF_A_B(name) \
  29. static void gen_##name(DisasContext *ctx) \
  30. { \
  31. TCGv_ptr ra, rb; \
  32. if (unlikely(!ctx->fpu_enabled)) { \
  33. gen_exception(ctx, POWERPC_EXCP_FPU); \
  34. return; \
  35. } \
  36. gen_update_nip(ctx, ctx->base.pc_next - 4); \
  37. ra = gen_fprp_ptr(rA(ctx->opcode)); \
  38. rb = gen_fprp_ptr(rB(ctx->opcode)); \
  39. gen_helper_##name(cpu_crf[crfD(ctx->opcode)], \
  40. cpu_env, ra, rb); \
  41. tcg_temp_free_ptr(ra); \
  42. tcg_temp_free_ptr(rb); \
  43. }
  44. #define GEN_DFP_BF_I_B(name) \
  45. static void gen_##name(DisasContext *ctx) \
  46. { \
  47. TCGv_i32 uim; \
  48. TCGv_ptr rb; \
  49. if (unlikely(!ctx->fpu_enabled)) { \
  50. gen_exception(ctx, POWERPC_EXCP_FPU); \
  51. return; \
  52. } \
  53. gen_update_nip(ctx, ctx->base.pc_next - 4); \
  54. uim = tcg_const_i32(UIMM5(ctx->opcode)); \
  55. rb = gen_fprp_ptr(rB(ctx->opcode)); \
  56. gen_helper_##name(cpu_crf[crfD(ctx->opcode)], \
  57. cpu_env, uim, rb); \
  58. tcg_temp_free_i32(uim); \
  59. tcg_temp_free_ptr(rb); \
  60. }
  61. #define GEN_DFP_BF_A_DCM(name) \
  62. static void gen_##name(DisasContext *ctx) \
  63. { \
  64. TCGv_ptr ra; \
  65. TCGv_i32 dcm; \
  66. if (unlikely(!ctx->fpu_enabled)) { \
  67. gen_exception(ctx, POWERPC_EXCP_FPU); \
  68. return; \
  69. } \
  70. gen_update_nip(ctx, ctx->base.pc_next - 4); \
  71. ra = gen_fprp_ptr(rA(ctx->opcode)); \
  72. dcm = tcg_const_i32(DCM(ctx->opcode)); \
  73. gen_helper_##name(cpu_crf[crfD(ctx->opcode)], \
  74. cpu_env, ra, dcm); \
  75. tcg_temp_free_ptr(ra); \
  76. tcg_temp_free_i32(dcm); \
  77. }
  78. #define GEN_DFP_T_B_U32_U32_Rc(name, u32f1, u32f2) \
  79. static void gen_##name(DisasContext *ctx) \
  80. { \
  81. TCGv_ptr rt, rb; \
  82. TCGv_i32 u32_1, u32_2; \
  83. if (unlikely(!ctx->fpu_enabled)) { \
  84. gen_exception(ctx, POWERPC_EXCP_FPU); \
  85. return; \
  86. } \
  87. gen_update_nip(ctx, ctx->base.pc_next - 4); \
  88. rt = gen_fprp_ptr(rD(ctx->opcode)); \
  89. rb = gen_fprp_ptr(rB(ctx->opcode)); \
  90. u32_1 = tcg_const_i32(u32f1(ctx->opcode)); \
  91. u32_2 = tcg_const_i32(u32f2(ctx->opcode)); \
  92. gen_helper_##name(cpu_env, rt, rb, u32_1, u32_2); \
  93. if (unlikely(Rc(ctx->opcode) != 0)) { \
  94. gen_set_cr1_from_fpscr(ctx); \
  95. } \
  96. tcg_temp_free_ptr(rt); \
  97. tcg_temp_free_ptr(rb); \
  98. tcg_temp_free_i32(u32_1); \
  99. tcg_temp_free_i32(u32_2); \
  100. }
  101. #define GEN_DFP_T_A_B_I32_Rc(name, i32fld) \
  102. static void gen_##name(DisasContext *ctx) \
  103. { \
  104. TCGv_ptr rt, ra, rb; \
  105. TCGv_i32 i32; \
  106. if (unlikely(!ctx->fpu_enabled)) { \
  107. gen_exception(ctx, POWERPC_EXCP_FPU); \
  108. return; \
  109. } \
  110. gen_update_nip(ctx, ctx->base.pc_next - 4); \
  111. rt = gen_fprp_ptr(rD(ctx->opcode)); \
  112. ra = gen_fprp_ptr(rA(ctx->opcode)); \
  113. rb = gen_fprp_ptr(rB(ctx->opcode)); \
  114. i32 = tcg_const_i32(i32fld(ctx->opcode)); \
  115. gen_helper_##name(cpu_env, rt, ra, rb, i32); \
  116. if (unlikely(Rc(ctx->opcode) != 0)) { \
  117. gen_set_cr1_from_fpscr(ctx); \
  118. } \
  119. tcg_temp_free_ptr(rt); \
  120. tcg_temp_free_ptr(rb); \
  121. tcg_temp_free_ptr(ra); \
  122. tcg_temp_free_i32(i32); \
  123. }
  124. #define GEN_DFP_T_B_Rc(name) \
  125. static void gen_##name(DisasContext *ctx) \
  126. { \
  127. TCGv_ptr rt, rb; \
  128. if (unlikely(!ctx->fpu_enabled)) { \
  129. gen_exception(ctx, POWERPC_EXCP_FPU); \
  130. return; \
  131. } \
  132. gen_update_nip(ctx, ctx->base.pc_next - 4); \
  133. rt = gen_fprp_ptr(rD(ctx->opcode)); \
  134. rb = gen_fprp_ptr(rB(ctx->opcode)); \
  135. gen_helper_##name(cpu_env, rt, rb); \
  136. if (unlikely(Rc(ctx->opcode) != 0)) { \
  137. gen_set_cr1_from_fpscr(ctx); \
  138. } \
  139. tcg_temp_free_ptr(rt); \
  140. tcg_temp_free_ptr(rb); \
  141. }
  142. #define GEN_DFP_T_FPR_I32_Rc(name, fprfld, i32fld) \
  143. static void gen_##name(DisasContext *ctx) \
  144. { \
  145. TCGv_ptr rt, rs; \
  146. TCGv_i32 i32; \
  147. if (unlikely(!ctx->fpu_enabled)) { \
  148. gen_exception(ctx, POWERPC_EXCP_FPU); \
  149. return; \
  150. } \
  151. gen_update_nip(ctx, ctx->base.pc_next - 4); \
  152. rt = gen_fprp_ptr(rD(ctx->opcode)); \
  153. rs = gen_fprp_ptr(fprfld(ctx->opcode)); \
  154. i32 = tcg_const_i32(i32fld(ctx->opcode)); \
  155. gen_helper_##name(cpu_env, rt, rs, i32); \
  156. if (unlikely(Rc(ctx->opcode) != 0)) { \
  157. gen_set_cr1_from_fpscr(ctx); \
  158. } \
  159. tcg_temp_free_ptr(rt); \
  160. tcg_temp_free_ptr(rs); \
  161. tcg_temp_free_i32(i32); \
  162. }
  163. GEN_DFP_T_A_B_Rc(dadd)
  164. GEN_DFP_T_A_B_Rc(daddq)
  165. GEN_DFP_T_A_B_Rc(dsub)
  166. GEN_DFP_T_A_B_Rc(dsubq)
  167. GEN_DFP_T_A_B_Rc(dmul)
  168. GEN_DFP_T_A_B_Rc(dmulq)
  169. GEN_DFP_T_A_B_Rc(ddiv)
  170. GEN_DFP_T_A_B_Rc(ddivq)
  171. GEN_DFP_BF_A_B(dcmpu)
  172. GEN_DFP_BF_A_B(dcmpuq)
  173. GEN_DFP_BF_A_B(dcmpo)
  174. GEN_DFP_BF_A_B(dcmpoq)
  175. GEN_DFP_BF_A_DCM(dtstdc)
  176. GEN_DFP_BF_A_DCM(dtstdcq)
  177. GEN_DFP_BF_A_DCM(dtstdg)
  178. GEN_DFP_BF_A_DCM(dtstdgq)
  179. GEN_DFP_BF_A_B(dtstex)
  180. GEN_DFP_BF_A_B(dtstexq)
  181. GEN_DFP_BF_A_B(dtstsf)
  182. GEN_DFP_BF_A_B(dtstsfq)
  183. GEN_DFP_BF_I_B(dtstsfi)
  184. GEN_DFP_BF_I_B(dtstsfiq)
  185. GEN_DFP_T_B_U32_U32_Rc(dquai, SIMM5, RMC)
  186. GEN_DFP_T_B_U32_U32_Rc(dquaiq, SIMM5, RMC)
  187. GEN_DFP_T_A_B_I32_Rc(dqua, RMC)
  188. GEN_DFP_T_A_B_I32_Rc(dquaq, RMC)
  189. GEN_DFP_T_A_B_I32_Rc(drrnd, RMC)
  190. GEN_DFP_T_A_B_I32_Rc(drrndq, RMC)
  191. GEN_DFP_T_B_U32_U32_Rc(drintx, FPW, RMC)
  192. GEN_DFP_T_B_U32_U32_Rc(drintxq, FPW, RMC)
  193. GEN_DFP_T_B_U32_U32_Rc(drintn, FPW, RMC)
  194. GEN_DFP_T_B_U32_U32_Rc(drintnq, FPW, RMC)
  195. GEN_DFP_T_B_Rc(dctdp)
  196. GEN_DFP_T_B_Rc(dctqpq)
  197. GEN_DFP_T_B_Rc(drsp)
  198. GEN_DFP_T_B_Rc(drdpq)
  199. GEN_DFP_T_B_Rc(dcffix)
  200. GEN_DFP_T_B_Rc(dcffixq)
  201. GEN_DFP_T_B_Rc(dctfix)
  202. GEN_DFP_T_B_Rc(dctfixq)
  203. GEN_DFP_T_FPR_I32_Rc(ddedpd, rB, SP)
  204. GEN_DFP_T_FPR_I32_Rc(ddedpdq, rB, SP)
  205. GEN_DFP_T_FPR_I32_Rc(denbcd, rB, SP)
  206. GEN_DFP_T_FPR_I32_Rc(denbcdq, rB, SP)
  207. GEN_DFP_T_B_Rc(dxex)
  208. GEN_DFP_T_B_Rc(dxexq)
  209. GEN_DFP_T_A_B_Rc(diex)
  210. GEN_DFP_T_A_B_Rc(diexq)
  211. GEN_DFP_T_FPR_I32_Rc(dscli, rA, DCM)
  212. GEN_DFP_T_FPR_I32_Rc(dscliq, rA, DCM)
  213. GEN_DFP_T_FPR_I32_Rc(dscri, rA, DCM)
  214. GEN_DFP_T_FPR_I32_Rc(dscriq, rA, DCM)
  215. #undef GEN_DFP_T_A_B_Rc
  216. #undef GEN_DFP_BF_A_B
  217. #undef GEN_DFP_BF_A_DCM
  218. #undef GEN_DFP_T_B_U32_U32_Rc
  219. #undef GEN_DFP_T_A_B_I32_Rc
  220. #undef GEN_DFP_T_B_Rc
  221. #undef GEN_DFP_T_FPR_I32_Rc