From fff7ca4617fcc9d96ea76447df35ee0b7448fa69 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 1 Mar 2018 18:12:18 -0500 Subject: [PATCH] tcg: Add helpers for clrsb The number of actual invocations does not warrent an opcode, and the backends generating it. But at least we can eliminate redundant helpers. Backports commit 086920c2c8008f125fd38781072fa25c3ad158ea from qemu --- qemu/aarch64.h | 5 ++++- qemu/aarch64eb.h | 5 ++++- qemu/arm.h | 5 ++++- qemu/armeb.h | 5 ++++- qemu/header_gen.py | 5 ++++- qemu/m68k.h | 5 ++++- qemu/mips.h | 5 ++++- qemu/mips64.h | 5 ++++- qemu/mips64el.h | 5 ++++- qemu/mipsel.h | 5 ++++- qemu/powerpc.h | 5 ++++- qemu/sparc.h | 5 ++++- qemu/sparc64.h | 5 ++++- qemu/tcg-runtime.c | 10 ++++++++++ qemu/tcg/tcg-op.c | 28 ++++++++++++++++++++++++++++ qemu/tcg/tcg-op.h | 4 ++++ qemu/tcg/tcg-runtime.h | 2 ++ qemu/x86_64.h | 5 ++++- 18 files changed, 100 insertions(+), 14 deletions(-) diff --git a/qemu/aarch64.h b/qemu/aarch64.h index bd4c0030..6c8cd37e 100644 --- a/qemu/aarch64.h +++ b/qemu/aarch64.h @@ -1564,7 +1564,8 @@ #define helper_be_stq_mmu helper_be_stq_mmu_aarch64 #define helper_be_stw_mmu helper_be_stw_mmu_aarch64 #define helper_clear_pstate_ss helper_clear_pstate_ss_aarch64 -#define helper_clz_arm helper_clz_arm_aarch64 +#define helper_clrsb_i32 helper_clrsb_i32_aarch64 +#define helper_clrsb_i64 helper_clrsb_i64_aarch64 #define helper_clz_i32 helper_clz_i32_aarch64 #define helper_clz_i64 helper_clz_i64_aarch64 #define helper_ctz_i32 helper_ctz_i32_aarch64 @@ -3010,6 +3011,8 @@ #define tcg_gen_bswap32_i64 tcg_gen_bswap32_i64_aarch64 #define tcg_gen_bswap64_i64 tcg_gen_bswap64_i64_aarch64 #define tcg_gen_callN tcg_gen_callN_aarch64 +#define tcg_gen_clrsb_i32 tcg_gen_clrsb_i32_aarch64 +#define tcg_gen_clrsb_i64 tcg_gen_clrsb_i64_aarch64 #define tcg_gen_clz_i32 tcg_gen_clz_i32_aarch64 #define tcg_gen_clz_i64 tcg_gen_clz_i64_aarch64 #define tcg_gen_clzi_i32 tcg_gen_clzi_i32_aarch64 diff --git a/qemu/aarch64eb.h b/qemu/aarch64eb.h index 21c70afb..b380bbf5 100644 --- a/qemu/aarch64eb.h +++ b/qemu/aarch64eb.h @@ -1564,7 +1564,8 @@ #define helper_be_stq_mmu helper_be_stq_mmu_aarch64eb #define helper_be_stw_mmu helper_be_stw_mmu_aarch64eb #define helper_clear_pstate_ss helper_clear_pstate_ss_aarch64eb -#define helper_clz_arm helper_clz_arm_aarch64eb +#define helper_clrsb_i32 helper_clrsb_i32_aarch64eb +#define helper_clrsb_i64 helper_clrsb_i64_aarch64eb #define helper_clz_i32 helper_clz_i32_aarch64eb #define helper_clz_i64 helper_clz_i64_aarch64eb #define helper_ctz_i32 helper_ctz_i32_aarch64eb @@ -3010,6 +3011,8 @@ #define tcg_gen_bswap32_i64 tcg_gen_bswap32_i64_aarch64eb #define tcg_gen_bswap64_i64 tcg_gen_bswap64_i64_aarch64eb #define tcg_gen_callN tcg_gen_callN_aarch64eb +#define tcg_gen_clrsb_i32 tcg_gen_clrsb_i32_aarch64eb +#define tcg_gen_clrsb_i64 tcg_gen_clrsb_i64_aarch64eb #define tcg_gen_clz_i32 tcg_gen_clz_i32_aarch64eb #define tcg_gen_clz_i64 tcg_gen_clz_i64_aarch64eb #define tcg_gen_clzi_i32 tcg_gen_clzi_i32_aarch64eb diff --git a/qemu/arm.h b/qemu/arm.h index 2d807cac..451ca6f0 100644 --- a/qemu/arm.h +++ b/qemu/arm.h @@ -1564,7 +1564,8 @@ #define helper_be_stq_mmu helper_be_stq_mmu_arm #define helper_be_stw_mmu helper_be_stw_mmu_arm #define helper_clear_pstate_ss helper_clear_pstate_ss_arm -#define helper_clz_arm helper_clz_arm_arm +#define helper_clrsb_i32 helper_clrsb_i32_arm +#define helper_clrsb_i64 helper_clrsb_i64_arm #define helper_clz_i32 helper_clz_i32_arm #define helper_clz_i64 helper_clz_i64_arm #define helper_ctz_i32 helper_ctz_i32_arm @@ -3010,6 +3011,8 @@ #define tcg_gen_bswap32_i64 tcg_gen_bswap32_i64_arm #define tcg_gen_bswap64_i64 tcg_gen_bswap64_i64_arm #define tcg_gen_callN tcg_gen_callN_arm +#define tcg_gen_clrsb_i32 tcg_gen_clrsb_i32_arm +#define tcg_gen_clrsb_i64 tcg_gen_clrsb_i64_arm #define tcg_gen_clz_i32 tcg_gen_clz_i32_arm #define tcg_gen_clz_i64 tcg_gen_clz_i64_arm #define tcg_gen_clzi_i32 tcg_gen_clzi_i32_arm diff --git a/qemu/armeb.h b/qemu/armeb.h index 322e3058..1c97d147 100644 --- a/qemu/armeb.h +++ b/qemu/armeb.h @@ -1564,7 +1564,8 @@ #define helper_be_stq_mmu helper_be_stq_mmu_armeb #define helper_be_stw_mmu helper_be_stw_mmu_armeb #define helper_clear_pstate_ss helper_clear_pstate_ss_armeb -#define helper_clz_arm helper_clz_arm_armeb +#define helper_clrsb_i32 helper_clrsb_i32_armeb +#define helper_clrsb_i64 helper_clrsb_i64_armeb #define helper_clz_i32 helper_clz_i32_armeb #define helper_clz_i64 helper_clz_i64_armeb #define helper_ctz_i32 helper_ctz_i32_armeb @@ -3010,6 +3011,8 @@ #define tcg_gen_bswap32_i64 tcg_gen_bswap32_i64_armeb #define tcg_gen_bswap64_i64 tcg_gen_bswap64_i64_armeb #define tcg_gen_callN tcg_gen_callN_armeb +#define tcg_gen_clrsb_i32 tcg_gen_clrsb_i32_armeb +#define tcg_gen_clrsb_i64 tcg_gen_clrsb_i64_armeb #define tcg_gen_clz_i32 tcg_gen_clz_i32_armeb #define tcg_gen_clz_i64 tcg_gen_clz_i64_armeb #define tcg_gen_clzi_i32 tcg_gen_clzi_i32_armeb diff --git a/qemu/header_gen.py b/qemu/header_gen.py index 2b2d2299..71cee8a0 100644 --- a/qemu/header_gen.py +++ b/qemu/header_gen.py @@ -1570,7 +1570,8 @@ symbols = ( 'helper_be_stq_mmu', 'helper_be_stw_mmu', 'helper_clear_pstate_ss', - 'helper_clz_arm', + 'helper_clrsb_i32', + 'helper_clrsb_i64', 'helper_clz_i32', 'helper_clz_i64', 'helper_ctz_i32', @@ -3016,6 +3017,8 @@ symbols = ( 'tcg_gen_bswap32_i64', 'tcg_gen_bswap64_i64', 'tcg_gen_callN', + 'tcg_gen_clrsb_i32', + 'tcg_gen_clrsb_i64', 'tcg_gen_clz_i32', 'tcg_gen_clz_i64', 'tcg_gen_clzi_i32', diff --git a/qemu/m68k.h b/qemu/m68k.h index fce15cc5..e45f827e 100644 --- a/qemu/m68k.h +++ b/qemu/m68k.h @@ -1564,7 +1564,8 @@ #define helper_be_stq_mmu helper_be_stq_mmu_m68k #define helper_be_stw_mmu helper_be_stw_mmu_m68k #define helper_clear_pstate_ss helper_clear_pstate_ss_m68k -#define helper_clz_arm helper_clz_arm_m68k +#define helper_clrsb_i32 helper_clrsb_i32_m68k +#define helper_clrsb_i64 helper_clrsb_i64_m68k #define helper_clz_i32 helper_clz_i32_m68k #define helper_clz_i64 helper_clz_i64_m68k #define helper_ctz_i32 helper_ctz_i32_m68k @@ -3010,6 +3011,8 @@ #define tcg_gen_bswap32_i64 tcg_gen_bswap32_i64_m68k #define tcg_gen_bswap64_i64 tcg_gen_bswap64_i64_m68k #define tcg_gen_callN tcg_gen_callN_m68k +#define tcg_gen_clrsb_i32 tcg_gen_clrsb_i32_m68k +#define tcg_gen_clrsb_i64 tcg_gen_clrsb_i64_m68k #define tcg_gen_clz_i32 tcg_gen_clz_i32_m68k #define tcg_gen_clz_i64 tcg_gen_clz_i64_m68k #define tcg_gen_clzi_i32 tcg_gen_clzi_i32_m68k diff --git a/qemu/mips.h b/qemu/mips.h index 556a5e08..c4dff822 100644 --- a/qemu/mips.h +++ b/qemu/mips.h @@ -1564,7 +1564,8 @@ #define helper_be_stq_mmu helper_be_stq_mmu_mips #define helper_be_stw_mmu helper_be_stw_mmu_mips #define helper_clear_pstate_ss helper_clear_pstate_ss_mips -#define helper_clz_arm helper_clz_arm_mips +#define helper_clrsb_i32 helper_clrsb_i32_mips +#define helper_clrsb_i64 helper_clrsb_i64_mips #define helper_clz_i32 helper_clz_i32_mips #define helper_clz_i64 helper_clz_i64_mips #define helper_ctz_i32 helper_ctz_i32_mips @@ -3010,6 +3011,8 @@ #define tcg_gen_bswap32_i64 tcg_gen_bswap32_i64_mips #define tcg_gen_bswap64_i64 tcg_gen_bswap64_i64_mips #define tcg_gen_callN tcg_gen_callN_mips +#define tcg_gen_clrsb_i32 tcg_gen_clrsb_i32_mips +#define tcg_gen_clrsb_i64 tcg_gen_clrsb_i64_mips #define tcg_gen_clz_i32 tcg_gen_clz_i32_mips #define tcg_gen_clz_i64 tcg_gen_clz_i64_mips #define tcg_gen_clzi_i32 tcg_gen_clzi_i32_mips diff --git a/qemu/mips64.h b/qemu/mips64.h index fea9ce9a..e0c00d82 100644 --- a/qemu/mips64.h +++ b/qemu/mips64.h @@ -1564,7 +1564,8 @@ #define helper_be_stq_mmu helper_be_stq_mmu_mips64 #define helper_be_stw_mmu helper_be_stw_mmu_mips64 #define helper_clear_pstate_ss helper_clear_pstate_ss_mips64 -#define helper_clz_arm helper_clz_arm_mips64 +#define helper_clrsb_i32 helper_clrsb_i32_mips64 +#define helper_clrsb_i64 helper_clrsb_i64_mips64 #define helper_clz_i32 helper_clz_i32_mips64 #define helper_clz_i64 helper_clz_i64_mips64 #define helper_ctz_i32 helper_ctz_i32_mips64 @@ -3010,6 +3011,8 @@ #define tcg_gen_bswap32_i64 tcg_gen_bswap32_i64_mips64 #define tcg_gen_bswap64_i64 tcg_gen_bswap64_i64_mips64 #define tcg_gen_callN tcg_gen_callN_mips64 +#define tcg_gen_clrsb_i32 tcg_gen_clrsb_i32_mips64 +#define tcg_gen_clrsb_i64 tcg_gen_clrsb_i64_mips64 #define tcg_gen_clz_i32 tcg_gen_clz_i32_mips64 #define tcg_gen_clz_i64 tcg_gen_clz_i64_mips64 #define tcg_gen_clzi_i32 tcg_gen_clzi_i32_mips64 diff --git a/qemu/mips64el.h b/qemu/mips64el.h index 941cdd69..a7839ea2 100644 --- a/qemu/mips64el.h +++ b/qemu/mips64el.h @@ -1564,7 +1564,8 @@ #define helper_be_stq_mmu helper_be_stq_mmu_mips64el #define helper_be_stw_mmu helper_be_stw_mmu_mips64el #define helper_clear_pstate_ss helper_clear_pstate_ss_mips64el -#define helper_clz_arm helper_clz_arm_mips64el +#define helper_clrsb_i32 helper_clrsb_i32_mips64el +#define helper_clrsb_i64 helper_clrsb_i64_mips64el #define helper_clz_i32 helper_clz_i32_mips64el #define helper_clz_i64 helper_clz_i64_mips64el #define helper_ctz_i32 helper_ctz_i32_mips64el @@ -3010,6 +3011,8 @@ #define tcg_gen_bswap32_i64 tcg_gen_bswap32_i64_mips64el #define tcg_gen_bswap64_i64 tcg_gen_bswap64_i64_mips64el #define tcg_gen_callN tcg_gen_callN_mips64el +#define tcg_gen_clrsb_i32 tcg_gen_clrsb_i32_mips64el +#define tcg_gen_clrsb_i64 tcg_gen_clrsb_i64_mips64el #define tcg_gen_clz_i32 tcg_gen_clz_i32_mips64el #define tcg_gen_clz_i64 tcg_gen_clz_i64_mips64el #define tcg_gen_clzi_i32 tcg_gen_clzi_i32_mips64el diff --git a/qemu/mipsel.h b/qemu/mipsel.h index 4986d359..0a779c65 100644 --- a/qemu/mipsel.h +++ b/qemu/mipsel.h @@ -1564,7 +1564,8 @@ #define helper_be_stq_mmu helper_be_stq_mmu_mipsel #define helper_be_stw_mmu helper_be_stw_mmu_mipsel #define helper_clear_pstate_ss helper_clear_pstate_ss_mipsel -#define helper_clz_arm helper_clz_arm_mipsel +#define helper_clrsb_i32 helper_clrsb_i32_mipsel +#define helper_clrsb_i64 helper_clrsb_i64_mipsel #define helper_clz_i32 helper_clz_i32_mipsel #define helper_clz_i64 helper_clz_i64_mipsel #define helper_ctz_i32 helper_ctz_i32_mipsel @@ -3010,6 +3011,8 @@ #define tcg_gen_bswap32_i64 tcg_gen_bswap32_i64_mipsel #define tcg_gen_bswap64_i64 tcg_gen_bswap64_i64_mipsel #define tcg_gen_callN tcg_gen_callN_mipsel +#define tcg_gen_clrsb_i32 tcg_gen_clrsb_i32_mipsel +#define tcg_gen_clrsb_i64 tcg_gen_clrsb_i64_mipsel #define tcg_gen_clz_i32 tcg_gen_clz_i32_mipsel #define tcg_gen_clz_i64 tcg_gen_clz_i64_mipsel #define tcg_gen_clzi_i32 tcg_gen_clzi_i32_mipsel diff --git a/qemu/powerpc.h b/qemu/powerpc.h index e3709dfe..05c1b7e0 100644 --- a/qemu/powerpc.h +++ b/qemu/powerpc.h @@ -1564,7 +1564,8 @@ #define helper_be_stq_mmu helper_be_stq_mmu_powerpc #define helper_be_stw_mmu helper_be_stw_mmu_powerpc #define helper_clear_pstate_ss helper_clear_pstate_ss_powerpc -#define helper_clz_arm helper_clz_arm_powerpc +#define helper_clrsb_i32 helper_clrsb_i32_powerpc +#define helper_clrsb_i64 helper_clrsb_i64_powerpc #define helper_clz_i32 helper_clz_i32_powerpc #define helper_clz_i64 helper_clz_i64_powerpc #define helper_ctz_i32 helper_ctz_i32_powerpc @@ -3010,6 +3011,8 @@ #define tcg_gen_bswap32_i64 tcg_gen_bswap32_i64_powerpc #define tcg_gen_bswap64_i64 tcg_gen_bswap64_i64_powerpc #define tcg_gen_callN tcg_gen_callN_powerpc +#define tcg_gen_clrsb_i32 tcg_gen_clrsb_i32_powerpc +#define tcg_gen_clrsb_i64 tcg_gen_clrsb_i64_powerpc #define tcg_gen_clz_i32 tcg_gen_clz_i32_powerpc #define tcg_gen_clz_i64 tcg_gen_clz_i64_powerpc #define tcg_gen_clzi_i32 tcg_gen_clzi_i32_powerpc diff --git a/qemu/sparc.h b/qemu/sparc.h index 8ce4619c..4887977d 100644 --- a/qemu/sparc.h +++ b/qemu/sparc.h @@ -1564,7 +1564,8 @@ #define helper_be_stq_mmu helper_be_stq_mmu_sparc #define helper_be_stw_mmu helper_be_stw_mmu_sparc #define helper_clear_pstate_ss helper_clear_pstate_ss_sparc -#define helper_clz_arm helper_clz_arm_sparc +#define helper_clrsb_i32 helper_clrsb_i32_sparc +#define helper_clrsb_i64 helper_clrsb_i64_sparc #define helper_clz_i32 helper_clz_i32_sparc #define helper_clz_i64 helper_clz_i64_sparc #define helper_ctz_i32 helper_ctz_i32_sparc @@ -3010,6 +3011,8 @@ #define tcg_gen_bswap32_i64 tcg_gen_bswap32_i64_sparc #define tcg_gen_bswap64_i64 tcg_gen_bswap64_i64_sparc #define tcg_gen_callN tcg_gen_callN_sparc +#define tcg_gen_clrsb_i32 tcg_gen_clrsb_i32_sparc +#define tcg_gen_clrsb_i64 tcg_gen_clrsb_i64_sparc #define tcg_gen_clz_i32 tcg_gen_clz_i32_sparc #define tcg_gen_clz_i64 tcg_gen_clz_i64_sparc #define tcg_gen_clzi_i32 tcg_gen_clzi_i32_sparc diff --git a/qemu/sparc64.h b/qemu/sparc64.h index 933cc256..d036b260 100644 --- a/qemu/sparc64.h +++ b/qemu/sparc64.h @@ -1564,7 +1564,8 @@ #define helper_be_stq_mmu helper_be_stq_mmu_sparc64 #define helper_be_stw_mmu helper_be_stw_mmu_sparc64 #define helper_clear_pstate_ss helper_clear_pstate_ss_sparc64 -#define helper_clz_arm helper_clz_arm_sparc64 +#define helper_clrsb_i32 helper_clrsb_i32_sparc64 +#define helper_clrsb_i64 helper_clrsb_i64_sparc64 #define helper_clz_i32 helper_clz_i32_sparc64 #define helper_clz_i64 helper_clz_i64_sparc64 #define helper_ctz_i32 helper_ctz_i32_sparc64 @@ -3010,6 +3011,8 @@ #define tcg_gen_bswap32_i64 tcg_gen_bswap32_i64_sparc64 #define tcg_gen_bswap64_i64 tcg_gen_bswap64_i64_sparc64 #define tcg_gen_callN tcg_gen_callN_sparc64 +#define tcg_gen_clrsb_i32 tcg_gen_clrsb_i32_sparc64 +#define tcg_gen_clrsb_i64 tcg_gen_clrsb_i64_sparc64 #define tcg_gen_clz_i32 tcg_gen_clz_i32_sparc64 #define tcg_gen_clz_i64 tcg_gen_clz_i64_sparc64 #define tcg_gen_clzi_i32 tcg_gen_clzi_i32_sparc64 diff --git a/qemu/tcg-runtime.c b/qemu/tcg-runtime.c index e424f861..7aad5823 100644 --- a/qemu/tcg-runtime.c +++ b/qemu/tcg-runtime.c @@ -122,6 +122,16 @@ uint64_t HELPER(ctz_i64)(uint64_t arg, uint64_t zero_val) return arg ? ctz64(arg) : zero_val; } +uint32_t HELPER(clrsb_i32)(uint32_t arg) +{ + return clrsb32(arg); +} + +uint64_t HELPER(clrsb_i64)(uint64_t arg) +{ + return clrsb64(arg); +} + void HELPER(exit_atomic)(CPUArchState *env) { cpu_loop_exit_atomic(ENV_GET_CPU(env), GETPC()); diff --git a/qemu/tcg/tcg-op.c b/qemu/tcg/tcg-op.c index 82059b74..2d9d5fc7 100644 --- a/qemu/tcg/tcg-op.c +++ b/qemu/tcg/tcg-op.c @@ -535,6 +535,20 @@ void tcg_gen_ctzi_i32(TCGContext *s, TCGv_i32 ret, TCGv_i32 arg1, uint32_t arg2) tcg_temp_free_i32(s, t); } +void tcg_gen_clrsb_i32(TCGContext *s, TCGv_i32 ret, TCGv_i32 arg) +{ + if (TCG_TARGET_HAS_clz_i32) { + TCGv_i32 t = tcg_temp_new_i32(s); + tcg_gen_sari_i32(s, t, arg, 31); + tcg_gen_xor_i32(s, t, t, arg); + tcg_gen_clzi_i32(s, t, t, 32); + tcg_gen_subi_i32(s, ret, t, 1); + tcg_temp_free_i32(s, t); + } else { + gen_helper_clrsb_i32(s, ret, arg); + } +} + void tcg_gen_rotl_i32(TCGContext *s, TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) { if (TCG_TARGET_HAS_rot_i32) { @@ -1852,6 +1866,20 @@ void tcg_gen_ctzi_i64(TCGContext *s, TCGv_i64 ret, TCGv_i64 arg1, uint64_t arg2) } } +void tcg_gen_clrsb_i64(TCGContext *s, TCGv_i64 ret, TCGv_i64 arg) +{ + if (TCG_TARGET_HAS_clz_i64 || TCG_TARGET_HAS_clz_i32) { + TCGv_i64 t = tcg_temp_new_i64(s); + tcg_gen_sari_i64(s, t, arg, 63); + tcg_gen_xor_i64(s, t, t, arg); + tcg_gen_clzi_i64(s, t, t, 64); + tcg_gen_subi_i64(s, ret, t, 1); + tcg_temp_free_i64(s, t); + } else { + gen_helper_clrsb_i64(s, ret, arg); + } +} + void tcg_gen_rotl_i64(TCGContext *s, TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) { if (TCG_TARGET_HAS_rot_i64) { diff --git a/qemu/tcg/tcg-op.h b/qemu/tcg/tcg-op.h index 1d9a0ab8..37b5d7ca 100644 --- a/qemu/tcg/tcg-op.h +++ b/qemu/tcg/tcg-op.h @@ -298,6 +298,7 @@ void tcg_gen_clz_i32(TCGContext *s, TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); void tcg_gen_ctz_i32(TCGContext *s, TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); void tcg_gen_clzi_i32(TCGContext *s, TCGv_i32 ret, TCGv_i32 arg1, uint32_t arg2); void tcg_gen_ctzi_i32(TCGContext *s, TCGv_i32 ret, TCGv_i32 arg1, uint32_t arg2); +void tcg_gen_clrsb_i32(TCGContext *s, TCGv_i32 ret, TCGv_i32 arg); void tcg_gen_rotl_i32(TCGContext *s, TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); void tcg_gen_rotli_i32(TCGContext *s, TCGv_i32 ret, TCGv_i32 arg1, unsigned arg2); void tcg_gen_rotr_i32(TCGContext *s, TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2); @@ -477,6 +478,7 @@ void tcg_gen_clz_i64(TCGContext *s, TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); void tcg_gen_ctz_i64(TCGContext *s, TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); void tcg_gen_clzi_i64(TCGContext *s, TCGv_i64 ret, TCGv_i64 arg1, uint64_t arg2); void tcg_gen_ctzi_i64(TCGContext *s, TCGv_i64 ret, TCGv_i64 arg1, uint64_t arg2); +void tcg_gen_clrsb_i64(TCGContext *s, TCGv_i64 ret, TCGv_i64 arg); void tcg_gen_rotl_i64(TCGContext *s, TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); void tcg_gen_rotli_i64(TCGContext *s, TCGv_i64 ret, TCGv_i64 arg1, unsigned arg2); void tcg_gen_rotr_i64(TCGContext *s, TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2); @@ -972,6 +974,7 @@ void tcg_gen_atomic_xor_fetch_i64(TCGContext *, TCGv_i64, TCGv, TCGv_i64, TCGArg #define tcg_gen_ctz_tl tcg_gen_ctz_i64 #define tcg_gen_clzi_tl tcg_gen_clzi_i64 #define tcg_gen_ctzi_tl tcg_gen_ctzi_i64 +#define tcg_gen_clrsb_tl tcg_gen_clrsb_i64 #define tcg_gen_rotl_tl tcg_gen_rotl_i64 #define tcg_gen_rotli_tl tcg_gen_rotli_i64 #define tcg_gen_rotr_tl tcg_gen_rotr_i64 @@ -1067,6 +1070,7 @@ void tcg_gen_atomic_xor_fetch_i64(TCGContext *, TCGv_i64, TCGv, TCGv_i64, TCGArg #define tcg_gen_ctz_tl tcg_gen_ctz_i32 #define tcg_gen_clzi_tl tcg_gen_clzi_i32 #define tcg_gen_ctzi_tl tcg_gen_ctzi_i32 +#define tcg_gen_clrsb_tl tcg_gen_clrsb_i32 #define tcg_gen_rotl_tl tcg_gen_rotl_i32 #define tcg_gen_rotli_tl tcg_gen_rotli_i32 #define tcg_gen_rotr_tl tcg_gen_rotr_i32 diff --git a/qemu/tcg/tcg-runtime.h b/qemu/tcg/tcg-runtime.h index 494496f5..9b22d2bd 100644 --- a/qemu/tcg/tcg-runtime.h +++ b/qemu/tcg/tcg-runtime.h @@ -19,6 +19,8 @@ DEF_HELPER_FLAGS_2(clz_i32, TCG_CALL_NO_RWG_SE, i32, i32, i32) DEF_HELPER_FLAGS_2(ctz_i32, TCG_CALL_NO_RWG_SE, i32, i32, i32) DEF_HELPER_FLAGS_2(clz_i64, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(ctz_i64, TCG_CALL_NO_RWG_SE, i64, i64, i64) +DEF_HELPER_FLAGS_1(clrsb_i32, TCG_CALL_NO_RWG_SE, i32, i32) +DEF_HELPER_FLAGS_1(clrsb_i64, TCG_CALL_NO_RWG_SE, i64, i64) DEF_HELPER_FLAGS_1(exit_atomic, TCG_CALL_NO_WG, noreturn, env) diff --git a/qemu/x86_64.h b/qemu/x86_64.h index 4ec21558..f8a30c3f 100644 --- a/qemu/x86_64.h +++ b/qemu/x86_64.h @@ -1564,7 +1564,8 @@ #define helper_be_stq_mmu helper_be_stq_mmu_x86_64 #define helper_be_stw_mmu helper_be_stw_mmu_x86_64 #define helper_clear_pstate_ss helper_clear_pstate_ss_x86_64 -#define helper_clz_arm helper_clz_arm_x86_64 +#define helper_clrsb_i32 helper_clrsb_i32_x86_64 +#define helper_clrsb_i64 helper_clrsb_i64_x86_64 #define helper_clz_i32 helper_clz_i32_x86_64 #define helper_clz_i64 helper_clz_i64_x86_64 #define helper_ctz_i32 helper_ctz_i32_x86_64 @@ -3010,6 +3011,8 @@ #define tcg_gen_bswap32_i64 tcg_gen_bswap32_i64_x86_64 #define tcg_gen_bswap64_i64 tcg_gen_bswap64_i64_x86_64 #define tcg_gen_callN tcg_gen_callN_x86_64 +#define tcg_gen_clrsb_i32 tcg_gen_clrsb_i32_x86_64 +#define tcg_gen_clrsb_i64 tcg_gen_clrsb_i64_x86_64 #define tcg_gen_clz_i32 tcg_gen_clz_i32_x86_64 #define tcg_gen_clz_i64 tcg_gen_clz_i64_x86_64 #define tcg_gen_clzi_i32 tcg_gen_clzi_i32_x86_64