On Wed, Mar 18, 2026 at 8:34 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> Move mo_endian_env() definition to "internals.h" for re-use.
> Do not restrict to system emulation only because this will
> also be used by user emulation code.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> target/riscv/internals.h | 12 ++++++++++++
> target/riscv/op_helper.c | 14 --------------
> 2 files changed, 12 insertions(+), 14 deletions(-)
>
> diff --git a/target/riscv/internals.h b/target/riscv/internals.h
> index 35b923c4bf5..860c47732b6 100644
> --- a/target/riscv/internals.h
> +++ b/target/riscv/internals.h
> @@ -62,6 +62,18 @@ static inline bool mmuidx_2stage(int mmu_idx)
> return mmu_idx & MMU_2STAGE_BIT;
> }
>
> +static inline MemOp mo_endian_env(CPURISCVState *env)
> +{
> + /*
> + * A couple of bits in MSTATUS set the endianness:
> + * - MSTATUS_UBE (User-mode),
> + * - MSTATUS_SBE (Supervisor-mode),
> + * - MSTATUS_MBE (Machine-mode)
> + * but we don't implement that yet.
> + */
> + return MO_TE;
> +}
> +
> /* share data between vector helpers and decode code */
> FIELD(VDATA, VM, 0, 1)
> FIELD(VDATA, LMUL, 1, 3)
> diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c
> index 6ccc127c304..dde40a55493 100644
> --- a/target/riscv/op_helper.c
> +++ b/target/riscv/op_helper.c
> @@ -28,20 +28,6 @@
> #include "exec/tlb-flags.h"
> #include "trace.h"
>
> -#ifndef CONFIG_USER_ONLY
> -static inline MemOp mo_endian_env(CPURISCVState *env)
> -{
> - /*
> - * A couple of bits in MSTATUS set the endianness:
> - * - MSTATUS_UBE (User-mode),
> - * - MSTATUS_SBE (Supervisor-mode),
> - * - MSTATUS_MBE (Machine-mode)
> - * but we don't implement that yet.
> - */
> - return MO_TE;
> -}
> -#endif
> -
> /* Exceptions processing helpers */
> G_NORETURN void riscv_raise_exception(CPURISCVState *env,
> RISCVException exception,
> --
> 2.53.0
>
>