vfpinstr.cpp 50 KB

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