qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v6 09/30] tcg/loongarch64: Implement tcg_out_mov and tcg_out_


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v6 09/30] tcg/loongarch64: Implement tcg_out_mov and tcg_out_movi
Date: Sun, 26 Sep 2021 08:48:40 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0

On 9/25/21 19:30, WANG Xuerui wrote:
> Signed-off-by: WANG Xuerui <git@xen0n.name>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  tcg/loongarch64/tcg-target.c.inc | 137 +++++++++++++++++++++++++++++++
>  1 file changed, 137 insertions(+)

> +static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
> +{
> +    if (ret == arg) {
> +        return true;
> +    }
> +    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);
> +        break;
> +    default:
> +        g_assert_not_reached();
> +    }
> +    return true;
> +}

> +static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd,
> +                         tcg_target_long val)
> +{
> +    /*
> +     * LoongArch conventionally loads 64-bit immediates in at most 4 steps,
> +     * with dedicated instructions for filling the respective bitfields
> +     * below:
> +     *
> +     *        6                   5                   4               3
> +     *  3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2
> +     * +-----------------------+---------------------------------------+...
> +     * |          hi52         |                  hi32                 |
> +     * +-----------------------+---------------------------------------+...
> +     *       3                   2                   1
> +     *     1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
> +     * ...+-------------------------------------+-------------------------+
> +     *    |                 hi12                |            lo           |
> +     * ...+-------------------------------------+-------------------------+
> +     *
> +     * Check if val belong to one of the several fast cases, before falling
> +     * back to the slow path.
> +     */

Lovely :)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]