Il mer 24 dic 2025, 16:24 Philippe Mathieu-Daudé <[email protected]> ha
scritto:

> Introduce load/store helpers taking an unsigned size argument.
>

Are they used anywhere (or do you have plans)?

Overall I like the introduction of MemOp! But host endianness should be the
basis of everything else instead of something to shun.

Paolo

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
> ---
>  docs/devel/loads-stores.rst             | 10 ++++++----
>  include/system/memory_ldst_endian.h.inc |  4 ++++
>  system/memory_ldst_endian.c.inc         | 14 ++++++++++++++
>  3 files changed, 24 insertions(+), 4 deletions(-)
>
> diff --git a/docs/devel/loads-stores.rst b/docs/devel/loads-stores.rst
> index c906c6509ee..8db6285538e 100644
> --- a/docs/devel/loads-stores.rst
> +++ b/docs/devel/loads-stores.rst
> @@ -375,6 +375,7 @@ succeeded using a MemTxResult return code.
>   - ``w`` : 16 bits
>   - ``l`` : 32 bits
>   - ``q`` : 64 bits
> + - ``n`` : size in bytes
>
>  ``endian``
>   - ``le`` : little endian
> @@ -384,8 +385,8 @@ The ``_{endian}`` suffix is omitted for byte accesses.
>
>  Regexes for git grep:
>   - ``\<address_space_\(read\|write\|rw\)\>``
> - - ``\<address_space_ldu\?[bwql]\(_[lb]e\)\?\>``
> - - ``\<address_space_st[bwql]\(_[lb]e\)\?\>``
> + - ``\<address_space_ldu\?[bwlqn]\(_[lb]e\)\?\>``
> + - ``\<address_space_st[bwlqn]\(_[lb]e\)\?\>``
>
>  ``address_space_write_rom``
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~
> @@ -431,6 +432,7 @@ device doing the access has no way to report such an
> error.
>   - ``w`` : 16 bits
>   - ``l`` : 32 bits
>   - ``q`` : 64 bits
> + - ``n`` : size in bytes
>
>  ``endian``
>   - ``le`` : little endian
> @@ -439,8 +441,8 @@ device doing the access has no way to report such an
> error.
>  The ``_{endian}_`` infix is omitted for byte accesses.
>
>  Regexes for git grep:
> - - ``\<ldu\?[bwlq]\(_[bl]e\)\?_phys\>``
> - - ``\<st[bwlq]\(_[bl]e\)\?_phys\>``
> + - ``\<ldu\?[bwlqn]\(_[bl]e\)\?_phys\>``
> + - ``\<st[bwlqn]\(_[bl]e\)\?_phys\>``
>
>  ``cpu_physical_memory_*``
>  ~~~~~~~~~~~~~~~~~~~~~~~~~
> diff --git a/include/system/memory_ldst_endian.h.inc
> b/include/system/memory_ldst_endian.h.inc
> index f5b6b496be5..77850f1a18d 100644
> --- a/include/system/memory_ldst_endian.h.inc
> +++ b/include/system/memory_ldst_endian.h.inc
> @@ -20,12 +20,16 @@ uint32_t ADDRESS_SPACE_LD(l)(ARG1_DECL, hwaddr addr,
>                               MemTxAttrs attrs, MemTxResult *result);
>  uint64_t ADDRESS_SPACE_LD(q)(ARG1_DECL, hwaddr addr,
>                               MemTxAttrs attrs, MemTxResult *result);
> +uint64_t ADDRESS_SPACE_LD(n)(ARG1_DECL, unsigned size, hwaddr addr,
> +                             MemTxAttrs attrs, MemTxResult *result);
>  void ADDRESS_SPACE_ST(w)(ARG1_DECL, hwaddr addr, uint16_t val,
>                           MemTxAttrs attrs, MemTxResult *result);
>  void ADDRESS_SPACE_ST(l)(ARG1_DECL, hwaddr addr, uint32_t val,
>                           MemTxAttrs attrs, MemTxResult *result);
>  void ADDRESS_SPACE_ST(q)(ARG1_DECL, hwaddr addr, uint64_t val,
>                           MemTxAttrs attrs, MemTxResult *result);
> +void ADDRESS_SPACE_ST(n)(ARG1_DECL, unsigned size, hwaddr addr, uint64_t
> val,
> +                         MemTxAttrs attrs, MemTxResult *result);
>
>  #undef ADDRESS_SPACE_LD
>  #undef ADDRESS_SPACE_ST
> diff --git a/system/memory_ldst_endian.c.inc
> b/system/memory_ldst_endian.c.inc
> index fb933de11f8..4ff050027f5 100644
> --- a/system/memory_ldst_endian.c.inc
> +++ b/system/memory_ldst_endian.c.inc
> @@ -40,6 +40,13 @@ uint64_t ADDRESS_SPACE_LD(q)(ARG1_DECL, hwaddr addr,
>                                          addr, attrs, result);
>  }
>
> +uint64_t ADDRESS_SPACE_LD(n)(ARG1_DECL, unsigned size, hwaddr addr,
> +                             MemTxAttrs attrs, MemTxResult *result)
> +{
> +    return ADDRESS_SPACE_LD_INTERNAL(m)(ARG1, MO_ENDIAN |
> size_memop(size),
> +                                        addr, attrs, result);
> +}
> +
>  void ADDRESS_SPACE_ST(w)(ARG1_DECL, hwaddr addr, uint16_t val,
>                           MemTxAttrs attrs, MemTxResult *result)
>  {
> @@ -61,6 +68,13 @@ void ADDRESS_SPACE_ST(q)(ARG1_DECL, hwaddr addr,
> uint64_t val,
>                                   addr, val, attrs, result);
>  }
>
> +void ADDRESS_SPACE_ST(n)(ARG1_DECL, unsigned size, hwaddr addr, uint64_t
> val,
> +                         MemTxAttrs attrs, MemTxResult *result)
> +{
> +    ADDRESS_SPACE_ST_INTERNAL(m)(ARG1, MO_ENDIAN | size_memop(size),
> +                                 addr, val, attrs, result);
> +}
> +
>  #undef ADDRESS_SPACE_LD
>  #undef ADDRESS_SPACE_LD_INTERNAL
>  #undef ADDRESS_SPACE_ST
> --
> 2.52.0
>
>

Reply via email to