diff options
Diffstat (limited to 'tcg/tcg-op.h')
-rw-r--r-- | tcg/tcg-op.h | 164 |
1 files changed, 129 insertions, 35 deletions
diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index b92b7bd162..469e444d5c 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -178,88 +178,115 @@ static inline void tcg_gen_movi_i32(TCGv ret, int32_t arg) static inline void tcg_gen_helper_0_0(void *func) { + TCGv t0; + t0 = tcg_const_ptr((tcg_target_long)func); tcg_gen_call(&tcg_ctx, - tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS, + t0, TCG_HELPER_CALL_FLAGS, 0, NULL, 0, NULL); + tcg_temp_free(t0); } static inline void tcg_gen_helper_0_1(void *func, TCGv arg) { + TCGv t0; + t0 = tcg_const_ptr((tcg_target_long)func); tcg_gen_call(&tcg_ctx, - tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS, + t0, TCG_HELPER_CALL_FLAGS, 0, NULL, 1, &arg); + tcg_temp_free(t0); } static inline void tcg_gen_helper_0_2(void *func, TCGv arg1, TCGv arg2) { TCGv args[2]; + TCGv t0; args[0] = arg1; args[1] = arg2; + t0 = tcg_const_ptr((tcg_target_long)func); tcg_gen_call(&tcg_ctx, - tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS, + t0, TCG_HELPER_CALL_FLAGS, 0, NULL, 2, args); + tcg_temp_free(t0); } static inline void tcg_gen_helper_0_3(void *func, TCGv arg1, TCGv arg2, TCGv arg3) { TCGv args[3]; + TCGv t0; args[0] = arg1; args[1] = arg2; args[2] = arg3; + t0 = tcg_const_ptr((tcg_target_long)func); tcg_gen_call(&tcg_ctx, - tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS, + t0, TCG_HELPER_CALL_FLAGS, 0, NULL, 3, args); + tcg_temp_free(t0); } static inline void tcg_gen_helper_0_4(void *func, TCGv arg1, TCGv arg2, TCGv arg3, TCGv arg4) { TCGv args[4]; + TCGv t0; args[0] = arg1; args[1] = arg2; args[2] = arg3; args[3] = arg4; + t0 = tcg_const_ptr((tcg_target_long)func); tcg_gen_call(&tcg_ctx, - tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS, + t0, TCG_HELPER_CALL_FLAGS, 0, NULL, 4, args); + tcg_temp_free(t0); } static inline void tcg_gen_helper_1_0(void *func, TCGv ret) { + TCGv t0; + t0 = tcg_const_ptr((tcg_target_long)func); tcg_gen_call(&tcg_ctx, - tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS, + t0, TCG_HELPER_CALL_FLAGS, 1, &ret, 0, NULL); + tcg_temp_free(t0); } static inline void tcg_gen_helper_1_1(void *func, TCGv ret, TCGv arg1) { + TCGv t0; + t0 = tcg_const_ptr((tcg_target_long)func); tcg_gen_call(&tcg_ctx, - tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS, + t0, TCG_HELPER_CALL_FLAGS, 1, &ret, 1, &arg1); + tcg_temp_free(t0); } static inline void tcg_gen_helper_1_2(void *func, TCGv ret, TCGv arg1, TCGv arg2) { TCGv args[2]; + TCGv t0; args[0] = arg1; args[1] = arg2; + t0 = tcg_const_ptr((tcg_target_long)func); tcg_gen_call(&tcg_ctx, - tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS, + t0, TCG_HELPER_CALL_FLAGS, 1, &ret, 2, args); + tcg_temp_free(t0); } static inline void tcg_gen_helper_1_3(void *func, TCGv ret, TCGv arg1, TCGv arg2, TCGv arg3) { TCGv args[3]; + TCGv t0; args[0] = arg1; args[1] = arg2; args[2] = arg3; + t0 = tcg_const_ptr((tcg_target_long)func); tcg_gen_call(&tcg_ctx, - tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS, + t0, TCG_HELPER_CALL_FLAGS, 1, &ret, 3, args); + tcg_temp_free(t0); } static inline void tcg_gen_helper_1_4(void *func, TCGv ret, @@ -267,13 +294,16 @@ static inline void tcg_gen_helper_1_4(void *func, TCGv ret, TCGv arg4) { TCGv args[4]; + TCGv t0; args[0] = arg1; args[1] = arg2; args[2] = arg3; args[3] = arg4; + t0 = tcg_const_ptr((tcg_target_long)func); tcg_gen_call(&tcg_ctx, - tcg_const_ptr((tcg_target_long)func), TCG_HELPER_CALL_FLAGS, + t0, TCG_HELPER_CALL_FLAGS, 1, &ret, 4, args); + tcg_temp_free(t0); } /* 32 bit ops */ @@ -329,7 +359,9 @@ static inline void tcg_gen_addi_i32(TCGv ret, TCGv arg1, int32_t arg2) if (arg2 == 0) { tcg_gen_mov_i32(ret, arg1); } else { - tcg_gen_add_i32(ret, arg1, tcg_const_i32(arg2)); + TCGv t0 = tcg_const_i32(arg2); + tcg_gen_add_i32(ret, arg1, t0); + tcg_temp_free(t0); } } @@ -344,7 +376,9 @@ static inline void tcg_gen_subi_i32(TCGv ret, TCGv arg1, int32_t arg2) if (arg2 == 0) { tcg_gen_mov_i32(ret, arg1); } else { - tcg_gen_sub_i32(ret, arg1, tcg_const_i32(arg2)); + TCGv t0 = tcg_const_i32(arg2); + tcg_gen_sub_i32(ret, arg1, t0); + tcg_temp_free(t0); } } @@ -361,7 +395,9 @@ static inline void tcg_gen_andi_i32(TCGv ret, TCGv arg1, int32_t arg2) } else if (arg2 == 0xffffffff) { tcg_gen_mov_i32(ret, arg1); } else { - tcg_gen_and_i32(ret, arg1, tcg_const_i32(arg2)); + TCGv t0 = tcg_const_i32(arg2); + tcg_gen_and_i32(ret, arg1, t0); + tcg_temp_free(t0); } } @@ -378,7 +414,9 @@ static inline void tcg_gen_ori_i32(TCGv ret, TCGv arg1, int32_t arg2) } else if (arg2 == 0) { tcg_gen_mov_i32(ret, arg1); } else { - tcg_gen_or_i32(ret, arg1, tcg_const_i32(arg2)); + TCGv t0 = tcg_const_i32(arg2); + tcg_gen_or_i32(ret, arg1, t0); + tcg_temp_free(t0); } } @@ -393,7 +431,9 @@ static inline void tcg_gen_xori_i32(TCGv ret, TCGv arg1, int32_t arg2) if (arg2 == 0) { tcg_gen_mov_i32(ret, arg1); } else { - tcg_gen_xor_i32(ret, arg1, tcg_const_i32(arg2)); + TCGv t0 = tcg_const_i32(arg2); + tcg_gen_xor_i32(ret, arg1, t0); + tcg_temp_free(t0); } } @@ -407,7 +447,9 @@ static inline void tcg_gen_shli_i32(TCGv ret, TCGv arg1, int32_t arg2) if (arg2 == 0) { tcg_gen_mov_i32(ret, arg1); } else { - tcg_gen_shl_i32(ret, arg1, tcg_const_i32(arg2)); + TCGv t0 = tcg_const_i32(arg2); + tcg_gen_shl_i32(ret, arg1, t0); + tcg_temp_free(t0); } } @@ -421,7 +463,9 @@ static inline void tcg_gen_shri_i32(TCGv ret, TCGv arg1, int32_t arg2) if (arg2 == 0) { tcg_gen_mov_i32(ret, arg1); } else { - tcg_gen_shr_i32(ret, arg1, tcg_const_i32(arg2)); + TCGv t0 = tcg_const_i32(arg2); + tcg_gen_shr_i32(ret, arg1, t0); + tcg_temp_free(t0); } } @@ -435,7 +479,9 @@ static inline void tcg_gen_sari_i32(TCGv ret, TCGv arg1, int32_t arg2) if (arg2 == 0) { tcg_gen_mov_i32(ret, arg1); } else { - tcg_gen_sar_i32(ret, arg1, tcg_const_i32(arg2)); + TCGv t0 = tcg_const_i32(arg2); + tcg_gen_sar_i32(ret, arg1, t0); + tcg_temp_free(t0); } } @@ -452,7 +498,9 @@ static inline void tcg_gen_mul_i32(TCGv ret, TCGv arg1, TCGv arg2) static inline void tcg_gen_muli_i32(TCGv ret, TCGv arg1, int32_t arg2) { - tcg_gen_mul_i32(ret, arg1, tcg_const_i32(arg2)); + TCGv t0 = tcg_const_i32(arg2); + tcg_gen_mul_i32(ret, arg1, t0); + tcg_temp_free(t0); } #ifdef TCG_TARGET_HAS_div_i32 @@ -482,6 +530,7 @@ static inline void tcg_gen_div_i32(TCGv ret, TCGv arg1, TCGv arg2) t0 = tcg_temp_new(TCG_TYPE_I32); tcg_gen_sari_i32(t0, arg1, 31); tcg_gen_op5(INDEX_op_div2_i32, ret, t0, arg1, t0, arg2); + tcg_temp_free(t0); } static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2) @@ -490,6 +539,7 @@ static inline void tcg_gen_rem_i32(TCGv ret, TCGv arg1, TCGv arg2) t0 = tcg_temp_new(TCG_TYPE_I32); tcg_gen_sari_i32(t0, arg1, 31); tcg_gen_op5(INDEX_op_div2_i32, t0, ret, arg1, t0, arg2); + tcg_temp_free(t0); } static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2) @@ -498,6 +548,7 @@ static inline void tcg_gen_divu_i32(TCGv ret, TCGv arg1, TCGv arg2) t0 = tcg_temp_new(TCG_TYPE_I32); tcg_gen_movi_i32(t0, 0); tcg_gen_op5(INDEX_op_divu2_i32, ret, t0, arg1, t0, arg2); + tcg_temp_free(t0); } static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2) @@ -506,6 +557,7 @@ static inline void tcg_gen_remu_i32(TCGv ret, TCGv arg1, TCGv arg2) t0 = tcg_temp_new(TCG_TYPE_I32); tcg_gen_movi_i32(t0, 0); tcg_gen_op5(INDEX_op_divu2_i32, t0, ret, arg1, t0, arg2); + tcg_temp_free(t0); } #endif @@ -608,7 +660,9 @@ static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2) static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2) { - tcg_gen_add_i64(ret, arg1, tcg_const_i64(arg2)); + TCGv t0 = tcg_const_i64(arg2); + tcg_gen_add_i64(ret, arg1, t0); + tcg_temp_free(t0); } static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2) @@ -619,7 +673,9 @@ static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2) static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2) { - tcg_gen_sub_i64(ret, arg1, tcg_const_i64(arg2)); + TCGv t0 = tcg_const_i64(arg2); + tcg_gen_sub_i64(ret, arg1, t0); + tcg_temp_free(t0); } static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2) @@ -713,11 +769,15 @@ static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2) tcg_gen_add_i32(TCGV_HIGH(t0), TCGV_HIGH(t0), t1); tcg_gen_mov_i64(ret, t0); + tcg_temp_free(t0); + tcg_temp_free(t1); } static inline void tcg_gen_muli_i64(TCGv ret, TCGv arg1, int64_t arg2) { - tcg_gen_mul_i64(ret, arg1, tcg_const_i64(arg2)); + TCGv t0 = tcg_const_i64(arg2); + tcg_gen_mul_i64(ret, arg1, t0); + tcg_temp_free(t0); } static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2) @@ -824,7 +884,9 @@ static inline void tcg_gen_add_i64(TCGv ret, TCGv arg1, TCGv arg2) static inline void tcg_gen_addi_i64(TCGv ret, TCGv arg1, int64_t arg2) { - tcg_gen_add_i64(ret, arg1, tcg_const_i64(arg2)); + TCGv t0 = tcg_const_i64(arg2); + tcg_gen_add_i64(ret, arg1, t0); + tcg_temp_free(t0); } static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2) @@ -834,7 +896,9 @@ static inline void tcg_gen_sub_i64(TCGv ret, TCGv arg1, TCGv arg2) static inline void tcg_gen_subi_i64(TCGv ret, TCGv arg1, int64_t arg2) { - tcg_gen_sub_i64(ret, arg1, tcg_const_i64(arg2)); + TCGv t0 = tcg_const_i64(arg2); + tcg_gen_sub_i64(ret, arg1, t0); + tcg_temp_free(t0); } static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2) @@ -844,7 +908,9 @@ static inline void tcg_gen_and_i64(TCGv ret, TCGv arg1, TCGv arg2) static inline void tcg_gen_andi_i64(TCGv ret, TCGv arg1, int64_t arg2) { - tcg_gen_and_i64(ret, arg1, tcg_const_i64(arg2)); + TCGv t0 = tcg_const_i64(arg2); + tcg_gen_and_i64(ret, arg1, t0); + tcg_temp_free(t0); } static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2) @@ -854,7 +920,9 @@ static inline void tcg_gen_or_i64(TCGv ret, TCGv arg1, TCGv arg2) static inline void tcg_gen_ori_i64(TCGv ret, TCGv arg1, int64_t arg2) { - tcg_gen_or_i64(ret, arg1, tcg_const_i64(arg2)); + TCGv t0 = tcg_const_i64(arg2); + tcg_gen_or_i64(ret, arg1, t0); + tcg_temp_free(t0); } static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2) @@ -864,7 +932,9 @@ static inline void tcg_gen_xor_i64(TCGv ret, TCGv arg1, TCGv arg2) static inline void tcg_gen_xori_i64(TCGv ret, TCGv arg1, int64_t arg2) { - tcg_gen_xor_i64(ret, arg1, tcg_const_i64(arg2)); + TCGv t0 = tcg_const_i64(arg2); + tcg_gen_xor_i64(ret, arg1, t0); + tcg_temp_free(t0); } static inline void tcg_gen_shl_i64(TCGv ret, TCGv arg1, TCGv arg2) @@ -877,7 +947,9 @@ static inline void tcg_gen_shli_i64(TCGv ret, TCGv arg1, int64_t arg2) if (arg2 == 0) { tcg_gen_mov_i64(ret, arg1); } else { - tcg_gen_shl_i64(ret, arg1, tcg_const_i64(arg2)); + TCGv t0 = tcg_const_i64(arg2); + tcg_gen_shl_i64(ret, arg1, t0); + tcg_temp_free(t0); } } @@ -891,7 +963,9 @@ static inline void tcg_gen_shri_i64(TCGv ret, TCGv arg1, int64_t arg2) if (arg2 == 0) { tcg_gen_mov_i64(ret, arg1); } else { - tcg_gen_shr_i64(ret, arg1, tcg_const_i64(arg2)); + TCGv t0 = tcg_const_i64(arg2); + tcg_gen_shr_i64(ret, arg1, t0); + tcg_temp_free(t0); } } @@ -905,7 +979,9 @@ static inline void tcg_gen_sari_i64(TCGv ret, TCGv arg1, int64_t arg2) if (arg2 == 0) { tcg_gen_mov_i64(ret, arg1); } else { - tcg_gen_sar_i64(ret, arg1, tcg_const_i64(arg2)); + TCGv t0 = tcg_const_i64(arg2); + tcg_gen_sar_i64(ret, arg1, t0); + tcg_temp_free(t0); } } @@ -922,7 +998,9 @@ static inline void tcg_gen_mul_i64(TCGv ret, TCGv arg1, TCGv arg2) static inline void tcg_gen_muli_i64(TCGv ret, TCGv arg1, int64_t arg2) { - tcg_gen_mul_i64(ret, arg1, tcg_const_i64(arg2)); + TCGv t0 = tcg_const_i64(arg2); + tcg_gen_mul_i64(ret, arg1, t0); + tcg_temp_free(t0); } #ifdef TCG_TARGET_HAS_div_i64 @@ -952,6 +1030,7 @@ static inline void tcg_gen_div_i64(TCGv ret, TCGv arg1, TCGv arg2) t0 = tcg_temp_new(TCG_TYPE_I64); tcg_gen_sari_i64(t0, arg1, 63); tcg_gen_op5(INDEX_op_div2_i64, ret, t0, arg1, t0, arg2); + tcg_temp_free(t0); } static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2) @@ -960,6 +1039,7 @@ static inline void tcg_gen_rem_i64(TCGv ret, TCGv arg1, TCGv arg2) t0 = tcg_temp_new(TCG_TYPE_I64); tcg_gen_sari_i64(t0, arg1, 63); tcg_gen_op5(INDEX_op_div2_i64, t0, ret, arg1, t0, arg2); + tcg_temp_free(t0); } static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2) @@ -968,6 +1048,7 @@ static inline void tcg_gen_divu_i64(TCGv ret, TCGv arg1, TCGv arg2) t0 = tcg_temp_new(TCG_TYPE_I64); tcg_gen_movi_i64(t0, 0); tcg_gen_op5(INDEX_op_divu2_i64, ret, t0, arg1, t0, arg2); + tcg_temp_free(t0); } static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2) @@ -976,6 +1057,7 @@ static inline void tcg_gen_remu_i64(TCGv ret, TCGv arg1, TCGv arg2) t0 = tcg_temp_new(TCG_TYPE_I64); tcg_gen_movi_i64(t0, 0); tcg_gen_op5(INDEX_op_divu2_i64, t0, ret, arg1, t0, arg2); + tcg_temp_free(t0); } #endif @@ -1030,6 +1112,8 @@ static inline void tcg_gen_bswap16_i32(TCGv ret, TCGv arg) tcg_gen_andi_i32(t1, arg, 0x000000ff); tcg_gen_shli_i32(t1, t1, 8); tcg_gen_or_i32(ret, t0, t1); + tcg_temp_free(t0); + tcg_temp_free(t1); #endif } @@ -1054,6 +1138,8 @@ static inline void tcg_gen_bswap_i32(TCGv ret, TCGv arg) tcg_gen_shri_i32(t1, arg, 24); tcg_gen_or_i32(ret, t0, t1); + tcg_temp_free(t0); + tcg_temp_free(t1); #endif } @@ -1121,6 +1207,8 @@ static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg) tcg_gen_bswap_i32(t1, TCGV_HIGH(arg)); tcg_gen_mov_i32(ret, t1); tcg_gen_mov_i32(TCGV_HIGH(ret), t0); + tcg_temp_free(t0); + tcg_temp_free(t1); } #else @@ -1227,6 +1315,8 @@ static inline void tcg_gen_bswap_i64(TCGv ret, TCGv arg) tcg_gen_shri_i64(t1, arg, 56); tcg_gen_or_i64(ret, t0, t1); + tcg_temp_free(t0); + tcg_temp_free(t1); #endif } @@ -1237,7 +1327,9 @@ static inline void tcg_gen_neg_i32(TCGv ret, TCGv arg) #ifdef TCG_TARGET_HAS_neg_i32 tcg_gen_op2(INDEX_op_neg_i32, ret, arg); #else - tcg_gen_sub_i32(ret, tcg_const_i32(0), arg); + TCGv t0 = tcg_const_i32(0); + tcg_gen_sub_i32(ret, t0, arg); + tcg_temp_free(t0); #endif } @@ -1246,18 +1338,20 @@ static inline void tcg_gen_neg_i64(TCGv ret, TCGv arg) #ifdef TCG_TARGET_HAS_neg_i64 tcg_gen_op2(INDEX_op_neg_i64, ret, arg); #else - tcg_gen_sub_i64(ret, tcg_const_i64(0), arg); + TCGv t0 = tcg_const_i64(0); + tcg_gen_sub_i64(ret, t0, arg); + tcg_temp_free(t0); #endif } static inline void tcg_gen_not_i32(TCGv ret, TCGv arg) { - tcg_gen_xor_i32(ret, arg, tcg_const_i32(-1)); + tcg_gen_xori_i32(ret, arg, -1); } static inline void tcg_gen_not_i64(TCGv ret, TCGv arg) { - tcg_gen_xor_i64(ret, arg, tcg_const_i64(-1)); + tcg_gen_xori_i64(ret, arg, -1); } static inline void tcg_gen_discard_i32(TCGv arg) |