vfpinstr.cpp 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789
  1. // Copyright 2012 Michael Kang, 2015 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. /* Notice: this file should not be compiled as is, and is meant to be
  5. included in other files only. */
  6. /* ----------------------------------------------------------------------- */
  7. /* CDP instructions */
  8. /* cond 1110 opc1 CRn- CRd- copr op20 CRm- CDP */
  9. /* ----------------------------------------------------------------------- */
  10. /* VMLA */
  11. /* cond 1110 0D00 Vn-- Vd-- 101X N0M0 Vm-- */
  12. #ifdef VFP_INTERPRETER_STRUCT
  13. typedef struct _vmla_inst {
  14. unsigned int instr;
  15. unsigned int dp_operation;
  16. } vmla_inst;
  17. #endif
  18. #ifdef VFP_INTERPRETER_TRANS
  19. static ARM_INST_PTR INTERPRETER_TRANSLATE(vmla)(unsigned int inst, int index)
  20. {
  21. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vmla_inst));
  22. vmla_inst *inst_cream = (vmla_inst *)inst_base->component;
  23. inst_base->cond = BITS(inst, 28, 31);
  24. inst_base->idx = index;
  25. inst_base->br = NON_BRANCH;
  26. inst_base->load_r15 = 0;
  27. inst_cream->dp_operation = BIT(inst, 8);
  28. inst_cream->instr = inst;
  29. return inst_base;
  30. }
  31. #endif
  32. #ifdef VFP_INTERPRETER_IMPL
  33. VMLA_INST:
  34. {
  35. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  36. CHECK_VFP_ENABLED;
  37. vmla_inst *inst_cream = (vmla_inst *)inst_base->component;
  38. int ret;
  39. if (inst_cream->dp_operation)
  40. ret = vfp_double_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  41. else
  42. ret = vfp_single_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  43. CHECK_VFP_CDP_RET;
  44. }
  45. cpu->Reg[15] += GET_INST_SIZE(cpu);
  46. INC_PC(sizeof(vmla_inst));
  47. FETCH_INST;
  48. GOTO_NEXT_INST;
  49. }
  50. #endif
  51. /* ----------------------------------------------------------------------- */
  52. /* VNMLS */
  53. /* cond 1110 0D00 Vn-- Vd-- 101X N1M0 Vm-- */
  54. #ifdef VFP_INTERPRETER_STRUCT
  55. typedef struct _vmls_inst {
  56. unsigned int instr;
  57. unsigned int dp_operation;
  58. } vmls_inst;
  59. #endif
  60. #ifdef VFP_INTERPRETER_TRANS
  61. static ARM_INST_PTR INTERPRETER_TRANSLATE(vmls)(unsigned int inst, int index)
  62. {
  63. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vmls_inst));
  64. vmls_inst *inst_cream = (vmls_inst *)inst_base->component;
  65. inst_base->cond = BITS(inst, 28, 31);
  66. inst_base->idx = index;
  67. inst_base->br = NON_BRANCH;
  68. inst_base->load_r15 = 0;
  69. inst_cream->dp_operation = BIT(inst, 8);
  70. inst_cream->instr = inst;
  71. return inst_base;
  72. }
  73. #endif
  74. #ifdef VFP_INTERPRETER_IMPL
  75. VMLS_INST:
  76. {
  77. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  78. CHECK_VFP_ENABLED;
  79. vmls_inst *inst_cream = (vmls_inst *)inst_base->component;
  80. int ret;
  81. if (inst_cream->dp_operation)
  82. ret = vfp_double_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  83. else
  84. ret = vfp_single_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  85. CHECK_VFP_CDP_RET;
  86. }
  87. cpu->Reg[15] += GET_INST_SIZE(cpu);
  88. INC_PC(sizeof(vmls_inst));
  89. FETCH_INST;
  90. GOTO_NEXT_INST;
  91. }
  92. #endif
  93. /* ----------------------------------------------------------------------- */
  94. /* VNMLA */
  95. /* cond 1110 0D01 Vn-- Vd-- 101X N1M0 Vm-- */
  96. #ifdef VFP_INTERPRETER_STRUCT
  97. typedef struct _vnmla_inst {
  98. unsigned int instr;
  99. unsigned int dp_operation;
  100. } vnmla_inst;
  101. #endif
  102. #ifdef VFP_INTERPRETER_TRANS
  103. static ARM_INST_PTR INTERPRETER_TRANSLATE(vnmla)(unsigned int inst, int index)
  104. {
  105. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vnmla_inst));
  106. vnmla_inst *inst_cream = (vnmla_inst *)inst_base->component;
  107. inst_base->cond = BITS(inst, 28, 31);
  108. inst_base->idx = index;
  109. inst_base->br = NON_BRANCH;
  110. inst_base->load_r15 = 0;
  111. inst_cream->dp_operation = BIT(inst, 8);
  112. inst_cream->instr = inst;
  113. return inst_base;
  114. }
  115. #endif
  116. #ifdef VFP_INTERPRETER_IMPL
  117. VNMLA_INST:
  118. {
  119. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  120. CHECK_VFP_ENABLED;
  121. vnmla_inst *inst_cream = (vnmla_inst *)inst_base->component;
  122. int ret;
  123. if (inst_cream->dp_operation)
  124. ret = vfp_double_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  125. else
  126. ret = vfp_single_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  127. CHECK_VFP_CDP_RET;
  128. }
  129. cpu->Reg[15] += GET_INST_SIZE(cpu);
  130. INC_PC(sizeof(vnmla_inst));
  131. FETCH_INST;
  132. GOTO_NEXT_INST;
  133. }
  134. #endif
  135. /* ----------------------------------------------------------------------- */
  136. /* VNMLS */
  137. /* cond 1110 0D01 Vn-- Vd-- 101X N0M0 Vm-- */
  138. #ifdef VFP_INTERPRETER_STRUCT
  139. typedef struct _vnmls_inst {
  140. unsigned int instr;
  141. unsigned int dp_operation;
  142. } vnmls_inst;
  143. #endif
  144. #ifdef VFP_INTERPRETER_TRANS
  145. static ARM_INST_PTR INTERPRETER_TRANSLATE(vnmls)(unsigned int inst, int index)
  146. {
  147. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vnmls_inst));
  148. vnmls_inst *inst_cream = (vnmls_inst *)inst_base->component;
  149. inst_base->cond = BITS(inst, 28, 31);
  150. inst_base->idx = index;
  151. inst_base->br = NON_BRANCH;
  152. inst_base->load_r15 = 0;
  153. inst_cream->dp_operation = BIT(inst, 8);
  154. inst_cream->instr = inst;
  155. return inst_base;
  156. }
  157. #endif
  158. #ifdef VFP_INTERPRETER_IMPL
  159. VNMLS_INST:
  160. {
  161. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  162. CHECK_VFP_ENABLED;
  163. vnmls_inst *inst_cream = (vnmls_inst *)inst_base->component;
  164. int ret;
  165. if (inst_cream->dp_operation)
  166. ret = vfp_double_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  167. else
  168. ret = vfp_single_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  169. CHECK_VFP_CDP_RET;
  170. }
  171. cpu->Reg[15] += GET_INST_SIZE(cpu);
  172. INC_PC(sizeof(vnmls_inst));
  173. FETCH_INST;
  174. GOTO_NEXT_INST;
  175. }
  176. #endif
  177. /* ----------------------------------------------------------------------- */
  178. /* VNMUL */
  179. /* cond 1110 0D10 Vn-- Vd-- 101X N0M0 Vm-- */
  180. #ifdef VFP_INTERPRETER_STRUCT
  181. typedef struct _vnmul_inst {
  182. unsigned int instr;
  183. unsigned int dp_operation;
  184. } vnmul_inst;
  185. #endif
  186. #ifdef VFP_INTERPRETER_TRANS
  187. static ARM_INST_PTR INTERPRETER_TRANSLATE(vnmul)(unsigned int inst, int index)
  188. {
  189. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vnmul_inst));
  190. vnmul_inst *inst_cream = (vnmul_inst *)inst_base->component;
  191. inst_base->cond = BITS(inst, 28, 31);
  192. inst_base->idx = index;
  193. inst_base->br = NON_BRANCH;
  194. inst_base->load_r15 = 0;
  195. inst_cream->dp_operation = BIT(inst, 8);
  196. inst_cream->instr = inst;
  197. return inst_base;
  198. }
  199. #endif
  200. #ifdef VFP_INTERPRETER_IMPL
  201. VNMUL_INST:
  202. {
  203. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  204. CHECK_VFP_ENABLED;
  205. vnmul_inst *inst_cream = (vnmul_inst *)inst_base->component;
  206. int ret;
  207. if (inst_cream->dp_operation)
  208. ret = vfp_double_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  209. else
  210. ret = vfp_single_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  211. CHECK_VFP_CDP_RET;
  212. }
  213. cpu->Reg[15] += GET_INST_SIZE(cpu);
  214. INC_PC(sizeof(vnmul_inst));
  215. FETCH_INST;
  216. GOTO_NEXT_INST;
  217. }
  218. #endif
  219. /* ----------------------------------------------------------------------- */
  220. /* VMUL */
  221. /* cond 1110 0D10 Vn-- Vd-- 101X N0M0 Vm-- */
  222. #ifdef VFP_INTERPRETER_STRUCT
  223. typedef struct _vmul_inst {
  224. unsigned int instr;
  225. unsigned int dp_operation;
  226. } vmul_inst;
  227. #endif
  228. #ifdef VFP_INTERPRETER_TRANS
  229. static ARM_INST_PTR INTERPRETER_TRANSLATE(vmul)(unsigned int inst, int index)
  230. {
  231. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vmul_inst));
  232. vmul_inst *inst_cream = (vmul_inst *)inst_base->component;
  233. inst_base->cond = BITS(inst, 28, 31);
  234. inst_base->idx = index;
  235. inst_base->br = NON_BRANCH;
  236. inst_base->load_r15 = 0;
  237. inst_cream->dp_operation = BIT(inst, 8);
  238. inst_cream->instr = inst;
  239. return inst_base;
  240. }
  241. #endif
  242. #ifdef VFP_INTERPRETER_IMPL
  243. VMUL_INST:
  244. {
  245. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  246. CHECK_VFP_ENABLED;
  247. vmul_inst *inst_cream = (vmul_inst *)inst_base->component;
  248. int ret;
  249. if (inst_cream->dp_operation)
  250. ret = vfp_double_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  251. else
  252. ret = vfp_single_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  253. CHECK_VFP_CDP_RET;
  254. }
  255. cpu->Reg[15] += GET_INST_SIZE(cpu);
  256. INC_PC(sizeof(vmul_inst));
  257. FETCH_INST;
  258. GOTO_NEXT_INST;
  259. }
  260. #endif
  261. /* ----------------------------------------------------------------------- */
  262. /* VADD */
  263. /* cond 1110 0D11 Vn-- Vd-- 101X N0M0 Vm-- */
  264. #ifdef VFP_INTERPRETER_STRUCT
  265. typedef struct _vadd_inst {
  266. unsigned int instr;
  267. unsigned int dp_operation;
  268. } vadd_inst;
  269. #endif
  270. #ifdef VFP_INTERPRETER_TRANS
  271. static ARM_INST_PTR INTERPRETER_TRANSLATE(vadd)(unsigned int inst, int index)
  272. {
  273. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vadd_inst));
  274. vadd_inst *inst_cream = (vadd_inst *)inst_base->component;
  275. inst_base->cond = BITS(inst, 28, 31);
  276. inst_base->idx = index;
  277. inst_base->br = NON_BRANCH;
  278. inst_base->load_r15 = 0;
  279. inst_cream->dp_operation = BIT(inst, 8);
  280. inst_cream->instr = inst;
  281. return inst_base;
  282. }
  283. #endif
  284. #ifdef VFP_INTERPRETER_IMPL
  285. VADD_INST:
  286. {
  287. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  288. CHECK_VFP_ENABLED;
  289. vadd_inst *inst_cream = (vadd_inst *)inst_base->component;
  290. int ret;
  291. if (inst_cream->dp_operation)
  292. ret = vfp_double_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  293. else
  294. ret = vfp_single_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  295. CHECK_VFP_CDP_RET;
  296. }
  297. cpu->Reg[15] += GET_INST_SIZE(cpu);
  298. INC_PC(sizeof(vadd_inst));
  299. FETCH_INST;
  300. GOTO_NEXT_INST;
  301. }
  302. #endif
  303. /* ----------------------------------------------------------------------- */
  304. /* VSUB */
  305. /* cond 1110 0D11 Vn-- Vd-- 101X N1M0 Vm-- */
  306. #ifdef VFP_INTERPRETER_STRUCT
  307. typedef struct _vsub_inst {
  308. unsigned int instr;
  309. unsigned int dp_operation;
  310. } vsub_inst;
  311. #endif
  312. #ifdef VFP_INTERPRETER_TRANS
  313. static ARM_INST_PTR INTERPRETER_TRANSLATE(vsub)(unsigned int inst, int index)
  314. {
  315. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vsub_inst));
  316. vsub_inst *inst_cream = (vsub_inst *)inst_base->component;
  317. inst_base->cond = BITS(inst, 28, 31);
  318. inst_base->idx = index;
  319. inst_base->br = NON_BRANCH;
  320. inst_base->load_r15 = 0;
  321. inst_cream->dp_operation = BIT(inst, 8);
  322. inst_cream->instr = inst;
  323. return inst_base;
  324. }
  325. #endif
  326. #ifdef VFP_INTERPRETER_IMPL
  327. VSUB_INST:
  328. {
  329. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  330. CHECK_VFP_ENABLED;
  331. vsub_inst *inst_cream = (vsub_inst *)inst_base->component;
  332. int ret;
  333. if (inst_cream->dp_operation)
  334. ret = vfp_double_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  335. else
  336. ret = vfp_single_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  337. CHECK_VFP_CDP_RET;
  338. }
  339. cpu->Reg[15] += GET_INST_SIZE(cpu);
  340. INC_PC(sizeof(vsub_inst));
  341. FETCH_INST;
  342. GOTO_NEXT_INST;
  343. }
  344. #endif
  345. /* ----------------------------------------------------------------------- */
  346. /* VDIV */
  347. /* cond 1110 1D00 Vn-- Vd-- 101X N0M0 Vm-- */
  348. #ifdef VFP_INTERPRETER_STRUCT
  349. typedef struct _vdiv_inst {
  350. unsigned int instr;
  351. unsigned int dp_operation;
  352. } vdiv_inst;
  353. #endif
  354. #ifdef VFP_INTERPRETER_TRANS
  355. static ARM_INST_PTR INTERPRETER_TRANSLATE(vdiv)(unsigned int inst, int index)
  356. {
  357. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vdiv_inst));
  358. vdiv_inst *inst_cream = (vdiv_inst *)inst_base->component;
  359. inst_base->cond = BITS(inst, 28, 31);
  360. inst_base->idx = index;
  361. inst_base->br = NON_BRANCH;
  362. inst_base->load_r15 = 0;
  363. inst_cream->dp_operation = BIT(inst, 8);
  364. inst_cream->instr = inst;
  365. return inst_base;
  366. }
  367. #endif
  368. #ifdef VFP_INTERPRETER_IMPL
  369. VDIV_INST:
  370. {
  371. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  372. CHECK_VFP_ENABLED;
  373. vdiv_inst *inst_cream = (vdiv_inst *)inst_base->component;
  374. int ret;
  375. if (inst_cream->dp_operation)
  376. ret = vfp_double_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  377. else
  378. ret = vfp_single_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  379. CHECK_VFP_CDP_RET;
  380. }
  381. cpu->Reg[15] += GET_INST_SIZE(cpu);
  382. INC_PC(sizeof(vdiv_inst));
  383. FETCH_INST;
  384. GOTO_NEXT_INST;
  385. }
  386. #endif
  387. /* ----------------------------------------------------------------------- */
  388. /* VMOVI move immediate */
  389. /* cond 1110 1D11 im4H Vd-- 101X 0000 im4L */
  390. /* cond 1110 opc1 CRn- CRd- copr op20 CRm- CDP */
  391. #ifdef VFP_INTERPRETER_STRUCT
  392. typedef struct _vmovi_inst {
  393. unsigned int single;
  394. unsigned int d;
  395. unsigned int imm;
  396. } vmovi_inst;
  397. #endif
  398. #ifdef VFP_INTERPRETER_TRANS
  399. static ARM_INST_PTR INTERPRETER_TRANSLATE(vmovi)(unsigned int inst, int index)
  400. {
  401. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vmovi_inst));
  402. vmovi_inst *inst_cream = (vmovi_inst *)inst_base->component;
  403. inst_base->cond = BITS(inst, 28, 31);
  404. inst_base->idx = index;
  405. inst_base->br = NON_BRANCH;
  406. inst_base->load_r15 = 0;
  407. inst_cream->single = BIT(inst, 8) == 0;
  408. inst_cream->d = (inst_cream->single ? BITS(inst,12,15)<<1 | BIT(inst,22) : BITS(inst,12,15) | BIT(inst,22)<<4);
  409. unsigned int imm8 = BITS(inst, 16, 19) << 4 | BITS(inst, 0, 3);
  410. if (inst_cream->single)
  411. inst_cream->imm = BIT(imm8, 7)<<31 | (BIT(imm8, 6)==0)<<30 | (BIT(imm8, 6) ? 0x1f : 0)<<25 | BITS(imm8, 0, 5)<<19;
  412. else
  413. inst_cream->imm = BIT(imm8, 7)<<31 | (BIT(imm8, 6)==0)<<30 | (BIT(imm8, 6) ? 0xff : 0)<<22 | BITS(imm8, 0, 5)<<16;
  414. return inst_base;
  415. }
  416. #endif
  417. #ifdef VFP_INTERPRETER_IMPL
  418. VMOVI_INST:
  419. {
  420. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  421. CHECK_VFP_ENABLED;
  422. vmovi_inst *inst_cream = (vmovi_inst *)inst_base->component;
  423. VMOVI(cpu, inst_cream->single, inst_cream->d, inst_cream->imm);
  424. }
  425. cpu->Reg[15] += GET_INST_SIZE(cpu);
  426. INC_PC(sizeof(vmovi_inst));
  427. FETCH_INST;
  428. GOTO_NEXT_INST;
  429. }
  430. #endif
  431. /* ----------------------------------------------------------------------- */
  432. /* VMOVR move register */
  433. /* cond 1110 1D11 0000 Vd-- 101X 01M0 Vm-- */
  434. /* cond 1110 opc1 CRn- CRd- copr op20 CRm- CDP */
  435. #ifdef VFP_INTERPRETER_STRUCT
  436. typedef struct _vmovr_inst {
  437. unsigned int single;
  438. unsigned int d;
  439. unsigned int m;
  440. } vmovr_inst;
  441. #endif
  442. #ifdef VFP_INTERPRETER_TRANS
  443. static ARM_INST_PTR INTERPRETER_TRANSLATE(vmovr)(unsigned int inst, int index)
  444. {
  445. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vmovr_inst));
  446. vmovr_inst *inst_cream = (vmovr_inst *)inst_base->component;
  447. inst_base->cond = BITS(inst, 28, 31);
  448. inst_base->idx = index;
  449. inst_base->br = NON_BRANCH;
  450. inst_base->load_r15 = 0;
  451. inst_cream->single = BIT(inst, 8) == 0;
  452. inst_cream->d = (inst_cream->single ? BITS(inst,12,15)<<1 | BIT(inst,22) : BITS(inst,12,15) | BIT(inst,22)<<4);
  453. inst_cream->m = (inst_cream->single ? BITS(inst, 0, 3)<<1 | BIT(inst, 5) : BITS(inst, 0, 3) | BIT(inst, 5)<<4);
  454. return inst_base;
  455. }
  456. #endif
  457. #ifdef VFP_INTERPRETER_IMPL
  458. VMOVR_INST:
  459. {
  460. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  461. CHECK_VFP_ENABLED;
  462. vmovr_inst *inst_cream = (vmovr_inst *)inst_base->component;
  463. VMOVR(cpu, inst_cream->single, inst_cream->d, inst_cream->m);
  464. }
  465. cpu->Reg[15] += GET_INST_SIZE(cpu);
  466. INC_PC(sizeof(vmovr_inst));
  467. FETCH_INST;
  468. GOTO_NEXT_INST;
  469. }
  470. #endif
  471. /* ----------------------------------------------------------------------- */
  472. /* VABS */
  473. /* cond 1110 1D11 0000 Vd-- 101X 11M0 Vm-- */
  474. #ifdef VFP_INTERPRETER_STRUCT
  475. typedef struct _vabs_inst {
  476. unsigned int instr;
  477. unsigned int dp_operation;
  478. } vabs_inst;
  479. #endif
  480. #ifdef VFP_INTERPRETER_TRANS
  481. static ARM_INST_PTR INTERPRETER_TRANSLATE(vabs)(unsigned int inst, int index)
  482. {
  483. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vabs_inst));
  484. vabs_inst *inst_cream = (vabs_inst *)inst_base->component;
  485. inst_base->cond = BITS(inst, 28, 31);
  486. inst_base->idx = index;
  487. inst_base->br = NON_BRANCH;
  488. inst_base->load_r15 = 0;
  489. inst_cream->dp_operation = BIT(inst, 8);
  490. inst_cream->instr = inst;
  491. return inst_base;
  492. }
  493. #endif
  494. #ifdef VFP_INTERPRETER_IMPL
  495. VABS_INST:
  496. {
  497. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  498. CHECK_VFP_ENABLED;
  499. vabs_inst *inst_cream = (vabs_inst *)inst_base->component;
  500. int ret;
  501. if (inst_cream->dp_operation)
  502. ret = vfp_double_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  503. else
  504. ret = vfp_single_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  505. CHECK_VFP_CDP_RET;
  506. }
  507. cpu->Reg[15] += GET_INST_SIZE(cpu);
  508. INC_PC(sizeof(vabs_inst));
  509. FETCH_INST;
  510. GOTO_NEXT_INST;
  511. }
  512. #endif
  513. /* ----------------------------------------------------------------------- */
  514. /* VNEG */
  515. /* cond 1110 1D11 0001 Vd-- 101X 11M0 Vm-- */
  516. #ifdef VFP_INTERPRETER_STRUCT
  517. typedef struct _vneg_inst {
  518. unsigned int instr;
  519. unsigned int dp_operation;
  520. } vneg_inst;
  521. #endif
  522. #ifdef VFP_INTERPRETER_TRANS
  523. static ARM_INST_PTR INTERPRETER_TRANSLATE(vneg)(unsigned int inst, int index)
  524. {
  525. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vneg_inst));
  526. vneg_inst *inst_cream = (vneg_inst *)inst_base->component;
  527. inst_base->cond = BITS(inst, 28, 31);
  528. inst_base->idx = index;
  529. inst_base->br = NON_BRANCH;
  530. inst_base->load_r15 = 0;
  531. inst_cream->dp_operation = BIT(inst, 8);
  532. inst_cream->instr = inst;
  533. return inst_base;
  534. }
  535. #endif
  536. #ifdef VFP_INTERPRETER_IMPL
  537. VNEG_INST:
  538. {
  539. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  540. CHECK_VFP_ENABLED;
  541. vneg_inst *inst_cream = (vneg_inst *)inst_base->component;
  542. int ret;
  543. if (inst_cream->dp_operation)
  544. ret = vfp_double_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  545. else
  546. ret = vfp_single_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  547. CHECK_VFP_CDP_RET;
  548. }
  549. cpu->Reg[15] += GET_INST_SIZE(cpu);
  550. INC_PC(sizeof(vneg_inst));
  551. FETCH_INST;
  552. GOTO_NEXT_INST;
  553. }
  554. #endif
  555. /* ----------------------------------------------------------------------- */
  556. /* VSQRT */
  557. /* cond 1110 1D11 0001 Vd-- 101X 11M0 Vm-- */
  558. #ifdef VFP_INTERPRETER_STRUCT
  559. typedef struct _vsqrt_inst {
  560. unsigned int instr;
  561. unsigned int dp_operation;
  562. } vsqrt_inst;
  563. #endif
  564. #ifdef VFP_INTERPRETER_TRANS
  565. static ARM_INST_PTR INTERPRETER_TRANSLATE(vsqrt)(unsigned int inst, int index)
  566. {
  567. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vsqrt_inst));
  568. vsqrt_inst *inst_cream = (vsqrt_inst *)inst_base->component;
  569. inst_base->cond = BITS(inst, 28, 31);
  570. inst_base->idx = index;
  571. inst_base->br = NON_BRANCH;
  572. inst_base->load_r15 = 0;
  573. inst_cream->dp_operation = BIT(inst, 8);
  574. inst_cream->instr = inst;
  575. return inst_base;
  576. }
  577. #endif
  578. #ifdef VFP_INTERPRETER_IMPL
  579. VSQRT_INST:
  580. {
  581. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  582. CHECK_VFP_ENABLED;
  583. vsqrt_inst *inst_cream = (vsqrt_inst *)inst_base->component;
  584. int ret;
  585. if (inst_cream->dp_operation)
  586. ret = vfp_double_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  587. else
  588. ret = vfp_single_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  589. CHECK_VFP_CDP_RET;
  590. }
  591. cpu->Reg[15] += GET_INST_SIZE(cpu);
  592. INC_PC(sizeof(vsqrt_inst));
  593. FETCH_INST;
  594. GOTO_NEXT_INST;
  595. }
  596. #endif
  597. /* ----------------------------------------------------------------------- */
  598. /* VCMP VCMPE */
  599. /* cond 1110 1D11 0100 Vd-- 101X E1M0 Vm-- Encoding 1 */
  600. #ifdef VFP_INTERPRETER_STRUCT
  601. typedef struct _vcmp_inst {
  602. unsigned int instr;
  603. unsigned int dp_operation;
  604. } vcmp_inst;
  605. #endif
  606. #ifdef VFP_INTERPRETER_TRANS
  607. static ARM_INST_PTR INTERPRETER_TRANSLATE(vcmp)(unsigned int inst, int index)
  608. {
  609. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vcmp_inst));
  610. vcmp_inst *inst_cream = (vcmp_inst *)inst_base->component;
  611. inst_base->cond = BITS(inst, 28, 31);
  612. inst_base->idx = index;
  613. inst_base->br = NON_BRANCH;
  614. inst_base->load_r15 = 0;
  615. inst_cream->dp_operation = BIT(inst, 8);
  616. inst_cream->instr = inst;
  617. return inst_base;
  618. }
  619. #endif
  620. #ifdef VFP_INTERPRETER_IMPL
  621. VCMP_INST:
  622. {
  623. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  624. CHECK_VFP_ENABLED;
  625. vcmp_inst *inst_cream = (vcmp_inst *)inst_base->component;
  626. int ret;
  627. if (inst_cream->dp_operation)
  628. ret = vfp_double_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  629. else
  630. ret = vfp_single_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  631. CHECK_VFP_CDP_RET;
  632. }
  633. cpu->Reg[15] += GET_INST_SIZE(cpu);
  634. INC_PC(sizeof(vcmp_inst));
  635. FETCH_INST;
  636. GOTO_NEXT_INST;
  637. }
  638. #endif
  639. /* ----------------------------------------------------------------------- */
  640. /* VCMP VCMPE */
  641. /* cond 1110 1D11 0100 Vd-- 101X E1M0 Vm-- Encoding 2 */
  642. #ifdef VFP_INTERPRETER_STRUCT
  643. typedef struct _vcmp2_inst {
  644. unsigned int instr;
  645. unsigned int dp_operation;
  646. } vcmp2_inst;
  647. #endif
  648. #ifdef VFP_INTERPRETER_TRANS
  649. static ARM_INST_PTR INTERPRETER_TRANSLATE(vcmp2)(unsigned int inst, int index)
  650. {
  651. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vcmp2_inst));
  652. vcmp2_inst *inst_cream = (vcmp2_inst *)inst_base->component;
  653. inst_base->cond = BITS(inst, 28, 31);
  654. inst_base->idx = index;
  655. inst_base->br = NON_BRANCH;
  656. inst_base->load_r15 = 0;
  657. inst_cream->dp_operation = BIT(inst, 8);
  658. inst_cream->instr = inst;
  659. return inst_base;
  660. }
  661. #endif
  662. #ifdef VFP_INTERPRETER_IMPL
  663. VCMP2_INST:
  664. {
  665. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  666. CHECK_VFP_ENABLED;
  667. vcmp2_inst *inst_cream = (vcmp2_inst *)inst_base->component;
  668. int ret;
  669. if (inst_cream->dp_operation)
  670. ret = vfp_double_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  671. else
  672. ret = vfp_single_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  673. CHECK_VFP_CDP_RET;
  674. }
  675. cpu->Reg[15] += GET_INST_SIZE(cpu);
  676. INC_PC(sizeof(vcmp2_inst));
  677. FETCH_INST;
  678. GOTO_NEXT_INST;
  679. }
  680. #endif
  681. /* ----------------------------------------------------------------------- */
  682. /* VCVTBDS between double and single */
  683. /* cond 1110 1D11 0111 Vd-- 101X 11M0 Vm-- */
  684. #ifdef VFP_INTERPRETER_STRUCT
  685. typedef struct _vcvtbds_inst {
  686. unsigned int instr;
  687. unsigned int dp_operation;
  688. } vcvtbds_inst;
  689. #endif
  690. #ifdef VFP_INTERPRETER_TRANS
  691. static ARM_INST_PTR INTERPRETER_TRANSLATE(vcvtbds)(unsigned int inst, int index)
  692. {
  693. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vcvtbds_inst));
  694. vcvtbds_inst *inst_cream = (vcvtbds_inst *)inst_base->component;
  695. inst_base->cond = BITS(inst, 28, 31);
  696. inst_base->idx = index;
  697. inst_base->br = NON_BRANCH;
  698. inst_base->load_r15 = 0;
  699. inst_cream->dp_operation = BIT(inst, 8);
  700. inst_cream->instr = inst;
  701. return inst_base;
  702. }
  703. #endif
  704. #ifdef VFP_INTERPRETER_IMPL
  705. VCVTBDS_INST:
  706. {
  707. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  708. CHECK_VFP_ENABLED;
  709. vcvtbds_inst *inst_cream = (vcvtbds_inst *)inst_base->component;
  710. int ret;
  711. if (inst_cream->dp_operation)
  712. ret = vfp_double_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  713. else
  714. ret = vfp_single_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  715. CHECK_VFP_CDP_RET;
  716. }
  717. cpu->Reg[15] += GET_INST_SIZE(cpu);
  718. INC_PC(sizeof(vcvtbds_inst));
  719. FETCH_INST;
  720. GOTO_NEXT_INST;
  721. }
  722. #endif
  723. /* ----------------------------------------------------------------------- */
  724. /* VCVTBFF between floating point and fixed point */
  725. /* cond 1110 1D11 1op2 Vd-- 101X X1M0 Vm-- */
  726. #ifdef VFP_INTERPRETER_STRUCT
  727. typedef struct _vcvtbff_inst {
  728. unsigned int instr;
  729. unsigned int dp_operation;
  730. } vcvtbff_inst;
  731. #endif
  732. #ifdef VFP_INTERPRETER_TRANS
  733. static ARM_INST_PTR INTERPRETER_TRANSLATE(vcvtbff)(unsigned int inst, int index)
  734. {
  735. VFP_DEBUG_UNTESTED(VCVTBFF);
  736. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vcvtbff_inst));
  737. vcvtbff_inst *inst_cream = (vcvtbff_inst *)inst_base->component;
  738. inst_base->cond = BITS(inst, 28, 31);
  739. inst_base->idx = index;
  740. inst_base->br = NON_BRANCH;
  741. inst_base->load_r15 = 0;
  742. inst_cream->dp_operation = BIT(inst, 8);
  743. inst_cream->instr = inst;
  744. return inst_base;
  745. }
  746. #endif
  747. #ifdef VFP_INTERPRETER_IMPL
  748. VCVTBFF_INST:
  749. {
  750. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  751. CHECK_VFP_ENABLED;
  752. vcvtbff_inst *inst_cream = (vcvtbff_inst *)inst_base->component;
  753. int ret;
  754. if (inst_cream->dp_operation)
  755. ret = vfp_double_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  756. else
  757. ret = vfp_single_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  758. CHECK_VFP_CDP_RET;
  759. }
  760. cpu->Reg[15] += GET_INST_SIZE(cpu);
  761. INC_PC(sizeof(vcvtbff_inst));
  762. FETCH_INST;
  763. GOTO_NEXT_INST;
  764. }
  765. #endif
  766. /* ----------------------------------------------------------------------- */
  767. /* VCVTBFI between floating point and integer */
  768. /* cond 1110 1D11 1op2 Vd-- 101X X1M0 Vm-- */
  769. #ifdef VFP_INTERPRETER_STRUCT
  770. typedef struct _vcvtbfi_inst {
  771. unsigned int instr;
  772. unsigned int dp_operation;
  773. } vcvtbfi_inst;
  774. #endif
  775. #ifdef VFP_INTERPRETER_TRANS
  776. static ARM_INST_PTR INTERPRETER_TRANSLATE(vcvtbfi)(unsigned int inst, int index)
  777. {
  778. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vcvtbfi_inst));
  779. vcvtbfi_inst *inst_cream = (vcvtbfi_inst *)inst_base->component;
  780. inst_base->cond = BITS(inst, 28, 31);
  781. inst_base->idx = index;
  782. inst_base->br = NON_BRANCH;
  783. inst_base->load_r15 = 0;
  784. inst_cream->dp_operation = BIT(inst, 8);
  785. inst_cream->instr = inst;
  786. return inst_base;
  787. }
  788. #endif
  789. #ifdef VFP_INTERPRETER_IMPL
  790. VCVTBFI_INST:
  791. {
  792. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  793. CHECK_VFP_ENABLED;
  794. vcvtbfi_inst *inst_cream = (vcvtbfi_inst *)inst_base->component;
  795. int ret;
  796. if (inst_cream->dp_operation)
  797. ret = vfp_double_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  798. else
  799. ret = vfp_single_cpdo(cpu, inst_cream->instr, cpu->VFP[VFP_FPSCR]);
  800. CHECK_VFP_CDP_RET;
  801. }
  802. cpu->Reg[15] += GET_INST_SIZE(cpu);
  803. INC_PC(sizeof(vcvtbfi_inst));
  804. FETCH_INST;
  805. GOTO_NEXT_INST;
  806. }
  807. #endif
  808. /* ----------------------------------------------------------------------- */
  809. /* MRC / MCR instructions */
  810. /* cond 1110 AAAL XXXX XXXX 101C XBB1 XXXX */
  811. /* cond 1110 op11 CRn- Rt-- copr op21 CRm- */
  812. /* ----------------------------------------------------------------------- */
  813. /* VMOVBRS between register and single precision */
  814. /* cond 1110 000o Vn-- Rt-- 1010 N001 0000 */
  815. /* cond 1110 op11 CRn- Rt-- copr op21 CRm- MRC */
  816. #ifdef VFP_INTERPRETER_STRUCT
  817. typedef struct _vmovbrs_inst {
  818. unsigned int to_arm;
  819. unsigned int t;
  820. unsigned int n;
  821. } vmovbrs_inst;
  822. #endif
  823. #ifdef VFP_INTERPRETER_TRANS
  824. static ARM_INST_PTR INTERPRETER_TRANSLATE(vmovbrs)(unsigned int inst, int index)
  825. {
  826. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vmovbrs_inst));
  827. vmovbrs_inst *inst_cream = (vmovbrs_inst *)inst_base->component;
  828. inst_base->cond = BITS(inst, 28, 31);
  829. inst_base->idx = index;
  830. inst_base->br = NON_BRANCH;
  831. inst_base->load_r15 = 0;
  832. inst_cream->to_arm = BIT(inst, 20) == 1;
  833. inst_cream->t = BITS(inst, 12, 15);
  834. inst_cream->n = BIT(inst, 7) | BITS(inst, 16, 19)<<1;
  835. return inst_base;
  836. }
  837. #endif
  838. #ifdef VFP_INTERPRETER_IMPL
  839. VMOVBRS_INST:
  840. {
  841. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  842. CHECK_VFP_ENABLED;
  843. vmovbrs_inst *inst_cream = (vmovbrs_inst *)inst_base->component;
  844. VMOVBRS(cpu, inst_cream->to_arm, inst_cream->t, inst_cream->n, &(cpu->Reg[inst_cream->t]));
  845. }
  846. cpu->Reg[15] += GET_INST_SIZE(cpu);
  847. INC_PC(sizeof(vmovbrs_inst));
  848. FETCH_INST;
  849. GOTO_NEXT_INST;
  850. }
  851. #endif
  852. /* ----------------------------------------------------------------------- */
  853. /* VMSR */
  854. /* cond 1110 1110 reg- Rt-- 1010 0001 0000 */
  855. /* cond 1110 op10 CRn- Rt-- copr op21 CRm- MCR */
  856. #ifdef VFP_INTERPRETER_STRUCT
  857. typedef struct _vmsr_inst {
  858. unsigned int reg;
  859. unsigned int Rd;
  860. } vmsr_inst;
  861. #endif
  862. #ifdef VFP_INTERPRETER_TRANS
  863. static ARM_INST_PTR INTERPRETER_TRANSLATE(vmsr)(unsigned int inst, int index)
  864. {
  865. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vmsr_inst));
  866. vmsr_inst *inst_cream = (vmsr_inst *)inst_base->component;
  867. inst_base->cond = BITS(inst, 28, 31);
  868. inst_base->idx = index;
  869. inst_base->br = NON_BRANCH;
  870. inst_base->load_r15 = 0;
  871. inst_cream->reg = BITS(inst, 16, 19);
  872. inst_cream->Rd = BITS(inst, 12, 15);
  873. return inst_base;
  874. }
  875. #endif
  876. #ifdef VFP_INTERPRETER_IMPL
  877. VMSR_INST:
  878. {
  879. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  880. /* FIXME: special case for access to FPSID and FPEXC, VFP must be disabled ,
  881. and in privilegied mode */
  882. /* Exceptions must be checked, according to v7 ref manual */
  883. CHECK_VFP_ENABLED;
  884. vmsr_inst *inst_cream = (vmsr_inst *)inst_base->component;
  885. VMSR(cpu, inst_cream->reg, inst_cream->Rd);
  886. }
  887. cpu->Reg[15] += GET_INST_SIZE(cpu);
  888. INC_PC(sizeof(vmsr_inst));
  889. FETCH_INST;
  890. GOTO_NEXT_INST;
  891. }
  892. #endif
  893. /* ----------------------------------------------------------------------- */
  894. /* VMOVBRC register to scalar */
  895. /* cond 1110 0XX0 Vd-- Rt-- 1011 DXX1 0000 */
  896. /* cond 1110 op10 CRn- Rt-- copr op21 CRm- MCR */
  897. #ifdef VFP_INTERPRETER_STRUCT
  898. typedef struct _vmovbrc_inst {
  899. unsigned int esize;
  900. unsigned int index;
  901. unsigned int d;
  902. unsigned int t;
  903. } vmovbrc_inst;
  904. #endif
  905. #ifdef VFP_INTERPRETER_TRANS
  906. static ARM_INST_PTR INTERPRETER_TRANSLATE(vmovbrc)(unsigned int inst, int index)
  907. {
  908. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vmovbrc_inst));
  909. vmovbrc_inst *inst_cream = (vmovbrc_inst *)inst_base->component;
  910. inst_base->cond = BITS(inst, 28, 31);
  911. inst_base->idx = index;
  912. inst_base->br = NON_BRANCH;
  913. inst_base->load_r15 = 0;
  914. inst_cream->d = BITS(inst, 16, 19)|BIT(inst, 7)<<4;
  915. inst_cream->t = BITS(inst, 12, 15);
  916. /* VFP variant of instruction */
  917. inst_cream->esize = 32;
  918. inst_cream->index = BIT(inst, 21);
  919. return inst_base;
  920. }
  921. #endif
  922. #ifdef VFP_INTERPRETER_IMPL
  923. VMOVBRC_INST:
  924. {
  925. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  926. CHECK_VFP_ENABLED;
  927. vmovbrc_inst *inst_cream = (vmovbrc_inst *)inst_base->component;
  928. VFP_DEBUG_UNIMPLEMENTED(VMOVBRC);
  929. }
  930. cpu->Reg[15] += GET_INST_SIZE(cpu);
  931. INC_PC(sizeof(vmovbrc_inst));
  932. FETCH_INST;
  933. GOTO_NEXT_INST;
  934. }
  935. #endif
  936. /* ----------------------------------------------------------------------- */
  937. /* VMRS */
  938. /* cond 1110 1111 CRn- Rt-- 1010 0001 0000 */
  939. /* cond 1110 op11 CRn- Rt-- copr op21 CRm- MRC */
  940. #ifdef VFP_INTERPRETER_STRUCT
  941. typedef struct _vmrs_inst {
  942. unsigned int reg;
  943. unsigned int Rt;
  944. } vmrs_inst;
  945. #endif
  946. #ifdef VFP_INTERPRETER_TRANS
  947. static ARM_INST_PTR INTERPRETER_TRANSLATE(vmrs)(unsigned int inst, int index)
  948. {
  949. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vmrs_inst));
  950. vmrs_inst *inst_cream = (vmrs_inst *)inst_base->component;
  951. inst_base->cond = BITS(inst, 28, 31);
  952. inst_base->idx = index;
  953. inst_base->br = NON_BRANCH;
  954. inst_base->load_r15 = 0;
  955. inst_cream->reg = BITS(inst, 16, 19);
  956. inst_cream->Rt = BITS(inst, 12, 15);
  957. return inst_base;
  958. }
  959. #endif
  960. #ifdef VFP_INTERPRETER_IMPL
  961. VMRS_INST:
  962. {
  963. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  964. /* FIXME: special case for access to FPSID and FPEXC, VFP must be disabled,
  965. and in privilegied mode */
  966. /* Exceptions must be checked, according to v7 ref manual */
  967. CHECK_VFP_ENABLED;
  968. vmrs_inst *inst_cream = (vmrs_inst *)inst_base->component;
  969. if (inst_cream->reg == 1) /* FPSCR */
  970. {
  971. if (inst_cream->Rt != 15)
  972. {
  973. cpu->Reg[inst_cream->Rt] = cpu->VFP[VFP_FPSCR];
  974. }
  975. else
  976. {
  977. cpu->NFlag = (cpu->VFP[VFP_FPSCR] >> 31) & 1;
  978. cpu->ZFlag = (cpu->VFP[VFP_FPSCR] >> 30) & 1;
  979. cpu->CFlag = (cpu->VFP[VFP_FPSCR] >> 29) & 1;
  980. cpu->VFlag = (cpu->VFP[VFP_FPSCR] >> 28) & 1;
  981. }
  982. }
  983. else
  984. {
  985. switch (inst_cream->reg)
  986. {
  987. case 0:
  988. cpu->Reg[inst_cream->Rt] = cpu->VFP[VFP_FPSID];
  989. break;
  990. case 6:
  991. /* MVFR1, VFPv3 only ? */
  992. LOG_TRACE(Core_ARM11, "\tr%d <= MVFR1 unimplemented\n", inst_cream->Rt);
  993. break;
  994. case 7:
  995. /* MVFR0, VFPv3 only? */
  996. LOG_TRACE(Core_ARM11, "\tr%d <= MVFR0 unimplemented\n", inst_cream->Rt);
  997. break;
  998. case 8:
  999. cpu->Reg[inst_cream->Rt] = cpu->VFP[VFP_FPEXC];
  1000. break;
  1001. default:
  1002. break;
  1003. }
  1004. }
  1005. }
  1006. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1007. INC_PC(sizeof(vmrs_inst));
  1008. FETCH_INST;
  1009. GOTO_NEXT_INST;
  1010. }
  1011. #endif
  1012. /* ----------------------------------------------------------------------- */
  1013. /* VMOVBCR scalar to register */
  1014. /* cond 1110 XXX1 Vd-- Rt-- 1011 NXX1 0000 */
  1015. /* cond 1110 op11 CRn- Rt-- copr op21 CRm- MCR */
  1016. #ifdef VFP_INTERPRETER_STRUCT
  1017. typedef struct _vmovbcr_inst {
  1018. unsigned int esize;
  1019. unsigned int index;
  1020. unsigned int d;
  1021. unsigned int t;
  1022. } vmovbcr_inst;
  1023. #endif
  1024. #ifdef VFP_INTERPRETER_TRANS
  1025. static ARM_INST_PTR INTERPRETER_TRANSLATE(vmovbcr)(unsigned int inst, int index)
  1026. {
  1027. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vmovbcr_inst));
  1028. vmovbcr_inst *inst_cream = (vmovbcr_inst *)inst_base->component;
  1029. inst_base->cond = BITS(inst, 28, 31);
  1030. inst_base->idx = index;
  1031. inst_base->br = NON_BRANCH;
  1032. inst_base->load_r15 = 0;
  1033. inst_cream->d = BITS(inst, 16, 19)|BIT(inst, 7)<<4;
  1034. inst_cream->t = BITS(inst, 12, 15);
  1035. /* VFP variant of instruction */
  1036. inst_cream->esize = 32;
  1037. inst_cream->index = BIT(inst, 21);
  1038. return inst_base;
  1039. }
  1040. #endif
  1041. #ifdef VFP_INTERPRETER_IMPL
  1042. VMOVBCR_INST:
  1043. {
  1044. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1045. CHECK_VFP_ENABLED;
  1046. vmovbcr_inst *inst_cream = (vmovbcr_inst *)inst_base->component;
  1047. VFP_DEBUG_UNIMPLEMENTED(VMOVBCR);
  1048. }
  1049. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1050. INC_PC(sizeof(vmovbcr_inst));
  1051. FETCH_INST;
  1052. GOTO_NEXT_INST;
  1053. }
  1054. #endif
  1055. /* ----------------------------------------------------------------------- */
  1056. /* MRRC / MCRR instructions */
  1057. /* cond 1100 0101 Rt2- Rt-- copr opc1 CRm- MRRC */
  1058. /* cond 1100 0100 Rt2- Rt-- copr opc1 CRm- MCRR */
  1059. /* ----------------------------------------------------------------------- */
  1060. /* VMOVBRRSS between 2 registers to 2 singles */
  1061. /* cond 1100 010X Rt2- Rt-- 1010 00X1 Vm-- */
  1062. /* cond 1100 0101 Rt2- Rt-- copr opc1 CRm- MRRC */
  1063. #ifdef VFP_INTERPRETER_STRUCT
  1064. typedef struct _vmovbrrss_inst {
  1065. unsigned int to_arm;
  1066. unsigned int t;
  1067. unsigned int t2;
  1068. unsigned int m;
  1069. } vmovbrrss_inst;
  1070. #endif
  1071. #ifdef VFP_INTERPRETER_TRANS
  1072. static ARM_INST_PTR INTERPRETER_TRANSLATE(vmovbrrss)(unsigned int inst, int index)
  1073. {
  1074. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vmovbrrss_inst));
  1075. vmovbrrss_inst *inst_cream = (vmovbrrss_inst *)inst_base->component;
  1076. inst_base->cond = BITS(inst, 28, 31);
  1077. inst_base->idx = index;
  1078. inst_base->br = NON_BRANCH;
  1079. inst_base->load_r15 = 0;
  1080. inst_cream->to_arm = BIT(inst, 20) == 1;
  1081. inst_cream->t = BITS(inst, 12, 15);
  1082. inst_cream->t2 = BITS(inst, 16, 19);
  1083. inst_cream->m = BITS(inst, 0, 3)<<1|BIT(inst, 5);
  1084. return inst_base;
  1085. }
  1086. #endif
  1087. #ifdef VFP_INTERPRETER_IMPL
  1088. VMOVBRRSS_INST:
  1089. {
  1090. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1091. CHECK_VFP_ENABLED;
  1092. vmovbrrss_inst* const inst_cream = (vmovbrrss_inst*)inst_base->component;
  1093. VMOVBRRSS(cpu, inst_cream->to_arm, inst_cream->t, inst_cream->t2, inst_cream->m,
  1094. &cpu->Reg[inst_cream->t], &cpu->Reg[inst_cream->t2]);
  1095. }
  1096. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1097. INC_PC(sizeof(vmovbrrss_inst));
  1098. FETCH_INST;
  1099. GOTO_NEXT_INST;
  1100. }
  1101. #endif
  1102. /* ----------------------------------------------------------------------- */
  1103. /* VMOVBRRD between 2 registers and 1 double */
  1104. /* cond 1100 010X Rt2- Rt-- 1011 00X1 Vm-- */
  1105. /* cond 1100 0101 Rt2- Rt-- copr opc1 CRm- MRRC */
  1106. #ifdef VFP_INTERPRETER_STRUCT
  1107. typedef struct _vmovbrrd_inst {
  1108. unsigned int to_arm;
  1109. unsigned int t;
  1110. unsigned int t2;
  1111. unsigned int m;
  1112. } vmovbrrd_inst;
  1113. #endif
  1114. #ifdef VFP_INTERPRETER_TRANS
  1115. static ARM_INST_PTR INTERPRETER_TRANSLATE(vmovbrrd)(unsigned int inst, int index)
  1116. {
  1117. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vmovbrrd_inst));
  1118. vmovbrrd_inst *inst_cream = (vmovbrrd_inst *)inst_base->component;
  1119. inst_base->cond = BITS(inst, 28, 31);
  1120. inst_base->idx = index;
  1121. inst_base->br = NON_BRANCH;
  1122. inst_base->load_r15 = 0;
  1123. inst_cream->to_arm = BIT(inst, 20) == 1;
  1124. inst_cream->t = BITS(inst, 12, 15);
  1125. inst_cream->t2 = BITS(inst, 16, 19);
  1126. inst_cream->m = BIT(inst, 5)<<4 | BITS(inst, 0, 3);
  1127. return inst_base;
  1128. }
  1129. #endif
  1130. #ifdef VFP_INTERPRETER_IMPL
  1131. VMOVBRRD_INST:
  1132. {
  1133. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1134. CHECK_VFP_ENABLED;
  1135. vmovbrrd_inst *inst_cream = (vmovbrrd_inst *)inst_base->component;
  1136. VMOVBRRD(cpu, inst_cream->to_arm, inst_cream->t, inst_cream->t2, inst_cream->m,
  1137. &(cpu->Reg[inst_cream->t]), &(cpu->Reg[inst_cream->t2]));
  1138. }
  1139. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1140. INC_PC(sizeof(vmovbrrd_inst));
  1141. FETCH_INST;
  1142. GOTO_NEXT_INST;
  1143. }
  1144. #endif
  1145. /* ----------------------------------------------------------------------- */
  1146. /* LDC/STC between 2 registers and 1 double */
  1147. /* cond 110X XXX1 Rn-- CRd- copr imm- imm- LDC */
  1148. /* cond 110X XXX0 Rn-- CRd- copr imm8 imm8 STC */
  1149. /* ----------------------------------------------------------------------- */
  1150. /* VSTR */
  1151. /* cond 1101 UD00 Rn-- Vd-- 101X imm8 imm8 */
  1152. #ifdef VFP_INTERPRETER_STRUCT
  1153. typedef struct _vstr_inst {
  1154. unsigned int single;
  1155. unsigned int n;
  1156. unsigned int d;
  1157. unsigned int imm32;
  1158. unsigned int add;
  1159. } vstr_inst;
  1160. #endif
  1161. #ifdef VFP_INTERPRETER_TRANS
  1162. static ARM_INST_PTR INTERPRETER_TRANSLATE(vstr)(unsigned int inst, int index)
  1163. {
  1164. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vstr_inst));
  1165. vstr_inst *inst_cream = (vstr_inst *)inst_base->component;
  1166. inst_base->cond = BITS(inst, 28, 31);
  1167. inst_base->idx = index;
  1168. inst_base->br = NON_BRANCH;
  1169. inst_base->load_r15 = 0;
  1170. inst_cream->single = BIT(inst, 8) == 0;
  1171. inst_cream->add = BIT(inst, 23);
  1172. inst_cream->imm32 = BITS(inst, 0,7) << 2;
  1173. inst_cream->d = (inst_cream->single ? BITS(inst, 12, 15)<<1|BIT(inst, 22) : BITS(inst, 12, 15)|BIT(inst, 22)<<4);
  1174. inst_cream->n = BITS(inst, 16, 19);
  1175. return inst_base;
  1176. }
  1177. #endif
  1178. #ifdef VFP_INTERPRETER_IMPL
  1179. VSTR_INST:
  1180. {
  1181. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1182. CHECK_VFP_ENABLED;
  1183. vstr_inst *inst_cream = (vstr_inst *)inst_base->component;
  1184. unsigned int base = (inst_cream->n == 15 ? (cpu->Reg[inst_cream->n] & 0xFFFFFFFC) + 8 : cpu->Reg[inst_cream->n]);
  1185. addr = (inst_cream->add ? base + inst_cream->imm32 : base - inst_cream->imm32);
  1186. if (inst_cream->single)
  1187. {
  1188. WriteMemory32(cpu, addr, cpu->ExtReg[inst_cream->d]);
  1189. }
  1190. else
  1191. {
  1192. const u32 word1 = cpu->ExtReg[inst_cream->d*2+0];
  1193. const u32 word2 = cpu->ExtReg[inst_cream->d*2+1];
  1194. if (InBigEndianMode(cpu)) {
  1195. WriteMemory32(cpu, addr + 0, word2);
  1196. WriteMemory32(cpu, addr + 4, word1);
  1197. } else {
  1198. WriteMemory32(cpu, addr + 0, word1);
  1199. WriteMemory32(cpu, addr + 4, word2);
  1200. }
  1201. }
  1202. }
  1203. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1204. INC_PC(sizeof(vstr_inst));
  1205. FETCH_INST;
  1206. GOTO_NEXT_INST;
  1207. }
  1208. #endif
  1209. /* ----------------------------------------------------------------------- */
  1210. /* VPUSH */
  1211. /* cond 1101 0D10 1101 Vd-- 101X imm8 imm8 */
  1212. #ifdef VFP_INTERPRETER_STRUCT
  1213. typedef struct _vpush_inst {
  1214. unsigned int single;
  1215. unsigned int d;
  1216. unsigned int imm32;
  1217. unsigned int regs;
  1218. } vpush_inst;
  1219. #endif
  1220. #ifdef VFP_INTERPRETER_TRANS
  1221. static ARM_INST_PTR INTERPRETER_TRANSLATE(vpush)(unsigned int inst, int index)
  1222. {
  1223. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vpush_inst));
  1224. vpush_inst *inst_cream = (vpush_inst *)inst_base->component;
  1225. inst_base->cond = BITS(inst, 28, 31);
  1226. inst_base->idx = index;
  1227. inst_base->br = NON_BRANCH;
  1228. inst_base->load_r15 = 0;
  1229. inst_cream->single = BIT(inst, 8) == 0;
  1230. inst_cream->d = (inst_cream->single ? BITS(inst, 12, 15)<<1|BIT(inst, 22) : BITS(inst, 12, 15)|BIT(inst, 22)<<4);
  1231. inst_cream->imm32 = BITS(inst, 0, 7)<<2;
  1232. inst_cream->regs = (inst_cream->single ? BITS(inst, 0, 7) : BITS(inst, 1, 7));
  1233. return inst_base;
  1234. }
  1235. #endif
  1236. #ifdef VFP_INTERPRETER_IMPL
  1237. VPUSH_INST:
  1238. {
  1239. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1240. CHECK_VFP_ENABLED;
  1241. vpush_inst *inst_cream = (vpush_inst *)inst_base->component;
  1242. addr = cpu->Reg[R13] - inst_cream->imm32;
  1243. for (unsigned int i = 0; i < inst_cream->regs; i++)
  1244. {
  1245. if (inst_cream->single)
  1246. {
  1247. WriteMemory32(cpu, addr, cpu->ExtReg[inst_cream->d+i]);
  1248. addr += 4;
  1249. }
  1250. else
  1251. {
  1252. const u32 word1 = cpu->ExtReg[(inst_cream->d+i)*2+0];
  1253. const u32 word2 = cpu->ExtReg[(inst_cream->d+i)*2+1];
  1254. if (InBigEndianMode(cpu)) {
  1255. WriteMemory32(cpu, addr + 0, word2);
  1256. WriteMemory32(cpu, addr + 4, word1);
  1257. } else {
  1258. WriteMemory32(cpu, addr + 0, word1);
  1259. WriteMemory32(cpu, addr + 4, word2);
  1260. }
  1261. addr += 8;
  1262. }
  1263. }
  1264. cpu->Reg[R13] -= inst_cream->imm32;
  1265. }
  1266. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1267. INC_PC(sizeof(vpush_inst));
  1268. FETCH_INST;
  1269. GOTO_NEXT_INST;
  1270. }
  1271. #endif
  1272. /* ----------------------------------------------------------------------- */
  1273. /* VSTM */
  1274. /* cond 110P UDW0 Rn-- Vd-- 101X imm8 imm8 */
  1275. #ifdef VFP_INTERPRETER_STRUCT
  1276. typedef struct _vstm_inst {
  1277. unsigned int single;
  1278. unsigned int add;
  1279. unsigned int wback;
  1280. unsigned int d;
  1281. unsigned int n;
  1282. unsigned int imm32;
  1283. unsigned int regs;
  1284. } vstm_inst;
  1285. #endif
  1286. #ifdef VFP_INTERPRETER_TRANS
  1287. static ARM_INST_PTR INTERPRETER_TRANSLATE(vstm)(unsigned int inst, int index)
  1288. {
  1289. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vstm_inst));
  1290. vstm_inst *inst_cream = (vstm_inst *)inst_base->component;
  1291. inst_base->cond = BITS(inst, 28, 31);
  1292. inst_base->idx = index;
  1293. inst_base->br = NON_BRANCH;
  1294. inst_base->load_r15 = 0;
  1295. inst_cream->single = BIT(inst, 8) == 0;
  1296. inst_cream->add = BIT(inst, 23);
  1297. inst_cream->wback = BIT(inst, 21);
  1298. inst_cream->d = (inst_cream->single ? BITS(inst, 12, 15)<<1|BIT(inst, 22) : BITS(inst, 12, 15)|BIT(inst, 22)<<4);
  1299. inst_cream->n = BITS(inst, 16, 19);
  1300. inst_cream->imm32 = BITS(inst, 0, 7)<<2;
  1301. inst_cream->regs = (inst_cream->single ? BITS(inst, 0, 7) : BITS(inst, 1, 7));
  1302. return inst_base;
  1303. }
  1304. #endif
  1305. #ifdef VFP_INTERPRETER_IMPL
  1306. VSTM_INST: /* encoding 1 */
  1307. {
  1308. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1309. CHECK_VFP_ENABLED;
  1310. vstm_inst *inst_cream = (vstm_inst *)inst_base->component;
  1311. addr = (inst_cream->add ? cpu->Reg[inst_cream->n] : cpu->Reg[inst_cream->n] - inst_cream->imm32);
  1312. for (unsigned int i = 0; i < inst_cream->regs; i++)
  1313. {
  1314. if (inst_cream->single)
  1315. {
  1316. WriteMemory32(cpu, addr, cpu->ExtReg[inst_cream->d+i]);
  1317. addr += 4;
  1318. }
  1319. else
  1320. {
  1321. const u32 word1 = cpu->ExtReg[(inst_cream->d+i)*2+0];
  1322. const u32 word2 = cpu->ExtReg[(inst_cream->d+i)*2+1];
  1323. if (InBigEndianMode(cpu)) {
  1324. WriteMemory32(cpu, addr + 0, word2);
  1325. WriteMemory32(cpu, addr + 4, word1);
  1326. } else {
  1327. WriteMemory32(cpu, addr + 0, word1);
  1328. WriteMemory32(cpu, addr + 4, word2);
  1329. }
  1330. addr += 8;
  1331. }
  1332. }
  1333. if (inst_cream->wback){
  1334. cpu->Reg[inst_cream->n] = (inst_cream->add ? cpu->Reg[inst_cream->n] + inst_cream->imm32 :
  1335. cpu->Reg[inst_cream->n] - inst_cream->imm32);
  1336. }
  1337. }
  1338. cpu->Reg[15] += 4;
  1339. INC_PC(sizeof(vstm_inst));
  1340. FETCH_INST;
  1341. GOTO_NEXT_INST;
  1342. }
  1343. #endif
  1344. /* ----------------------------------------------------------------------- */
  1345. /* VPOP */
  1346. /* cond 1100 1D11 1101 Vd-- 101X imm8 imm8 */
  1347. #ifdef VFP_INTERPRETER_STRUCT
  1348. typedef struct _vpop_inst {
  1349. unsigned int single;
  1350. unsigned int d;
  1351. unsigned int imm32;
  1352. unsigned int regs;
  1353. } vpop_inst;
  1354. #endif
  1355. #ifdef VFP_INTERPRETER_TRANS
  1356. static ARM_INST_PTR INTERPRETER_TRANSLATE(vpop)(unsigned int inst, int index)
  1357. {
  1358. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vpop_inst));
  1359. vpop_inst *inst_cream = (vpop_inst *)inst_base->component;
  1360. inst_base->cond = BITS(inst, 28, 31);
  1361. inst_base->idx = index;
  1362. inst_base->br = NON_BRANCH;
  1363. inst_base->load_r15 = 0;
  1364. inst_cream->single = BIT(inst, 8) == 0;
  1365. inst_cream->d = (inst_cream->single ? (BITS(inst, 12, 15)<<1)|BIT(inst, 22) : BITS(inst, 12, 15)|(BIT(inst, 22)<<4));
  1366. inst_cream->imm32 = BITS(inst, 0, 7)<<2;
  1367. inst_cream->regs = (inst_cream->single ? BITS(inst, 0, 7) : BITS(inst, 1, 7));
  1368. return inst_base;
  1369. }
  1370. #endif
  1371. #ifdef VFP_INTERPRETER_IMPL
  1372. VPOP_INST:
  1373. {
  1374. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1375. CHECK_VFP_ENABLED;
  1376. vpop_inst *inst_cream = (vpop_inst *)inst_base->component;
  1377. addr = cpu->Reg[R13];
  1378. for (unsigned int i = 0; i < inst_cream->regs; i++)
  1379. {
  1380. if (inst_cream->single)
  1381. {
  1382. cpu->ExtReg[inst_cream->d+i] = ReadMemory32(cpu, addr);
  1383. addr += 4;
  1384. }
  1385. else
  1386. {
  1387. const u32 word1 = ReadMemory32(cpu, addr + 0);
  1388. const u32 word2 = ReadMemory32(cpu, addr + 4);
  1389. if (InBigEndianMode(cpu)) {
  1390. cpu->ExtReg[(inst_cream->d+i)*2+0] = word2;
  1391. cpu->ExtReg[(inst_cream->d+i)*2+1] = word1;
  1392. } else {
  1393. cpu->ExtReg[(inst_cream->d+i)*2+0] = word1;
  1394. cpu->ExtReg[(inst_cream->d+i)*2+1] = word2;
  1395. }
  1396. addr += 8;
  1397. }
  1398. }
  1399. cpu->Reg[R13] += inst_cream->imm32;
  1400. }
  1401. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1402. INC_PC(sizeof(vpop_inst));
  1403. FETCH_INST;
  1404. GOTO_NEXT_INST;
  1405. }
  1406. #endif
  1407. /* ----------------------------------------------------------------------- */
  1408. /* VLDR */
  1409. /* cond 1101 UD01 Rn-- Vd-- 101X imm8 imm8 */
  1410. #ifdef VFP_INTERPRETER_STRUCT
  1411. typedef struct _vldr_inst {
  1412. unsigned int single;
  1413. unsigned int n;
  1414. unsigned int d;
  1415. unsigned int imm32;
  1416. unsigned int add;
  1417. } vldr_inst;
  1418. #endif
  1419. #ifdef VFP_INTERPRETER_TRANS
  1420. static ARM_INST_PTR INTERPRETER_TRANSLATE(vldr)(unsigned int inst, int index)
  1421. {
  1422. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vldr_inst));
  1423. vldr_inst *inst_cream = (vldr_inst *)inst_base->component;
  1424. inst_base->cond = BITS(inst, 28, 31);
  1425. inst_base->idx = index;
  1426. inst_base->br = NON_BRANCH;
  1427. inst_base->load_r15 = 0;
  1428. inst_cream->single = BIT(inst, 8) == 0;
  1429. inst_cream->add = BIT(inst, 23);
  1430. inst_cream->imm32 = BITS(inst, 0,7) << 2;
  1431. inst_cream->d = (inst_cream->single ? BITS(inst, 12, 15)<<1|BIT(inst, 22) : BITS(inst, 12, 15)|BIT(inst, 22)<<4);
  1432. inst_cream->n = BITS(inst, 16, 19);
  1433. return inst_base;
  1434. }
  1435. #endif
  1436. #ifdef VFP_INTERPRETER_IMPL
  1437. VLDR_INST:
  1438. {
  1439. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1440. CHECK_VFP_ENABLED;
  1441. vldr_inst *inst_cream = (vldr_inst *)inst_base->component;
  1442. unsigned int base = (inst_cream->n == 15 ? (cpu->Reg[inst_cream->n] & 0xFFFFFFFC) + 8 : cpu->Reg[inst_cream->n]);
  1443. addr = (inst_cream->add ? base + inst_cream->imm32 : base - inst_cream->imm32);
  1444. if (inst_cream->single)
  1445. {
  1446. cpu->ExtReg[inst_cream->d] = ReadMemory32(cpu, addr);
  1447. }
  1448. else
  1449. {
  1450. const u32 word1 = ReadMemory32(cpu, addr + 0);
  1451. const u32 word2 = ReadMemory32(cpu, addr + 4);
  1452. if (InBigEndianMode(cpu)) {
  1453. cpu->ExtReg[inst_cream->d*2+0] = word2;
  1454. cpu->ExtReg[inst_cream->d*2+1] = word1;
  1455. } else {
  1456. cpu->ExtReg[inst_cream->d*2+0] = word1;
  1457. cpu->ExtReg[inst_cream->d*2+1] = word2;
  1458. }
  1459. }
  1460. }
  1461. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1462. INC_PC(sizeof(vldr_inst));
  1463. FETCH_INST;
  1464. GOTO_NEXT_INST;
  1465. }
  1466. #endif
  1467. /* ----------------------------------------------------------------------- */
  1468. /* VLDM */
  1469. /* cond 110P UDW1 Rn-- Vd-- 101X imm8 imm8 */
  1470. #ifdef VFP_INTERPRETER_STRUCT
  1471. typedef struct _vldm_inst {
  1472. unsigned int single;
  1473. unsigned int add;
  1474. unsigned int wback;
  1475. unsigned int d;
  1476. unsigned int n;
  1477. unsigned int imm32;
  1478. unsigned int regs;
  1479. } vldm_inst;
  1480. #endif
  1481. #ifdef VFP_INTERPRETER_TRANS
  1482. static ARM_INST_PTR INTERPRETER_TRANSLATE(vldm)(unsigned int inst, int index)
  1483. {
  1484. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vldm_inst));
  1485. vldm_inst *inst_cream = (vldm_inst *)inst_base->component;
  1486. inst_base->cond = BITS(inst, 28, 31);
  1487. inst_base->idx = index;
  1488. inst_base->br = NON_BRANCH;
  1489. inst_base->load_r15 = 0;
  1490. inst_cream->single = BIT(inst, 8) == 0;
  1491. inst_cream->add = BIT(inst, 23);
  1492. inst_cream->wback = BIT(inst, 21);
  1493. inst_cream->d = (inst_cream->single ? BITS(inst, 12, 15)<<1|BIT(inst, 22) : BITS(inst, 12, 15)|BIT(inst, 22)<<4);
  1494. inst_cream->n = BITS(inst, 16, 19);
  1495. inst_cream->imm32 = BITS(inst, 0, 7)<<2;
  1496. inst_cream->regs = (inst_cream->single ? BITS(inst, 0, 7) : BITS(inst, 1, 7));
  1497. return inst_base;
  1498. }
  1499. #endif
  1500. #ifdef VFP_INTERPRETER_IMPL
  1501. VLDM_INST:
  1502. {
  1503. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1504. CHECK_VFP_ENABLED;
  1505. vldm_inst *inst_cream = (vldm_inst *)inst_base->component;
  1506. addr = (inst_cream->add ? cpu->Reg[inst_cream->n] : cpu->Reg[inst_cream->n] - inst_cream->imm32);
  1507. for (unsigned int i = 0; i < inst_cream->regs; i++)
  1508. {
  1509. if (inst_cream->single)
  1510. {
  1511. cpu->ExtReg[inst_cream->d+i] = ReadMemory32(cpu, addr);
  1512. addr += 4;
  1513. }
  1514. else
  1515. {
  1516. const u32 word1 = ReadMemory32(cpu, addr + 0);
  1517. const u32 word2 = ReadMemory32(cpu, addr + 4);
  1518. if (InBigEndianMode(cpu)) {
  1519. cpu->ExtReg[(inst_cream->d+i)*2+0] = word2;
  1520. cpu->ExtReg[(inst_cream->d+i)*2+1] = word1;
  1521. } else {
  1522. cpu->ExtReg[(inst_cream->d+i)*2+0] = word1;
  1523. cpu->ExtReg[(inst_cream->d+i)*2+1] = word2;
  1524. }
  1525. addr += 8;
  1526. }
  1527. }
  1528. if (inst_cream->wback){
  1529. cpu->Reg[inst_cream->n] = (inst_cream->add ? cpu->Reg[inst_cream->n] + inst_cream->imm32 :
  1530. cpu->Reg[inst_cream->n] - inst_cream->imm32);
  1531. }
  1532. }
  1533. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1534. INC_PC(sizeof(vldm_inst));
  1535. FETCH_INST;
  1536. GOTO_NEXT_INST;
  1537. }
  1538. #endif