Signed-off-by: Richard Henderson <[email protected]>
---
include/tcg/tcg-op-common.h | 2 --
include/tcg/tcg-op-def2.h.inc | 1 +
tcg/tcg-op.c | 63 ++++++++++++-----------------------
3 files changed, 22 insertions(+), 44 deletions(-)
diff --git a/include/tcg/tcg-op-common.h b/include/tcg/tcg-op-common.h
index cdaa805c47b..94f880a81e7 100644
--- a/include/tcg/tcg-op-common.h
+++ b/include/tcg/tcg-op-common.h
@@ -142,7 +142,6 @@ void tcg_gen_plugin_mem_cb(TCGv_i64 addr, unsigned meminfo);
/* 32 bit ops */
-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);
void tcg_gen_rotri_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2);
@@ -197,7 +196,6 @@ void tcg_gen_st_i32(TCGv_i32 arg1, TCGv_ptr arg2,
tcg_target_long offset);
/* 64 bit ops */
-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);
void tcg_gen_rotri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2);
diff --git a/include/tcg/tcg-op-def2.h.inc b/include/tcg/tcg-op-def2.h.inc
index 0f370e4e04b..61d00fa493d 100644
--- a/include/tcg/tcg-op-def2.h.inc
+++ b/include/tcg/tcg-op-def2.h.inc
@@ -41,6 +41,7 @@ DEF_RRR(or)
DEF_RRR(orc)
DEF_RRR(rem)
DEF_RRR(remu)
+DEF_RRR(rotl)
DEF_RRR(sar)
DEF_RRR(shl)
DEF_RRR(shr)
diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
index 549d257de8b..677e93736f5 100644
--- a/tcg/tcg-op.c
+++ b/tcg/tcg-op.c
@@ -806,6 +806,27 @@ static void gen_remu(TCGType type, TCGTemp *dst, TCGTemp
*src1, TCGTemp *src2)
}
}
+static void gen_rotl(TCGType type, TCGTemp *dst, TCGTemp *src1, TCGTemp *src2)
+{
+ if (tcg_op_supported(INDEX_op_rotl, type, 0)) {
+ gen_op_ttt(INDEX_op_rotl, type, dst, src1, src2);
+ } else if (tcg_op_supported(INDEX_op_rotr, type, 0)) {
+ TCGTemp *tmp = tcg_temp_new_internal(type, TEMP_EBB);
+ gen_neg(type, tmp, src2);
+ gen_op_ttt(INDEX_op_rotr, type, dst, src1, tmp);
+ tcg_temp_free_internal(tmp);
+ } else {
+ TCGTemp *t0 = tcg_temp_new_internal(type, TEMP_EBB);
+ TCGTemp *t1 = tcg_temp_new_internal(type, TEMP_EBB);
+ gen_shl(type, t0, src1, src2);
+ gen_neg(type, t1, src2);
+ gen_shr(type, t1, src1, t1);
+ gen_or(type, dst, t0, t1);
+ tcg_temp_free_internal(t0);
+ tcg_temp_free_internal(t1);
+ }
+}
+
static void gen_sar(TCGType type, TCGTemp *dst, TCGTemp *src1, TCGTemp *src2)
{
gen_op_ttt(INDEX_op_sar, type, dst, src1, src2);
@@ -972,27 +993,6 @@ static void gen_xori(TCGType type, TCGTemp *dst, TCGTemp
*src1, int64_t src2)
/* 32 bit ops */
-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)) {
- tcg_gen_op3_i32(INDEX_op_rotl, ret, arg1, arg2);
- } else if (tcg_op_supported(INDEX_op_rotr, TCG_TYPE_I32, 0)) {
- TCGv_i32 t0 = tcg_temp_ebb_new_i32();
- tcg_gen_neg_i32(t0, arg2);
- tcg_gen_op3_i32(INDEX_op_rotr, ret, arg1, t0);
- tcg_temp_free_i32(t0);
- } else {
- TCGv_i32 t0 = tcg_temp_ebb_new_i32();
- TCGv_i32 t1 = tcg_temp_ebb_new_i32();
- tcg_gen_shl_i32(t0, arg1, arg2);
- tcg_gen_neg_i32(t1, arg2);
- tcg_gen_shr_i32(t1, arg1, t1);
- tcg_gen_or_i32(ret, t0, t1);
- tcg_temp_free_i32(t0);
- tcg_temp_free_i32(t1);
- }
-}
-
void tcg_gen_rotli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2)
{
tcg_debug_assert(arg2 >= 0 && arg2 < 32);
@@ -1803,27 +1803,6 @@ void tcg_gen_revbit64_i64(TCGv_i64 ret, TCGv_i64 arg)
}
}
-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)) {
- tcg_gen_op3_i64(INDEX_op_rotl, ret, arg1, arg2);
- } else if (tcg_op_supported(INDEX_op_rotl, TCG_TYPE_I64, 0)) {
- TCGv_i64 t0 = tcg_temp_ebb_new_i64();
- tcg_gen_neg_i64(t0, arg2);
- tcg_gen_op3_i64(INDEX_op_rotr, ret, arg1, t0);
- tcg_temp_free_i64(t0);
- } else {
- TCGv_i64 t0 = tcg_temp_ebb_new_i64();
- TCGv_i64 t1 = tcg_temp_ebb_new_i64();
- tcg_gen_shl_i64(t0, arg1, arg2);
- tcg_gen_neg_i64(t1, arg2);
- tcg_gen_shr_i64(t1, arg1, t1);
- tcg_gen_or_i64(ret, t0, t1);
- tcg_temp_free_i64(t0);
- tcg_temp_free_i64(t1);
- }
-}
-
void tcg_gen_rotli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
{
tcg_debug_assert(arg2 >= 0 && arg2 < 64);
--
2.53.0