diff mbox series

[03/18] tcg/loongarch64: Handle i32 and i64 moves between gr and fr

Message ID 20240527211912.14060-4-richard.henderson@linaro.org
State New
Headers show
Series tcg/loongarch64: Support v64 and v256 | expand

Commit Message

Richard Henderson May 27, 2024, 9:18 p.m. UTC
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/loongarch64/tcg-target.c.inc | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

Comments

gaosong June 17, 2024, 9:06 a.m. UTC | #1
在 2024/5/28 上午5:18, Richard Henderson 写道:
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   tcg/loongarch64/tcg-target.c.inc | 22 +++++++++++++++++-----
>   1 file changed, 17 insertions(+), 5 deletions(-)
Reviewed-by: Song Gao <gaosong@loongson.cn>

Thanks.
Song Gao
> diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc
> index b9078ac793..de5369536e 100644
> --- a/tcg/loongarch64/tcg-target.c.inc
> +++ b/tcg/loongarch64/tcg-target.c.inc
> @@ -303,11 +303,23 @@ static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
>       switch (type) {
>       case TCG_TYPE_I32:
>       case TCG_TYPE_I64:
> -        /*
> -         * Conventional register-register move used in LoongArch is
> -         * `or dst, src, zero`.
> -         */
> -        tcg_out_opc_or(s, ret, arg, TCG_REG_ZERO);
> +        if (ret < TCG_REG_V0) {
> +            if (arg < TCG_REG_V0) {
> +                /*
> +                 * Conventional register-register move used in LoongArch is
> +                 * `or dst, src, zero`.
> +                 */
> +                tcg_out_opc_or(s, ret, arg, TCG_REG_ZERO);
> +            } else {
> +                tcg_out_opc_movfr2gr_d(s, ret, arg);
> +            }
> +        } else {
> +            if (arg < TCG_REG_V0) {
> +                tcg_out_opc_movgr2fr_d(s, ret, arg);
> +            } else {
> +                tcg_out_opc_fmov_d(s, ret, arg);
> +            }
> +        }
>           break;
>       case TCG_TYPE_V128:
>           tcg_out_opc_vori_b(s, ret, arg, 0);
diff mbox series

Patch

diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc
index b9078ac793..de5369536e 100644
--- a/tcg/loongarch64/tcg-target.c.inc
+++ b/tcg/loongarch64/tcg-target.c.inc
@@ -303,11 +303,23 @@  static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
     switch (type) {
     case TCG_TYPE_I32:
     case TCG_TYPE_I64:
-        /*
-         * Conventional register-register move used in LoongArch is
-         * `or dst, src, zero`.
-         */
-        tcg_out_opc_or(s, ret, arg, TCG_REG_ZERO);
+        if (ret < TCG_REG_V0) {
+            if (arg < TCG_REG_V0) {
+                /*
+                 * Conventional register-register move used in LoongArch is
+                 * `or dst, src, zero`.
+                 */
+                tcg_out_opc_or(s, ret, arg, TCG_REG_ZERO);
+            } else {
+                tcg_out_opc_movfr2gr_d(s, ret, arg);
+            }
+        } else {
+            if (arg < TCG_REG_V0) {
+                tcg_out_opc_movgr2fr_d(s, ret, arg);
+            } else {
+                tcg_out_opc_fmov_d(s, ret, arg);
+            }
+        }
         break;
     case TCG_TYPE_V128:
         tcg_out_opc_vori_b(s, ret, arg, 0);