qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: "Frédéric Pétrot" <frederic.petrot@univ-grenoble-alpes.fr>,
	qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: bin.meng@windriver.com, richard.henderson@linaro.org,
	palmer@dabbelt.com,  fabien.portas@grenoble-inp.org,
	alistair.francis@wdc.com
Subject: Re: [PATCH v8 09/18] target/riscv: accessors to registers upper part and 128-bit load/store
Date: Fri, 10 Oct 2025 17:05:46 +0200	[thread overview]
Message-ID: <39bc0cef-cda7-43f7-8d9c-870599a6e91d@linaro.org> (raw)
In-Reply-To: <20220106210108.138226-10-frederic.petrot@univ-grenoble-alpes.fr>

Hi Frédéric,

(old patch merged as commit a2f827ff4f44)

On 6/1/22 22:00, Frédéric Pétrot wrote:
> Get function to retrieve the 64 top bits of a register, stored in the gprh
> field of the cpu state. Set function that writes the 128-bit value at once.
> The access to the gprh field can not be protected at compile time to make
> sure it is accessed only in the 128-bit version of the processor because we
> have no way to indicate that the misa_mxl_max field is const.
> 
> The 128-bit ISA adds ldu, lq and sq. We provide support for these
> instructions. Note that (a) we compute only 64-bit addresses to actually
> access memory, cowardly utilizing the existing address translation mechanism
> of QEMU, and (b) we assume for now little-endian memory accesses.
> 
> Signed-off-by: Frédéric Pétrot <frederic.petrot@univ-grenoble-alpes.fr>
> Co-authored-by: Fabien Portas <fabien.portas@grenoble-inp.org>
> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
> ---
>   target/riscv/insn16.decode              |  27 ++++++-
>   target/riscv/insn32.decode              |   5 ++
>   target/riscv/translate.c                |  41 ++++++++++
>   target/riscv/insn_trans/trans_rvi.c.inc | 100 ++++++++++++++++++++++--
>   4 files changed, 163 insertions(+), 10 deletions(-)


