vfpinstr.cpp 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785
  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. struct vmla_inst {
  14. unsigned int instr;
  15. unsigned int dp_operation;
  16. };
  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. struct vmls_inst {
  56. unsigned int instr;
  57. unsigned int dp_operation;
  58. };
  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. struct vnmla_inst {
  98. unsigned int instr;
  99. unsigned int dp_operation;
  100. };
  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. struct vnmls_inst {
  140. unsigned int instr;
  141. unsigned int dp_operation;
  142. };
  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. struct vnmul_inst {
  182. unsigned int instr;
  183. unsigned int dp_operation;
  184. };
  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. struct vmul_inst {
  224. unsigned int instr;
  225. unsigned int dp_operation;
  226. };
  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. struct vadd_inst {
  266. unsigned int instr;
  267. unsigned int dp_operation;
  268. };
  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. struct vsub_inst {
  308. unsigned int instr;
  309. unsigned int dp_operation;
  310. };
  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. struct vdiv_inst {
  350. unsigned int instr;
  351. unsigned int dp_operation;
  352. };
  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. struct vmovi_inst {
  393. unsigned int single;
  394. unsigned int d;
  395. unsigned int imm;
  396. };
  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. struct vmovr_inst {
  437. unsigned int single;
  438. unsigned int d;
  439. unsigned int m;
  440. };
  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. struct vneg_inst {
  518. unsigned int instr;
  519. unsigned int dp_operation;
  520. };
  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. struct vsqrt_inst {
  560. unsigned int instr;
  561. unsigned int dp_operation;
  562. };
  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. struct vcmp_inst {
  602. unsigned int instr;
  603. unsigned int dp_operation;
  604. };
  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. struct vcmp2_inst {
  644. unsigned int instr;
  645. unsigned int dp_operation;
  646. };
  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. struct vcvtbds_inst {
  686. unsigned int instr;
  687. unsigned int dp_operation;
  688. };
  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. struct vcvtbff_inst {
  728. unsigned int instr;
  729. unsigned int dp_operation;
  730. };
  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. struct vcvtbfi_inst {
  771. unsigned int instr;
  772. unsigned int dp_operation;
  773. };
  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. struct vmovbrs_inst {
  818. unsigned int to_arm;
  819. unsigned int t;
  820. unsigned int n;
  821. };
  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. struct vmsr_inst {
  858. unsigned int reg;
  859. unsigned int Rd;
  860. };
  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 privileged 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. struct vmovbrc_inst {
  899. unsigned int esize;
  900. unsigned int index;
  901. unsigned int d;
  902. unsigned int t;
  903. };
  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. VFP_DEBUG_UNIMPLEMENTED(VMOVBRC);
  928. }
  929. cpu->Reg[15] += GET_INST_SIZE(cpu);
  930. INC_PC(sizeof(vmovbrc_inst));
  931. FETCH_INST;
  932. GOTO_NEXT_INST;
  933. }
  934. #endif
  935. /* ----------------------------------------------------------------------- */
  936. /* VMRS */
  937. /* cond 1110 1111 CRn- Rt-- 1010 0001 0000 */
  938. /* cond 1110 op11 CRn- Rt-- copr op21 CRm- MRC */
  939. #ifdef VFP_INTERPRETER_STRUCT
  940. struct vmrs_inst {
  941. unsigned int reg;
  942. unsigned int Rt;
  943. };
  944. #endif
  945. #ifdef VFP_INTERPRETER_TRANS
  946. static ARM_INST_PTR INTERPRETER_TRANSLATE(vmrs)(unsigned int inst, int index)
  947. {
  948. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vmrs_inst));
  949. vmrs_inst *inst_cream = (vmrs_inst *)inst_base->component;
  950. inst_base->cond = BITS(inst, 28, 31);
  951. inst_base->idx = index;
  952. inst_base->br = NON_BRANCH;
  953. inst_base->load_r15 = 0;
  954. inst_cream->reg = BITS(inst, 16, 19);
  955. inst_cream->Rt = BITS(inst, 12, 15);
  956. return inst_base;
  957. }
  958. #endif
  959. #ifdef VFP_INTERPRETER_IMPL
  960. VMRS_INST:
  961. {
  962. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  963. /* FIXME: special case for access to FPSID and FPEXC, VFP must be disabled,
  964. and in privileged mode */
  965. /* Exceptions must be checked, according to v7 ref manual */
  966. CHECK_VFP_ENABLED;
  967. vmrs_inst *inst_cream = (vmrs_inst *)inst_base->component;
  968. if (inst_cream->reg == 1) /* FPSCR */
  969. {
  970. if (inst_cream->Rt != 15)
  971. {
  972. cpu->Reg[inst_cream->Rt] = cpu->VFP[VFP_FPSCR];
  973. }
  974. else
  975. {
  976. cpu->NFlag = (cpu->VFP[VFP_FPSCR] >> 31) & 1;
  977. cpu->ZFlag = (cpu->VFP[VFP_FPSCR] >> 30) & 1;
  978. cpu->CFlag = (cpu->VFP[VFP_FPSCR] >> 29) & 1;
  979. cpu->VFlag = (cpu->VFP[VFP_FPSCR] >> 28) & 1;
  980. }
  981. }
  982. else
  983. {
  984. switch (inst_cream->reg)
  985. {
  986. case 0:
  987. cpu->Reg[inst_cream->Rt] = cpu->VFP[VFP_FPSID];
  988. break;
  989. case 6:
  990. /* MVFR1, VFPv3 only ? */
  991. LOG_TRACE(Core_ARM11, "\tr%d <= MVFR1 unimplemented\n", inst_cream->Rt);
  992. break;
  993. case 7:
  994. /* MVFR0, VFPv3 only? */
  995. LOG_TRACE(Core_ARM11, "\tr%d <= MVFR0 unimplemented\n", inst_cream->Rt);
  996. break;
  997. case 8:
  998. cpu->Reg[inst_cream->Rt] = cpu->VFP[VFP_FPEXC];
  999. break;
  1000. default:
  1001. break;
  1002. }
  1003. }
  1004. }
  1005. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1006. INC_PC(sizeof(vmrs_inst));
  1007. FETCH_INST;
  1008. GOTO_NEXT_INST;
  1009. }
  1010. #endif
  1011. /* ----------------------------------------------------------------------- */
  1012. /* VMOVBCR scalar to register */
  1013. /* cond 1110 XXX1 Vd-- Rt-- 1011 NXX1 0000 */
  1014. /* cond 1110 op11 CRn- Rt-- copr op21 CRm- MCR */
  1015. #ifdef VFP_INTERPRETER_STRUCT
  1016. struct vmovbcr_inst {
  1017. unsigned int esize;
  1018. unsigned int index;
  1019. unsigned int d;
  1020. unsigned int t;
  1021. };
  1022. #endif
  1023. #ifdef VFP_INTERPRETER_TRANS
  1024. static ARM_INST_PTR INTERPRETER_TRANSLATE(vmovbcr)(unsigned int inst, int index)
  1025. {
  1026. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vmovbcr_inst));
  1027. vmovbcr_inst *inst_cream = (vmovbcr_inst *)inst_base->component;
  1028. inst_base->cond = BITS(inst, 28, 31);
  1029. inst_base->idx = index;
  1030. inst_base->br = NON_BRANCH;
  1031. inst_base->load_r15 = 0;
  1032. inst_cream->d = BITS(inst, 16, 19)|BIT(inst, 7)<<4;
  1033. inst_cream->t = BITS(inst, 12, 15);
  1034. /* VFP variant of instruction */
  1035. inst_cream->esize = 32;
  1036. inst_cream->index = BIT(inst, 21);
  1037. return inst_base;
  1038. }
  1039. #endif
  1040. #ifdef VFP_INTERPRETER_IMPL
  1041. VMOVBCR_INST:
  1042. {
  1043. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1044. CHECK_VFP_ENABLED;
  1045. VFP_DEBUG_UNIMPLEMENTED(VMOVBCR);
  1046. }
  1047. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1048. INC_PC(sizeof(vmovbcr_inst));
  1049. FETCH_INST;
  1050. GOTO_NEXT_INST;
  1051. }
  1052. #endif
  1053. /* ----------------------------------------------------------------------- */
  1054. /* MRRC / MCRR instructions */
  1055. /* cond 1100 0101 Rt2- Rt-- copr opc1 CRm- MRRC */
  1056. /* cond 1100 0100 Rt2- Rt-- copr opc1 CRm- MCRR */
  1057. /* ----------------------------------------------------------------------- */
  1058. /* VMOVBRRSS between 2 registers to 2 singles */
  1059. /* cond 1100 010X Rt2- Rt-- 1010 00X1 Vm-- */
  1060. /* cond 1100 0101 Rt2- Rt-- copr opc1 CRm- MRRC */
  1061. #ifdef VFP_INTERPRETER_STRUCT
  1062. struct vmovbrrss_inst {
  1063. unsigned int to_arm;
  1064. unsigned int t;
  1065. unsigned int t2;
  1066. unsigned int m;
  1067. };
  1068. #endif
  1069. #ifdef VFP_INTERPRETER_TRANS
  1070. static ARM_INST_PTR INTERPRETER_TRANSLATE(vmovbrrss)(unsigned int inst, int index)
  1071. {
  1072. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vmovbrrss_inst));
  1073. vmovbrrss_inst *inst_cream = (vmovbrrss_inst *)inst_base->component;
  1074. inst_base->cond = BITS(inst, 28, 31);
  1075. inst_base->idx = index;
  1076. inst_base->br = NON_BRANCH;
  1077. inst_base->load_r15 = 0;
  1078. inst_cream->to_arm = BIT(inst, 20) == 1;
  1079. inst_cream->t = BITS(inst, 12, 15);
  1080. inst_cream->t2 = BITS(inst, 16, 19);
  1081. inst_cream->m = BITS(inst, 0, 3)<<1|BIT(inst, 5);
  1082. return inst_base;
  1083. }
  1084. #endif
  1085. #ifdef VFP_INTERPRETER_IMPL
  1086. VMOVBRRSS_INST:
  1087. {
  1088. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1089. CHECK_VFP_ENABLED;
  1090. vmovbrrss_inst* const inst_cream = (vmovbrrss_inst*)inst_base->component;
  1091. VMOVBRRSS(cpu, inst_cream->to_arm, inst_cream->t, inst_cream->t2, inst_cream->m,
  1092. &cpu->Reg[inst_cream->t], &cpu->Reg[inst_cream->t2]);
  1093. }
  1094. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1095. INC_PC(sizeof(vmovbrrss_inst));
  1096. FETCH_INST;
  1097. GOTO_NEXT_INST;
  1098. }
  1099. #endif
  1100. /* ----------------------------------------------------------------------- */
  1101. /* VMOVBRRD between 2 registers and 1 double */
  1102. /* cond 1100 010X Rt2- Rt-- 1011 00X1 Vm-- */
  1103. /* cond 1100 0101 Rt2- Rt-- copr opc1 CRm- MRRC */
  1104. #ifdef VFP_INTERPRETER_STRUCT
  1105. struct vmovbrrd_inst {
  1106. unsigned int to_arm;
  1107. unsigned int t;
  1108. unsigned int t2;
  1109. unsigned int m;
  1110. };
  1111. #endif
  1112. #ifdef VFP_INTERPRETER_TRANS
  1113. static ARM_INST_PTR INTERPRETER_TRANSLATE(vmovbrrd)(unsigned int inst, int index)
  1114. {
  1115. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vmovbrrd_inst));
  1116. vmovbrrd_inst *inst_cream = (vmovbrrd_inst *)inst_base->component;
  1117. inst_base->cond = BITS(inst, 28, 31);
  1118. inst_base->idx = index;
  1119. inst_base->br = NON_BRANCH;
  1120. inst_base->load_r15 = 0;
  1121. inst_cream->to_arm = BIT(inst, 20) == 1;
  1122. inst_cream->t = BITS(inst, 12, 15);
  1123. inst_cream->t2 = BITS(inst, 16, 19);
  1124. inst_cream->m = BIT(inst, 5)<<4 | BITS(inst, 0, 3);
  1125. return inst_base;
  1126. }
  1127. #endif
  1128. #ifdef VFP_INTERPRETER_IMPL
  1129. VMOVBRRD_INST:
  1130. {
  1131. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1132. CHECK_VFP_ENABLED;
  1133. vmovbrrd_inst *inst_cream = (vmovbrrd_inst *)inst_base->component;
  1134. VMOVBRRD(cpu, inst_cream->to_arm, inst_cream->t, inst_cream->t2, inst_cream->m,
  1135. &(cpu->Reg[inst_cream->t]), &(cpu->Reg[inst_cream->t2]));
  1136. }
  1137. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1138. INC_PC(sizeof(vmovbrrd_inst));
  1139. FETCH_INST;
  1140. GOTO_NEXT_INST;
  1141. }
  1142. #endif
  1143. /* ----------------------------------------------------------------------- */
  1144. /* LDC/STC between 2 registers and 1 double */
  1145. /* cond 110X XXX1 Rn-- CRd- copr imm- imm- LDC */
  1146. /* cond 110X XXX0 Rn-- CRd- copr imm8 imm8 STC */
  1147. /* ----------------------------------------------------------------------- */
  1148. /* VSTR */
  1149. /* cond 1101 UD00 Rn-- Vd-- 101X imm8 imm8 */
  1150. #ifdef VFP_INTERPRETER_STRUCT
  1151. struct vstr_inst {
  1152. unsigned int single;
  1153. unsigned int n;
  1154. unsigned int d;
  1155. unsigned int imm32;
  1156. unsigned int add;
  1157. };
  1158. #endif
  1159. #ifdef VFP_INTERPRETER_TRANS
  1160. static ARM_INST_PTR INTERPRETER_TRANSLATE(vstr)(unsigned int inst, int index)
  1161. {
  1162. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vstr_inst));
  1163. vstr_inst *inst_cream = (vstr_inst *)inst_base->component;
  1164. inst_base->cond = BITS(inst, 28, 31);
  1165. inst_base->idx = index;
  1166. inst_base->br = NON_BRANCH;
  1167. inst_base->load_r15 = 0;
  1168. inst_cream->single = BIT(inst, 8) == 0;
  1169. inst_cream->add = BIT(inst, 23);
  1170. inst_cream->imm32 = BITS(inst, 0,7) << 2;
  1171. inst_cream->d = (inst_cream->single ? BITS(inst, 12, 15)<<1|BIT(inst, 22) : BITS(inst, 12, 15)|BIT(inst, 22)<<4);
  1172. inst_cream->n = BITS(inst, 16, 19);
  1173. return inst_base;
  1174. }
  1175. #endif
  1176. #ifdef VFP_INTERPRETER_IMPL
  1177. VSTR_INST:
  1178. {
  1179. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1180. CHECK_VFP_ENABLED;
  1181. vstr_inst *inst_cream = (vstr_inst *)inst_base->component;
  1182. unsigned int base = (inst_cream->n == 15 ? (cpu->Reg[inst_cream->n] & 0xFFFFFFFC) + 8 : cpu->Reg[inst_cream->n]);
  1183. addr = (inst_cream->add ? base + inst_cream->imm32 : base - inst_cream->imm32);
  1184. if (inst_cream->single)
  1185. {
  1186. WriteMemory32(cpu, addr, cpu->ExtReg[inst_cream->d]);
  1187. }
  1188. else
  1189. {
  1190. const u32 word1 = cpu->ExtReg[inst_cream->d*2+0];
  1191. const u32 word2 = cpu->ExtReg[inst_cream->d*2+1];
  1192. if (InBigEndianMode(cpu)) {
  1193. WriteMemory32(cpu, addr + 0, word2);
  1194. WriteMemory32(cpu, addr + 4, word1);
  1195. } else {
  1196. WriteMemory32(cpu, addr + 0, word1);
  1197. WriteMemory32(cpu, addr + 4, word2);
  1198. }
  1199. }
  1200. }
  1201. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1202. INC_PC(sizeof(vstr_inst));
  1203. FETCH_INST;
  1204. GOTO_NEXT_INST;
  1205. }
  1206. #endif
  1207. /* ----------------------------------------------------------------------- */
  1208. /* VPUSH */
  1209. /* cond 1101 0D10 1101 Vd-- 101X imm8 imm8 */
  1210. #ifdef VFP_INTERPRETER_STRUCT
  1211. struct vpush_inst {
  1212. unsigned int single;
  1213. unsigned int d;
  1214. unsigned int imm32;
  1215. unsigned int regs;
  1216. };
  1217. #endif
  1218. #ifdef VFP_INTERPRETER_TRANS
  1219. static ARM_INST_PTR INTERPRETER_TRANSLATE(vpush)(unsigned int inst, int index)
  1220. {
  1221. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vpush_inst));
  1222. vpush_inst *inst_cream = (vpush_inst *)inst_base->component;
  1223. inst_base->cond = BITS(inst, 28, 31);
  1224. inst_base->idx = index;
  1225. inst_base->br = NON_BRANCH;
  1226. inst_base->load_r15 = 0;
  1227. inst_cream->single = BIT(inst, 8) == 0;
  1228. inst_cream->d = (inst_cream->single ? BITS(inst, 12, 15)<<1|BIT(inst, 22) : BITS(inst, 12, 15)|BIT(inst, 22)<<4);
  1229. inst_cream->imm32 = BITS(inst, 0, 7)<<2;
  1230. inst_cream->regs = (inst_cream->single ? BITS(inst, 0, 7) : BITS(inst, 1, 7));
  1231. return inst_base;
  1232. }
  1233. #endif
  1234. #ifdef VFP_INTERPRETER_IMPL
  1235. VPUSH_INST:
  1236. {
  1237. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1238. CHECK_VFP_ENABLED;
  1239. vpush_inst *inst_cream = (vpush_inst *)inst_base->component;
  1240. addr = cpu->Reg[R13] - inst_cream->imm32;
  1241. for (unsigned int i = 0; i < inst_cream->regs; i++)
  1242. {
  1243. if (inst_cream->single)
  1244. {
  1245. WriteMemory32(cpu, addr, cpu->ExtReg[inst_cream->d+i]);
  1246. addr += 4;
  1247. }
  1248. else
  1249. {
  1250. const u32 word1 = cpu->ExtReg[(inst_cream->d+i)*2+0];
  1251. const u32 word2 = cpu->ExtReg[(inst_cream->d+i)*2+1];
  1252. if (InBigEndianMode(cpu)) {
  1253. WriteMemory32(cpu, addr + 0, word2);
  1254. WriteMemory32(cpu, addr + 4, word1);
  1255. } else {
  1256. WriteMemory32(cpu, addr + 0, word1);
  1257. WriteMemory32(cpu, addr + 4, word2);
  1258. }
  1259. addr += 8;
  1260. }
  1261. }
  1262. cpu->Reg[R13] -= inst_cream->imm32;
  1263. }
  1264. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1265. INC_PC(sizeof(vpush_inst));
  1266. FETCH_INST;
  1267. GOTO_NEXT_INST;
  1268. }
  1269. #endif
  1270. /* ----------------------------------------------------------------------- */
  1271. /* VSTM */
  1272. /* cond 110P UDW0 Rn-- Vd-- 101X imm8 imm8 */
  1273. #ifdef VFP_INTERPRETER_STRUCT
  1274. struct vstm_inst {
  1275. unsigned int single;
  1276. unsigned int add;
  1277. unsigned int wback;
  1278. unsigned int d;
  1279. unsigned int n;
  1280. unsigned int imm32;
  1281. unsigned int regs;
  1282. };
  1283. #endif
  1284. #ifdef VFP_INTERPRETER_TRANS
  1285. static ARM_INST_PTR INTERPRETER_TRANSLATE(vstm)(unsigned int inst, int index)
  1286. {
  1287. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vstm_inst));
  1288. vstm_inst *inst_cream = (vstm_inst *)inst_base->component;
  1289. inst_base->cond = BITS(inst, 28, 31);
  1290. inst_base->idx = index;
  1291. inst_base->br = NON_BRANCH;
  1292. inst_base->load_r15 = 0;
  1293. inst_cream->single = BIT(inst, 8) == 0;
  1294. inst_cream->add = BIT(inst, 23);
  1295. inst_cream->wback = BIT(inst, 21);
  1296. inst_cream->d = (inst_cream->single ? BITS(inst, 12, 15)<<1|BIT(inst, 22) : BITS(inst, 12, 15)|BIT(inst, 22)<<4);
  1297. inst_cream->n = BITS(inst, 16, 19);
  1298. inst_cream->imm32 = BITS(inst, 0, 7)<<2;
  1299. inst_cream->regs = (inst_cream->single ? BITS(inst, 0, 7) : BITS(inst, 1, 7));
  1300. return inst_base;
  1301. }
  1302. #endif
  1303. #ifdef VFP_INTERPRETER_IMPL
  1304. VSTM_INST: /* encoding 1 */
  1305. {
  1306. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1307. CHECK_VFP_ENABLED;
  1308. vstm_inst *inst_cream = (vstm_inst *)inst_base->component;
  1309. addr = (inst_cream->add ? cpu->Reg[inst_cream->n] : cpu->Reg[inst_cream->n] - inst_cream->imm32);
  1310. for (unsigned int i = 0; i < inst_cream->regs; i++)
  1311. {
  1312. if (inst_cream->single)
  1313. {
  1314. WriteMemory32(cpu, addr, cpu->ExtReg[inst_cream->d+i]);
  1315. addr += 4;
  1316. }
  1317. else
  1318. {
  1319. const u32 word1 = cpu->ExtReg[(inst_cream->d+i)*2+0];
  1320. const u32 word2 = cpu->ExtReg[(inst_cream->d+i)*2+1];
  1321. if (InBigEndianMode(cpu)) {
  1322. WriteMemory32(cpu, addr + 0, word2);
  1323. WriteMemory32(cpu, addr + 4, word1);
  1324. } else {
  1325. WriteMemory32(cpu, addr + 0, word1);
  1326. WriteMemory32(cpu, addr + 4, word2);
  1327. }
  1328. addr += 8;
  1329. }
  1330. }
  1331. if (inst_cream->wback){
  1332. cpu->Reg[inst_cream->n] = (inst_cream->add ? cpu->Reg[inst_cream->n] + inst_cream->imm32 :
  1333. cpu->Reg[inst_cream->n] - inst_cream->imm32);
  1334. }
  1335. }
  1336. cpu->Reg[15] += 4;
  1337. INC_PC(sizeof(vstm_inst));
  1338. FETCH_INST;
  1339. GOTO_NEXT_INST;
  1340. }
  1341. #endif
  1342. /* ----------------------------------------------------------------------- */
  1343. /* VPOP */
  1344. /* cond 1100 1D11 1101 Vd-- 101X imm8 imm8 */
  1345. #ifdef VFP_INTERPRETER_STRUCT
  1346. struct vpop_inst {
  1347. unsigned int single;
  1348. unsigned int d;
  1349. unsigned int imm32;
  1350. unsigned int regs;
  1351. };
  1352. #endif
  1353. #ifdef VFP_INTERPRETER_TRANS
  1354. static ARM_INST_PTR INTERPRETER_TRANSLATE(vpop)(unsigned int inst, int index)
  1355. {
  1356. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vpop_inst));
  1357. vpop_inst *inst_cream = (vpop_inst *)inst_base->component;
  1358. inst_base->cond = BITS(inst, 28, 31);
  1359. inst_base->idx = index;
  1360. inst_base->br = NON_BRANCH;
  1361. inst_base->load_r15 = 0;
  1362. inst_cream->single = BIT(inst, 8) == 0;
  1363. inst_cream->d = (inst_cream->single ? (BITS(inst, 12, 15)<<1)|BIT(inst, 22) : BITS(inst, 12, 15)|(BIT(inst, 22)<<4));
  1364. inst_cream->imm32 = BITS(inst, 0, 7)<<2;
  1365. inst_cream->regs = (inst_cream->single ? BITS(inst, 0, 7) : BITS(inst, 1, 7));
  1366. return inst_base;
  1367. }
  1368. #endif
  1369. #ifdef VFP_INTERPRETER_IMPL
  1370. VPOP_INST:
  1371. {
  1372. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1373. CHECK_VFP_ENABLED;
  1374. vpop_inst *inst_cream = (vpop_inst *)inst_base->component;
  1375. addr = cpu->Reg[R13];
  1376. for (unsigned int i = 0; i < inst_cream->regs; i++)
  1377. {
  1378. if (inst_cream->single)
  1379. {
  1380. cpu->ExtReg[inst_cream->d+i] = ReadMemory32(cpu, addr);
  1381. addr += 4;
  1382. }
  1383. else
  1384. {
  1385. const u32 word1 = ReadMemory32(cpu, addr + 0);
  1386. const u32 word2 = ReadMemory32(cpu, addr + 4);
  1387. if (InBigEndianMode(cpu)) {
  1388. cpu->ExtReg[(inst_cream->d+i)*2+0] = word2;
  1389. cpu->ExtReg[(inst_cream->d+i)*2+1] = word1;
  1390. } else {
  1391. cpu->ExtReg[(inst_cream->d+i)*2+0] = word1;
  1392. cpu->ExtReg[(inst_cream->d+i)*2+1] = word2;
  1393. }
  1394. addr += 8;
  1395. }
  1396. }
  1397. cpu->Reg[R13] += inst_cream->imm32;
  1398. }
  1399. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1400. INC_PC(sizeof(vpop_inst));
  1401. FETCH_INST;
  1402. GOTO_NEXT_INST;
  1403. }
  1404. #endif
  1405. /* ----------------------------------------------------------------------- */
  1406. /* VLDR */
  1407. /* cond 1101 UD01 Rn-- Vd-- 101X imm8 imm8 */
  1408. #ifdef VFP_INTERPRETER_STRUCT
  1409. struct vldr_inst {
  1410. unsigned int single;
  1411. unsigned int n;
  1412. unsigned int d;
  1413. unsigned int imm32;
  1414. unsigned int add;
  1415. };
  1416. #endif
  1417. #ifdef VFP_INTERPRETER_TRANS
  1418. static ARM_INST_PTR INTERPRETER_TRANSLATE(vldr)(unsigned int inst, int index)
  1419. {
  1420. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vldr_inst));
  1421. vldr_inst *inst_cream = (vldr_inst *)inst_base->component;
  1422. inst_base->cond = BITS(inst, 28, 31);
  1423. inst_base->idx = index;
  1424. inst_base->br = NON_BRANCH;
  1425. inst_base->load_r15 = 0;
  1426. inst_cream->single = BIT(inst, 8) == 0;
  1427. inst_cream->add = BIT(inst, 23);
  1428. inst_cream->imm32 = BITS(inst, 0,7) << 2;
  1429. inst_cream->d = (inst_cream->single ? BITS(inst, 12, 15)<<1|BIT(inst, 22) : BITS(inst, 12, 15)|BIT(inst, 22)<<4);
  1430. inst_cream->n = BITS(inst, 16, 19);
  1431. return inst_base;
  1432. }
  1433. #endif
  1434. #ifdef VFP_INTERPRETER_IMPL
  1435. VLDR_INST:
  1436. {
  1437. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1438. CHECK_VFP_ENABLED;
  1439. vldr_inst *inst_cream = (vldr_inst *)inst_base->component;
  1440. unsigned int base = (inst_cream->n == 15 ? (cpu->Reg[inst_cream->n] & 0xFFFFFFFC) + 8 : cpu->Reg[inst_cream->n]);
  1441. addr = (inst_cream->add ? base + inst_cream->imm32 : base - inst_cream->imm32);
  1442. if (inst_cream->single)
  1443. {
  1444. cpu->ExtReg[inst_cream->d] = ReadMemory32(cpu, addr);
  1445. }
  1446. else
  1447. {
  1448. const u32 word1 = ReadMemory32(cpu, addr + 0);
  1449. const u32 word2 = ReadMemory32(cpu, addr + 4);
  1450. if (InBigEndianMode(cpu)) {
  1451. cpu->ExtReg[inst_cream->d*2+0] = word2;
  1452. cpu->ExtReg[inst_cream->d*2+1] = word1;
  1453. } else {
  1454. cpu->ExtReg[inst_cream->d*2+0] = word1;
  1455. cpu->ExtReg[inst_cream->d*2+1] = word2;
  1456. }
  1457. }
  1458. }
  1459. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1460. INC_PC(sizeof(vldr_inst));
  1461. FETCH_INST;
  1462. GOTO_NEXT_INST;
  1463. }
  1464. #endif
  1465. /* ----------------------------------------------------------------------- */
  1466. /* VLDM */
  1467. /* cond 110P UDW1 Rn-- Vd-- 101X imm8 imm8 */
  1468. #ifdef VFP_INTERPRETER_STRUCT
  1469. struct vldm_inst {
  1470. unsigned int single;
  1471. unsigned int add;
  1472. unsigned int wback;
  1473. unsigned int d;
  1474. unsigned int n;
  1475. unsigned int imm32;
  1476. unsigned int regs;
  1477. };
  1478. #endif
  1479. #ifdef VFP_INTERPRETER_TRANS
  1480. static ARM_INST_PTR INTERPRETER_TRANSLATE(vldm)(unsigned int inst, int index)
  1481. {
  1482. arm_inst *inst_base = (arm_inst *)AllocBuffer(sizeof(arm_inst) + sizeof(vldm_inst));
  1483. vldm_inst *inst_cream = (vldm_inst *)inst_base->component;
  1484. inst_base->cond = BITS(inst, 28, 31);
  1485. inst_base->idx = index;
  1486. inst_base->br = NON_BRANCH;
  1487. inst_base->load_r15 = 0;
  1488. inst_cream->single = BIT(inst, 8) == 0;
  1489. inst_cream->add = BIT(inst, 23);
  1490. inst_cream->wback = BIT(inst, 21);
  1491. inst_cream->d = (inst_cream->single ? BITS(inst, 12, 15)<<1|BIT(inst, 22) : BITS(inst, 12, 15)|BIT(inst, 22)<<4);
  1492. inst_cream->n = BITS(inst, 16, 19);
  1493. inst_cream->imm32 = BITS(inst, 0, 7)<<2;
  1494. inst_cream->regs = (inst_cream->single ? BITS(inst, 0, 7) : BITS(inst, 1, 7));
  1495. return inst_base;
  1496. }
  1497. #endif
  1498. #ifdef VFP_INTERPRETER_IMPL
  1499. VLDM_INST:
  1500. {
  1501. if ((inst_base->cond == 0xe) || CondPassed(cpu, inst_base->cond)) {
  1502. CHECK_VFP_ENABLED;
  1503. vldm_inst *inst_cream = (vldm_inst *)inst_base->component;
  1504. addr = (inst_cream->add ? cpu->Reg[inst_cream->n] : cpu->Reg[inst_cream->n] - inst_cream->imm32);
  1505. for (unsigned int i = 0; i < inst_cream->regs; i++)
  1506. {
  1507. if (inst_cream->single)
  1508. {
  1509. cpu->ExtReg[inst_cream->d+i] = ReadMemory32(cpu, addr);
  1510. addr += 4;
  1511. }
  1512. else
  1513. {
  1514. const u32 word1 = ReadMemory32(cpu, addr + 0);
  1515. const u32 word2 = ReadMemory32(cpu, addr + 4);
  1516. if (InBigEndianMode(cpu)) {
  1517. cpu->ExtReg[(inst_cream->d+i)*2+0] = word2;
  1518. cpu->ExtReg[(inst_cream->d+i)*2+1] = word1;
  1519. } else {
  1520. cpu->ExtReg[(inst_cream->d+i)*2+0] = word1;
  1521. cpu->ExtReg[(inst_cream->d+i)*2+1] = word2;
  1522. }
  1523. addr += 8;
  1524. }
  1525. }
  1526. if (inst_cream->wback){
  1527. cpu->Reg[inst_cream->n] = (inst_cream->add ? cpu->Reg[inst_cream->n] + inst_cream->imm32 :
  1528. cpu->Reg[inst_cream->n] - inst_cream->imm32);
  1529. }
  1530. }
  1531. cpu->Reg[15] += GET_INST_SIZE(cpu);
  1532. INC_PC(sizeof(vldm_inst));
  1533. FETCH_INST;
  1534. GOTO_NEXT_INST;
  1535. }
  1536. #endif