arm_dyncom_trans.cpp 72 KB

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