diff mbox series

[1/2] target/xtensa: Implement xtensa_isa_is_big_endian()

Message ID 20241205232437.85235-2-philmd@linaro.org (mailing list archive)
State New
Headers show
Series target/xtensa: Remove tswap() calls in semihosting | expand

Commit Message

Philippe Mathieu-Daudé Dec. 5, 2024, 11:24 p.m. UTC
Xtensa internal fields are opaque, only accessible by
the Xtensa libisa. Implement xtensa_isa_is_big_endian()
to get vCPU endianness. This should be implemented in
libisa, not QEMU, but I couldn't figure out where to
contribute this.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/xtensa/xtensa-isa.h | 1 +
 target/xtensa/xtensa-isa.c     | 7 +++++++
 2 files changed, 8 insertions(+)

Comments

Max Filippov Dec. 6, 2024, 12:35 p.m. UTC | #1
On Thu, Dec 5, 2024 at 3:24 PM Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> Xtensa internal fields are opaque, only accessible by
> the Xtensa libisa. Implement xtensa_isa_is_big_endian()
> to get vCPU endianness. This should be implemented in
> libisa, not QEMU, but I couldn't figure out where to
> contribute this.

This is a beautified version of what xtensa has in binutils, but
binutils is also
just another user of that internal Tensilica library. Perhaps I should make
an artificial "upstream" for this library just to track this kind of changes.
Let me look at it.

> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  include/hw/xtensa/xtensa-isa.h | 1 +
>  target/xtensa/xtensa-isa.c     | 7 +++++++
>  2 files changed, 8 insertions(+)
>
> diff --git a/include/hw/xtensa/xtensa-isa.h b/include/hw/xtensa/xtensa-isa.h
> index a289531bdc8..1cb8e6ccb66 100644
> --- a/include/hw/xtensa/xtensa-isa.h
> +++ b/include/hw/xtensa/xtensa-isa.h
> @@ -829,6 +829,7 @@ const char *xtensa_funcUnit_name(xtensa_isa isa, xtensa_funcUnit fun);
>
>  int xtensa_funcUnit_num_copies(xtensa_isa isa, xtensa_funcUnit fun);
>
> +bool xtensa_isa_is_big_endian(xtensa_isa isa);

This file doesn't include stdbool.h and other boolean functions in it
(e.g. xtensa_opcode_is_branch()) return int. I'd suggest sticking with
that. With that change:

Acked-by: Max Filippov <jcmvbkbc@gmail.com>

>  #ifdef __cplusplus
>  }
> diff --git a/target/xtensa/xtensa-isa.c b/target/xtensa/xtensa-isa.c
> index 630b4f9da1b..36eb4bcf3d4 100644
> --- a/target/xtensa/xtensa-isa.c
> +++ b/target/xtensa/xtensa-isa.c
> @@ -1741,3 +1741,10 @@ int xtensa_funcUnit_num_copies(xtensa_isa isa, xtensa_funcUnit fun)
>      CHECK_FUNCUNIT(intisa, fun, XTENSA_UNDEFINED);
>      return intisa->funcUnits[fun].num_copies;
>  }
> +
> +bool xtensa_isa_is_big_endian(xtensa_isa isa)
> +{
> +    xtensa_isa_internal *intisa = (xtensa_isa_internal *)isa;
> +
> +    return intisa->is_big_endian;
> +}
diff mbox series

Patch

diff --git a/include/hw/xtensa/xtensa-isa.h b/include/hw/xtensa/xtensa-isa.h
index a289531bdc8..1cb8e6ccb66 100644
--- a/include/hw/xtensa/xtensa-isa.h
+++ b/include/hw/xtensa/xtensa-isa.h
@@ -829,6 +829,7 @@  const char *xtensa_funcUnit_name(xtensa_isa isa, xtensa_funcUnit fun);
 
 int xtensa_funcUnit_num_copies(xtensa_isa isa, xtensa_funcUnit fun);
 
+bool xtensa_isa_is_big_endian(xtensa_isa isa);
 
 #ifdef __cplusplus
 }
diff --git a/target/xtensa/xtensa-isa.c b/target/xtensa/xtensa-isa.c
index 630b4f9da1b..36eb4bcf3d4 100644
--- a/target/xtensa/xtensa-isa.c
+++ b/target/xtensa/xtensa-isa.c
@@ -1741,3 +1741,10 @@  int xtensa_funcUnit_num_copies(xtensa_isa isa, xtensa_funcUnit fun)
     CHECK_FUNCUNIT(intisa, fun, XTENSA_UNDEFINED);
     return intisa->funcUnits[fun].num_copies;
 }
+
+bool xtensa_isa_is_big_endian(xtensa_isa isa)
+{
+    xtensa_isa_internal *intisa = (xtensa_isa_internal *)isa;
+
+    return intisa->is_big_endian;
+}