tcg-op.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023
  1. /*
  2. * Tiny Code Generator for QEMU
  3. *
  4. * Copyright (c) 2008 Fabrice Bellard
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. */
  24. #include "tcg.h"
  25. #include "exec/helper-proto.h"
  26. #include "exec/helper-gen.h"
  27. /* Basic output routines. Not for general consumption. */
  28. void tcg_gen_op1(TCGContext *, TCGOpcode, TCGArg);
  29. void tcg_gen_op2(TCGContext *, TCGOpcode, TCGArg, TCGArg);
  30. void tcg_gen_op3(TCGContext *, TCGOpcode, TCGArg, TCGArg, TCGArg);
  31. void tcg_gen_op4(TCGContext *, TCGOpcode, TCGArg, TCGArg, TCGArg, TCGArg);
  32. void tcg_gen_op5(TCGContext *, TCGOpcode, TCGArg, TCGArg, TCGArg,
  33. TCGArg, TCGArg);
  34. void tcg_gen_op6(TCGContext *, TCGOpcode, TCGArg, TCGArg, TCGArg,
  35. TCGArg, TCGArg, TCGArg);
  36. static inline void tcg_gen_op1_i32(TCGOpcode opc, TCGv_i32 a1)
  37. {
  38. tcg_gen_op1(&tcg_ctx, opc, GET_TCGV_I32(a1));
  39. }
  40. static inline void tcg_gen_op1_i64(TCGOpcode opc, TCGv_i64 a1)
  41. {
  42. tcg_gen_op1(&tcg_ctx, opc, GET_TCGV_I64(a1));
  43. }
  44. static inline void tcg_gen_op1i(TCGOpcode opc, TCGArg a1)
  45. {
  46. tcg_gen_op1(&tcg_ctx, opc, a1);
  47. }
  48. static inline void tcg_gen_op2_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2)
  49. {
  50. tcg_gen_op2(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2));
  51. }
  52. static inline void tcg_gen_op2_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2)
  53. {
  54. tcg_gen_op2(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2));
  55. }
  56. static inline void tcg_gen_op2i_i32(TCGOpcode opc, TCGv_i32 a1, TCGArg a2)
  57. {
  58. tcg_gen_op2(&tcg_ctx, opc, GET_TCGV_I32(a1), a2);
  59. }
  60. static inline void tcg_gen_op2i_i64(TCGOpcode opc, TCGv_i64 a1, TCGArg a2)
  61. {
  62. tcg_gen_op2(&tcg_ctx, opc, GET_TCGV_I64(a1), a2);
  63. }
  64. static inline void tcg_gen_op2ii(TCGOpcode opc, TCGArg a1, TCGArg a2)
  65. {
  66. tcg_gen_op2(&tcg_ctx, opc, a1, a2);
  67. }
  68. static inline void tcg_gen_op3_i32(TCGOpcode opc, TCGv_i32 a1,
  69. TCGv_i32 a2, TCGv_i32 a3)
  70. {
  71. tcg_gen_op3(&tcg_ctx, opc, GET_TCGV_I32(a1),
  72. GET_TCGV_I32(a2), GET_TCGV_I32(a3));
  73. }
  74. static inline void tcg_gen_op3_i64(TCGOpcode opc, TCGv_i64 a1,
  75. TCGv_i64 a2, TCGv_i64 a3)
  76. {
  77. tcg_gen_op3(&tcg_ctx, opc, GET_TCGV_I64(a1),
  78. GET_TCGV_I64(a2), GET_TCGV_I64(a3));
  79. }
  80. static inline void tcg_gen_op3i_i32(TCGOpcode opc, TCGv_i32 a1,
  81. TCGv_i32 a2, TCGArg a3)
  82. {
  83. tcg_gen_op3(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), a3);
  84. }
  85. static inline void tcg_gen_op3i_i64(TCGOpcode opc, TCGv_i64 a1,
  86. TCGv_i64 a2, TCGArg a3)
  87. {
  88. tcg_gen_op3(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), a3);
  89. }
  90. static inline void tcg_gen_ldst_op_i32(TCGOpcode opc, TCGv_i32 val,
  91. TCGv_ptr base, TCGArg offset)
  92. {
  93. tcg_gen_op3(&tcg_ctx, opc, GET_TCGV_I32(val), GET_TCGV_PTR(base), offset);
  94. }
  95. static inline void tcg_gen_ldst_op_i64(TCGOpcode opc, TCGv_i64 val,
  96. TCGv_ptr base, TCGArg offset)
  97. {
  98. tcg_gen_op3(&tcg_ctx, opc, GET_TCGV_I64(val), GET_TCGV_PTR(base), offset);
  99. }
  100. static inline void tcg_gen_op4_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2,
  101. TCGv_i32 a3, TCGv_i32 a4)
  102. {
  103. tcg_gen_op4(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2),
  104. GET_TCGV_I32(a3), GET_TCGV_I32(a4));
  105. }
  106. static inline void tcg_gen_op4_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2,
  107. TCGv_i64 a3, TCGv_i64 a4)
  108. {
  109. tcg_gen_op4(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2),
  110. GET_TCGV_I64(a3), GET_TCGV_I64(a4));
  111. }
  112. static inline void tcg_gen_op4i_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2,
  113. TCGv_i32 a3, TCGArg a4)
  114. {
  115. tcg_gen_op4(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2),
  116. GET_TCGV_I32(a3), a4);
  117. }
  118. static inline void tcg_gen_op4i_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2,
  119. TCGv_i64 a3, TCGArg a4)
  120. {
  121. tcg_gen_op4(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2),
  122. GET_TCGV_I64(a3), a4);
  123. }
  124. static inline void tcg_gen_op4ii_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2,
  125. TCGArg a3, TCGArg a4)
  126. {
  127. tcg_gen_op4(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2), a3, a4);
  128. }
  129. static inline void tcg_gen_op4ii_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2,
  130. TCGArg a3, TCGArg a4)
  131. {
  132. tcg_gen_op4(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2), a3, a4);
  133. }
  134. static inline void tcg_gen_op5_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2,
  135. TCGv_i32 a3, TCGv_i32 a4, TCGv_i32 a5)
  136. {
  137. tcg_gen_op5(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2),
  138. GET_TCGV_I32(a3), GET_TCGV_I32(a4), GET_TCGV_I32(a5));
  139. }
  140. static inline void tcg_gen_op5_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2,
  141. TCGv_i64 a3, TCGv_i64 a4, TCGv_i64 a5)
  142. {
  143. tcg_gen_op5(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2),
  144. GET_TCGV_I64(a3), GET_TCGV_I64(a4), GET_TCGV_I64(a5));
  145. }
  146. static inline void tcg_gen_op5i_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2,
  147. TCGv_i32 a3, TCGv_i32 a4, TCGArg a5)
  148. {
  149. tcg_gen_op5(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2),
  150. GET_TCGV_I32(a3), GET_TCGV_I32(a4), a5);
  151. }
  152. static inline void tcg_gen_op5i_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2,
  153. TCGv_i64 a3, TCGv_i64 a4, TCGArg a5)
  154. {
  155. tcg_gen_op5(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2),
  156. GET_TCGV_I64(a3), GET_TCGV_I64(a4), a5);
  157. }
  158. static inline void tcg_gen_op5ii_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2,
  159. TCGv_i32 a3, TCGArg a4, TCGArg a5)
  160. {
  161. tcg_gen_op5(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2),
  162. GET_TCGV_I32(a3), a4, a5);
  163. }
  164. static inline void tcg_gen_op5ii_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2,
  165. TCGv_i64 a3, TCGArg a4, TCGArg a5)
  166. {
  167. tcg_gen_op5(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2),
  168. GET_TCGV_I64(a3), a4, a5);
  169. }
  170. static inline void tcg_gen_op6_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2,
  171. TCGv_i32 a3, TCGv_i32 a4,
  172. TCGv_i32 a5, TCGv_i32 a6)
  173. {
  174. tcg_gen_op6(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2),
  175. GET_TCGV_I32(a3), GET_TCGV_I32(a4), GET_TCGV_I32(a5),
  176. GET_TCGV_I32(a6));
  177. }
  178. static inline void tcg_gen_op6_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2,
  179. TCGv_i64 a3, TCGv_i64 a4,
  180. TCGv_i64 a5, TCGv_i64 a6)
  181. {
  182. tcg_gen_op6(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2),
  183. GET_TCGV_I64(a3), GET_TCGV_I64(a4), GET_TCGV_I64(a5),
  184. GET_TCGV_I64(a6));
  185. }
  186. static inline void tcg_gen_op6i_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2,
  187. TCGv_i32 a3, TCGv_i32 a4,
  188. TCGv_i32 a5, TCGArg a6)
  189. {
  190. tcg_gen_op6(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2),
  191. GET_TCGV_I32(a3), GET_TCGV_I32(a4), GET_TCGV_I32(a5), a6);
  192. }
  193. static inline void tcg_gen_op6i_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2,
  194. TCGv_i64 a3, TCGv_i64 a4,
  195. TCGv_i64 a5, TCGArg a6)
  196. {
  197. tcg_gen_op6(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2),
  198. GET_TCGV_I64(a3), GET_TCGV_I64(a4), GET_TCGV_I64(a5), a6);
  199. }
  200. static inline void tcg_gen_op6ii_i32(TCGOpcode opc, TCGv_i32 a1, TCGv_i32 a2,
  201. TCGv_i32 a3, TCGv_i32 a4,
  202. TCGArg a5, TCGArg a6)
  203. {
  204. tcg_gen_op6(&tcg_ctx, opc, GET_TCGV_I32(a1), GET_TCGV_I32(a2),
  205. GET_TCGV_I32(a3), GET_TCGV_I32(a4), a5, a6);
  206. }
  207. static inline void tcg_gen_op6ii_i64(TCGOpcode opc, TCGv_i64 a1, TCGv_i64 a2,
  208. TCGv_i64 a3, TCGv_i64 a4,
  209. TCGArg a5, TCGArg a6)
  210. {
  211. tcg_gen_op6(&tcg_ctx, opc, GET_TCGV_I64(a1), GET_TCGV_I64(a2),
  212. GET_TCGV_I64(a3), GET_TCGV_I64(a4), a5, a6);
  213. }
  214. /* Generic ops. */
  215. static inline void gen_set_label(TCGLabel *l)
  216. {
  217. tcg_gen_op1(&tcg_ctx, INDEX_op_set_label, label_arg(l));
  218. }
  219. static inline void tcg_gen_br(TCGLabel *l)
  220. {
  221. tcg_gen_op1(&tcg_ctx, INDEX_op_br, label_arg(l));
  222. }
  223. /* Helper calls. */
  224. /* 32 bit ops */
  225. void tcg_gen_addi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2);
  226. void tcg_gen_subfi_i32(TCGv_i32 ret, int32_t arg1, TCGv_i32 arg2);
  227. void tcg_gen_subi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2);
  228. void tcg_gen_andi_i32(TCGv_i32 ret, TCGv_i32 arg1, uint32_t arg2);
  229. void tcg_gen_ori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2);
  230. void tcg_gen_xori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2);
  231. void tcg_gen_shli_i32(TCGv_i32 ret, TCGv_i32 arg1, unsigned arg2);
  232. void tcg_gen_shri_i32(TCGv_i32 ret, TCGv_i32 arg1, unsigned arg2);
  233. void tcg_gen_sari_i32(TCGv_i32 ret, TCGv_i32 arg1, unsigned arg2);
  234. void tcg_gen_muli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2);
  235. void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
  236. void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
  237. void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
  238. void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
  239. void tcg_gen_andc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
  240. void tcg_gen_eqv_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
  241. void tcg_gen_nand_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
  242. void tcg_gen_nor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
  243. void tcg_gen_orc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
  244. void tcg_gen_rotl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
  245. void tcg_gen_rotli_i32(TCGv_i32 ret, TCGv_i32 arg1, unsigned arg2);
  246. void tcg_gen_rotr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
  247. void tcg_gen_rotri_i32(TCGv_i32 ret, TCGv_i32 arg1, unsigned arg2);
  248. void tcg_gen_deposit_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2,
  249. unsigned int ofs, unsigned int len);
  250. void tcg_gen_brcond_i32(TCGCond cond, TCGv_i32 arg1, TCGv_i32 arg2, TCGLabel *);
  251. void tcg_gen_brcondi_i32(TCGCond cond, TCGv_i32 arg1, int32_t arg2, TCGLabel *);
  252. void tcg_gen_setcond_i32(TCGCond cond, TCGv_i32 ret,
  253. TCGv_i32 arg1, TCGv_i32 arg2);
  254. void tcg_gen_setcondi_i32(TCGCond cond, TCGv_i32 ret,
  255. TCGv_i32 arg1, int32_t arg2);
  256. void tcg_gen_movcond_i32(TCGCond cond, TCGv_i32 ret, TCGv_i32 c1,
  257. TCGv_i32 c2, TCGv_i32 v1, TCGv_i32 v2);
  258. void tcg_gen_add2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 al,
  259. TCGv_i32 ah, TCGv_i32 bl, TCGv_i32 bh);
  260. void tcg_gen_sub2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 al,
  261. TCGv_i32 ah, TCGv_i32 bl, TCGv_i32 bh);
  262. void tcg_gen_mulu2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 arg1, TCGv_i32 arg2);
  263. void tcg_gen_muls2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 arg1, TCGv_i32 arg2);
  264. void tcg_gen_ext8s_i32(TCGv_i32 ret, TCGv_i32 arg);
  265. void tcg_gen_ext16s_i32(TCGv_i32 ret, TCGv_i32 arg);
  266. void tcg_gen_ext8u_i32(TCGv_i32 ret, TCGv_i32 arg);
  267. void tcg_gen_ext16u_i32(TCGv_i32 ret, TCGv_i32 arg);
  268. void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg);
  269. void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg);
  270. static inline void tcg_gen_discard_i32(TCGv_i32 arg)
  271. {
  272. tcg_gen_op1_i32(INDEX_op_discard, arg);
  273. }
  274. static inline void tcg_gen_mov_i32(TCGv_i32 ret, TCGv_i32 arg)
  275. {
  276. if (!TCGV_EQUAL_I32(ret, arg)) {
  277. tcg_gen_op2_i32(INDEX_op_mov_i32, ret, arg);
  278. }
  279. }
  280. static inline void tcg_gen_movi_i32(TCGv_i32 ret, int32_t arg)
  281. {
  282. tcg_gen_op2i_i32(INDEX_op_movi_i32, ret, arg);
  283. }
  284. static inline void tcg_gen_ld8u_i32(TCGv_i32 ret, TCGv_ptr arg2,
  285. tcg_target_long offset)
  286. {
  287. tcg_gen_ldst_op_i32(INDEX_op_ld8u_i32, ret, arg2, offset);
  288. }
  289. static inline void tcg_gen_ld8s_i32(TCGv_i32 ret, TCGv_ptr arg2,
  290. tcg_target_long offset)
  291. {
  292. tcg_gen_ldst_op_i32(INDEX_op_ld8s_i32, ret, arg2, offset);
  293. }
  294. static inline void tcg_gen_ld16u_i32(TCGv_i32 ret, TCGv_ptr arg2,
  295. tcg_target_long offset)
  296. {
  297. tcg_gen_ldst_op_i32(INDEX_op_ld16u_i32, ret, arg2, offset);
  298. }
  299. static inline void tcg_gen_ld16s_i32(TCGv_i32 ret, TCGv_ptr arg2,
  300. tcg_target_long offset)
  301. {
  302. tcg_gen_ldst_op_i32(INDEX_op_ld16s_i32, ret, arg2, offset);
  303. }
  304. static inline void tcg_gen_ld_i32(TCGv_i32 ret, TCGv_ptr arg2,
  305. tcg_target_long offset)
  306. {
  307. tcg_gen_ldst_op_i32(INDEX_op_ld_i32, ret, arg2, offset);
  308. }
  309. static inline void tcg_gen_st8_i32(TCGv_i32 arg1, TCGv_ptr arg2,
  310. tcg_target_long offset)
  311. {
  312. tcg_gen_ldst_op_i32(INDEX_op_st8_i32, arg1, arg2, offset);
  313. }
  314. static inline void tcg_gen_st16_i32(TCGv_i32 arg1, TCGv_ptr arg2,
  315. tcg_target_long offset)
  316. {
  317. tcg_gen_ldst_op_i32(INDEX_op_st16_i32, arg1, arg2, offset);
  318. }
  319. static inline void tcg_gen_st_i32(TCGv_i32 arg1, TCGv_ptr arg2,
  320. tcg_target_long offset)
  321. {
  322. tcg_gen_ldst_op_i32(INDEX_op_st_i32, arg1, arg2, offset);
  323. }
  324. static inline void tcg_gen_add_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
  325. {
  326. tcg_gen_op3_i32(INDEX_op_add_i32, ret, arg1, arg2);
  327. }
  328. static inline void tcg_gen_sub_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
  329. {
  330. tcg_gen_op3_i32(INDEX_op_sub_i32, ret, arg1, arg2);
  331. }
  332. static inline void tcg_gen_and_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
  333. {
  334. tcg_gen_op3_i32(INDEX_op_and_i32, ret, arg1, arg2);
  335. }
  336. static inline void tcg_gen_or_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
  337. {
  338. tcg_gen_op3_i32(INDEX_op_or_i32, ret, arg1, arg2);
  339. }
  340. static inline void tcg_gen_xor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
  341. {
  342. tcg_gen_op3_i32(INDEX_op_xor_i32, ret, arg1, arg2);
  343. }
  344. static inline void tcg_gen_shl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
  345. {
  346. tcg_gen_op3_i32(INDEX_op_shl_i32, ret, arg1, arg2);
  347. }
  348. static inline void tcg_gen_shr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
  349. {
  350. tcg_gen_op3_i32(INDEX_op_shr_i32, ret, arg1, arg2);
  351. }
  352. static inline void tcg_gen_sar_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
  353. {
  354. tcg_gen_op3_i32(INDEX_op_sar_i32, ret, arg1, arg2);
  355. }
  356. static inline void tcg_gen_mul_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
  357. {
  358. tcg_gen_op3_i32(INDEX_op_mul_i32, ret, arg1, arg2);
  359. }
  360. static inline void tcg_gen_neg_i32(TCGv_i32 ret, TCGv_i32 arg)
  361. {
  362. if (TCG_TARGET_HAS_neg_i32) {
  363. tcg_gen_op2_i32(INDEX_op_neg_i32, ret, arg);
  364. } else {
  365. tcg_gen_subfi_i32(ret, 0, arg);
  366. }
  367. }
  368. static inline void tcg_gen_not_i32(TCGv_i32 ret, TCGv_i32 arg)
  369. {
  370. if (TCG_TARGET_HAS_not_i32) {
  371. tcg_gen_op2_i32(INDEX_op_not_i32, ret, arg);
  372. } else {
  373. tcg_gen_xori_i32(ret, arg, -1);
  374. }
  375. }
  376. /* 64 bit ops */
  377. void tcg_gen_addi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2);
  378. void tcg_gen_subfi_i64(TCGv_i64 ret, int64_t arg1, TCGv_i64 arg2);
  379. void tcg_gen_subi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2);
  380. void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, uint64_t arg2);
  381. void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2);
  382. void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2);
  383. void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, unsigned arg2);
  384. void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, unsigned arg2);
  385. void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, unsigned arg2);
  386. void tcg_gen_muli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2);
  387. void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  388. void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  389. void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  390. void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  391. void tcg_gen_andc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  392. void tcg_gen_eqv_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  393. void tcg_gen_nand_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  394. void tcg_gen_nor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  395. void tcg_gen_orc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  396. void tcg_gen_rotl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  397. void tcg_gen_rotli_i64(TCGv_i64 ret, TCGv_i64 arg1, unsigned arg2);
  398. void tcg_gen_rotr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  399. void tcg_gen_rotri_i64(TCGv_i64 ret, TCGv_i64 arg1, unsigned arg2);
  400. void tcg_gen_deposit_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2,
  401. unsigned int ofs, unsigned int len);
  402. void tcg_gen_brcond_i64(TCGCond cond, TCGv_i64 arg1, TCGv_i64 arg2, TCGLabel *);
  403. void tcg_gen_brcondi_i64(TCGCond cond, TCGv_i64 arg1, int64_t arg2, TCGLabel *);
  404. void tcg_gen_setcond_i64(TCGCond cond, TCGv_i64 ret,
  405. TCGv_i64 arg1, TCGv_i64 arg2);
  406. void tcg_gen_setcondi_i64(TCGCond cond, TCGv_i64 ret,
  407. TCGv_i64 arg1, int64_t arg2);
  408. void tcg_gen_movcond_i64(TCGCond cond, TCGv_i64 ret, TCGv_i64 c1,
  409. TCGv_i64 c2, TCGv_i64 v1, TCGv_i64 v2);
  410. void tcg_gen_add2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 al,
  411. TCGv_i64 ah, TCGv_i64 bl, TCGv_i64 bh);
  412. void tcg_gen_sub2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 al,
  413. TCGv_i64 ah, TCGv_i64 bl, TCGv_i64 bh);
  414. void tcg_gen_mulu2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 arg1, TCGv_i64 arg2);
  415. void tcg_gen_muls2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 arg1, TCGv_i64 arg2);
  416. void tcg_gen_not_i64(TCGv_i64 ret, TCGv_i64 arg);
  417. void tcg_gen_ext8s_i64(TCGv_i64 ret, TCGv_i64 arg);
  418. void tcg_gen_ext16s_i64(TCGv_i64 ret, TCGv_i64 arg);
  419. void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg);
  420. void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg);
  421. void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg);
  422. void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg);
  423. void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg);
  424. void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg);
  425. void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg);
  426. #if TCG_TARGET_REG_BITS == 64
  427. static inline void tcg_gen_discard_i64(TCGv_i64 arg)
  428. {
  429. tcg_gen_op1_i64(INDEX_op_discard, arg);
  430. }
  431. static inline void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg)
  432. {
  433. if (!TCGV_EQUAL_I64(ret, arg)) {
  434. tcg_gen_op2_i64(INDEX_op_mov_i64, ret, arg);
  435. }
  436. }
  437. static inline void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg)
  438. {
  439. tcg_gen_op2i_i64(INDEX_op_movi_i64, ret, arg);
  440. }
  441. static inline void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_ptr arg2,
  442. tcg_target_long offset)
  443. {
  444. tcg_gen_ldst_op_i64(INDEX_op_ld8u_i64, ret, arg2, offset);
  445. }
  446. static inline void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_ptr arg2,
  447. tcg_target_long offset)
  448. {
  449. tcg_gen_ldst_op_i64(INDEX_op_ld8s_i64, ret, arg2, offset);
  450. }
  451. static inline void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_ptr arg2,
  452. tcg_target_long offset)
  453. {
  454. tcg_gen_ldst_op_i64(INDEX_op_ld16u_i64, ret, arg2, offset);
  455. }
  456. static inline void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_ptr arg2,
  457. tcg_target_long offset)
  458. {
  459. tcg_gen_ldst_op_i64(INDEX_op_ld16s_i64, ret, arg2, offset);
  460. }
  461. static inline void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_ptr arg2,
  462. tcg_target_long offset)
  463. {
  464. tcg_gen_ldst_op_i64(INDEX_op_ld32u_i64, ret, arg2, offset);
  465. }
  466. static inline void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_ptr arg2,
  467. tcg_target_long offset)
  468. {
  469. tcg_gen_ldst_op_i64(INDEX_op_ld32s_i64, ret, arg2, offset);
  470. }
  471. static inline void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2,
  472. tcg_target_long offset)
  473. {
  474. tcg_gen_ldst_op_i64(INDEX_op_ld_i64, ret, arg2, offset);
  475. }
  476. static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2,
  477. tcg_target_long offset)
  478. {
  479. tcg_gen_ldst_op_i64(INDEX_op_st8_i64, arg1, arg2, offset);
  480. }
  481. static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2,
  482. tcg_target_long offset)
  483. {
  484. tcg_gen_ldst_op_i64(INDEX_op_st16_i64, arg1, arg2, offset);
  485. }
  486. static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2,
  487. tcg_target_long offset)
  488. {
  489. tcg_gen_ldst_op_i64(INDEX_op_st32_i64, arg1, arg2, offset);
  490. }
  491. static inline void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2,
  492. tcg_target_long offset)
  493. {
  494. tcg_gen_ldst_op_i64(INDEX_op_st_i64, arg1, arg2, offset);
  495. }
  496. static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
  497. {
  498. tcg_gen_op3_i64(INDEX_op_add_i64, ret, arg1, arg2);
  499. }
  500. static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
  501. {
  502. tcg_gen_op3_i64(INDEX_op_sub_i64, ret, arg1, arg2);
  503. }
  504. static inline void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
  505. {
  506. tcg_gen_op3_i64(INDEX_op_and_i64, ret, arg1, arg2);
  507. }
  508. static inline void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
  509. {
  510. tcg_gen_op3_i64(INDEX_op_or_i64, ret, arg1, arg2);
  511. }
  512. static inline void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
  513. {
  514. tcg_gen_op3_i64(INDEX_op_xor_i64, ret, arg1, arg2);
  515. }
  516. static inline void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
  517. {
  518. tcg_gen_op3_i64(INDEX_op_shl_i64, ret, arg1, arg2);
  519. }
  520. static inline void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
  521. {
  522. tcg_gen_op3_i64(INDEX_op_shr_i64, ret, arg1, arg2);
  523. }
  524. static inline void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
  525. {
  526. tcg_gen_op3_i64(INDEX_op_sar_i64, ret, arg1, arg2);
  527. }
  528. static inline void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
  529. {
  530. tcg_gen_op3_i64(INDEX_op_mul_i64, ret, arg1, arg2);
  531. }
  532. #else /* TCG_TARGET_REG_BITS == 32 */
  533. static inline void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2,
  534. tcg_target_long offset)
  535. {
  536. tcg_gen_st8_i32(TCGV_LOW(arg1), arg2, offset);
  537. }
  538. static inline void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2,
  539. tcg_target_long offset)
  540. {
  541. tcg_gen_st16_i32(TCGV_LOW(arg1), arg2, offset);
  542. }
  543. static inline void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2,
  544. tcg_target_long offset)
  545. {
  546. tcg_gen_st_i32(TCGV_LOW(arg1), arg2, offset);
  547. }
  548. static inline void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
  549. {
  550. tcg_gen_add2_i32(TCGV_LOW(ret), TCGV_HIGH(ret), TCGV_LOW(arg1),
  551. TCGV_HIGH(arg1), TCGV_LOW(arg2), TCGV_HIGH(arg2));
  552. }
  553. static inline void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
  554. {
  555. tcg_gen_sub2_i32(TCGV_LOW(ret), TCGV_HIGH(ret), TCGV_LOW(arg1),
  556. TCGV_HIGH(arg1), TCGV_LOW(arg2), TCGV_HIGH(arg2));
  557. }
  558. void tcg_gen_discard_i64(TCGv_i64 arg);
  559. void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg);
  560. void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg);
  561. void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset);
  562. void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset);
  563. void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset);
  564. void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset);
  565. void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset);
  566. void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset);
  567. void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset);
  568. void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset);
  569. void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  570. void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  571. void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  572. void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  573. void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  574. void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  575. void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
  576. #endif /* TCG_TARGET_REG_BITS */
  577. static inline void tcg_gen_neg_i64(TCGv_i64 ret, TCGv_i64 arg)
  578. {
  579. if (TCG_TARGET_HAS_neg_i64) {
  580. tcg_gen_op2_i64(INDEX_op_neg_i64, ret, arg);
  581. } else {
  582. tcg_gen_subfi_i64(ret, 0, arg);
  583. }
  584. }
  585. /* Size changing operations. */
  586. void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg);
  587. void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg);
  588. void tcg_gen_concat_i32_i64(TCGv_i64 dest, TCGv_i32 low, TCGv_i32 high);
  589. void tcg_gen_extrl_i64_i32(TCGv_i32 ret, TCGv_i64 arg);
  590. void tcg_gen_extrh_i64_i32(TCGv_i32 ret, TCGv_i64 arg);
  591. void tcg_gen_extr_i64_i32(TCGv_i32 lo, TCGv_i32 hi, TCGv_i64 arg);
  592. void tcg_gen_extr32_i64(TCGv_i64 lo, TCGv_i64 hi, TCGv_i64 arg);
  593. static inline void tcg_gen_concat32_i64(TCGv_i64 ret, TCGv_i64 lo, TCGv_i64 hi)
  594. {
  595. tcg_gen_deposit_i64(ret, lo, hi, 32, 32);
  596. }
  597. /* QEMU specific operations. */
  598. #ifndef TARGET_LONG_BITS
  599. #error must include QEMU headers
  600. #endif
  601. #if TARGET_INSN_START_WORDS == 1
  602. # if TARGET_LONG_BITS <= TCG_TARGET_REG_BITS
  603. static inline void tcg_gen_insn_start(target_ulong pc)
  604. {
  605. tcg_gen_op1(&tcg_ctx, INDEX_op_insn_start, pc);
  606. }
  607. # else
  608. static inline void tcg_gen_insn_start(target_ulong pc)
  609. {
  610. tcg_gen_op2(&tcg_ctx, INDEX_op_insn_start,
  611. (uint32_t)pc, (uint32_t)(pc >> 32));
  612. }
  613. # endif
  614. #elif TARGET_INSN_START_WORDS == 2
  615. # if TARGET_LONG_BITS <= TCG_TARGET_REG_BITS
  616. static inline void tcg_gen_insn_start(target_ulong pc, target_ulong a1)
  617. {
  618. tcg_gen_op2(&tcg_ctx, INDEX_op_insn_start, pc, a1);
  619. }
  620. # else
  621. static inline void tcg_gen_insn_start(target_ulong pc, target_ulong a1)
  622. {
  623. tcg_gen_op4(&tcg_ctx, INDEX_op_insn_start,
  624. (uint32_t)pc, (uint32_t)(pc >> 32),
  625. (uint32_t)a1, (uint32_t)(a1 >> 32));
  626. }
  627. # endif
  628. #elif TARGET_INSN_START_WORDS == 3
  629. # if TARGET_LONG_BITS <= TCG_TARGET_REG_BITS
  630. static inline void tcg_gen_insn_start(target_ulong pc, target_ulong a1,
  631. target_ulong a2)
  632. {
  633. tcg_gen_op3(&tcg_ctx, INDEX_op_insn_start, pc, a1, a2);
  634. }
  635. # else
  636. static inline void tcg_gen_insn_start(target_ulong pc, target_ulong a1,
  637. target_ulong a2)
  638. {
  639. tcg_gen_op6(&tcg_ctx, INDEX_op_insn_start,
  640. (uint32_t)pc, (uint32_t)(pc >> 32),
  641. (uint32_t)a1, (uint32_t)(a1 >> 32),
  642. (uint32_t)a2, (uint32_t)(a2 >> 32));
  643. }
  644. # endif
  645. #else
  646. # error "Unhandled number of operands to insn_start"
  647. #endif
  648. static inline void tcg_gen_exit_tb(uintptr_t val)
  649. {
  650. tcg_gen_op1i(INDEX_op_exit_tb, val);
  651. }
  652. void tcg_gen_goto_tb(unsigned idx);
  653. #if TARGET_LONG_BITS == 32
  654. #define TCGv TCGv_i32
  655. #define tcg_temp_new() tcg_temp_new_i32()
  656. #define tcg_global_reg_new tcg_global_reg_new_i32
  657. #define tcg_global_mem_new tcg_global_mem_new_i32
  658. #define tcg_temp_local_new() tcg_temp_local_new_i32()
  659. #define tcg_temp_free tcg_temp_free_i32
  660. #define TCGV_UNUSED(x) TCGV_UNUSED_I32(x)
  661. #define TCGV_IS_UNUSED(x) TCGV_IS_UNUSED_I32(x)
  662. #define TCGV_EQUAL(a, b) TCGV_EQUAL_I32(a, b)
  663. #define tcg_gen_qemu_ld_tl tcg_gen_qemu_ld_i32
  664. #define tcg_gen_qemu_st_tl tcg_gen_qemu_st_i32
  665. #else
  666. #define TCGv TCGv_i64
  667. #define tcg_temp_new() tcg_temp_new_i64()
  668. #define tcg_global_reg_new tcg_global_reg_new_i64
  669. #define tcg_global_mem_new tcg_global_mem_new_i64
  670. #define tcg_temp_local_new() tcg_temp_local_new_i64()
  671. #define tcg_temp_free tcg_temp_free_i64
  672. #define TCGV_UNUSED(x) TCGV_UNUSED_I64(x)
  673. #define TCGV_IS_UNUSED(x) TCGV_IS_UNUSED_I64(x)
  674. #define TCGV_EQUAL(a, b) TCGV_EQUAL_I64(a, b)
  675. #define tcg_gen_qemu_ld_tl tcg_gen_qemu_ld_i64
  676. #define tcg_gen_qemu_st_tl tcg_gen_qemu_st_i64
  677. #endif
  678. void tcg_gen_qemu_ld_i32(TCGv_i32, TCGv, TCGArg, TCGMemOp);
  679. void tcg_gen_qemu_st_i32(TCGv_i32, TCGv, TCGArg, TCGMemOp);
  680. void tcg_gen_qemu_ld_i64(TCGv_i64, TCGv, TCGArg, TCGMemOp);
  681. void tcg_gen_qemu_st_i64(TCGv_i64, TCGv, TCGArg, TCGMemOp);
  682. static inline void tcg_gen_qemu_ld8u(TCGv ret, TCGv addr, int mem_index)
  683. {
  684. tcg_gen_qemu_ld_tl(ret, addr, mem_index, MO_UB);
  685. }
  686. static inline void tcg_gen_qemu_ld8s(TCGv ret, TCGv addr, int mem_index)
  687. {
  688. tcg_gen_qemu_ld_tl(ret, addr, mem_index, MO_SB);
  689. }
  690. static inline void tcg_gen_qemu_ld16u(TCGv ret, TCGv addr, int mem_index)
  691. {
  692. tcg_gen_qemu_ld_tl(ret, addr, mem_index, MO_TEUW);
  693. }
  694. static inline void tcg_gen_qemu_ld16s(TCGv ret, TCGv addr, int mem_index)
  695. {
  696. tcg_gen_qemu_ld_tl(ret, addr, mem_index, MO_TESW);
  697. }
  698. static inline void tcg_gen_qemu_ld32u(TCGv ret, TCGv addr, int mem_index)
  699. {
  700. tcg_gen_qemu_ld_tl(ret, addr, mem_index, MO_TEUL);
  701. }
  702. static inline void tcg_gen_qemu_ld32s(TCGv ret, TCGv addr, int mem_index)
  703. {
  704. tcg_gen_qemu_ld_tl(ret, addr, mem_index, MO_TESL);
  705. }
  706. static inline void tcg_gen_qemu_ld64(TCGv_i64 ret, TCGv addr, int mem_index)
  707. {
  708. tcg_gen_qemu_ld_i64(ret, addr, mem_index, MO_TEQ);
  709. }
  710. static inline void tcg_gen_qemu_st8(TCGv arg, TCGv addr, int mem_index)
  711. {
  712. tcg_gen_qemu_st_tl(arg, addr, mem_index, MO_UB);
  713. }
  714. static inline void tcg_gen_qemu_st16(TCGv arg, TCGv addr, int mem_index)
  715. {
  716. tcg_gen_qemu_st_tl(arg, addr, mem_index, MO_TEUW);
  717. }
  718. static inline void tcg_gen_qemu_st32(TCGv arg, TCGv addr, int mem_index)
  719. {
  720. tcg_gen_qemu_st_tl(arg, addr, mem_index, MO_TEUL);
  721. }
  722. static inline void tcg_gen_qemu_st64(TCGv_i64 arg, TCGv addr, int mem_index)
  723. {
  724. tcg_gen_qemu_st_i64(arg, addr, mem_index, MO_TEQ);
  725. }
  726. #if TARGET_LONG_BITS == 64
  727. #define tcg_gen_movi_tl tcg_gen_movi_i64
  728. #define tcg_gen_mov_tl tcg_gen_mov_i64
  729. #define tcg_gen_ld8u_tl tcg_gen_ld8u_i64
  730. #define tcg_gen_ld8s_tl tcg_gen_ld8s_i64
  731. #define tcg_gen_ld16u_tl tcg_gen_ld16u_i64
  732. #define tcg_gen_ld16s_tl tcg_gen_ld16s_i64
  733. #define tcg_gen_ld32u_tl tcg_gen_ld32u_i64
  734. #define tcg_gen_ld32s_tl tcg_gen_ld32s_i64
  735. #define tcg_gen_ld_tl tcg_gen_ld_i64
  736. #define tcg_gen_st8_tl tcg_gen_st8_i64
  737. #define tcg_gen_st16_tl tcg_gen_st16_i64
  738. #define tcg_gen_st32_tl tcg_gen_st32_i64
  739. #define tcg_gen_st_tl tcg_gen_st_i64
  740. #define tcg_gen_add_tl tcg_gen_add_i64
  741. #define tcg_gen_addi_tl tcg_gen_addi_i64
  742. #define tcg_gen_sub_tl tcg_gen_sub_i64
  743. #define tcg_gen_neg_tl tcg_gen_neg_i64
  744. #define tcg_gen_subfi_tl tcg_gen_subfi_i64
  745. #define tcg_gen_subi_tl tcg_gen_subi_i64
  746. #define tcg_gen_and_tl tcg_gen_and_i64
  747. #define tcg_gen_andi_tl tcg_gen_andi_i64
  748. #define tcg_gen_or_tl tcg_gen_or_i64
  749. #define tcg_gen_ori_tl tcg_gen_ori_i64
  750. #define tcg_gen_xor_tl tcg_gen_xor_i64
  751. #define tcg_gen_xori_tl tcg_gen_xori_i64
  752. #define tcg_gen_not_tl tcg_gen_not_i64
  753. #define tcg_gen_shl_tl tcg_gen_shl_i64
  754. #define tcg_gen_shli_tl tcg_gen_shli_i64
  755. #define tcg_gen_shr_tl tcg_gen_shr_i64
  756. #define tcg_gen_shri_tl tcg_gen_shri_i64
  757. #define tcg_gen_sar_tl tcg_gen_sar_i64
  758. #define tcg_gen_sari_tl tcg_gen_sari_i64
  759. #define tcg_gen_brcond_tl tcg_gen_brcond_i64
  760. #define tcg_gen_brcondi_tl tcg_gen_brcondi_i64
  761. #define tcg_gen_setcond_tl tcg_gen_setcond_i64
  762. #define tcg_gen_setcondi_tl tcg_gen_setcondi_i64
  763. #define tcg_gen_mul_tl tcg_gen_mul_i64
  764. #define tcg_gen_muli_tl tcg_gen_muli_i64
  765. #define tcg_gen_div_tl tcg_gen_div_i64
  766. #define tcg_gen_rem_tl tcg_gen_rem_i64
  767. #define tcg_gen_divu_tl tcg_gen_divu_i64
  768. #define tcg_gen_remu_tl tcg_gen_remu_i64
  769. #define tcg_gen_discard_tl tcg_gen_discard_i64
  770. #define tcg_gen_trunc_tl_i32 tcg_gen_extrl_i64_i32
  771. #define tcg_gen_trunc_i64_tl tcg_gen_mov_i64
  772. #define tcg_gen_extu_i32_tl tcg_gen_extu_i32_i64
  773. #define tcg_gen_ext_i32_tl tcg_gen_ext_i32_i64
  774. #define tcg_gen_extu_tl_i64 tcg_gen_mov_i64
  775. #define tcg_gen_ext_tl_i64 tcg_gen_mov_i64
  776. #define tcg_gen_ext8u_tl tcg_gen_ext8u_i64
  777. #define tcg_gen_ext8s_tl tcg_gen_ext8s_i64
  778. #define tcg_gen_ext16u_tl tcg_gen_ext16u_i64
  779. #define tcg_gen_ext16s_tl tcg_gen_ext16s_i64
  780. #define tcg_gen_ext32u_tl tcg_gen_ext32u_i64
  781. #define tcg_gen_ext32s_tl tcg_gen_ext32s_i64
  782. #define tcg_gen_bswap16_tl tcg_gen_bswap16_i64
  783. #define tcg_gen_bswap32_tl tcg_gen_bswap32_i64
  784. #define tcg_gen_bswap64_tl tcg_gen_bswap64_i64
  785. #define tcg_gen_concat_tl_i64 tcg_gen_concat32_i64
  786. #define tcg_gen_extr_i64_tl tcg_gen_extr32_i64
  787. #define tcg_gen_andc_tl tcg_gen_andc_i64
  788. #define tcg_gen_eqv_tl tcg_gen_eqv_i64
  789. #define tcg_gen_nand_tl tcg_gen_nand_i64
  790. #define tcg_gen_nor_tl tcg_gen_nor_i64
  791. #define tcg_gen_orc_tl tcg_gen_orc_i64
  792. #define tcg_gen_rotl_tl tcg_gen_rotl_i64
  793. #define tcg_gen_rotli_tl tcg_gen_rotli_i64
  794. #define tcg_gen_rotr_tl tcg_gen_rotr_i64
  795. #define tcg_gen_rotri_tl tcg_gen_rotri_i64
  796. #define tcg_gen_deposit_tl tcg_gen_deposit_i64
  797. #define tcg_const_tl tcg_const_i64
  798. #define tcg_const_local_tl tcg_const_local_i64
  799. #define tcg_gen_movcond_tl tcg_gen_movcond_i64
  800. #define tcg_gen_add2_tl tcg_gen_add2_i64
  801. #define tcg_gen_sub2_tl tcg_gen_sub2_i64
  802. #define tcg_gen_mulu2_tl tcg_gen_mulu2_i64
  803. #define tcg_gen_muls2_tl tcg_gen_muls2_i64
  804. #else
  805. #define tcg_gen_movi_tl tcg_gen_movi_i32
  806. #define tcg_gen_mov_tl tcg_gen_mov_i32
  807. #define tcg_gen_ld8u_tl tcg_gen_ld8u_i32
  808. #define tcg_gen_ld8s_tl tcg_gen_ld8s_i32
  809. #define tcg_gen_ld16u_tl tcg_gen_ld16u_i32
  810. #define tcg_gen_ld16s_tl tcg_gen_ld16s_i32
  811. #define tcg_gen_ld32u_tl tcg_gen_ld_i32
  812. #define tcg_gen_ld32s_tl tcg_gen_ld_i32
  813. #define tcg_gen_ld_tl tcg_gen_ld_i32
  814. #define tcg_gen_st8_tl tcg_gen_st8_i32
  815. #define tcg_gen_st16_tl tcg_gen_st16_i32
  816. #define tcg_gen_st32_tl tcg_gen_st_i32
  817. #define tcg_gen_st_tl tcg_gen_st_i32
  818. #define tcg_gen_add_tl tcg_gen_add_i32
  819. #define tcg_gen_addi_tl tcg_gen_addi_i32
  820. #define tcg_gen_sub_tl tcg_gen_sub_i32
  821. #define tcg_gen_neg_tl tcg_gen_neg_i32
  822. #define tcg_gen_subfi_tl tcg_gen_subfi_i32
  823. #define tcg_gen_subi_tl tcg_gen_subi_i32
  824. #define tcg_gen_and_tl tcg_gen_and_i32
  825. #define tcg_gen_andi_tl tcg_gen_andi_i32
  826. #define tcg_gen_or_tl tcg_gen_or_i32
  827. #define tcg_gen_ori_tl tcg_gen_ori_i32
  828. #define tcg_gen_xor_tl tcg_gen_xor_i32
  829. #define tcg_gen_xori_tl tcg_gen_xori_i32
  830. #define tcg_gen_not_tl tcg_gen_not_i32
  831. #define tcg_gen_shl_tl tcg_gen_shl_i32
  832. #define tcg_gen_shli_tl tcg_gen_shli_i32
  833. #define tcg_gen_shr_tl tcg_gen_shr_i32
  834. #define tcg_gen_shri_tl tcg_gen_shri_i32
  835. #define tcg_gen_sar_tl tcg_gen_sar_i32
  836. #define tcg_gen_sari_tl tcg_gen_sari_i32
  837. #define tcg_gen_brcond_tl tcg_gen_brcond_i32
  838. #define tcg_gen_brcondi_tl tcg_gen_brcondi_i32
  839. #define tcg_gen_setcond_tl tcg_gen_setcond_i32
  840. #define tcg_gen_setcondi_tl tcg_gen_setcondi_i32
  841. #define tcg_gen_mul_tl tcg_gen_mul_i32
  842. #define tcg_gen_muli_tl tcg_gen_muli_i32
  843. #define tcg_gen_div_tl tcg_gen_div_i32
  844. #define tcg_gen_rem_tl tcg_gen_rem_i32
  845. #define tcg_gen_divu_tl tcg_gen_divu_i32
  846. #define tcg_gen_remu_tl tcg_gen_remu_i32
  847. #define tcg_gen_discard_tl tcg_gen_discard_i32
  848. #define tcg_gen_trunc_tl_i32 tcg_gen_mov_i32
  849. #define tcg_gen_trunc_i64_tl tcg_gen_extrl_i64_i32
  850. #define tcg_gen_extu_i32_tl tcg_gen_mov_i32
  851. #define tcg_gen_ext_i32_tl tcg_gen_mov_i32
  852. #define tcg_gen_extu_tl_i64 tcg_gen_extu_i32_i64
  853. #define tcg_gen_ext_tl_i64 tcg_gen_ext_i32_i64
  854. #define tcg_gen_ext8u_tl tcg_gen_ext8u_i32
  855. #define tcg_gen_ext8s_tl tcg_gen_ext8s_i32
  856. #define tcg_gen_ext16u_tl tcg_gen_ext16u_i32
  857. #define tcg_gen_ext16s_tl tcg_gen_ext16s_i32
  858. #define tcg_gen_ext32u_tl tcg_gen_mov_i32
  859. #define tcg_gen_ext32s_tl tcg_gen_mov_i32
  860. #define tcg_gen_bswap16_tl tcg_gen_bswap16_i32
  861. #define tcg_gen_bswap32_tl tcg_gen_bswap32_i32
  862. #define tcg_gen_concat_tl_i64 tcg_gen_concat_i32_i64
  863. #define tcg_gen_extr_i64_tl tcg_gen_extr_i64_i32
  864. #define tcg_gen_andc_tl tcg_gen_andc_i32
  865. #define tcg_gen_eqv_tl tcg_gen_eqv_i32
  866. #define tcg_gen_nand_tl tcg_gen_nand_i32
  867. #define tcg_gen_nor_tl tcg_gen_nor_i32
  868. #define tcg_gen_orc_tl tcg_gen_orc_i32
  869. #define tcg_gen_rotl_tl tcg_gen_rotl_i32
  870. #define tcg_gen_rotli_tl tcg_gen_rotli_i32
  871. #define tcg_gen_rotr_tl tcg_gen_rotr_i32
  872. #define tcg_gen_rotri_tl tcg_gen_rotri_i32
  873. #define tcg_gen_deposit_tl tcg_gen_deposit_i32
  874. #define tcg_const_tl tcg_const_i32
  875. #define tcg_const_local_tl tcg_const_local_i32
  876. #define tcg_gen_movcond_tl tcg_gen_movcond_i32
  877. #define tcg_gen_add2_tl tcg_gen_add2_i32
  878. #define tcg_gen_sub2_tl tcg_gen_sub2_i32
  879. #define tcg_gen_mulu2_tl tcg_gen_mulu2_i32
  880. #define tcg_gen_muls2_tl tcg_gen_muls2_i32
  881. #endif
  882. #if UINTPTR_MAX == UINT32_MAX
  883. # define tcg_gen_ld_ptr(R, A, O) \
  884. tcg_gen_ld_i32(TCGV_PTR_TO_NAT(R), (A), (O))
  885. # define tcg_gen_discard_ptr(A) \
  886. tcg_gen_discard_i32(TCGV_PTR_TO_NAT(A))
  887. # define tcg_gen_add_ptr(R, A, B) \
  888. tcg_gen_add_i32(TCGV_PTR_TO_NAT(R), TCGV_PTR_TO_NAT(A), TCGV_PTR_TO_NAT(B))
  889. # define tcg_gen_addi_ptr(R, A, B) \
  890. tcg_gen_addi_i32(TCGV_PTR_TO_NAT(R), TCGV_PTR_TO_NAT(A), (B))
  891. # define tcg_gen_ext_i32_ptr(R, A) \
  892. tcg_gen_mov_i32(TCGV_PTR_TO_NAT(R), (A))
  893. #else
  894. # define tcg_gen_ld_ptr(R, A, O) \
  895. tcg_gen_ld_i64(TCGV_PTR_TO_NAT(R), (A), (O))
  896. # define tcg_gen_discard_ptr(A) \
  897. tcg_gen_discard_i64(TCGV_PTR_TO_NAT(A))
  898. # define tcg_gen_add_ptr(R, A, B) \
  899. tcg_gen_add_i64(TCGV_PTR_TO_NAT(R), TCGV_PTR_TO_NAT(A), TCGV_PTR_TO_NAT(B))
  900. # define tcg_gen_addi_ptr(R, A, B) \
  901. tcg_gen_addi_i64(TCGV_PTR_TO_NAT(R), TCGV_PTR_TO_NAT(A), (B))
  902. # define tcg_gen_ext_i32_ptr(R, A) \
  903. tcg_gen_ext_i32_i64(TCGV_PTR_TO_NAT(R), (A))
  904. #endif /* UINTPTR_MAX == UINT32_MAX */