Signed-off-by: Richard Henderson <[email protected]>
---
include/tcg/tcg-op-common.h | 2 --
include/tcg/tcg-op-def.h.inc | 1 +
tcg/tcg-op.c | 41 +++++++++++++++---------------------
3 files changed, 18 insertions(+), 26 deletions(-)
diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h
index b477d980a3e..b3cd4bbf63b 100644
--- a/include/tcg/tcg-op-common.h
+++ b/include/tcg/tcg-op-common.h
@@ -132,7 +132,6 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo);
void tcg_gen_ctz_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
void tcg_gen_ctzi_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2);
void tcg_gen_clrsb_i32(TCGv_i32 ret, TCGv_i32 arg);
-void tcg_gen_ctpop_i32(TCGv_i32 a1, TCGv_i32 a2);
void tcg_gen_rotl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
void tcg_gen_rotli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2);
void tcg_gen_rotr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2);
@@ -191,7 +190,6 @@ void tcg_gen_st_i32(TCGv_i32 arg1, TCGv_ptr arg2,
tcg_target_long offset);
void tcg_gen_ctz_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
void tcg_gen_ctzi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2);
void tcg_gen_clrsb_i64(TCGv_i64 ret, TCGv_i64 arg);
-void tcg_gen_ctpop_i64(TCGv_i64 a1, TCGv_i64 a2);
void tcg_gen_rotl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
void tcg_gen_rotli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2);
void tcg_gen_rotr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2);
diff --git a/include/tcg/tcg-op-def.h.inc b/include/tcg/tcg-op-def.h.inc
index 7d0d219918f..2de0aacd93c 100644
--- a/include/tcg/tcg-op-def.h.inc
+++ b/include/tcg/tcg-op-def.h.inc
@@ -9,6 +9,7 @@ DEF4(brcond, TCGCond, TCGV, TCGV, TCGLabelPtr)
DEF4(brcondi, TCGCond, TCGV, TINT, TCGLabelPtr)
DEF3(clz, TCGV, TCGV, TCGV)
DEF3(clzi, TCGV, TCGV, TINT)
+DEF2(ctpop, TCGV, TCGV)
DEF1(discard, TCGV)
DEF3(div, TCGV, TCGV, TCGV)
DEF3(divu, TCGV, TCGV, TCGV)
diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
index afab6fd3c82..abc78e480d0 100644
--- a/tcg/tcg-op.c
+++ b/tcg/tcg-op.c
@@ -523,6 +523,23 @@ static void gen_clzi(TCGType type, TCGTemp *dst, TCGTemp
*src1, int64_t src2)
gen_clz(type, dst, src1, tcg_constant_internal(type, src2));
}
+static void gen_ctpop(TCGType type, TCGTemp *dst, TCGTemp *src)
+{
+ if (tcg_op_supported(INDEX_op_ctpop, type, 0)) {
+ gen_op_tt(INDEX_op_ctpop, type, dst, src);
+ } else if (type == TCG_TYPE_I64) {
+ gen_helper_ctpop_i64(temp_tcgv_i64(dst), temp_tcgv_i64(src));
+ } else if (tcg_op_supported(INDEX_op_ctpop, TCG_TYPE_I64, 0)) {
+ g_autoptr(TCGTemp) tmp = tcg_temp_new_ebb(TCG_TYPE_I64);
+
+ gen_extu_i32_i64(tmp, src);
+ gen_op_tt(INDEX_op_ctpop, TCG_TYPE_I64, tmp, src);
+ gen_extrl_i64_i32(dst, tmp);
+ } else {
+ gen_helper_ctpop_i32(temp_tcgv_i32(dst), temp_tcgv_i32(src));
+ }
+}
+
static void gen_discard(TCGType type, TCGTemp *src)
{
tcg_gen_op1(INDEX_op_discard, type, temp_arg(src));
@@ -920,21 +937,6 @@ void tcg_gen_clrsb_i32(TCGv_i32 ret, TCGv_i32 arg)
}
}
-void tcg_gen_ctpop_i32(TCGv_i32 ret, TCGv_i32 arg1)
-{
- if (tcg_op_supported(INDEX_op_ctpop, TCG_TYPE_I32, 0)) {
- tcg_gen_op2_i32(INDEX_op_ctpop, ret, arg1);
- } else if (tcg_op_supported(INDEX_op_ctpop, TCG_TYPE_I64, 0)) {
- TCGv_i64 t = tcg_temp_ebb_new_i64();
- tcg_gen_extu_i32_i64(t, arg1);
- tcg_gen_ctpop_i64(t, t);
- tcg_gen_extrl_i64_i32(ret, t);
- tcg_temp_free_i64(t);
- } else {
- gen_helper_ctpop_i32(ret, arg1);
- }
-}
-
void tcg_gen_rotl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
{
if (tcg_op_supported(INDEX_op_rotl, TCG_TYPE_I32, 0)) {
@@ -1825,15 +1827,6 @@ void tcg_gen_clrsb_i64(TCGv_i64 ret, TCGv_i64 arg)
}
}
-void tcg_gen_ctpop_i64(TCGv_i64 ret, TCGv_i64 arg1)
-{
- if (tcg_op_supported(INDEX_op_ctpop, TCG_TYPE_I64, 0)) {
- tcg_gen_op2_i64(INDEX_op_ctpop, ret, arg1);
- } else {
- gen_helper_ctpop_i64(ret, arg1);
- }
-}
-
void tcg_gen_rotl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
{
if (tcg_op_supported(INDEX_op_rotl, TCG_TYPE_I64, 0)) {
--
2.53.0