1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Target independent opcode generation functions. 4 * 5 * Copyright (c) 2008 Fabrice Bellard 6 */ 7 8 #ifndef TCG_TCG_OP_COMMON_H 9 #define TCG_TCG_OP_COMMON_H 10 11 #include "tcg/tcg.h" 12 #include "exec/helper-proto-common.h" 13 #include "exec/helper-gen-common.h" 14 15 TCGv_i32 tcg_constant_i32(int32_t val); 16 TCGv_i64 tcg_constant_i64(int64_t val); 17 TCGv_vec tcg_constant_vec(TCGType type, unsigned vece, int64_t val); 18 TCGv_vec tcg_constant_vec_matching(TCGv_vec match, unsigned vece, int64_t val); 19 20 TCGv_i32 tcg_temp_new_i32(void); 21 TCGv_i64 tcg_temp_new_i64(void); 22 TCGv_ptr tcg_temp_new_ptr(void); 23 TCGv_i128 tcg_temp_new_i128(void); 24 TCGv_vec tcg_temp_new_vec(TCGType type); 25 TCGv_vec tcg_temp_new_vec_matching(TCGv_vec match); 26 27 TCGv_i32 tcg_global_mem_new_i32(TCGv_ptr reg, intptr_t off, const char *name); 28 TCGv_i64 tcg_global_mem_new_i64(TCGv_ptr reg, intptr_t off, const char *name); 29 TCGv_ptr tcg_global_mem_new_ptr(TCGv_ptr reg, intptr_t off, const char *name); 30 31 /* Generic ops. */ 32 33 void gen_set_label(TCGLabel *l); 34 void tcg_gen_br(TCGLabel *l); 35 void tcg_gen_mb(TCGBar); 36 37 /** 38 * tcg_gen_exit_tb() - output exit_tb TCG operation 39 * @tb: The TranslationBlock from which we are exiting 40 * @idx: Direct jump slot index, or exit request 41 * 42 * See tcg/README for more info about this TCG operation. 43 * See also tcg.h and the block comment above TB_EXIT_MASK. 44 * 45 * For a normal exit from the TB, back to the main loop, @tb should 46 * be NULL and @idx should be 0. Otherwise, @tb should be valid and 47 * @idx should be one of the TB_EXIT_ values. 48 */ 49 void tcg_gen_exit_tb(const TranslationBlock *tb, unsigned idx); 50 51 /** 52 * tcg_gen_goto_tb() - output goto_tb TCG operation 53 * @idx: Direct jump slot index (0 or 1) 54 * 55 * See tcg/README for more info about this TCG operation. 56 * 57 * NOTE: In system emulation, direct jumps with goto_tb are only safe within 58 * the pages this TB resides in because we don't take care of direct jumps when 59 * address mapping changes, e.g. in tlb_flush(). In user mode, there's only a 60 * static address translation, so the destination address is always valid, TBs 61 * are always invalidated properly, and direct jumps are reset when mapping 62 * changes. 63 */ 64 void tcg_gen_goto_tb(unsigned idx); 65 66 /** 67 * tcg_gen_lookup_and_goto_ptr() - look up the current TB, jump to it if valid 68 * @addr: Guest address of the target TB 69 * 70 * If the TB is not valid, jump to the epilogue. 71 * 72 * This operation is optional. If the TCG backend does not implement goto_ptr, 73 * this op is equivalent to calling tcg_gen_exit_tb() with 0 as the argument. 74 */ 75 void tcg_gen_lookup_and_goto_ptr(void); 76 77 void tcg_gen_plugin_cb_start(unsigned from, unsigned type, unsigned wr); 78 void tcg_gen_plugin_cb_end(void); 79 80 /* 32 bit ops */ 81 82 void tcg_gen_movi_i32(TCGv_i32 ret, int32_t arg); 83 void tcg_gen_addi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2); 84 void tcg_gen_subfi_i32(TCGv_i32 ret, int32_t arg1, TCGv_i32 arg2); 85 void tcg_gen_subi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2); 86 void tcg_gen_andi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2); 87 void tcg_gen_ori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2); 88 void tcg_gen_xori_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2); 89 void tcg_gen_shli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2); 90 void tcg_gen_shri_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2); 91 void tcg_gen_sari_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2); 92 void tcg_gen_muli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2); 93 void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 94 void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 95 void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 96 void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 97 void tcg_gen_andc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 98 void tcg_gen_eqv_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 99 void tcg_gen_nand_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 100 void tcg_gen_nor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 101 void tcg_gen_orc_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 102 void tcg_gen_clz_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 103 void tcg_gen_ctz_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 104 void tcg_gen_clzi_i32(TCGv_i32 ret, TCGv_i32 arg1, uint32_t arg2); 105 void tcg_gen_ctzi_i32(TCGv_i32 ret, TCGv_i32 arg1, uint32_t arg2); 106 void tcg_gen_clrsb_i32(TCGv_i32 ret, TCGv_i32 arg); 107 void tcg_gen_ctpop_i32(TCGv_i32 a1, TCGv_i32 a2); 108 void tcg_gen_rotl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 109 void tcg_gen_rotli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2); 110 void tcg_gen_rotr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 111 void tcg_gen_rotri_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2); 112 void tcg_gen_deposit_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2, 113 unsigned int ofs, unsigned int len); 114 void tcg_gen_deposit_z_i32(TCGv_i32 ret, TCGv_i32 arg, 115 unsigned int ofs, unsigned int len); 116 void tcg_gen_extract_i32(TCGv_i32 ret, TCGv_i32 arg, 117 unsigned int ofs, unsigned int len); 118 void tcg_gen_sextract_i32(TCGv_i32 ret, TCGv_i32 arg, 119 unsigned int ofs, unsigned int len); 120 void tcg_gen_extract2_i32(TCGv_i32 ret, TCGv_i32 al, TCGv_i32 ah, 121 unsigned int ofs); 122 void tcg_gen_brcond_i32(TCGCond cond, TCGv_i32 arg1, TCGv_i32 arg2, TCGLabel *); 123 void tcg_gen_brcondi_i32(TCGCond cond, TCGv_i32 arg1, int32_t arg2, TCGLabel *); 124 void tcg_gen_setcond_i32(TCGCond cond, TCGv_i32 ret, 125 TCGv_i32 arg1, TCGv_i32 arg2); 126 void tcg_gen_setcondi_i32(TCGCond cond, TCGv_i32 ret, 127 TCGv_i32 arg1, int32_t arg2); 128 void tcg_gen_negsetcond_i32(TCGCond cond, TCGv_i32 ret, 129 TCGv_i32 arg1, TCGv_i32 arg2); 130 void tcg_gen_negsetcondi_i32(TCGCond cond, TCGv_i32 ret, 131 TCGv_i32 arg1, int32_t arg2); 132 void tcg_gen_movcond_i32(TCGCond cond, TCGv_i32 ret, TCGv_i32 c1, 133 TCGv_i32 c2, TCGv_i32 v1, TCGv_i32 v2); 134 void tcg_gen_add2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 al, 135 TCGv_i32 ah, TCGv_i32 bl, TCGv_i32 bh); 136 void tcg_gen_sub2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 al, 137 TCGv_i32 ah, TCGv_i32 bl, TCGv_i32 bh); 138 void tcg_gen_mulu2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 arg1, TCGv_i32 arg2); 139 void tcg_gen_muls2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 arg1, TCGv_i32 arg2); 140 void tcg_gen_mulsu2_i32(TCGv_i32 rl, TCGv_i32 rh, TCGv_i32 arg1, TCGv_i32 arg2); 141 void tcg_gen_ext8s_i32(TCGv_i32 ret, TCGv_i32 arg); 142 void tcg_gen_ext16s_i32(TCGv_i32 ret, TCGv_i32 arg); 143 void tcg_gen_ext8u_i32(TCGv_i32 ret, TCGv_i32 arg); 144 void tcg_gen_ext16u_i32(TCGv_i32 ret, TCGv_i32 arg); 145 void tcg_gen_ext_i32(TCGv_i32 ret, TCGv_i32 val, MemOp opc); 146 void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg, int flags); 147 void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg); 148 void tcg_gen_hswap_i32(TCGv_i32 ret, TCGv_i32 arg); 149 void tcg_gen_smin_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2); 150 void tcg_gen_smax_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2); 151 void tcg_gen_umin_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2); 152 void tcg_gen_umax_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2); 153 void tcg_gen_abs_i32(TCGv_i32, TCGv_i32); 154 155 /* Replicate a value of size @vece from @in to all the lanes in @out */ 156 void tcg_gen_dup_i32(unsigned vece, TCGv_i32 out, TCGv_i32 in); 157 158 void tcg_gen_discard_i32(TCGv_i32 arg); 159 void tcg_gen_mov_i32(TCGv_i32 ret, TCGv_i32 arg); 160 161 void tcg_gen_ld8u_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset); 162 void tcg_gen_ld8s_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset); 163 void tcg_gen_ld16u_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset); 164 void tcg_gen_ld16s_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset); 165 void tcg_gen_ld_i32(TCGv_i32 ret, TCGv_ptr arg2, tcg_target_long offset); 166 167 void tcg_gen_st8_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset); 168 void tcg_gen_st16_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset); 169 void tcg_gen_st_i32(TCGv_i32 arg1, TCGv_ptr arg2, tcg_target_long offset); 170 171 void tcg_gen_add_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 172 void tcg_gen_sub_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 173 void tcg_gen_and_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 174 void tcg_gen_or_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 175 void tcg_gen_xor_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 176 void tcg_gen_shl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 177 void tcg_gen_shr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 178 void tcg_gen_sar_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 179 void tcg_gen_mul_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); 180 void tcg_gen_neg_i32(TCGv_i32 ret, TCGv_i32 arg); 181 void tcg_gen_not_i32(TCGv_i32 ret, TCGv_i32 arg); 182 183 /* 64 bit ops */ 184 185 void tcg_gen_movi_i64(TCGv_i64 ret, int64_t arg); 186 void tcg_gen_addi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2); 187 void tcg_gen_subfi_i64(TCGv_i64 ret, int64_t arg1, TCGv_i64 arg2); 188 void tcg_gen_subi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2); 189 void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2); 190 void tcg_gen_ori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2); 191 void tcg_gen_xori_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2); 192 void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2); 193 void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2); 194 void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2); 195 void tcg_gen_muli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2); 196 void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 197 void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 198 void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 199 void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 200 void tcg_gen_andc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 201 void tcg_gen_eqv_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 202 void tcg_gen_nand_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 203 void tcg_gen_nor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 204 void tcg_gen_orc_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 205 void tcg_gen_clz_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 206 void tcg_gen_ctz_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 207 void tcg_gen_clzi_i64(TCGv_i64 ret, TCGv_i64 arg1, uint64_t arg2); 208 void tcg_gen_ctzi_i64(TCGv_i64 ret, TCGv_i64 arg1, uint64_t arg2); 209 void tcg_gen_clrsb_i64(TCGv_i64 ret, TCGv_i64 arg); 210 void tcg_gen_ctpop_i64(TCGv_i64 a1, TCGv_i64 a2); 211 void tcg_gen_rotl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 212 void tcg_gen_rotli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2); 213 void tcg_gen_rotr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 214 void tcg_gen_rotri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2); 215 void tcg_gen_deposit_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2, 216 unsigned int ofs, unsigned int len); 217 void tcg_gen_deposit_z_i64(TCGv_i64 ret, TCGv_i64 arg, 218 unsigned int ofs, unsigned int len); 219 void tcg_gen_extract_i64(TCGv_i64 ret, TCGv_i64 arg, 220 unsigned int ofs, unsigned int len); 221 void tcg_gen_sextract_i64(TCGv_i64 ret, TCGv_i64 arg, 222 unsigned int ofs, unsigned int len); 223 void tcg_gen_extract2_i64(TCGv_i64 ret, TCGv_i64 al, TCGv_i64 ah, 224 unsigned int ofs); 225 void tcg_gen_brcond_i64(TCGCond cond, TCGv_i64 arg1, TCGv_i64 arg2, TCGLabel *); 226 void tcg_gen_brcondi_i64(TCGCond cond, TCGv_i64 arg1, int64_t arg2, TCGLabel *); 227 void tcg_gen_setcond_i64(TCGCond cond, TCGv_i64 ret, 228 TCGv_i64 arg1, TCGv_i64 arg2); 229 void tcg_gen_setcondi_i64(TCGCond cond, TCGv_i64 ret, 230 TCGv_i64 arg1, int64_t arg2); 231 void tcg_gen_negsetcond_i64(TCGCond cond, TCGv_i64 ret, 232 TCGv_i64 arg1, TCGv_i64 arg2); 233 void tcg_gen_negsetcondi_i64(TCGCond cond, TCGv_i64 ret, 234 TCGv_i64 arg1, int64_t arg2); 235 void tcg_gen_movcond_i64(TCGCond cond, TCGv_i64 ret, TCGv_i64 c1, 236 TCGv_i64 c2, TCGv_i64 v1, TCGv_i64 v2); 237 void tcg_gen_add2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 al, 238 TCGv_i64 ah, TCGv_i64 bl, TCGv_i64 bh); 239 void tcg_gen_sub2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 al, 240 TCGv_i64 ah, TCGv_i64 bl, TCGv_i64 bh); 241 void tcg_gen_mulu2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 arg1, TCGv_i64 arg2); 242 void tcg_gen_muls2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 arg1, TCGv_i64 arg2); 243 void tcg_gen_mulsu2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 arg1, TCGv_i64 arg2); 244 void tcg_gen_not_i64(TCGv_i64 ret, TCGv_i64 arg); 245 void tcg_gen_ext8s_i64(TCGv_i64 ret, TCGv_i64 arg); 246 void tcg_gen_ext16s_i64(TCGv_i64 ret, TCGv_i64 arg); 247 void tcg_gen_ext32s_i64(TCGv_i64 ret, TCGv_i64 arg); 248 void tcg_gen_ext8u_i64(TCGv_i64 ret, TCGv_i64 arg); 249 void tcg_gen_ext16u_i64(TCGv_i64 ret, TCGv_i64 arg); 250 void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg); 251 void tcg_gen_ext_i64(TCGv_i64 ret, TCGv_i64 val, MemOp opc); 252 void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg, int flags); 253 void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg, int flags); 254 void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg); 255 void tcg_gen_hswap_i64(TCGv_i64 ret, TCGv_i64 arg); 256 void tcg_gen_wswap_i64(TCGv_i64 ret, TCGv_i64 arg); 257 void tcg_gen_smin_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2); 258 void tcg_gen_smax_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2); 259 void tcg_gen_umin_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2); 260 void tcg_gen_umax_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2); 261 void tcg_gen_abs_i64(TCGv_i64, TCGv_i64); 262 263 /* Replicate a value of size @vece from @in to all the lanes in @out */ 264 void tcg_gen_dup_i64(unsigned vece, TCGv_i64 out, TCGv_i64 in); 265 266 void tcg_gen_st8_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset); 267 void tcg_gen_st16_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset); 268 void tcg_gen_st32_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset); 269 270 void tcg_gen_add_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 271 void tcg_gen_sub_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 272 273 void tcg_gen_discard_i64(TCGv_i64 arg); 274 void tcg_gen_mov_i64(TCGv_i64 ret, TCGv_i64 arg); 275 void tcg_gen_ld8u_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset); 276 void tcg_gen_ld8s_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset); 277 void tcg_gen_ld16u_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset); 278 void tcg_gen_ld16s_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset); 279 void tcg_gen_ld32u_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset); 280 void tcg_gen_ld32s_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset); 281 void tcg_gen_ld_i64(TCGv_i64 ret, TCGv_ptr arg2, tcg_target_long offset); 282 void tcg_gen_st_i64(TCGv_i64 arg1, TCGv_ptr arg2, tcg_target_long offset); 283 void tcg_gen_and_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 284 void tcg_gen_or_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 285 void tcg_gen_xor_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 286 void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 287 void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 288 void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 289 void tcg_gen_mul_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); 290 void tcg_gen_neg_i64(TCGv_i64 ret, TCGv_i64 arg); 291 292 293 /* Size changing operations. */ 294 295 void tcg_gen_extu_i32_i64(TCGv_i64 ret, TCGv_i32 arg); 296 void tcg_gen_ext_i32_i64(TCGv_i64 ret, TCGv_i32 arg); 297 void tcg_gen_concat_i32_i64(TCGv_i64 dest, TCGv_i32 low, TCGv_i32 high); 298 void tcg_gen_extrl_i64_i32(TCGv_i32 ret, TCGv_i64 arg); 299 void tcg_gen_extrh_i64_i32(TCGv_i32 ret, TCGv_i64 arg); 300 void tcg_gen_extr_i64_i32(TCGv_i32 lo, TCGv_i32 hi, TCGv_i64 arg); 301 void tcg_gen_extr32_i64(TCGv_i64 lo, TCGv_i64 hi, TCGv_i64 arg); 302 void tcg_gen_concat32_i64(TCGv_i64 ret, TCGv_i64 lo, TCGv_i64 hi); 303 304 void tcg_gen_extr_i128_i64(TCGv_i64 lo, TCGv_i64 hi, TCGv_i128 arg); 305 void tcg_gen_concat_i64_i128(TCGv_i128 ret, TCGv_i64 lo, TCGv_i64 hi); 306 307 /* 128 bit ops */ 308 309 void tcg_gen_mov_i128(TCGv_i128 dst, TCGv_i128 src); 310 void tcg_gen_ld_i128(TCGv_i128 ret, TCGv_ptr base, tcg_target_long offset); 311 void tcg_gen_st_i128(TCGv_i128 val, TCGv_ptr base, tcg_target_long offset); 312 313 /* Local load/store bit ops */ 314 315 void tcg_gen_qemu_ld_i32_chk(TCGv_i32, TCGTemp *, TCGArg, MemOp, TCGType); 316 void tcg_gen_qemu_st_i32_chk(TCGv_i32, TCGTemp *, TCGArg, MemOp, TCGType); 317 void tcg_gen_qemu_ld_i64_chk(TCGv_i64, TCGTemp *, TCGArg, MemOp, TCGType); 318 void tcg_gen_qemu_st_i64_chk(TCGv_i64, TCGTemp *, TCGArg, MemOp, TCGType); 319 void tcg_gen_qemu_ld_i128_chk(TCGv_i128, TCGTemp *, TCGArg, MemOp, TCGType); 320 void tcg_gen_qemu_st_i128_chk(TCGv_i128, TCGTemp *, TCGArg, MemOp, TCGType); 321 322 /* Atomic ops */ 323 324 void tcg_gen_atomic_cmpxchg_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, TCGv_i32, 325 TCGArg, MemOp, TCGType); 326 void tcg_gen_atomic_cmpxchg_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, TCGv_i64, 327 TCGArg, MemOp, TCGType); 328 void tcg_gen_atomic_cmpxchg_i128_chk(TCGv_i128, TCGTemp *, TCGv_i128, 329 TCGv_i128, TCGArg, MemOp, TCGType); 330 331 void tcg_gen_nonatomic_cmpxchg_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, TCGv_i32, 332 TCGArg, MemOp, TCGType); 333 void tcg_gen_nonatomic_cmpxchg_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, TCGv_i64, 334 TCGArg, MemOp, TCGType); 335 void tcg_gen_nonatomic_cmpxchg_i128_chk(TCGv_i128, TCGTemp *, TCGv_i128, 336 TCGv_i128, TCGArg, MemOp, TCGType); 337 338 void tcg_gen_atomic_xchg_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, 339 TCGArg, MemOp, TCGType); 340 void tcg_gen_atomic_xchg_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, 341 TCGArg, MemOp, TCGType); 342 343 void tcg_gen_atomic_fetch_add_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, 344 TCGArg, MemOp, TCGType); 345 void tcg_gen_atomic_fetch_add_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, 346 TCGArg, MemOp, TCGType); 347 void tcg_gen_atomic_fetch_and_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, 348 TCGArg, MemOp, TCGType); 349 void tcg_gen_atomic_fetch_and_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, 350 TCGArg, MemOp, TCGType); 351 void tcg_gen_atomic_fetch_or_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, 352 TCGArg, MemOp, TCGType); 353 void tcg_gen_atomic_fetch_or_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, 354 TCGArg, MemOp, TCGType); 355 void tcg_gen_atomic_fetch_xor_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, 356 TCGArg, MemOp, TCGType); 357 void tcg_gen_atomic_fetch_xor_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, 358 TCGArg, MemOp, TCGType); 359 void tcg_gen_atomic_fetch_smin_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, 360 TCGArg, MemOp, TCGType); 361 void tcg_gen_atomic_fetch_smin_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, 362 TCGArg, MemOp, TCGType); 363 void tcg_gen_atomic_fetch_umin_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, 364 TCGArg, MemOp, TCGType); 365 void tcg_gen_atomic_fetch_umin_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, 366 TCGArg, MemOp, TCGType); 367 void tcg_gen_atomic_fetch_smax_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, 368 TCGArg, MemOp, TCGType); 369 void tcg_gen_atomic_fetch_smax_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, 370 TCGArg, MemOp, TCGType); 371 void tcg_gen_atomic_fetch_umax_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, 372 TCGArg, MemOp, TCGType); 373 void tcg_gen_atomic_fetch_umax_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, 374 TCGArg, MemOp, TCGType); 375 376 void tcg_gen_atomic_add_fetch_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, 377 TCGArg, MemOp, TCGType); 378 void tcg_gen_atomic_add_fetch_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, 379 TCGArg, MemOp, TCGType); 380 void tcg_gen_atomic_and_fetch_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, 381 TCGArg, MemOp, TCGType); 382 void tcg_gen_atomic_and_fetch_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, 383 TCGArg, MemOp, TCGType); 384 void tcg_gen_atomic_or_fetch_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, 385 TCGArg, MemOp, TCGType); 386 void tcg_gen_atomic_or_fetch_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, 387 TCGArg, MemOp, TCGType); 388 void tcg_gen_atomic_xor_fetch_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, 389 TCGArg, MemOp, TCGType); 390 void tcg_gen_atomic_xor_fetch_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, 391 TCGArg, MemOp, TCGType); 392 void tcg_gen_atomic_smin_fetch_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, 393 TCGArg, MemOp, TCGType); 394 void tcg_gen_atomic_smin_fetch_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, 395 TCGArg, MemOp, TCGType); 396 void tcg_gen_atomic_umin_fetch_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, 397 TCGArg, MemOp, TCGType); 398 void tcg_gen_atomic_umin_fetch_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, 399 TCGArg, MemOp, TCGType); 400 void tcg_gen_atomic_smax_fetch_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, 401 TCGArg, MemOp, TCGType); 402 void tcg_gen_atomic_smax_fetch_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, 403 TCGArg, MemOp, TCGType); 404 void tcg_gen_atomic_umax_fetch_i32_chk(TCGv_i32, TCGTemp *, TCGv_i32, 405 TCGArg, MemOp, TCGType); 406 void tcg_gen_atomic_umax_fetch_i64_chk(TCGv_i64, TCGTemp *, TCGv_i64, 407 TCGArg, MemOp, TCGType); 408 409 /* Vector ops */ 410 411 void tcg_gen_mov_vec(TCGv_vec, TCGv_vec); 412 void tcg_gen_dup_i32_vec(unsigned vece, TCGv_vec, TCGv_i32); 413 void tcg_gen_dup_i64_vec(unsigned vece, TCGv_vec, TCGv_i64); 414 void tcg_gen_dup_mem_vec(unsigned vece, TCGv_vec, TCGv_ptr, tcg_target_long); 415 void tcg_gen_dupi_vec(unsigned vece, TCGv_vec, uint64_t); 416 void tcg_gen_add_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 417 void tcg_gen_sub_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 418 void tcg_gen_mul_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 419 void tcg_gen_and_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 420 void tcg_gen_or_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 421 void tcg_gen_xor_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 422 void tcg_gen_andc_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 423 void tcg_gen_orc_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 424 void tcg_gen_nand_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 425 void tcg_gen_nor_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 426 void tcg_gen_eqv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 427 void tcg_gen_not_vec(unsigned vece, TCGv_vec r, TCGv_vec a); 428 void tcg_gen_neg_vec(unsigned vece, TCGv_vec r, TCGv_vec a); 429 void tcg_gen_abs_vec(unsigned vece, TCGv_vec r, TCGv_vec a); 430 void tcg_gen_ssadd_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 431 void tcg_gen_usadd_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 432 void tcg_gen_sssub_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 433 void tcg_gen_ussub_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 434 void tcg_gen_smin_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 435 void tcg_gen_umin_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 436 void tcg_gen_smax_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 437 void tcg_gen_umax_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec b); 438 439 void tcg_gen_shli_vec(unsigned vece, TCGv_vec r, TCGv_vec a, int64_t i); 440 void tcg_gen_shri_vec(unsigned vece, TCGv_vec r, TCGv_vec a, int64_t i); 441 void tcg_gen_sari_vec(unsigned vece, TCGv_vec r, TCGv_vec a, int64_t i); 442 void tcg_gen_rotli_vec(unsigned vece, TCGv_vec r, TCGv_vec a, int64_t i); 443 void tcg_gen_rotri_vec(unsigned vece, TCGv_vec r, TCGv_vec a, int64_t i); 444 445 void tcg_gen_shls_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_i32 s); 446 void tcg_gen_shrs_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_i32 s); 447 void tcg_gen_sars_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_i32 s); 448 void tcg_gen_rotls_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_i32 s); 449 450 void tcg_gen_shlv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec s); 451 void tcg_gen_shrv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec s); 452 void tcg_gen_sarv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec s); 453 void tcg_gen_rotlv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec s); 454 void tcg_gen_rotrv_vec(unsigned vece, TCGv_vec r, TCGv_vec a, TCGv_vec s); 455 456 void tcg_gen_cmp_vec(TCGCond cond, unsigned vece, TCGv_vec r, 457 TCGv_vec a, TCGv_vec b); 458 459 void tcg_gen_bitsel_vec(unsigned vece, TCGv_vec r, TCGv_vec a, 460 TCGv_vec b, TCGv_vec c); 461 void tcg_gen_cmpsel_vec(TCGCond cond, unsigned vece, TCGv_vec r, 462 TCGv_vec a, TCGv_vec b, TCGv_vec c, TCGv_vec d); 463 464 void tcg_gen_ld_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset); 465 void tcg_gen_st_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset); 466 void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t); 467 468 /* Host pointer ops */ 469 470 #if UINTPTR_MAX == UINT32_MAX 471 # define PTR i32 472 # define NAT TCGv_i32 473 #else 474 # define PTR i64 475 # define NAT TCGv_i64 476 #endif 477 478 TCGv_ptr tcg_constant_ptr_int(intptr_t x); 479 #define tcg_constant_ptr(X) tcg_constant_ptr_int((intptr_t)(X)) 480 481 static inline void tcg_gen_ld_ptr(TCGv_ptr r, TCGv_ptr a, intptr_t o) 482 { 483 glue(tcg_gen_ld_,PTR)((NAT)r, a, o); 484 } 485 486 static inline void tcg_gen_st_ptr(TCGv_ptr r, TCGv_ptr a, intptr_t o) 487 { 488 glue(tcg_gen_st_, PTR)((NAT)r, a, o); 489 } 490 491 static inline void tcg_gen_discard_ptr(TCGv_ptr a) 492 { 493 glue(tcg_gen_discard_,PTR)((NAT)a); 494 } 495 496 static inline void tcg_gen_add_ptr(TCGv_ptr r, TCGv_ptr a, TCGv_ptr b) 497 { 498 glue(tcg_gen_add_,PTR)((NAT)r, (NAT)a, (NAT)b); 499 } 500 501 static inline void tcg_gen_addi_ptr(TCGv_ptr r, TCGv_ptr a, intptr_t b) 502 { 503 glue(tcg_gen_addi_,PTR)((NAT)r, (NAT)a, b); 504 } 505 506 static inline void tcg_gen_mov_ptr(TCGv_ptr d, TCGv_ptr s) 507 { 508 glue(tcg_gen_mov_,PTR)((NAT)d, (NAT)s); 509 } 510 511 static inline void tcg_gen_movi_ptr(TCGv_ptr d, intptr_t s) 512 { 513 glue(tcg_gen_movi_,PTR)((NAT)d, s); 514 } 515 516 static inline void tcg_gen_brcondi_ptr(TCGCond cond, TCGv_ptr a, 517 intptr_t b, TCGLabel *label) 518 { 519 glue(tcg_gen_brcondi_,PTR)(cond, (NAT)a, b, label); 520 } 521 522 static inline void tcg_gen_ext_i32_ptr(TCGv_ptr r, TCGv_i32 a) 523 { 524 #if UINTPTR_MAX == UINT32_MAX 525 tcg_gen_mov_i32((NAT)r, a); 526 #else 527 tcg_gen_ext_i32_i64((NAT)r, a); 528 #endif 529 } 530 531 static inline void tcg_gen_trunc_i64_ptr(TCGv_ptr r, TCGv_i64 a) 532 { 533 #if UINTPTR_MAX == UINT32_MAX 534 tcg_gen_extrl_i64_i32((NAT)r, a); 535 #else 536 tcg_gen_mov_i64((NAT)r, a); 537 #endif 538 } 539 540 static inline void tcg_gen_extu_ptr_i64(TCGv_i64 r, TCGv_ptr a) 541 { 542 #if UINTPTR_MAX == UINT32_MAX 543 tcg_gen_extu_i32_i64(r, (NAT)a); 544 #else 545 tcg_gen_mov_i64(r, (NAT)a); 546 #endif 547 } 548 549 static inline void tcg_gen_trunc_ptr_i32(TCGv_i32 r, TCGv_ptr a) 550 { 551 #if UINTPTR_MAX == UINT32_MAX 552 tcg_gen_mov_i32(r, (NAT)a); 553 #else 554 tcg_gen_extrl_i64_i32(r, (NAT)a); 555 #endif 556 } 557 558 #undef PTR 559 #undef NAT 560 561 #endif /* TCG_TCG_OP_COMMON_H */ 562