diff mbox series

[v2,15/36] tcg: Use tcg_constant_{i32,i64} with tcg plugins

Message ID 20200422011722.13287-16-richard.henderson@linaro.org
State Superseded
Headers show
Series tcg 5.1 omnibus patch set | expand

Commit Message

Richard Henderson April 22, 2020, 1:17 a.m. UTC
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 accel/tcg/plugin-gen.c | 49 +++++++++++++++++++-----------------------
 1 file changed, 22 insertions(+), 27 deletions(-)

-- 
2.20.1

Comments

Alex Bennée April 22, 2020, 5:18 p.m. UTC | #1
Richard Henderson <richard.henderson@linaro.org> writes:

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>


Reviewed-by: Alex Bennée <alex.bennee@linaro.org>


> ---

>  accel/tcg/plugin-gen.c | 49 +++++++++++++++++++-----------------------

>  1 file changed, 22 insertions(+), 27 deletions(-)

>

> diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c

> index 51580d51a0..e5dc9d0ca9 100644

> --- a/accel/tcg/plugin-gen.c

> +++ b/accel/tcg/plugin-gen.c

> @@ -284,8 +284,8 @@ static TCGOp *copy_extu_i32_i64(TCGOp **begin_op, TCGOp *op)

>      if (TCG_TARGET_REG_BITS == 32) {

>          /* mov_i32 */

>          op = copy_op(begin_op, op, INDEX_op_mov_i32);

> -        /* movi_i32 */

> -        op = copy_op(begin_op, op, INDEX_op_movi_i32);

> +        /* mov_i32 w/ $0 */

> +        op = copy_op(begin_op, op, INDEX_op_mov_i32);

>      } else {

>          /* extu_i32_i64 */

>          op = copy_op(begin_op, op, INDEX_op_extu_i32_i64);

> @@ -306,39 +306,34 @@ static TCGOp *copy_mov_i64(TCGOp **begin_op, TCGOp *op)

>      return op;

>  }

>  

> -static TCGOp *copy_movi_i64(TCGOp **begin_op, TCGOp *op, uint64_t v)

> -{

> -    if (TCG_TARGET_REG_BITS == 32) {

> -        /* 2x movi_i32 */

> -        op = copy_op(begin_op, op, INDEX_op_movi_i32);

> -        op->args[1] = v;

> -

> -        op = copy_op(begin_op, op, INDEX_op_movi_i32);

> -        op->args[1] = v >> 32;

> -    } else {

> -        /* movi_i64 */

> -        op = copy_op(begin_op, op, INDEX_op_movi_i64);

> -        op->args[1] = v;

> -    }

> -    return op;

> -}

> -

>  static TCGOp *copy_const_ptr(TCGOp **begin_op, TCGOp *op, void *ptr)

>  {

>      if (UINTPTR_MAX == UINT32_MAX) {

> -        /* movi_i32 */

> -        op = copy_op(begin_op, op, INDEX_op_movi_i32);

> -        op->args[1] = (uintptr_t)ptr;

> +        /* mov_i32 */

> +        op = copy_op(begin_op, op, INDEX_op_mov_i32);

> +        op->args[1] = tcgv_i32_arg(tcg_constant_i32((uintptr_t)ptr));

>      } else {

> -        /* movi_i64 */

> -        op = copy_movi_i64(begin_op, op, (uint64_t)(uintptr_t)ptr);

> +        /* mov_i64 */

> +        op = copy_op(begin_op, op, INDEX_op_mov_i64);

> +        op->args[1] = tcgv_i64_arg(tcg_constant_i64((uintptr_t)ptr));

>      }

>      return op;

>  }

>  

>  static TCGOp *copy_const_i64(TCGOp **begin_op, TCGOp *op, uint64_t v)

>  {

> -    return copy_movi_i64(begin_op, op, v);

> +    if (TCG_TARGET_REG_BITS == 32) {

> +        /* 2x mov_i32 */

> +        op = copy_op(begin_op, op, INDEX_op_mov_i32);

> +        op->args[1] = tcgv_i32_arg(tcg_constant_i32(v));

> +        op = copy_op(begin_op, op, INDEX_op_mov_i32);

> +        op->args[1] = tcgv_i32_arg(tcg_constant_i32(v >> 32));

> +    } else {

> +        /* mov_i64 */

> +        op = copy_op(begin_op, op, INDEX_op_mov_i64);

> +        op->args[1] = tcgv_i64_arg(tcg_constant_i64(v));

> +    }

> +    return op;

>  }

>  

>  static TCGOp *copy_extu_tl_i64(TCGOp **begin_op, TCGOp *op)