> +/* Compute only 64-bit addresses to use the address translation mechanism */
> +static bool gen_load_i128(DisasContext *ctx, arg_lb *a, MemOp memop)
> +{
> +    TCGv src1l = get_gpr(ctx, a->rs1, EXT_NONE);
> +    TCGv destl = dest_gpr(ctx, a->rd);
> +    TCGv desth = dest_gprh(ctx, a->rd);
> +    TCGv addrl = tcg_temp_new();
> +
> +    tcg_gen_addi_tl(addrl, src1l, a->imm);
> +
> +    if ((memop & MO_SIZE) <= MO_64) {
> +        tcg_gen_qemu_ld_tl(destl, addrl, ctx->mem_idx, memop);
> +        if (memop & MO_SIGN) {
> +            tcg_gen_sari_tl(desth, destl, 63);
> +        } else {
> +            tcg_gen_movi_tl(desth, 0);
> +        }
> +    } else {
> +        /* assume little-endian memory access for now */
> +        tcg_gen_qemu_ld_tl(destl, addrl, ctx->mem_idx, MO_TEUQ);
> +        tcg_gen_addi_tl(addrl, addrl, 8);
> +        tcg_gen_qemu_ld_tl(desth, addrl, ctx->mem_idx, MO_TEUQ);

I am confused by this "assume little-endian access" comment, since
you set the MO_TE flag (target endianness). I suppose you added the
comment since the @memop argument is ignored in this code path.
Maybe you want 'MO_LEUQ' here instead, to select little endianness?

> +    }
> +
> +    gen_set_gpr128(ctx, a->rd, destl, desth);
> +
> +    tcg_temp_free(addrl);
> +    return true;
> +}
> +
> +static bool gen_load(DisasContext *ctx, arg_lb *a, MemOp memop)
> +{
> +    if (get_xl(ctx) == MXL_RV128) {
> +        return gen_load_i128(ctx, a, memop);
> +    } else {
> +        return gen_load_tl(ctx, a, memop);
> +    }
> +}



  reply	other threads:[~2025-10-10 15:07 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-06 21:00 [PATCH v8 00/18] Adding partial support for 128-bit riscv target Frédéric Pétrot
2022-01-06 21:00 ` [PATCH v8 01/18] exec/memop: Adding signedness to quad definitions Frédéric Pétrot
2022-01-06 21:00 ` [PATCH v8 02/18] exec/memop: Adding signed quad and octo defines Frédéric Pétrot
2022-01-06 21:00 ` [PATCH v8 03/18] qemu/int128: addition of div/rem 128-bit operations Frédéric Pétrot
2022-01-06 21:00 ` [PATCH v8 04/18] target/riscv: additional macros to check instruction support Frédéric Pétrot
2022-01-06 21:00 ` [PATCH v8 05/18] target/riscv: separation of bitwise logic and arithmetic helpers Frédéric Pétrot
2022-01-06 21:00 ` [PATCH v8 06/18] target/riscv: array for the 64 upper bits of 128-bit registers Frédéric Pétrot
2022-01-06 21:00 ` [PATCH v8 07/18] target/riscv: setup everything for rv64 to support rv128 execution Frédéric Pétrot
2022-01-06 21:24   ` Alistair Francis
2022-01-07  6:23     ` Frédéric Pétrot
2022-01-07  6:47       ` Alistair Francis
2022-01-07 16:46         ` Frédéric Pétrot
2022-01-06 21:00 ` [PATCH v8 08/18] target/riscv: moving some insns close to similar insns Frédéric Pétrot
2022-01-06 21:00 ` [PATCH v8 09/18] target/riscv: accessors to registers upper part and 128-bit load/store Frédéric Pétrot
2025-10-10 15:05   ` Philippe Mathieu-Daudé [this message]
2025-10-10 15:54     ` Philippe Mathieu-Daudé
2022-01-06 21:01 ` [PATCH v8 10/18] target/riscv: support for 128-bit bitwise instructions Frédéric Pétrot
2022-01-06 21:01 ` [PATCH v8 11/18] target/riscv: support for 128-bit U-type instructions Frédéric Pétrot
2022-01-06 21:01 ` [PATCH v8 12/18] target/riscv: support for 128-bit shift instructions Frédéric Pétrot
2022-01-06 21:01 ` [PATCH v8 13/18] target/riscv: support for 128-bit arithmetic instructions Frédéric Pétrot
2022-01-06 21:01 ` [PATCH v8 14/18] target/riscv: support for 128-bit M extension Frédéric Pétrot
2022-01-06 21:01 ` [PATCH v8 15/18] target/riscv: adding high part of some csrs Frédéric Pétrot
2022-01-06 21:01 ` [PATCH v8 16/18] target/riscv: helper functions to wrap calls to 128-bit csr insns Frédéric Pétrot
2022-01-06 21:01 ` [PATCH v8 17/18] target/riscv: modification of the trans_csrxx for 128-bit support Frédéric Pétrot
2022-01-06 21:01 ` [PATCH v8 18/18] target/riscv: actual functions to realize crs 128-bit insns Frédéric Pétrot
2022-01-09 22:06 ` [PATCH v8 00/18] Adding partial support for 128-bit riscv target Alistair Francis
2025-03-21 15:08 ` Philippe Mathieu-Daudé
2025-04-04  3:26   ` Alistair Francis
2025-04-06 18:24     ` Frédéric Pétrot
2025-04-06 23:25       ` Alistair Francis
2025-09-23 13:47         ` Philippe Mathieu-Daudé
2025-09-23 17:37           ` Frédéric Pétrot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=39bc0cef-cda7-43f7-8d9c-870599a6e91d@linaro.org \
    --to=philmd@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=bin.meng@windriver.com \
    --cc=fabien.portas@grenoble-inp.org \
    --cc=frederic.petrot@univ-grenoble-alpes.fr \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).