arm_dyncom_trans.cpp 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887
  1. #include <cstdlib>
  2. #include "common/assert.h"
  3. #include "common/common_types.h"
  4. #include "core/arm/dyncom/arm_dyncom_interpreter.h"
  5. #include "core/arm/dyncom/arm_dyncom_trans.h"
  6. #include "core/arm/skyeye_common/armstate.h"
  7. #include "core/arm/skyeye_common/armsupp.h"
  8. #include "core/arm/skyeye_common/vfp/vfp.h"
  9. char trans_cache_buf[TRANS_CACHE_SIZE];
  10. size_t trans_cache_buf_top = 0;
  11. static void* AllocBuffer(size_t size) {
  12. size_t start = trans_cache_buf_top;
  13. trans_cache_buf_top += size;
  14. ASSERT_MSG(trans_cache_buf_top <= TRANS_CACHE_SIZE, "Translation cache is full!");
  15. return static_cast<void*>(&trans_cache_buf[start]);
  16. }
  17. #define glue(x, y) x##y
  18. #define INTERPRETER_TRANSLATE(s) glue(InterpreterTranslate_, s)
  19. shtop_fp_t GetShifterOp(unsigned int inst);
  20. get_addr_fp_t GetAddressingOp(unsigned int inst);
  21. get_addr_fp_t GetAddressingOpLoadStoreT(unsigned int inst);
  22. static ARM_INST_PTR INTERPRETER_TRANSLATE(adc)(unsigned int inst, int index) {
  23. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(adc_inst));
  24. adc_inst* inst_cream = (adc_inst*)inst_base->component;
  25. inst_base->cond = BITS(inst, 28, 31);
  26. inst_base->idx = index;
  27. inst_base->br = TransExtData::NON_BRANCH;
  28. inst_cream->I = BIT(inst, 25);
  29. inst_cream->S = BIT(inst, 20);
  30. inst_cream->Rn = BITS(inst, 16, 19);
  31. inst_cream->Rd = BITS(inst, 12, 15);
  32. inst_cream->shifter_operand = BITS(inst, 0, 11);
  33. inst_cream->shtop_func = GetShifterOp(inst);
  34. if (inst_cream->Rd == 15)
  35. inst_base->br = TransExtData::INDIRECT_BRANCH;
  36. return inst_base;
  37. }
  38. static ARM_INST_PTR INTERPRETER_TRANSLATE(add)(unsigned int inst, int index) {
  39. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(add_inst));
  40. add_inst* inst_cream = (add_inst*)inst_base->component;
  41. inst_base->cond = BITS(inst, 28, 31);
  42. inst_base->idx = index;
  43. inst_base->br = TransExtData::NON_BRANCH;
  44. inst_cream->I = BIT(inst, 25);
  45. inst_cream->S = BIT(inst, 20);
  46. inst_cream->Rn = BITS(inst, 16, 19);
  47. inst_cream->Rd = BITS(inst, 12, 15);
  48. inst_cream->shifter_operand = BITS(inst, 0, 11);
  49. inst_cream->shtop_func = GetShifterOp(inst);
  50. if (inst_cream->Rd == 15)
  51. inst_base->br = TransExtData::INDIRECT_BRANCH;
  52. return inst_base;
  53. }
  54. static ARM_INST_PTR INTERPRETER_TRANSLATE(and)(unsigned int inst, int index) {
  55. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(and_inst));
  56. and_inst* inst_cream = (and_inst*)inst_base->component;
  57. inst_base->cond = BITS(inst, 28, 31);
  58. inst_base->idx = index;
  59. inst_base->br = TransExtData::NON_BRANCH;
  60. inst_cream->I = BIT(inst, 25);
  61. inst_cream->S = BIT(inst, 20);
  62. inst_cream->Rn = BITS(inst, 16, 19);
  63. inst_cream->Rd = BITS(inst, 12, 15);
  64. inst_cream->shifter_operand = BITS(inst, 0, 11);
  65. inst_cream->shtop_func = GetShifterOp(inst);
  66. if (inst_cream->Rd == 15)
  67. inst_base->br = TransExtData::INDIRECT_BRANCH;
  68. return inst_base;
  69. }
  70. static ARM_INST_PTR INTERPRETER_TRANSLATE(bbl)(unsigned int inst, int index) {
  71. #define POSBRANCH ((inst & 0x7fffff) << 2)
  72. #define NEGBRANCH ((0xff000000 | (inst & 0xffffff)) << 2)
  73. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(bbl_inst));
  74. bbl_inst* inst_cream = (bbl_inst*)inst_base->component;
  75. inst_base->cond = BITS(inst, 28, 31);
  76. inst_base->idx = index;
  77. inst_base->br = TransExtData::DIRECT_BRANCH;
  78. if (BIT(inst, 24))
  79. inst_base->br = TransExtData::CALL;
  80. inst_cream->L = BIT(inst, 24);
  81. inst_cream->signed_immed_24 = BIT(inst, 23) ? NEGBRANCH : POSBRANCH;
  82. return inst_base;
  83. }
  84. static ARM_INST_PTR INTERPRETER_TRANSLATE(bic)(unsigned int inst, int index) {
  85. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(bic_inst));
  86. bic_inst* inst_cream = (bic_inst*)inst_base->component;
  87. inst_base->cond = BITS(inst, 28, 31);
  88. inst_base->idx = index;
  89. inst_base->br = TransExtData::NON_BRANCH;
  90. inst_cream->I = BIT(inst, 25);
  91. inst_cream->S = BIT(inst, 20);
  92. inst_cream->Rn = BITS(inst, 16, 19);
  93. inst_cream->Rd = BITS(inst, 12, 15);
  94. inst_cream->shifter_operand = BITS(inst, 0, 11);
  95. inst_cream->shtop_func = GetShifterOp(inst);
  96. if (inst_cream->Rd == 15)
  97. inst_base->br = TransExtData::INDIRECT_BRANCH;
  98. return inst_base;
  99. }
  100. static ARM_INST_PTR INTERPRETER_TRANSLATE(bkpt)(unsigned int inst, int index) {
  101. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(bkpt_inst));
  102. bkpt_inst* const inst_cream = (bkpt_inst*)inst_base->component;
  103. inst_base->cond = BITS(inst, 28, 31);
  104. inst_base->idx = index;
  105. inst_base->br = TransExtData::NON_BRANCH;
  106. inst_cream->imm = (BITS(inst, 8, 19) << 4) | BITS(inst, 0, 3);
  107. return inst_base;
  108. }
  109. static ARM_INST_PTR INTERPRETER_TRANSLATE(blx)(unsigned int inst, int index) {
  110. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(blx_inst));
  111. blx_inst* inst_cream = (blx_inst*)inst_base->component;
  112. inst_base->cond = BITS(inst, 28, 31);
  113. inst_base->idx = index;
  114. inst_base->br = TransExtData::INDIRECT_BRANCH;
  115. inst_cream->inst = inst;
  116. if (BITS(inst, 20, 27) == 0x12 && BITS(inst, 4, 7) == 0x3) {
  117. inst_cream->val.Rm = BITS(inst, 0, 3);
  118. } else {
  119. inst_cream->val.signed_immed_24 = BITS(inst, 0, 23);
  120. }
  121. return inst_base;
  122. }
  123. static ARM_INST_PTR INTERPRETER_TRANSLATE(bx)(unsigned int inst, int index) {
  124. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(bx_inst));
  125. bx_inst* inst_cream = (bx_inst*)inst_base->component;
  126. inst_base->cond = BITS(inst, 28, 31);
  127. inst_base->idx = index;
  128. inst_base->br = TransExtData::INDIRECT_BRANCH;
  129. inst_cream->Rm = BITS(inst, 0, 3);
  130. return inst_base;
  131. }
  132. static ARM_INST_PTR INTERPRETER_TRANSLATE(bxj)(unsigned int inst, int index) {
  133. return INTERPRETER_TRANSLATE(bx)(inst, index);
  134. }
  135. static ARM_INST_PTR INTERPRETER_TRANSLATE(cdp)(unsigned int inst, int index) {
  136. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(cdp_inst));
  137. cdp_inst* inst_cream = (cdp_inst*)inst_base->component;
  138. inst_base->cond = BITS(inst, 28, 31);
  139. inst_base->idx = index;
  140. inst_base->br = TransExtData::NON_BRANCH;
  141. inst_cream->CRm = BITS(inst, 0, 3);
  142. inst_cream->CRd = BITS(inst, 12, 15);
  143. inst_cream->CRn = BITS(inst, 16, 19);
  144. inst_cream->cp_num = BITS(inst, 8, 11);
  145. inst_cream->opcode_2 = BITS(inst, 5, 7);
  146. inst_cream->opcode_1 = BITS(inst, 20, 23);
  147. inst_cream->inst = inst;
  148. LOG_TRACE(Core_ARM, "inst %x index %x", inst, index);
  149. return inst_base;
  150. }
  151. static ARM_INST_PTR INTERPRETER_TRANSLATE(clrex)(unsigned int inst, int index) {
  152. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(clrex_inst));
  153. inst_base->cond = BITS(inst, 28, 31);
  154. inst_base->idx = index;
  155. inst_base->br = TransExtData::NON_BRANCH;
  156. return inst_base;
  157. }
  158. static ARM_INST_PTR INTERPRETER_TRANSLATE(clz)(unsigned int inst, int index) {
  159. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(clz_inst));
  160. clz_inst* inst_cream = (clz_inst*)inst_base->component;
  161. inst_base->cond = BITS(inst, 28, 31);
  162. inst_base->idx = index;
  163. inst_base->br = TransExtData::NON_BRANCH;
  164. inst_cream->Rm = BITS(inst, 0, 3);
  165. inst_cream->Rd = BITS(inst, 12, 15);
  166. return inst_base;
  167. }
  168. static ARM_INST_PTR INTERPRETER_TRANSLATE(cmn)(unsigned int inst, int index) {
  169. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(cmn_inst));
  170. cmn_inst* inst_cream = (cmn_inst*)inst_base->component;
  171. inst_base->cond = BITS(inst, 28, 31);
  172. inst_base->idx = index;
  173. inst_base->br = TransExtData::NON_BRANCH;
  174. inst_cream->I = BIT(inst, 25);
  175. inst_cream->Rn = BITS(inst, 16, 19);
  176. inst_cream->shifter_operand = BITS(inst, 0, 11);
  177. inst_cream->shtop_func = GetShifterOp(inst);
  178. return inst_base;
  179. }
  180. static ARM_INST_PTR INTERPRETER_TRANSLATE(cmp)(unsigned int inst, int index) {
  181. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(cmp_inst));
  182. cmp_inst* inst_cream = (cmp_inst*)inst_base->component;
  183. inst_base->cond = BITS(inst, 28, 31);
  184. inst_base->idx = index;
  185. inst_base->br = TransExtData::NON_BRANCH;
  186. inst_cream->I = BIT(inst, 25);
  187. inst_cream->Rn = BITS(inst, 16, 19);
  188. inst_cream->shifter_operand = BITS(inst, 0, 11);
  189. inst_cream->shtop_func = GetShifterOp(inst);
  190. return inst_base;
  191. }
  192. static ARM_INST_PTR INTERPRETER_TRANSLATE(cps)(unsigned int inst, int index) {
  193. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(cps_inst));
  194. cps_inst* inst_cream = (cps_inst*)inst_base->component;
  195. inst_base->cond = BITS(inst, 28, 31);
  196. inst_base->idx = index;
  197. inst_base->br = TransExtData::NON_BRANCH;
  198. inst_cream->imod0 = BIT(inst, 18);
  199. inst_cream->imod1 = BIT(inst, 19);
  200. inst_cream->mmod = BIT(inst, 17);
  201. inst_cream->A = BIT(inst, 8);
  202. inst_cream->I = BIT(inst, 7);
  203. inst_cream->F = BIT(inst, 6);
  204. inst_cream->mode = BITS(inst, 0, 4);
  205. return inst_base;
  206. }
  207. static ARM_INST_PTR INTERPRETER_TRANSLATE(cpy)(unsigned int inst, int index) {
  208. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(mov_inst));
  209. mov_inst* inst_cream = (mov_inst*)inst_base->component;
  210. inst_base->cond = BITS(inst, 28, 31);
  211. inst_base->idx = index;
  212. inst_base->br = TransExtData::NON_BRANCH;
  213. inst_cream->I = BIT(inst, 25);
  214. inst_cream->S = BIT(inst, 20);
  215. inst_cream->Rd = BITS(inst, 12, 15);
  216. inst_cream->shifter_operand = BITS(inst, 0, 11);
  217. inst_cream->shtop_func = GetShifterOp(inst);
  218. if (inst_cream->Rd == 15) {
  219. inst_base->br = TransExtData::INDIRECT_BRANCH;
  220. }
  221. return inst_base;
  222. }
  223. static ARM_INST_PTR INTERPRETER_TRANSLATE(eor)(unsigned int inst, int index) {
  224. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(eor_inst));
  225. eor_inst* inst_cream = (eor_inst*)inst_base->component;
  226. inst_base->cond = BITS(inst, 28, 31);
  227. inst_base->idx = index;
  228. inst_base->br = TransExtData::NON_BRANCH;
  229. inst_cream->I = BIT(inst, 25);
  230. inst_cream->S = BIT(inst, 20);
  231. inst_cream->Rn = BITS(inst, 16, 19);
  232. inst_cream->Rd = BITS(inst, 12, 15);
  233. inst_cream->shifter_operand = BITS(inst, 0, 11);
  234. inst_cream->shtop_func = GetShifterOp(inst);
  235. if (inst_cream->Rd == 15)
  236. inst_base->br = TransExtData::INDIRECT_BRANCH;
  237. return inst_base;
  238. }
  239. static ARM_INST_PTR INTERPRETER_TRANSLATE(ldc)(unsigned int inst, int index) {
  240. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldc_inst));
  241. inst_base->cond = BITS(inst, 28, 31);
  242. inst_base->idx = index;
  243. inst_base->br = TransExtData::NON_BRANCH;
  244. return inst_base;
  245. }
  246. static ARM_INST_PTR INTERPRETER_TRANSLATE(ldm)(unsigned int inst, int index) {
  247. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  248. ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
  249. inst_base->cond = BITS(inst, 28, 31);
  250. inst_base->idx = index;
  251. inst_base->br = TransExtData::NON_BRANCH;
  252. inst_cream->inst = inst;
  253. inst_cream->get_addr = GetAddressingOp(inst);
  254. if (BIT(inst, 15)) {
  255. inst_base->br = TransExtData::INDIRECT_BRANCH;
  256. }
  257. return inst_base;
  258. }
  259. static ARM_INST_PTR INTERPRETER_TRANSLATE(sxth)(unsigned int inst, int index) {
  260. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(sxtb_inst));
  261. sxtb_inst* inst_cream = (sxtb_inst*)inst_base->component;
  262. inst_base->cond = BITS(inst, 28, 31);
  263. inst_base->idx = index;
  264. inst_base->br = TransExtData::NON_BRANCH;
  265. inst_cream->Rd = BITS(inst, 12, 15);
  266. inst_cream->Rm = BITS(inst, 0, 3);
  267. inst_cream->rotate = BITS(inst, 10, 11);
  268. return inst_base;
  269. }
  270. static ARM_INST_PTR INTERPRETER_TRANSLATE(ldr)(unsigned int inst, int index) {
  271. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  272. ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
  273. inst_base->cond = BITS(inst, 28, 31);
  274. inst_base->idx = index;
  275. inst_base->br = TransExtData::NON_BRANCH;
  276. inst_cream->inst = inst;
  277. inst_cream->get_addr = GetAddressingOp(inst);
  278. if (BITS(inst, 12, 15) == 15)
  279. inst_base->br = TransExtData::INDIRECT_BRANCH;
  280. return inst_base;
  281. }
  282. static ARM_INST_PTR INTERPRETER_TRANSLATE(ldrcond)(unsigned int inst, int index) {
  283. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  284. ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
  285. inst_base->cond = BITS(inst, 28, 31);
  286. inst_base->idx = index;
  287. inst_base->br = TransExtData::NON_BRANCH;
  288. inst_cream->inst = inst;
  289. inst_cream->get_addr = GetAddressingOp(inst);
  290. if (BITS(inst, 12, 15) == 15)
  291. inst_base->br = TransExtData::INDIRECT_BRANCH;
  292. return inst_base;
  293. }
  294. static ARM_INST_PTR INTERPRETER_TRANSLATE(uxth)(unsigned int inst, int index) {
  295. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(uxth_inst));
  296. uxth_inst* inst_cream = (uxth_inst*)inst_base->component;
  297. inst_base->cond = BITS(inst, 28, 31);
  298. inst_base->idx = index;
  299. inst_base->br = TransExtData::NON_BRANCH;
  300. inst_cream->Rd = BITS(inst, 12, 15);
  301. inst_cream->rotate = BITS(inst, 10, 11);
  302. inst_cream->Rm = BITS(inst, 0, 3);
  303. return inst_base;
  304. }
  305. static ARM_INST_PTR INTERPRETER_TRANSLATE(uxtah)(unsigned int inst, int index) {
  306. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(uxtah_inst));
  307. uxtah_inst* inst_cream = (uxtah_inst*)inst_base->component;
  308. inst_base->cond = BITS(inst, 28, 31);
  309. inst_base->idx = index;
  310. inst_base->br = TransExtData::NON_BRANCH;
  311. inst_cream->Rn = BITS(inst, 16, 19);
  312. inst_cream->Rd = BITS(inst, 12, 15);
  313. inst_cream->rotate = BITS(inst, 10, 11);
  314. inst_cream->Rm = BITS(inst, 0, 3);
  315. return inst_base;
  316. }
  317. static ARM_INST_PTR INTERPRETER_TRANSLATE(ldrb)(unsigned int inst, int index) {
  318. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  319. ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
  320. inst_base->cond = BITS(inst, 28, 31);
  321. inst_base->idx = index;
  322. inst_base->br = TransExtData::NON_BRANCH;
  323. inst_cream->inst = inst;
  324. inst_cream->get_addr = GetAddressingOp(inst);
  325. return inst_base;
  326. }
  327. static ARM_INST_PTR INTERPRETER_TRANSLATE(ldrbt)(unsigned int inst, int index) {
  328. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  329. ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
  330. inst_base->cond = BITS(inst, 28, 31);
  331. inst_base->idx = index;
  332. inst_base->br = TransExtData::NON_BRANCH;
  333. inst_cream->inst = inst;
  334. inst_cream->get_addr = GetAddressingOpLoadStoreT(inst);
  335. return inst_base;
  336. }
  337. static ARM_INST_PTR INTERPRETER_TRANSLATE(ldrd)(unsigned int inst, int index) {
  338. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  339. ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
  340. inst_base->cond = BITS(inst, 28, 31);
  341. inst_base->idx = index;
  342. inst_base->br = TransExtData::NON_BRANCH;
  343. inst_cream->inst = inst;
  344. inst_cream->get_addr = GetAddressingOp(inst);
  345. return inst_base;
  346. }
  347. static ARM_INST_PTR INTERPRETER_TRANSLATE(ldrex)(unsigned int inst, int index) {
  348. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(generic_arm_inst));
  349. generic_arm_inst* inst_cream = (generic_arm_inst*)inst_base->component;
  350. inst_base->cond = BITS(inst, 28, 31);
  351. inst_base->idx = index;
  352. inst_base->br = (BITS(inst, 12, 15) == 15) ? TransExtData::INDIRECT_BRANCH
  353. : TransExtData::NON_BRANCH; // Branch if dest is R15
  354. inst_cream->Rn = BITS(inst, 16, 19);
  355. inst_cream->Rd = BITS(inst, 12, 15);
  356. return inst_base;
  357. }
  358. static ARM_INST_PTR INTERPRETER_TRANSLATE(ldrexb)(unsigned int inst, int index) {
  359. return INTERPRETER_TRANSLATE(ldrex)(inst, index);
  360. }
  361. static ARM_INST_PTR INTERPRETER_TRANSLATE(ldrexh)(unsigned int inst, int index) {
  362. return INTERPRETER_TRANSLATE(ldrex)(inst, index);
  363. }
  364. static ARM_INST_PTR INTERPRETER_TRANSLATE(ldrexd)(unsigned int inst, int index) {
  365. return INTERPRETER_TRANSLATE(ldrex)(inst, index);
  366. }
  367. static ARM_INST_PTR INTERPRETER_TRANSLATE(ldrh)(unsigned int inst, int index) {
  368. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  369. ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
  370. inst_base->cond = BITS(inst, 28, 31);
  371. inst_base->idx = index;
  372. inst_base->br = TransExtData::NON_BRANCH;
  373. inst_cream->inst = inst;
  374. inst_cream->get_addr = GetAddressingOp(inst);
  375. return inst_base;
  376. }
  377. static ARM_INST_PTR INTERPRETER_TRANSLATE(ldrsb)(unsigned int inst, int index) {
  378. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  379. ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
  380. inst_base->cond = BITS(inst, 28, 31);
  381. inst_base->idx = index;
  382. inst_base->br = TransExtData::NON_BRANCH;
  383. inst_cream->inst = inst;
  384. inst_cream->get_addr = GetAddressingOp(inst);
  385. return inst_base;
  386. }
  387. static ARM_INST_PTR INTERPRETER_TRANSLATE(ldrsh)(unsigned int inst, int index) {
  388. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  389. ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
  390. inst_base->cond = BITS(inst, 28, 31);
  391. inst_base->idx = index;
  392. inst_base->br = TransExtData::NON_BRANCH;
  393. inst_cream->inst = inst;
  394. inst_cream->get_addr = GetAddressingOp(inst);
  395. return inst_base;
  396. }
  397. static ARM_INST_PTR INTERPRETER_TRANSLATE(ldrt)(unsigned int inst, int index) {
  398. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  399. ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
  400. inst_base->cond = BITS(inst, 28, 31);
  401. inst_base->idx = index;
  402. inst_base->br = TransExtData::NON_BRANCH;
  403. inst_cream->inst = inst;
  404. inst_cream->get_addr = GetAddressingOpLoadStoreT(inst);
  405. if (BITS(inst, 12, 15) == 15) {
  406. inst_base->br = TransExtData::INDIRECT_BRANCH;
  407. }
  408. return inst_base;
  409. }
  410. static ARM_INST_PTR INTERPRETER_TRANSLATE(mcr)(unsigned int inst, int index) {
  411. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(mcr_inst));
  412. mcr_inst* inst_cream = (mcr_inst*)inst_base->component;
  413. inst_base->cond = BITS(inst, 28, 31);
  414. inst_base->idx = index;
  415. inst_base->br = TransExtData::NON_BRANCH;
  416. inst_cream->crn = BITS(inst, 16, 19);
  417. inst_cream->crm = BITS(inst, 0, 3);
  418. inst_cream->opcode_1 = BITS(inst, 21, 23);
  419. inst_cream->opcode_2 = BITS(inst, 5, 7);
  420. inst_cream->Rd = BITS(inst, 12, 15);
  421. inst_cream->cp_num = BITS(inst, 8, 11);
  422. inst_cream->inst = inst;
  423. return inst_base;
  424. }
  425. static ARM_INST_PTR INTERPRETER_TRANSLATE(mcrr)(unsigned int inst, int index) {
  426. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(mcrr_inst));
  427. mcrr_inst* const inst_cream = (mcrr_inst*)inst_base->component;
  428. inst_base->cond = BITS(inst, 28, 31);
  429. inst_base->idx = index;
  430. inst_base->br = TransExtData::NON_BRANCH;
  431. inst_cream->crm = BITS(inst, 0, 3);
  432. inst_cream->opcode_1 = BITS(inst, 4, 7);
  433. inst_cream->cp_num = BITS(inst, 8, 11);
  434. inst_cream->rt = BITS(inst, 12, 15);
  435. inst_cream->rt2 = BITS(inst, 16, 19);
  436. return inst_base;
  437. }
  438. static ARM_INST_PTR INTERPRETER_TRANSLATE(mla)(unsigned int inst, int index) {
  439. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(mla_inst));
  440. mla_inst* inst_cream = (mla_inst*)inst_base->component;
  441. inst_base->cond = BITS(inst, 28, 31);
  442. inst_base->idx = index;
  443. inst_base->br = TransExtData::NON_BRANCH;
  444. inst_cream->S = BIT(inst, 20);
  445. inst_cream->Rn = BITS(inst, 12, 15);
  446. inst_cream->Rd = BITS(inst, 16, 19);
  447. inst_cream->Rs = BITS(inst, 8, 11);
  448. inst_cream->Rm = BITS(inst, 0, 3);
  449. return inst_base;
  450. }
  451. static ARM_INST_PTR INTERPRETER_TRANSLATE(mov)(unsigned int inst, int index) {
  452. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(mov_inst));
  453. mov_inst* inst_cream = (mov_inst*)inst_base->component;
  454. inst_base->cond = BITS(inst, 28, 31);
  455. inst_base->idx = index;
  456. inst_base->br = TransExtData::NON_BRANCH;
  457. inst_cream->I = BIT(inst, 25);
  458. inst_cream->S = BIT(inst, 20);
  459. inst_cream->Rd = BITS(inst, 12, 15);
  460. inst_cream->shifter_operand = BITS(inst, 0, 11);
  461. inst_cream->shtop_func = GetShifterOp(inst);
  462. if (inst_cream->Rd == 15) {
  463. inst_base->br = TransExtData::INDIRECT_BRANCH;
  464. }
  465. return inst_base;
  466. }
  467. static ARM_INST_PTR INTERPRETER_TRANSLATE(mrc)(unsigned int inst, int index) {
  468. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(mrc_inst));
  469. mrc_inst* inst_cream = (mrc_inst*)inst_base->component;
  470. inst_base->cond = BITS(inst, 28, 31);
  471. inst_base->idx = index;
  472. inst_base->br = TransExtData::NON_BRANCH;
  473. inst_cream->crn = BITS(inst, 16, 19);
  474. inst_cream->crm = BITS(inst, 0, 3);
  475. inst_cream->opcode_1 = BITS(inst, 21, 23);
  476. inst_cream->opcode_2 = BITS(inst, 5, 7);
  477. inst_cream->Rd = BITS(inst, 12, 15);
  478. inst_cream->cp_num = BITS(inst, 8, 11);
  479. inst_cream->inst = inst;
  480. return inst_base;
  481. }
  482. static ARM_INST_PTR INTERPRETER_TRANSLATE(mrrc)(unsigned int inst, int index) {
  483. return INTERPRETER_TRANSLATE(mcrr)(inst, index);
  484. }
  485. static ARM_INST_PTR INTERPRETER_TRANSLATE(mrs)(unsigned int inst, int index) {
  486. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(mrs_inst));
  487. mrs_inst* inst_cream = (mrs_inst*)inst_base->component;
  488. inst_base->cond = BITS(inst, 28, 31);
  489. inst_base->idx = index;
  490. inst_base->br = TransExtData::NON_BRANCH;
  491. inst_cream->Rd = BITS(inst, 12, 15);
  492. inst_cream->R = BIT(inst, 22);
  493. return inst_base;
  494. }
  495. static ARM_INST_PTR INTERPRETER_TRANSLATE(msr)(unsigned int inst, int index) {
  496. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(msr_inst));
  497. msr_inst* inst_cream = (msr_inst*)inst_base->component;
  498. inst_base->cond = BITS(inst, 28, 31);
  499. inst_base->idx = index;
  500. inst_base->br = TransExtData::NON_BRANCH;
  501. inst_cream->field_mask = BITS(inst, 16, 19);
  502. inst_cream->R = BIT(inst, 22);
  503. inst_cream->inst = inst;
  504. return inst_base;
  505. }
  506. static ARM_INST_PTR INTERPRETER_TRANSLATE(mul)(unsigned int inst, int index) {
  507. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(mul_inst));
  508. mul_inst* inst_cream = (mul_inst*)inst_base->component;
  509. inst_base->cond = BITS(inst, 28, 31);
  510. inst_base->idx = index;
  511. inst_base->br = TransExtData::NON_BRANCH;
  512. inst_cream->S = BIT(inst, 20);
  513. inst_cream->Rm = BITS(inst, 0, 3);
  514. inst_cream->Rs = BITS(inst, 8, 11);
  515. inst_cream->Rd = BITS(inst, 16, 19);
  516. return inst_base;
  517. }
  518. static ARM_INST_PTR INTERPRETER_TRANSLATE(mvn)(unsigned int inst, int index) {
  519. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(mvn_inst));
  520. mvn_inst* inst_cream = (mvn_inst*)inst_base->component;
  521. inst_base->cond = BITS(inst, 28, 31);
  522. inst_base->idx = index;
  523. inst_base->br = TransExtData::NON_BRANCH;
  524. inst_cream->I = BIT(inst, 25);
  525. inst_cream->S = BIT(inst, 20);
  526. inst_cream->Rd = BITS(inst, 12, 15);
  527. inst_cream->shifter_operand = BITS(inst, 0, 11);
  528. inst_cream->shtop_func = GetShifterOp(inst);
  529. if (inst_cream->Rd == 15) {
  530. inst_base->br = TransExtData::INDIRECT_BRANCH;
  531. }
  532. return inst_base;
  533. }
  534. static ARM_INST_PTR INTERPRETER_TRANSLATE(orr)(unsigned int inst, int index) {
  535. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(orr_inst));
  536. orr_inst* inst_cream = (orr_inst*)inst_base->component;
  537. inst_base->cond = BITS(inst, 28, 31);
  538. inst_base->idx = index;
  539. inst_base->br = TransExtData::NON_BRANCH;
  540. inst_cream->I = BIT(inst, 25);
  541. inst_cream->S = BIT(inst, 20);
  542. inst_cream->Rd = BITS(inst, 12, 15);
  543. inst_cream->Rn = BITS(inst, 16, 19);
  544. inst_cream->shifter_operand = BITS(inst, 0, 11);
  545. inst_cream->shtop_func = GetShifterOp(inst);
  546. if (inst_cream->Rd == 15)
  547. inst_base->br = TransExtData::INDIRECT_BRANCH;
  548. return inst_base;
  549. }
  550. // NOP introduced in ARMv6K.
  551. static ARM_INST_PTR INTERPRETER_TRANSLATE(nop)(unsigned int inst, int index) {
  552. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst));
  553. inst_base->cond = BITS(inst, 28, 31);
  554. inst_base->idx = index;
  555. inst_base->br = TransExtData::NON_BRANCH;
  556. return inst_base;
  557. }
  558. static ARM_INST_PTR INTERPRETER_TRANSLATE(pkhbt)(unsigned int inst, int index) {
  559. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(pkh_inst));
  560. pkh_inst* inst_cream = (pkh_inst*)inst_base->component;
  561. inst_base->cond = BITS(inst, 28, 31);
  562. inst_base->idx = index;
  563. inst_base->br = TransExtData::NON_BRANCH;
  564. inst_cream->Rd = BITS(inst, 12, 15);
  565. inst_cream->Rn = BITS(inst, 16, 19);
  566. inst_cream->Rm = BITS(inst, 0, 3);
  567. inst_cream->imm = BITS(inst, 7, 11);
  568. return inst_base;
  569. }
  570. static ARM_INST_PTR INTERPRETER_TRANSLATE(pkhtb)(unsigned int inst, int index) {
  571. return INTERPRETER_TRANSLATE(pkhbt)(inst, index);
  572. }
  573. static ARM_INST_PTR INTERPRETER_TRANSLATE(pld)(unsigned int inst, int index) {
  574. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(pld_inst));
  575. inst_base->cond = BITS(inst, 28, 31);
  576. inst_base->idx = index;
  577. inst_base->br = TransExtData::NON_BRANCH;
  578. return inst_base;
  579. }
  580. static ARM_INST_PTR INTERPRETER_TRANSLATE(qadd)(unsigned int inst, int index) {
  581. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(generic_arm_inst));
  582. generic_arm_inst* const inst_cream = (generic_arm_inst*)inst_base->component;
  583. inst_base->cond = BITS(inst, 28, 31);
  584. inst_base->idx = index;
  585. inst_base->br = TransExtData::NON_BRANCH;
  586. inst_cream->op1 = BITS(inst, 21, 22);
  587. inst_cream->Rm = BITS(inst, 0, 3);
  588. inst_cream->Rn = BITS(inst, 16, 19);
  589. inst_cream->Rd = BITS(inst, 12, 15);
  590. return inst_base;
  591. }
  592. static ARM_INST_PTR INTERPRETER_TRANSLATE(qdadd)(unsigned int inst, int index) {
  593. return INTERPRETER_TRANSLATE(qadd)(inst, index);
  594. }
  595. static ARM_INST_PTR INTERPRETER_TRANSLATE(qdsub)(unsigned int inst, int index) {
  596. return INTERPRETER_TRANSLATE(qadd)(inst, index);
  597. }
  598. static ARM_INST_PTR INTERPRETER_TRANSLATE(qsub)(unsigned int inst, int index) {
  599. return INTERPRETER_TRANSLATE(qadd)(inst, index);
  600. }
  601. static ARM_INST_PTR INTERPRETER_TRANSLATE(qadd8)(unsigned int inst, int index) {
  602. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(generic_arm_inst));
  603. generic_arm_inst* const inst_cream = (generic_arm_inst*)inst_base->component;
  604. inst_base->cond = BITS(inst, 28, 31);
  605. inst_base->idx = index;
  606. inst_base->br = TransExtData::NON_BRANCH;
  607. inst_cream->Rm = BITS(inst, 0, 3);
  608. inst_cream->Rn = BITS(inst, 16, 19);
  609. inst_cream->Rd = BITS(inst, 12, 15);
  610. inst_cream->op1 = BITS(inst, 20, 21);
  611. inst_cream->op2 = BITS(inst, 5, 7);
  612. return inst_base;
  613. }
  614. static ARM_INST_PTR INTERPRETER_TRANSLATE(qadd16)(unsigned int inst, int index) {
  615. return INTERPRETER_TRANSLATE(qadd8)(inst, index);
  616. }
  617. static ARM_INST_PTR INTERPRETER_TRANSLATE(qaddsubx)(unsigned int inst, int index) {
  618. return INTERPRETER_TRANSLATE(qadd8)(inst, index);
  619. }
  620. static ARM_INST_PTR INTERPRETER_TRANSLATE(qsub8)(unsigned int inst, int index) {
  621. return INTERPRETER_TRANSLATE(qadd8)(inst, index);
  622. }
  623. static ARM_INST_PTR INTERPRETER_TRANSLATE(qsub16)(unsigned int inst, int index) {
  624. return INTERPRETER_TRANSLATE(qadd8)(inst, index);
  625. }
  626. static ARM_INST_PTR INTERPRETER_TRANSLATE(qsubaddx)(unsigned int inst, int index) {
  627. return INTERPRETER_TRANSLATE(qadd8)(inst, index);
  628. }
  629. static ARM_INST_PTR INTERPRETER_TRANSLATE(rev)(unsigned int inst, int index) {
  630. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(rev_inst));
  631. rev_inst* const inst_cream = (rev_inst*)inst_base->component;
  632. inst_base->cond = BITS(inst, 28, 31);
  633. inst_base->idx = index;
  634. inst_base->br = TransExtData::NON_BRANCH;
  635. inst_cream->Rm = BITS(inst, 0, 3);
  636. inst_cream->Rd = BITS(inst, 12, 15);
  637. inst_cream->op1 = BITS(inst, 20, 22);
  638. inst_cream->op2 = BITS(inst, 5, 7);
  639. return inst_base;
  640. }
  641. static ARM_INST_PTR INTERPRETER_TRANSLATE(rev16)(unsigned int inst, int index) {
  642. return INTERPRETER_TRANSLATE(rev)(inst, index);
  643. }
  644. static ARM_INST_PTR INTERPRETER_TRANSLATE(revsh)(unsigned int inst, int index) {
  645. return INTERPRETER_TRANSLATE(rev)(inst, index);
  646. }
  647. static ARM_INST_PTR INTERPRETER_TRANSLATE(rfe)(unsigned int inst, int index) {
  648. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  649. ldst_inst* const inst_cream = (ldst_inst*)inst_base->component;
  650. inst_base->cond = AL;
  651. inst_base->idx = index;
  652. inst_base->br = TransExtData::INDIRECT_BRANCH;
  653. inst_cream->inst = inst;
  654. inst_cream->get_addr = GetAddressingOp(inst);
  655. return inst_base;
  656. }
  657. static ARM_INST_PTR INTERPRETER_TRANSLATE(rsb)(unsigned int inst, int index) {
  658. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(rsb_inst));
  659. rsb_inst* inst_cream = (rsb_inst*)inst_base->component;
  660. inst_base->cond = BITS(inst, 28, 31);
  661. inst_base->idx = index;
  662. inst_base->br = TransExtData::NON_BRANCH;
  663. inst_cream->I = BIT(inst, 25);
  664. inst_cream->S = BIT(inst, 20);
  665. inst_cream->Rn = BITS(inst, 16, 19);
  666. inst_cream->Rd = BITS(inst, 12, 15);
  667. inst_cream->shifter_operand = BITS(inst, 0, 11);
  668. inst_cream->shtop_func = GetShifterOp(inst);
  669. if (inst_cream->Rd == 15)
  670. inst_base->br = TransExtData::INDIRECT_BRANCH;
  671. return inst_base;
  672. }
  673. static ARM_INST_PTR INTERPRETER_TRANSLATE(rsc)(unsigned int inst, int index) {
  674. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(rsc_inst));
  675. rsc_inst* inst_cream = (rsc_inst*)inst_base->component;
  676. inst_base->cond = BITS(inst, 28, 31);
  677. inst_base->idx = index;
  678. inst_base->br = TransExtData::NON_BRANCH;
  679. inst_cream->I = BIT(inst, 25);
  680. inst_cream->S = BIT(inst, 20);
  681. inst_cream->Rn = BITS(inst, 16, 19);
  682. inst_cream->Rd = BITS(inst, 12, 15);
  683. inst_cream->shifter_operand = BITS(inst, 0, 11);
  684. inst_cream->shtop_func = GetShifterOp(inst);
  685. if (inst_cream->Rd == 15)
  686. inst_base->br = TransExtData::INDIRECT_BRANCH;
  687. return inst_base;
  688. }
  689. static ARM_INST_PTR INTERPRETER_TRANSLATE(sadd8)(unsigned int inst, int index) {
  690. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(generic_arm_inst));
  691. generic_arm_inst* const inst_cream = (generic_arm_inst*)inst_base->component;
  692. inst_base->cond = BITS(inst, 28, 31);
  693. inst_base->idx = index;
  694. inst_base->br = TransExtData::NON_BRANCH;
  695. inst_cream->Rm = BITS(inst, 0, 3);
  696. inst_cream->Rn = BITS(inst, 16, 19);
  697. inst_cream->Rd = BITS(inst, 12, 15);
  698. inst_cream->op1 = BITS(inst, 20, 21);
  699. inst_cream->op2 = BITS(inst, 5, 7);
  700. return inst_base;
  701. }
  702. static ARM_INST_PTR INTERPRETER_TRANSLATE(sadd16)(unsigned int inst, int index) {
  703. return INTERPRETER_TRANSLATE(sadd8)(inst, index);
  704. }
  705. static ARM_INST_PTR INTERPRETER_TRANSLATE(saddsubx)(unsigned int inst, int index) {
  706. return INTERPRETER_TRANSLATE(sadd8)(inst, index);
  707. }
  708. static ARM_INST_PTR INTERPRETER_TRANSLATE(ssub8)(unsigned int inst, int index) {
  709. return INTERPRETER_TRANSLATE(sadd8)(inst, index);
  710. }
  711. static ARM_INST_PTR INTERPRETER_TRANSLATE(ssub16)(unsigned int inst, int index) {
  712. return INTERPRETER_TRANSLATE(sadd8)(inst, index);
  713. }
  714. static ARM_INST_PTR INTERPRETER_TRANSLATE(ssubaddx)(unsigned int inst, int index) {
  715. return INTERPRETER_TRANSLATE(sadd8)(inst, index);
  716. }
  717. static ARM_INST_PTR INTERPRETER_TRANSLATE(sbc)(unsigned int inst, int index) {
  718. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(sbc_inst));
  719. sbc_inst* inst_cream = (sbc_inst*)inst_base->component;
  720. inst_base->cond = BITS(inst, 28, 31);
  721. inst_base->idx = index;
  722. inst_base->br = TransExtData::NON_BRANCH;
  723. inst_cream->I = BIT(inst, 25);
  724. inst_cream->S = BIT(inst, 20);
  725. inst_cream->Rn = BITS(inst, 16, 19);
  726. inst_cream->Rd = BITS(inst, 12, 15);
  727. inst_cream->shifter_operand = BITS(inst, 0, 11);
  728. inst_cream->shtop_func = GetShifterOp(inst);
  729. if (inst_cream->Rd == 15)
  730. inst_base->br = TransExtData::INDIRECT_BRANCH;
  731. return inst_base;
  732. }
  733. static ARM_INST_PTR INTERPRETER_TRANSLATE(sel)(unsigned int inst, int index) {
  734. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(generic_arm_inst));
  735. generic_arm_inst* const inst_cream = (generic_arm_inst*)inst_base->component;
  736. inst_base->cond = BITS(inst, 28, 31);
  737. inst_base->idx = index;
  738. inst_base->br = TransExtData::NON_BRANCH;
  739. inst_cream->Rm = BITS(inst, 0, 3);
  740. inst_cream->Rn = BITS(inst, 16, 19);
  741. inst_cream->Rd = BITS(inst, 12, 15);
  742. inst_cream->op1 = BITS(inst, 20, 22);
  743. inst_cream->op2 = BITS(inst, 5, 7);
  744. return inst_base;
  745. }
  746. static ARM_INST_PTR INTERPRETER_TRANSLATE(setend)(unsigned int inst, int index) {
  747. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(setend_inst));
  748. setend_inst* const inst_cream = (setend_inst*)inst_base->component;
  749. inst_base->cond = AL;
  750. inst_base->idx = index;
  751. inst_base->br = TransExtData::NON_BRANCH;
  752. inst_cream->set_bigend = BIT(inst, 9);
  753. return inst_base;
  754. }
  755. static ARM_INST_PTR INTERPRETER_TRANSLATE(sev)(unsigned int inst, int index) {
  756. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst));
  757. inst_base->cond = BITS(inst, 28, 31);
  758. inst_base->idx = index;
  759. inst_base->br = TransExtData::NON_BRANCH;
  760. return inst_base;
  761. }
  762. static ARM_INST_PTR INTERPRETER_TRANSLATE(shadd8)(unsigned int inst, int index) {
  763. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(generic_arm_inst));
  764. generic_arm_inst* const inst_cream = (generic_arm_inst*)inst_base->component;
  765. inst_base->cond = BITS(inst, 28, 31);
  766. inst_base->idx = index;
  767. inst_base->br = TransExtData::NON_BRANCH;
  768. inst_cream->op1 = BITS(inst, 20, 21);
  769. inst_cream->op2 = BITS(inst, 5, 7);
  770. inst_cream->Rm = BITS(inst, 0, 3);
  771. inst_cream->Rn = BITS(inst, 16, 19);
  772. inst_cream->Rd = BITS(inst, 12, 15);
  773. return inst_base;
  774. }
  775. static ARM_INST_PTR INTERPRETER_TRANSLATE(shadd16)(unsigned int inst, int index) {
  776. return INTERPRETER_TRANSLATE(shadd8)(inst, index);
  777. }
  778. static ARM_INST_PTR INTERPRETER_TRANSLATE(shaddsubx)(unsigned int inst, int index) {
  779. return INTERPRETER_TRANSLATE(shadd8)(inst, index);
  780. }
  781. static ARM_INST_PTR INTERPRETER_TRANSLATE(shsub8)(unsigned int inst, int index) {
  782. return INTERPRETER_TRANSLATE(shadd8)(inst, index);
  783. }
  784. static ARM_INST_PTR INTERPRETER_TRANSLATE(shsub16)(unsigned int inst, int index) {
  785. return INTERPRETER_TRANSLATE(shadd8)(inst, index);
  786. }
  787. static ARM_INST_PTR INTERPRETER_TRANSLATE(shsubaddx)(unsigned int inst, int index) {
  788. return INTERPRETER_TRANSLATE(shadd8)(inst, index);
  789. }
  790. static ARM_INST_PTR INTERPRETER_TRANSLATE(smla)(unsigned int inst, int index) {
  791. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(smla_inst));
  792. smla_inst* inst_cream = (smla_inst*)inst_base->component;
  793. inst_base->cond = BITS(inst, 28, 31);
  794. inst_base->idx = index;
  795. inst_base->br = TransExtData::NON_BRANCH;
  796. inst_cream->x = BIT(inst, 5);
  797. inst_cream->y = BIT(inst, 6);
  798. inst_cream->Rm = BITS(inst, 0, 3);
  799. inst_cream->Rs = BITS(inst, 8, 11);
  800. inst_cream->Rd = BITS(inst, 16, 19);
  801. inst_cream->Rn = BITS(inst, 12, 15);
  802. return inst_base;
  803. }
  804. static ARM_INST_PTR INTERPRETER_TRANSLATE(smlad)(unsigned int inst, int index) {
  805. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(smlad_inst));
  806. smlad_inst* const inst_cream = (smlad_inst*)inst_base->component;
  807. inst_base->cond = BITS(inst, 28, 31);
  808. inst_base->idx = index;
  809. inst_base->br = TransExtData::NON_BRANCH;
  810. inst_cream->m = BIT(inst, 5);
  811. inst_cream->Rn = BITS(inst, 0, 3);
  812. inst_cream->Rm = BITS(inst, 8, 11);
  813. inst_cream->Rd = BITS(inst, 16, 19);
  814. inst_cream->Ra = BITS(inst, 12, 15);
  815. inst_cream->op1 = BITS(inst, 20, 22);
  816. inst_cream->op2 = BITS(inst, 5, 7);
  817. return inst_base;
  818. }
  819. static ARM_INST_PTR INTERPRETER_TRANSLATE(smuad)(unsigned int inst, int index) {
  820. return INTERPRETER_TRANSLATE(smlad)(inst, index);
  821. }
  822. static ARM_INST_PTR INTERPRETER_TRANSLATE(smusd)(unsigned int inst, int index) {
  823. return INTERPRETER_TRANSLATE(smlad)(inst, index);
  824. }
  825. static ARM_INST_PTR INTERPRETER_TRANSLATE(smlsd)(unsigned int inst, int index) {
  826. return INTERPRETER_TRANSLATE(smlad)(inst, index);
  827. }
  828. static ARM_INST_PTR INTERPRETER_TRANSLATE(smlal)(unsigned int inst, int index) {
  829. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(umlal_inst));
  830. umlal_inst* inst_cream = (umlal_inst*)inst_base->component;
  831. inst_base->cond = BITS(inst, 28, 31);
  832. inst_base->idx = index;
  833. inst_base->br = TransExtData::NON_BRANCH;
  834. inst_cream->S = BIT(inst, 20);
  835. inst_cream->Rm = BITS(inst, 0, 3);
  836. inst_cream->Rs = BITS(inst, 8, 11);
  837. inst_cream->RdHi = BITS(inst, 16, 19);
  838. inst_cream->RdLo = BITS(inst, 12, 15);
  839. return inst_base;
  840. }
  841. static ARM_INST_PTR INTERPRETER_TRANSLATE(smlalxy)(unsigned int inst, int index) {
  842. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(smlalxy_inst));
  843. smlalxy_inst* const inst_cream = (smlalxy_inst*)inst_base->component;
  844. inst_base->cond = BITS(inst, 28, 31);
  845. inst_base->idx = index;
  846. inst_base->br = TransExtData::NON_BRANCH;
  847. inst_cream->x = BIT(inst, 5);
  848. inst_cream->y = BIT(inst, 6);
  849. inst_cream->RdLo = BITS(inst, 12, 15);
  850. inst_cream->RdHi = BITS(inst, 16, 19);
  851. inst_cream->Rn = BITS(inst, 0, 4);
  852. inst_cream->Rm = BITS(inst, 8, 11);
  853. return inst_base;
  854. }
  855. static ARM_INST_PTR INTERPRETER_TRANSLATE(smlaw)(unsigned int inst, int index) {
  856. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(smlad_inst));
  857. smlad_inst* const inst_cream = (smlad_inst*)inst_base->component;
  858. inst_base->cond = BITS(inst, 28, 31);
  859. inst_base->idx = index;
  860. inst_base->br = TransExtData::NON_BRANCH;
  861. inst_cream->Ra = BITS(inst, 12, 15);
  862. inst_cream->Rm = BITS(inst, 8, 11);
  863. inst_cream->Rn = BITS(inst, 0, 3);
  864. inst_cream->Rd = BITS(inst, 16, 19);
  865. inst_cream->m = BIT(inst, 6);
  866. return inst_base;
  867. }
  868. static ARM_INST_PTR INTERPRETER_TRANSLATE(smlald)(unsigned int inst, int index) {
  869. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(smlald_inst));
  870. smlald_inst* const inst_cream = (smlald_inst*)inst_base->component;
  871. inst_base->cond = BITS(inst, 28, 31);
  872. inst_base->idx = index;
  873. inst_base->br = TransExtData::NON_BRANCH;
  874. inst_cream->Rm = BITS(inst, 8, 11);
  875. inst_cream->Rn = BITS(inst, 0, 3);
  876. inst_cream->RdLo = BITS(inst, 12, 15);
  877. inst_cream->RdHi = BITS(inst, 16, 19);
  878. inst_cream->swap = BIT(inst, 5);
  879. inst_cream->op1 = BITS(inst, 20, 22);
  880. inst_cream->op2 = BITS(inst, 5, 7);
  881. return inst_base;
  882. }
  883. static ARM_INST_PTR INTERPRETER_TRANSLATE(smlsld)(unsigned int inst, int index) {
  884. return INTERPRETER_TRANSLATE(smlald)(inst, index);
  885. }
  886. static ARM_INST_PTR INTERPRETER_TRANSLATE(smmla)(unsigned int inst, int index) {
  887. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(smlad_inst));
  888. smlad_inst* const inst_cream = (smlad_inst*)inst_base->component;
  889. inst_base->cond = BITS(inst, 28, 31);
  890. inst_base->idx = index;
  891. inst_base->br = TransExtData::NON_BRANCH;
  892. inst_cream->m = BIT(inst, 5);
  893. inst_cream->Ra = BITS(inst, 12, 15);
  894. inst_cream->Rm = BITS(inst, 8, 11);
  895. inst_cream->Rn = BITS(inst, 0, 3);
  896. inst_cream->Rd = BITS(inst, 16, 19);
  897. inst_cream->op1 = BITS(inst, 20, 22);
  898. inst_cream->op2 = BITS(inst, 5, 7);
  899. return inst_base;
  900. }
  901. static ARM_INST_PTR INTERPRETER_TRANSLATE(smmls)(unsigned int inst, int index) {
  902. return INTERPRETER_TRANSLATE(smmla)(inst, index);
  903. }
  904. static ARM_INST_PTR INTERPRETER_TRANSLATE(smmul)(unsigned int inst, int index) {
  905. return INTERPRETER_TRANSLATE(smmla)(inst, index);
  906. }
  907. static ARM_INST_PTR INTERPRETER_TRANSLATE(smul)(unsigned int inst, int index) {
  908. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(smul_inst));
  909. smul_inst* inst_cream = (smul_inst*)inst_base->component;
  910. inst_base->cond = BITS(inst, 28, 31);
  911. inst_base->idx = index;
  912. inst_base->br = TransExtData::NON_BRANCH;
  913. inst_cream->Rd = BITS(inst, 16, 19);
  914. inst_cream->Rs = BITS(inst, 8, 11);
  915. inst_cream->Rm = BITS(inst, 0, 3);
  916. inst_cream->x = BIT(inst, 5);
  917. inst_cream->y = BIT(inst, 6);
  918. return inst_base;
  919. }
  920. static ARM_INST_PTR INTERPRETER_TRANSLATE(smull)(unsigned int inst, int index) {
  921. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(umull_inst));
  922. umull_inst* inst_cream = (umull_inst*)inst_base->component;
  923. inst_base->cond = BITS(inst, 28, 31);
  924. inst_base->idx = index;
  925. inst_base->br = TransExtData::NON_BRANCH;
  926. inst_cream->S = BIT(inst, 20);
  927. inst_cream->Rm = BITS(inst, 0, 3);
  928. inst_cream->Rs = BITS(inst, 8, 11);
  929. inst_cream->RdHi = BITS(inst, 16, 19);
  930. inst_cream->RdLo = BITS(inst, 12, 15);
  931. return inst_base;
  932. }
  933. static ARM_INST_PTR INTERPRETER_TRANSLATE(smulw)(unsigned int inst, int index) {
  934. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(smlad_inst));
  935. smlad_inst* inst_cream = (smlad_inst*)inst_base->component;
  936. inst_base->cond = BITS(inst, 28, 31);
  937. inst_base->idx = index;
  938. inst_base->br = TransExtData::NON_BRANCH;
  939. inst_cream->m = BIT(inst, 6);
  940. inst_cream->Rm = BITS(inst, 8, 11);
  941. inst_cream->Rn = BITS(inst, 0, 3);
  942. inst_cream->Rd = BITS(inst, 16, 19);
  943. return inst_base;
  944. }
  945. static ARM_INST_PTR INTERPRETER_TRANSLATE(srs)(unsigned int inst, int index) {
  946. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  947. ldst_inst* const inst_cream = (ldst_inst*)inst_base->component;
  948. inst_base->cond = AL;
  949. inst_base->idx = index;
  950. inst_base->br = TransExtData::NON_BRANCH;
  951. inst_cream->inst = inst;
  952. inst_cream->get_addr = GetAddressingOp(inst);
  953. return inst_base;
  954. }
  955. static ARM_INST_PTR INTERPRETER_TRANSLATE(ssat)(unsigned int inst, int index) {
  956. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ssat_inst));
  957. ssat_inst* const inst_cream = (ssat_inst*)inst_base->component;
  958. inst_base->cond = BITS(inst, 28, 31);
  959. inst_base->idx = index;
  960. inst_base->br = TransExtData::NON_BRANCH;
  961. inst_cream->Rn = BITS(inst, 0, 3);
  962. inst_cream->Rd = BITS(inst, 12, 15);
  963. inst_cream->imm5 = BITS(inst, 7, 11);
  964. inst_cream->sat_imm = BITS(inst, 16, 20);
  965. inst_cream->shift_type = BIT(inst, 6);
  966. return inst_base;
  967. }
  968. static ARM_INST_PTR INTERPRETER_TRANSLATE(ssat16)(unsigned int inst, int index) {
  969. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ssat_inst));
  970. ssat_inst* const inst_cream = (ssat_inst*)inst_base->component;
  971. inst_base->cond = BITS(inst, 28, 31);
  972. inst_base->idx = index;
  973. inst_base->br = TransExtData::NON_BRANCH;
  974. inst_cream->Rn = BITS(inst, 0, 3);
  975. inst_cream->Rd = BITS(inst, 12, 15);
  976. inst_cream->sat_imm = BITS(inst, 16, 19);
  977. return inst_base;
  978. }
  979. static ARM_INST_PTR INTERPRETER_TRANSLATE(stc)(unsigned int inst, int index) {
  980. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(stc_inst));
  981. inst_base->cond = BITS(inst, 28, 31);
  982. inst_base->idx = index;
  983. inst_base->br = TransExtData::NON_BRANCH;
  984. return inst_base;
  985. }
  986. static ARM_INST_PTR INTERPRETER_TRANSLATE(stm)(unsigned int inst, int index) {
  987. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  988. ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
  989. inst_base->cond = BITS(inst, 28, 31);
  990. inst_base->idx = index;
  991. inst_base->br = TransExtData::NON_BRANCH;
  992. inst_cream->inst = inst;
  993. inst_cream->get_addr = GetAddressingOp(inst);
  994. return inst_base;
  995. }
  996. static ARM_INST_PTR INTERPRETER_TRANSLATE(sxtb)(unsigned int inst, int index) {
  997. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(sxtb_inst));
  998. sxtb_inst* inst_cream = (sxtb_inst*)inst_base->component;
  999. inst_base->cond = BITS(inst, 28, 31);
  1000. inst_base->idx = index;
  1001. inst_base->br = TransExtData::NON_BRANCH;
  1002. inst_cream->Rd = BITS(inst, 12, 15);
  1003. inst_cream->Rm = BITS(inst, 0, 3);
  1004. inst_cream->rotate = BITS(inst, 10, 11);
  1005. return inst_base;
  1006. }
  1007. static ARM_INST_PTR INTERPRETER_TRANSLATE(str)(unsigned int inst, int index) {
  1008. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  1009. ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
  1010. inst_base->cond = BITS(inst, 28, 31);
  1011. inst_base->idx = index;
  1012. inst_base->br = TransExtData::NON_BRANCH;
  1013. inst_cream->inst = inst;
  1014. inst_cream->get_addr = GetAddressingOp(inst);
  1015. return inst_base;
  1016. }
  1017. static ARM_INST_PTR INTERPRETER_TRANSLATE(uxtb)(unsigned int inst, int index) {
  1018. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(uxth_inst));
  1019. uxth_inst* inst_cream = (uxth_inst*)inst_base->component;
  1020. inst_base->cond = BITS(inst, 28, 31);
  1021. inst_base->idx = index;
  1022. inst_base->br = TransExtData::NON_BRANCH;
  1023. inst_cream->Rd = BITS(inst, 12, 15);
  1024. inst_cream->rotate = BITS(inst, 10, 11);
  1025. inst_cream->Rm = BITS(inst, 0, 3);
  1026. return inst_base;
  1027. }
  1028. static ARM_INST_PTR INTERPRETER_TRANSLATE(uxtab)(unsigned int inst, int index) {
  1029. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(uxtab_inst));
  1030. uxtab_inst* inst_cream = (uxtab_inst*)inst_base->component;
  1031. inst_base->cond = BITS(inst, 28, 31);
  1032. inst_base->idx = index;
  1033. inst_base->br = TransExtData::NON_BRANCH;
  1034. inst_cream->Rd = BITS(inst, 12, 15);
  1035. inst_cream->rotate = BITS(inst, 10, 11);
  1036. inst_cream->Rm = BITS(inst, 0, 3);
  1037. inst_cream->Rn = BITS(inst, 16, 19);
  1038. return inst_base;
  1039. }
  1040. static ARM_INST_PTR INTERPRETER_TRANSLATE(strb)(unsigned int inst, int index) {
  1041. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  1042. ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
  1043. inst_base->cond = BITS(inst, 28, 31);
  1044. inst_base->idx = index;
  1045. inst_base->br = TransExtData::NON_BRANCH;
  1046. inst_cream->inst = inst;
  1047. inst_cream->get_addr = GetAddressingOp(inst);
  1048. return inst_base;
  1049. }
  1050. static ARM_INST_PTR INTERPRETER_TRANSLATE(strbt)(unsigned int inst, int index) {
  1051. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  1052. ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
  1053. inst_base->cond = BITS(inst, 28, 31);
  1054. inst_base->idx = index;
  1055. inst_base->br = TransExtData::NON_BRANCH;
  1056. inst_cream->inst = inst;
  1057. inst_cream->get_addr = GetAddressingOpLoadStoreT(inst);
  1058. return inst_base;
  1059. }
  1060. static ARM_INST_PTR INTERPRETER_TRANSLATE(strd)(unsigned int inst, int index) {
  1061. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  1062. ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
  1063. inst_base->cond = BITS(inst, 28, 31);
  1064. inst_base->idx = index;
  1065. inst_base->br = TransExtData::NON_BRANCH;
  1066. inst_cream->inst = inst;
  1067. inst_cream->get_addr = GetAddressingOp(inst);
  1068. return inst_base;
  1069. }
  1070. static ARM_INST_PTR INTERPRETER_TRANSLATE(strex)(unsigned int inst, int index) {
  1071. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(generic_arm_inst));
  1072. generic_arm_inst* inst_cream = (generic_arm_inst*)inst_base->component;
  1073. inst_base->cond = BITS(inst, 28, 31);
  1074. inst_base->idx = index;
  1075. inst_base->br = TransExtData::NON_BRANCH;
  1076. inst_cream->Rn = BITS(inst, 16, 19);
  1077. inst_cream->Rd = BITS(inst, 12, 15);
  1078. inst_cream->Rm = BITS(inst, 0, 3);
  1079. return inst_base;
  1080. }
  1081. static ARM_INST_PTR INTERPRETER_TRANSLATE(strexb)(unsigned int inst, int index) {
  1082. return INTERPRETER_TRANSLATE(strex)(inst, index);
  1083. }
  1084. static ARM_INST_PTR INTERPRETER_TRANSLATE(strexh)(unsigned int inst, int index) {
  1085. return INTERPRETER_TRANSLATE(strex)(inst, index);
  1086. }
  1087. static ARM_INST_PTR INTERPRETER_TRANSLATE(strexd)(unsigned int inst, int index) {
  1088. return INTERPRETER_TRANSLATE(strex)(inst, index);
  1089. }
  1090. static ARM_INST_PTR INTERPRETER_TRANSLATE(strh)(unsigned int inst, int index) {
  1091. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  1092. ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
  1093. inst_base->cond = BITS(inst, 28, 31);
  1094. inst_base->idx = index;
  1095. inst_base->br = TransExtData::NON_BRANCH;
  1096. inst_cream->inst = inst;
  1097. inst_cream->get_addr = GetAddressingOp(inst);
  1098. return inst_base;
  1099. }
  1100. static ARM_INST_PTR INTERPRETER_TRANSLATE(strt)(unsigned int inst, int index) {
  1101. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(ldst_inst));
  1102. ldst_inst* inst_cream = (ldst_inst*)inst_base->component;
  1103. inst_base->cond = BITS(inst, 28, 31);
  1104. inst_base->idx = index;
  1105. inst_base->br = TransExtData::NON_BRANCH;
  1106. inst_cream->inst = inst;
  1107. inst_cream->get_addr = GetAddressingOpLoadStoreT(inst);
  1108. return inst_base;
  1109. }
  1110. static ARM_INST_PTR INTERPRETER_TRANSLATE(sub)(unsigned int inst, int index) {
  1111. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(sub_inst));
  1112. sub_inst* inst_cream = (sub_inst*)inst_base->component;
  1113. inst_base->cond = BITS(inst, 28, 31);
  1114. inst_base->idx = index;
  1115. inst_base->br = TransExtData::NON_BRANCH;
  1116. inst_cream->I = BIT(inst, 25);
  1117. inst_cream->S = BIT(inst, 20);
  1118. inst_cream->Rn = BITS(inst, 16, 19);
  1119. inst_cream->Rd = BITS(inst, 12, 15);
  1120. inst_cream->shifter_operand = BITS(inst, 0, 11);
  1121. inst_cream->shtop_func = GetShifterOp(inst);
  1122. if (inst_cream->Rd == 15)
  1123. inst_base->br = TransExtData::INDIRECT_BRANCH;
  1124. return inst_base;
  1125. }
  1126. static ARM_INST_PTR INTERPRETER_TRANSLATE(swi)(unsigned int inst, int index) {
  1127. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(swi_inst));
  1128. swi_inst* inst_cream = (swi_inst*)inst_base->component;
  1129. inst_base->cond = BITS(inst, 28, 31);
  1130. inst_base->idx = index;
  1131. inst_base->br = TransExtData::NON_BRANCH;
  1132. inst_cream->num = BITS(inst, 0, 23);
  1133. return inst_base;
  1134. }
  1135. static ARM_INST_PTR INTERPRETER_TRANSLATE(swp)(unsigned int inst, int index) {
  1136. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(swp_inst));
  1137. swp_inst* inst_cream = (swp_inst*)inst_base->component;
  1138. inst_base->cond = BITS(inst, 28, 31);
  1139. inst_base->idx = index;
  1140. inst_base->br = TransExtData::NON_BRANCH;
  1141. inst_cream->Rn = BITS(inst, 16, 19);
  1142. inst_cream->Rd = BITS(inst, 12, 15);
  1143. inst_cream->Rm = BITS(inst, 0, 3);
  1144. return inst_base;
  1145. }
  1146. static ARM_INST_PTR INTERPRETER_TRANSLATE(swpb)(unsigned int inst, int index) {
  1147. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(swp_inst));
  1148. swp_inst* inst_cream = (swp_inst*)inst_base->component;
  1149. inst_base->cond = BITS(inst, 28, 31);
  1150. inst_base->idx = index;
  1151. inst_base->br = TransExtData::NON_BRANCH;
  1152. inst_cream->Rn = BITS(inst, 16, 19);
  1153. inst_cream->Rd = BITS(inst, 12, 15);
  1154. inst_cream->Rm = BITS(inst, 0, 3);
  1155. return inst_base;
  1156. }
  1157. static ARM_INST_PTR INTERPRETER_TRANSLATE(sxtab)(unsigned int inst, int index) {
  1158. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(sxtab_inst));
  1159. sxtab_inst* inst_cream = (sxtab_inst*)inst_base->component;
  1160. inst_base->cond = BITS(inst, 28, 31);
  1161. inst_base->idx = index;
  1162. inst_base->br = TransExtData::NON_BRANCH;
  1163. inst_cream->Rd = BITS(inst, 12, 15);
  1164. inst_cream->rotate = BITS(inst, 10, 11);
  1165. inst_cream->Rm = BITS(inst, 0, 3);
  1166. inst_cream->Rn = BITS(inst, 16, 19);
  1167. return inst_base;
  1168. }
  1169. static ARM_INST_PTR INTERPRETER_TRANSLATE(sxtab16)(unsigned int inst, int index) {
  1170. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(sxtab_inst));
  1171. sxtab_inst* const inst_cream = (sxtab_inst*)inst_base->component;
  1172. inst_base->cond = BITS(inst, 28, 31);
  1173. inst_base->idx = index;
  1174. inst_base->br = TransExtData::NON_BRANCH;
  1175. inst_cream->Rm = BITS(inst, 0, 3);
  1176. inst_cream->Rn = BITS(inst, 16, 19);
  1177. inst_cream->Rd = BITS(inst, 12, 15);
  1178. inst_cream->rotate = BITS(inst, 10, 11);
  1179. return inst_base;
  1180. }
  1181. static ARM_INST_PTR INTERPRETER_TRANSLATE(sxtb16)(unsigned int inst, int index) {
  1182. return INTERPRETER_TRANSLATE(sxtab16)(inst, index);
  1183. }
  1184. static ARM_INST_PTR INTERPRETER_TRANSLATE(sxtah)(unsigned int inst, int index) {
  1185. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(sxtah_inst));
  1186. sxtah_inst* inst_cream = (sxtah_inst*)inst_base->component;
  1187. inst_base->cond = BITS(inst, 28, 31);
  1188. inst_base->idx = index;
  1189. inst_base->br = TransExtData::NON_BRANCH;
  1190. inst_cream->Rd = BITS(inst, 12, 15);
  1191. inst_cream->rotate = BITS(inst, 10, 11);
  1192. inst_cream->Rm = BITS(inst, 0, 3);
  1193. inst_cream->Rn = BITS(inst, 16, 19);
  1194. return inst_base;
  1195. }
  1196. static ARM_INST_PTR INTERPRETER_TRANSLATE(teq)(unsigned int inst, int index) {
  1197. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(teq_inst));
  1198. teq_inst* inst_cream = (teq_inst*)inst_base->component;
  1199. inst_base->cond = BITS(inst, 28, 31);
  1200. inst_base->idx = index;
  1201. inst_base->br = TransExtData::NON_BRANCH;
  1202. inst_cream->I = BIT(inst, 25);
  1203. inst_cream->Rn = BITS(inst, 16, 19);
  1204. inst_cream->shifter_operand = BITS(inst, 0, 11);
  1205. inst_cream->shtop_func = GetShifterOp(inst);
  1206. return inst_base;
  1207. }
  1208. static ARM_INST_PTR INTERPRETER_TRANSLATE(tst)(unsigned int inst, int index) {
  1209. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(tst_inst));
  1210. tst_inst* inst_cream = (tst_inst*)inst_base->component;
  1211. inst_base->cond = BITS(inst, 28, 31);
  1212. inst_base->idx = index;
  1213. inst_base->br = TransExtData::NON_BRANCH;
  1214. inst_cream->I = BIT(inst, 25);
  1215. inst_cream->S = BIT(inst, 20);
  1216. inst_cream->Rn = BITS(inst, 16, 19);
  1217. inst_cream->Rd = BITS(inst, 12, 15);
  1218. inst_cream->shifter_operand = BITS(inst, 0, 11);
  1219. inst_cream->shtop_func = GetShifterOp(inst);
  1220. return inst_base;
  1221. }
  1222. static ARM_INST_PTR INTERPRETER_TRANSLATE(uadd8)(unsigned int inst, int index) {
  1223. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(generic_arm_inst));
  1224. generic_arm_inst* const inst_cream = (generic_arm_inst*)inst_base->component;
  1225. inst_base->cond = BITS(inst, 28, 31);
  1226. inst_base->idx = index;
  1227. inst_base->br = TransExtData::NON_BRANCH;
  1228. inst_cream->op1 = BITS(inst, 20, 21);
  1229. inst_cream->op2 = BITS(inst, 5, 7);
  1230. inst_cream->Rm = BITS(inst, 0, 3);
  1231. inst_cream->Rn = BITS(inst, 16, 19);
  1232. inst_cream->Rd = BITS(inst, 12, 15);
  1233. return inst_base;
  1234. }
  1235. static ARM_INST_PTR INTERPRETER_TRANSLATE(uadd16)(unsigned int inst, int index) {
  1236. return INTERPRETER_TRANSLATE(uadd8)(inst, index);
  1237. }
  1238. static ARM_INST_PTR INTERPRETER_TRANSLATE(uaddsubx)(unsigned int inst, int index) {
  1239. return INTERPRETER_TRANSLATE(uadd8)(inst, index);
  1240. }
  1241. static ARM_INST_PTR INTERPRETER_TRANSLATE(usub8)(unsigned int inst, int index) {
  1242. return INTERPRETER_TRANSLATE(uadd8)(inst, index);
  1243. }
  1244. static ARM_INST_PTR INTERPRETER_TRANSLATE(usub16)(unsigned int inst, int index) {
  1245. return INTERPRETER_TRANSLATE(uadd8)(inst, index);
  1246. }
  1247. static ARM_INST_PTR INTERPRETER_TRANSLATE(usubaddx)(unsigned int inst, int index) {
  1248. return INTERPRETER_TRANSLATE(uadd8)(inst, index);
  1249. }
  1250. static ARM_INST_PTR INTERPRETER_TRANSLATE(uhadd8)(unsigned int inst, int index) {
  1251. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(generic_arm_inst));
  1252. generic_arm_inst* const inst_cream = (generic_arm_inst*)inst_base->component;
  1253. inst_base->cond = BITS(inst, 28, 31);
  1254. inst_base->idx = index;
  1255. inst_base->br = TransExtData::NON_BRANCH;
  1256. inst_cream->op1 = BITS(inst, 20, 21);
  1257. inst_cream->op2 = BITS(inst, 5, 7);
  1258. inst_cream->Rm = BITS(inst, 0, 3);
  1259. inst_cream->Rn = BITS(inst, 16, 19);
  1260. inst_cream->Rd = BITS(inst, 12, 15);
  1261. return inst_base;
  1262. }
  1263. static ARM_INST_PTR INTERPRETER_TRANSLATE(uhadd16)(unsigned int inst, int index) {
  1264. return INTERPRETER_TRANSLATE(uhadd8)(inst, index);
  1265. }
  1266. static ARM_INST_PTR INTERPRETER_TRANSLATE(uhaddsubx)(unsigned int inst, int index) {
  1267. return INTERPRETER_TRANSLATE(uhadd8)(inst, index);
  1268. }
  1269. static ARM_INST_PTR INTERPRETER_TRANSLATE(uhsub8)(unsigned int inst, int index) {
  1270. return INTERPRETER_TRANSLATE(uhadd8)(inst, index);
  1271. }
  1272. static ARM_INST_PTR INTERPRETER_TRANSLATE(uhsub16)(unsigned int inst, int index) {
  1273. return INTERPRETER_TRANSLATE(uhadd8)(inst, index);
  1274. }
  1275. static ARM_INST_PTR INTERPRETER_TRANSLATE(uhsubaddx)(unsigned int inst, int index) {
  1276. return INTERPRETER_TRANSLATE(uhadd8)(inst, index);
  1277. }
  1278. static ARM_INST_PTR INTERPRETER_TRANSLATE(umaal)(unsigned int inst, int index) {
  1279. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(umaal_inst));
  1280. umaal_inst* const inst_cream = (umaal_inst*)inst_base->component;
  1281. inst_base->cond = BITS(inst, 28, 31);
  1282. inst_base->idx = index;
  1283. inst_base->br = TransExtData::NON_BRANCH;
  1284. inst_cream->Rm = BITS(inst, 8, 11);
  1285. inst_cream->Rn = BITS(inst, 0, 3);
  1286. inst_cream->RdLo = BITS(inst, 12, 15);
  1287. inst_cream->RdHi = BITS(inst, 16, 19);
  1288. return inst_base;
  1289. }
  1290. static ARM_INST_PTR INTERPRETER_TRANSLATE(umlal)(unsigned int inst, int index) {
  1291. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(umlal_inst));
  1292. umlal_inst* inst_cream = (umlal_inst*)inst_base->component;
  1293. inst_base->cond = BITS(inst, 28, 31);
  1294. inst_base->idx = index;
  1295. inst_base->br = TransExtData::NON_BRANCH;
  1296. inst_cream->S = BIT(inst, 20);
  1297. inst_cream->Rm = BITS(inst, 0, 3);
  1298. inst_cream->Rs = BITS(inst, 8, 11);
  1299. inst_cream->RdHi = BITS(inst, 16, 19);
  1300. inst_cream->RdLo = BITS(inst, 12, 15);
  1301. return inst_base;
  1302. }
  1303. static ARM_INST_PTR INTERPRETER_TRANSLATE(umull)(unsigned int inst, int index) {
  1304. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(umull_inst));
  1305. umull_inst* inst_cream = (umull_inst*)inst_base->component;
  1306. inst_base->cond = BITS(inst, 28, 31);
  1307. inst_base->idx = index;
  1308. inst_base->br = TransExtData::NON_BRANCH;
  1309. inst_cream->S = BIT(inst, 20);
  1310. inst_cream->Rm = BITS(inst, 0, 3);
  1311. inst_cream->Rs = BITS(inst, 8, 11);
  1312. inst_cream->RdHi = BITS(inst, 16, 19);
  1313. inst_cream->RdLo = BITS(inst, 12, 15);
  1314. return inst_base;
  1315. }
  1316. static ARM_INST_PTR INTERPRETER_TRANSLATE(b_2_thumb)(unsigned int tinst, int index) {
  1317. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(b_2_thumb));
  1318. b_2_thumb* inst_cream = (b_2_thumb*)inst_base->component;
  1319. inst_cream->imm = ((tinst & 0x3FF) << 1) | ((tinst & (1 << 10)) ? 0xFFFFF800 : 0);
  1320. inst_base->idx = index;
  1321. inst_base->br = TransExtData::DIRECT_BRANCH;
  1322. return inst_base;
  1323. }
  1324. static ARM_INST_PTR INTERPRETER_TRANSLATE(b_cond_thumb)(unsigned int tinst, int index) {
  1325. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(b_cond_thumb));
  1326. b_cond_thumb* inst_cream = (b_cond_thumb*)inst_base->component;
  1327. inst_cream->imm = (((tinst & 0x7F) << 1) | ((tinst & (1 << 7)) ? 0xFFFFFF00 : 0));
  1328. inst_cream->cond = ((tinst >> 8) & 0xf);
  1329. inst_base->idx = index;
  1330. inst_base->br = TransExtData::DIRECT_BRANCH;
  1331. return inst_base;
  1332. }
  1333. static ARM_INST_PTR INTERPRETER_TRANSLATE(bl_1_thumb)(unsigned int tinst, int index) {
  1334. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(bl_1_thumb));
  1335. bl_1_thumb* inst_cream = (bl_1_thumb*)inst_base->component;
  1336. inst_cream->imm = (((tinst & 0x07FF) << 12) | ((tinst & (1 << 10)) ? 0xFF800000 : 0));
  1337. inst_base->idx = index;
  1338. inst_base->br = TransExtData::NON_BRANCH;
  1339. return inst_base;
  1340. }
  1341. static ARM_INST_PTR INTERPRETER_TRANSLATE(bl_2_thumb)(unsigned int tinst, int index) {
  1342. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(bl_2_thumb));
  1343. bl_2_thumb* inst_cream = (bl_2_thumb*)inst_base->component;
  1344. inst_cream->imm = (tinst & 0x07FF) << 1;
  1345. inst_base->idx = index;
  1346. inst_base->br = TransExtData::DIRECT_BRANCH;
  1347. return inst_base;
  1348. }
  1349. static ARM_INST_PTR INTERPRETER_TRANSLATE(blx_1_thumb)(unsigned int tinst, int index) {
  1350. arm_inst* inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(blx_1_thumb));
  1351. blx_1_thumb* inst_cream = (blx_1_thumb*)inst_base->component;
  1352. inst_cream->imm = (tinst & 0x07FF) << 1;
  1353. inst_cream->instr = tinst;
  1354. inst_base->idx = index;
  1355. inst_base->br = TransExtData::DIRECT_BRANCH;
  1356. return inst_base;
  1357. }
  1358. static ARM_INST_PTR INTERPRETER_TRANSLATE(uqadd8)(unsigned int inst, int index) {
  1359. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(generic_arm_inst));
  1360. generic_arm_inst* const inst_cream = (generic_arm_inst*)inst_base->component;
  1361. inst_base->cond = BITS(inst, 28, 31);
  1362. inst_base->idx = index;
  1363. inst_base->br = TransExtData::NON_BRANCH;
  1364. inst_cream->Rm = BITS(inst, 0, 3);
  1365. inst_cream->Rn = BITS(inst, 16, 19);
  1366. inst_cream->Rd = BITS(inst, 12, 15);
  1367. inst_cream->op1 = BITS(inst, 20, 21);
  1368. inst_cream->op2 = BITS(inst, 5, 7);
  1369. return inst_base;
  1370. }
  1371. static ARM_INST_PTR INTERPRETER_TRANSLATE(uqadd16)(unsigned int inst, int index) {
  1372. return INTERPRETER_TRANSLATE(uqadd8)(inst, index);
  1373. }
  1374. static ARM_INST_PTR INTERPRETER_TRANSLATE(uqaddsubx)(unsigned int inst, int index) {
  1375. return INTERPRETER_TRANSLATE(uqadd8)(inst, index);
  1376. }
  1377. static ARM_INST_PTR INTERPRETER_TRANSLATE(uqsub8)(unsigned int inst, int index) {
  1378. return INTERPRETER_TRANSLATE(uqadd8)(inst, index);
  1379. }
  1380. static ARM_INST_PTR INTERPRETER_TRANSLATE(uqsub16)(unsigned int inst, int index) {
  1381. return INTERPRETER_TRANSLATE(uqadd8)(inst, index);
  1382. }
  1383. static ARM_INST_PTR INTERPRETER_TRANSLATE(uqsubaddx)(unsigned int inst, int index) {
  1384. return INTERPRETER_TRANSLATE(uqadd8)(inst, index);
  1385. }
  1386. static ARM_INST_PTR INTERPRETER_TRANSLATE(usada8)(unsigned int inst, int index) {
  1387. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(generic_arm_inst));
  1388. generic_arm_inst* const inst_cream = (generic_arm_inst*)inst_base->component;
  1389. inst_base->cond = BITS(inst, 28, 31);
  1390. inst_base->idx = index;
  1391. inst_base->br = TransExtData::NON_BRANCH;
  1392. inst_cream->op1 = BITS(inst, 20, 24);
  1393. inst_cream->op2 = BITS(inst, 5, 7);
  1394. inst_cream->Rd = BITS(inst, 16, 19);
  1395. inst_cream->Rm = BITS(inst, 8, 11);
  1396. inst_cream->Rn = BITS(inst, 0, 3);
  1397. inst_cream->Ra = BITS(inst, 12, 15);
  1398. return inst_base;
  1399. }
  1400. static ARM_INST_PTR INTERPRETER_TRANSLATE(usad8)(unsigned int inst, int index) {
  1401. return INTERPRETER_TRANSLATE(usada8)(inst, index);
  1402. }
  1403. static ARM_INST_PTR INTERPRETER_TRANSLATE(usat)(unsigned int inst, int index) {
  1404. return INTERPRETER_TRANSLATE(ssat)(inst, index);
  1405. }
  1406. static ARM_INST_PTR INTERPRETER_TRANSLATE(usat16)(unsigned int inst, int index) {
  1407. return INTERPRETER_TRANSLATE(ssat16)(inst, index);
  1408. }
  1409. static ARM_INST_PTR INTERPRETER_TRANSLATE(uxtab16)(unsigned int inst, int index) {
  1410. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst) + sizeof(uxtab_inst));
  1411. uxtab_inst* const inst_cream = (uxtab_inst*)inst_base->component;
  1412. inst_base->cond = BITS(inst, 28, 31);
  1413. inst_base->idx = index;
  1414. inst_base->br = TransExtData::NON_BRANCH;
  1415. inst_cream->Rm = BITS(inst, 0, 3);
  1416. inst_cream->Rn = BITS(inst, 16, 19);
  1417. inst_cream->Rd = BITS(inst, 12, 15);
  1418. inst_cream->rotate = BITS(inst, 10, 11);
  1419. return inst_base;
  1420. }
  1421. static ARM_INST_PTR INTERPRETER_TRANSLATE(uxtb16)(unsigned int inst, int index) {
  1422. return INTERPRETER_TRANSLATE(uxtab16)(inst, index);
  1423. }
  1424. static ARM_INST_PTR INTERPRETER_TRANSLATE(wfe)(unsigned int inst, int index) {
  1425. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst));
  1426. inst_base->cond = BITS(inst, 28, 31);
  1427. inst_base->idx = index;
  1428. inst_base->br = TransExtData::NON_BRANCH;
  1429. return inst_base;
  1430. }
  1431. static ARM_INST_PTR INTERPRETER_TRANSLATE(wfi)(unsigned int inst, int index) {
  1432. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst));
  1433. inst_base->cond = BITS(inst, 28, 31);
  1434. inst_base->idx = index;
  1435. inst_base->br = TransExtData::NON_BRANCH;
  1436. return inst_base;
  1437. }
  1438. static ARM_INST_PTR INTERPRETER_TRANSLATE(yield)(unsigned int inst, int index) {
  1439. arm_inst* const inst_base = (arm_inst*)AllocBuffer(sizeof(arm_inst));
  1440. inst_base->cond = BITS(inst, 28, 31);
  1441. inst_base->idx = index;
  1442. inst_base->br = TransExtData::NON_BRANCH;
  1443. return inst_base;
  1444. }
  1445. // Floating point VFPv3 instructions
  1446. #define VFP_INTERPRETER_TRANS
  1447. #include "core/arm/skyeye_common/vfp/vfpinstr.cpp"
  1448. #undef VFP_INTERPRETER_TRANS
  1449. const transop_fp_t arm_instruction_trans[] = {
  1450. INTERPRETER_TRANSLATE(vmla), INTERPRETER_TRANSLATE(vmls), INTERPRETER_TRANSLATE(vnmla),
  1451. INTERPRETER_TRANSLATE(vnmls), INTERPRETER_TRANSLATE(vnmul), INTERPRETER_TRANSLATE(vmul),
  1452. INTERPRETER_TRANSLATE(vadd), INTERPRETER_TRANSLATE(vsub), INTERPRETER_TRANSLATE(vdiv),
  1453. INTERPRETER_TRANSLATE(vmovi), INTERPRETER_TRANSLATE(vmovr), INTERPRETER_TRANSLATE(vabs),
  1454. INTERPRETER_TRANSLATE(vneg), INTERPRETER_TRANSLATE(vsqrt), INTERPRETER_TRANSLATE(vcmp),
  1455. INTERPRETER_TRANSLATE(vcmp2), INTERPRETER_TRANSLATE(vcvtbds), INTERPRETER_TRANSLATE(vcvtbff),
  1456. INTERPRETER_TRANSLATE(vcvtbfi), INTERPRETER_TRANSLATE(vmovbrs), INTERPRETER_TRANSLATE(vmsr),
  1457. INTERPRETER_TRANSLATE(vmovbrc), INTERPRETER_TRANSLATE(vmrs), INTERPRETER_TRANSLATE(vmovbcr),
  1458. INTERPRETER_TRANSLATE(vmovbrrss), INTERPRETER_TRANSLATE(vmovbrrd), INTERPRETER_TRANSLATE(vstr),
  1459. INTERPRETER_TRANSLATE(vpush), INTERPRETER_TRANSLATE(vstm), INTERPRETER_TRANSLATE(vpop),
  1460. INTERPRETER_TRANSLATE(vldr), INTERPRETER_TRANSLATE(vldm),
  1461. INTERPRETER_TRANSLATE(srs), INTERPRETER_TRANSLATE(rfe), INTERPRETER_TRANSLATE(bkpt),
  1462. INTERPRETER_TRANSLATE(blx), INTERPRETER_TRANSLATE(cps), INTERPRETER_TRANSLATE(pld),
  1463. INTERPRETER_TRANSLATE(setend), INTERPRETER_TRANSLATE(clrex), INTERPRETER_TRANSLATE(rev16),
  1464. INTERPRETER_TRANSLATE(usad8), INTERPRETER_TRANSLATE(sxtb), INTERPRETER_TRANSLATE(uxtb),
  1465. INTERPRETER_TRANSLATE(sxth), INTERPRETER_TRANSLATE(sxtb16), INTERPRETER_TRANSLATE(uxth),
  1466. INTERPRETER_TRANSLATE(uxtb16), INTERPRETER_TRANSLATE(cpy), INTERPRETER_TRANSLATE(uxtab),
  1467. INTERPRETER_TRANSLATE(ssub8), INTERPRETER_TRANSLATE(shsub8), INTERPRETER_TRANSLATE(ssubaddx),
  1468. INTERPRETER_TRANSLATE(strex), INTERPRETER_TRANSLATE(strexb), INTERPRETER_TRANSLATE(swp),
  1469. INTERPRETER_TRANSLATE(swpb), INTERPRETER_TRANSLATE(ssub16), INTERPRETER_TRANSLATE(ssat16),
  1470. INTERPRETER_TRANSLATE(shsubaddx), INTERPRETER_TRANSLATE(qsubaddx),
  1471. INTERPRETER_TRANSLATE(shaddsubx), INTERPRETER_TRANSLATE(shadd8), INTERPRETER_TRANSLATE(shadd16),
  1472. INTERPRETER_TRANSLATE(sel), INTERPRETER_TRANSLATE(saddsubx), INTERPRETER_TRANSLATE(sadd8),
  1473. INTERPRETER_TRANSLATE(sadd16), INTERPRETER_TRANSLATE(shsub16), INTERPRETER_TRANSLATE(umaal),
  1474. INTERPRETER_TRANSLATE(uxtab16), INTERPRETER_TRANSLATE(usubaddx), INTERPRETER_TRANSLATE(usub8),
  1475. INTERPRETER_TRANSLATE(usub16), INTERPRETER_TRANSLATE(usat16), INTERPRETER_TRANSLATE(usada8),
  1476. INTERPRETER_TRANSLATE(uqsubaddx), INTERPRETER_TRANSLATE(uqsub8), INTERPRETER_TRANSLATE(uqsub16),
  1477. INTERPRETER_TRANSLATE(uqaddsubx), INTERPRETER_TRANSLATE(uqadd8), INTERPRETER_TRANSLATE(uqadd16),
  1478. INTERPRETER_TRANSLATE(sxtab), INTERPRETER_TRANSLATE(uhsubaddx), INTERPRETER_TRANSLATE(uhsub8),
  1479. INTERPRETER_TRANSLATE(uhsub16), INTERPRETER_TRANSLATE(uhaddsubx), INTERPRETER_TRANSLATE(uhadd8),
  1480. INTERPRETER_TRANSLATE(uhadd16), INTERPRETER_TRANSLATE(uaddsubx), INTERPRETER_TRANSLATE(uadd8),
  1481. INTERPRETER_TRANSLATE(uadd16), INTERPRETER_TRANSLATE(sxtah), INTERPRETER_TRANSLATE(sxtab16),
  1482. INTERPRETER_TRANSLATE(qadd8), INTERPRETER_TRANSLATE(bxj), INTERPRETER_TRANSLATE(clz),
  1483. INTERPRETER_TRANSLATE(uxtah), INTERPRETER_TRANSLATE(bx), INTERPRETER_TRANSLATE(rev),
  1484. INTERPRETER_TRANSLATE(blx), INTERPRETER_TRANSLATE(revsh), INTERPRETER_TRANSLATE(qadd),
  1485. INTERPRETER_TRANSLATE(qadd16), INTERPRETER_TRANSLATE(qaddsubx), INTERPRETER_TRANSLATE(ldrex),
  1486. INTERPRETER_TRANSLATE(qdadd), INTERPRETER_TRANSLATE(qdsub), INTERPRETER_TRANSLATE(qsub),
  1487. INTERPRETER_TRANSLATE(ldrexb), INTERPRETER_TRANSLATE(qsub8), INTERPRETER_TRANSLATE(qsub16),
  1488. INTERPRETER_TRANSLATE(smuad), INTERPRETER_TRANSLATE(smmul), INTERPRETER_TRANSLATE(smusd),
  1489. INTERPRETER_TRANSLATE(smlsd), INTERPRETER_TRANSLATE(smlsld), INTERPRETER_TRANSLATE(smmla),
  1490. INTERPRETER_TRANSLATE(smmls), INTERPRETER_TRANSLATE(smlald), INTERPRETER_TRANSLATE(smlad),
  1491. INTERPRETER_TRANSLATE(smlaw), INTERPRETER_TRANSLATE(smulw), INTERPRETER_TRANSLATE(pkhtb),
  1492. INTERPRETER_TRANSLATE(pkhbt), INTERPRETER_TRANSLATE(smul), INTERPRETER_TRANSLATE(smlalxy),
  1493. INTERPRETER_TRANSLATE(smla), INTERPRETER_TRANSLATE(mcrr), INTERPRETER_TRANSLATE(mrrc),
  1494. INTERPRETER_TRANSLATE(cmp), INTERPRETER_TRANSLATE(tst), INTERPRETER_TRANSLATE(teq),
  1495. INTERPRETER_TRANSLATE(cmn), INTERPRETER_TRANSLATE(smull), INTERPRETER_TRANSLATE(umull),
  1496. INTERPRETER_TRANSLATE(umlal), INTERPRETER_TRANSLATE(smlal), INTERPRETER_TRANSLATE(mul),
  1497. INTERPRETER_TRANSLATE(mla), INTERPRETER_TRANSLATE(ssat), INTERPRETER_TRANSLATE(usat),
  1498. INTERPRETER_TRANSLATE(mrs), INTERPRETER_TRANSLATE(msr), INTERPRETER_TRANSLATE(and),
  1499. INTERPRETER_TRANSLATE(bic), INTERPRETER_TRANSLATE(ldm), INTERPRETER_TRANSLATE(eor),
  1500. INTERPRETER_TRANSLATE(add), INTERPRETER_TRANSLATE(rsb), INTERPRETER_TRANSLATE(rsc),
  1501. INTERPRETER_TRANSLATE(sbc), INTERPRETER_TRANSLATE(adc), INTERPRETER_TRANSLATE(sub),
  1502. INTERPRETER_TRANSLATE(orr), INTERPRETER_TRANSLATE(mvn), INTERPRETER_TRANSLATE(mov),
  1503. INTERPRETER_TRANSLATE(stm), INTERPRETER_TRANSLATE(ldm), INTERPRETER_TRANSLATE(ldrsh),
  1504. INTERPRETER_TRANSLATE(stm), INTERPRETER_TRANSLATE(ldm), INTERPRETER_TRANSLATE(ldrsb),
  1505. INTERPRETER_TRANSLATE(strd), INTERPRETER_TRANSLATE(ldrh), INTERPRETER_TRANSLATE(strh),
  1506. INTERPRETER_TRANSLATE(ldrd), INTERPRETER_TRANSLATE(strt), INTERPRETER_TRANSLATE(strbt),
  1507. INTERPRETER_TRANSLATE(ldrbt), INTERPRETER_TRANSLATE(ldrt), INTERPRETER_TRANSLATE(mrc),
  1508. INTERPRETER_TRANSLATE(mcr), INTERPRETER_TRANSLATE(msr), INTERPRETER_TRANSLATE(msr),
  1509. INTERPRETER_TRANSLATE(msr), INTERPRETER_TRANSLATE(msr), INTERPRETER_TRANSLATE(msr),
  1510. INTERPRETER_TRANSLATE(ldrb), INTERPRETER_TRANSLATE(strb), INTERPRETER_TRANSLATE(ldr),
  1511. INTERPRETER_TRANSLATE(ldrcond), INTERPRETER_TRANSLATE(str), INTERPRETER_TRANSLATE(cdp),
  1512. INTERPRETER_TRANSLATE(stc), INTERPRETER_TRANSLATE(ldc), INTERPRETER_TRANSLATE(ldrexd),
  1513. INTERPRETER_TRANSLATE(strexd), INTERPRETER_TRANSLATE(ldrexh), INTERPRETER_TRANSLATE(strexh),
  1514. INTERPRETER_TRANSLATE(nop), INTERPRETER_TRANSLATE(yield), INTERPRETER_TRANSLATE(wfe),
  1515. INTERPRETER_TRANSLATE(wfi), INTERPRETER_TRANSLATE(sev), INTERPRETER_TRANSLATE(swi),
  1516. INTERPRETER_TRANSLATE(bbl),
  1517. // All the thumb instructions should be placed the end of table
  1518. INTERPRETER_TRANSLATE(b_2_thumb), INTERPRETER_TRANSLATE(b_cond_thumb),
  1519. INTERPRETER_TRANSLATE(bl_1_thumb), INTERPRETER_TRANSLATE(bl_2_thumb),
  1520. INTERPRETER_TRANSLATE(blx_1_thumb),
  1521. };
  1522. const size_t arm_instruction_trans_len = sizeof(arm_instruction_trans) / sizeof(transop_fp_t);