> @@ -486,8 +481,8 @@ static TCGOp *append_mem_cb(const struct qemu_plugin_dyn_cb *cb,

>  

>      tcg_debug_assert(type == PLUGIN_GEN_CB_MEM);

>  

> -    /* const_i32 == movi_i32 ("info", so it remains as is) */

> -    op = copy_op(&begin_op, op, INDEX_op_movi_i32);

> +    /* const_i32 == mov_i32 ("info", so it remains as is) */

> +    op = copy_op(&begin_op, op, INDEX_op_mov_i32);

>  

>      /* const_ptr */

>      op = copy_const_ptr(&begin_op, op, cb->userp);



-- 
Alex Bennée
diff mbox series

Patch

diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c
index 51580d51a0..e5dc9d0ca9 100644
--- a/accel/tcg/plugin-gen.c
+++ b/accel/tcg/plugin-gen.c
@@ -284,8 +284,8 @@  static TCGOp *copy_extu_i32_i64(TCGOp **begin_op, TCGOp *op)
     if (TCG_TARGET_REG_BITS == 32) {
         /* mov_i32 */
         op = copy_op(begin_op, op, INDEX_op_mov_i32);
-        /* movi_i32 */
-        op = copy_op(begin_op, op, INDEX_op_movi_i32);
+        /* mov_i32 w/ $0 */
+        op = copy_op(begin_op, op, INDEX_op_mov_i32);
     } else {
         /* extu_i32_i64 */
         op = copy_op(begin_op, op, INDEX_op_extu_i32_i64);
@@ -306,39 +306,34 @@  static TCGOp *copy_mov_i64(TCGOp **begin_op, TCGOp *op)
     return op;
 }
 
-static TCGOp *copy_movi_i64(TCGOp **begin_op, TCGOp *op, uint64_t v)
-{
-    if (TCG_TARGET_REG_BITS == 32) {
-        /* 2x movi_i32 */
-        op = copy_op(begin_op, op, INDEX_op_movi_i32);
-        op->args[1] = v;
-
-        op = copy_op(begin_op, op, INDEX_op_movi_i32);
-        op->args[1] = v >> 32;
-    } else {
-        /* movi_i64 */
-        op = copy_op(begin_op, op, INDEX_op_movi_i64);
-        op->args[1] = v;
-    }
-    return op;
-}
-
 static TCGOp *copy_const_ptr(TCGOp **begin_op, TCGOp *op, void *ptr)
 {
     if (UINTPTR_MAX == UINT32_MAX) {
-        /* movi_i32 */
-        op = copy_op(begin_op, op, INDEX_op_movi_i32);
-        op->args[1] = (uintptr_t)ptr;
+        /* mov_i32 */
+        op = copy_op(begin_op, op, INDEX_op_mov_i32);
+        op->args[1] = tcgv_i32_arg(tcg_constant_i32((uintptr_t)ptr));
     } else {
-        /* movi_i64 */
-        op = copy_movi_i64(begin_op, op, (uint64_t)(uintptr_t)ptr);
+        /* mov_i64 */
+        op = copy_op(begin_op, op, INDEX_op_mov_i64);
+        op->args[1] = tcgv_i64_arg(tcg_constant_i64((uintptr_t)ptr));
     }
     return op;
 }
 
 static TCGOp *copy_const_i64(TCGOp **begin_op, TCGOp *op, uint64_t v)
 {
-    return copy_movi_i64(begin_op, op, v);
+    if (TCG_TARGET_REG_BITS == 32) {
+        /* 2x mov_i32 */
+        op = copy_op(begin_op, op, INDEX_op_mov_i32);
+        op->args[1] = tcgv_i32_arg(tcg_constant_i32(v));
+        op = copy_op(begin_op, op, INDEX_op_mov_i32);
+        op->args[1] = tcgv_i32_arg(tcg_constant_i32(v >> 32));
+    } else {
+        /* mov_i64 */
+        op = copy_op(begin_op, op, INDEX_op_mov_i64);
+        op->args[1] = tcgv_i64_arg(tcg_constant_i64(v));
+    }
+    return op;
 }
 
 static TCGOp *copy_extu_tl_i64(TCGOp **begin_op, TCGOp *op)
@@ -486,8 +481,8 @@  static TCGOp *append_mem_cb(const struct qemu_plugin_dyn_cb *cb,
 
     tcg_debug_assert(type == PLUGIN_GEN_CB_MEM);
 
-    /* const_i32 == movi_i32 ("info", so it remains as is) */
-    op = copy_op(&begin_op, op, INDEX_op_movi_i32);
+    /* const_i32 == mov_i32 ("info", so it remains as is) */
+    op = copy_op(&begin_op, op, INDEX_op_mov_i32);
 
     /* const_ptr */
     op = copy_const_ptr(&begin_op, op, cb->userp);