diff mbox series

[17/20] disas: Use cpu_datapath_is_big_endian()

Message ID 20241204202602.58083-18-philmd@linaro.org
State New
Headers show
Series target: Implement CPUClass::datapath_is_big_endian() handlers | expand

Commit Message

Philippe Mathieu-Daudé Dec. 4, 2024, 8:25 p.m. UTC
Rather that using the binary endianness, use the vCPU one.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 disas/disas-common.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Richard Henderson Dec. 4, 2024, 11:40 p.m. UTC | #1
On 12/4/24 14:25, Philippe Mathieu-Daudé wrote:
> Rather that using the binary endianness, use the vCPU one.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   disas/disas-common.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/disas/disas-common.c b/disas/disas-common.c
> index 7377de0715c..ef91c43449e 100644
> --- a/disas/disas-common.c
> +++ b/disas/disas-common.c
> @@ -7,7 +7,6 @@
>   #include "disas/disas.h"
>   #include "disas/capstone.h"
>   #include "hw/core/cpu.h"
> -#include "exec/tswap.h"
>   #include "disas-internal.h"
>   
>   
> @@ -61,7 +60,7 @@ void disas_initialize_debug_target(CPUDebug *s, CPUState *cpu)
>   
>       s->cpu = cpu;
>       s->info.print_address_func = print_address;
> -    if (qemu_binary_is_bigendian()) {
> +    if (cpu_datapath_is_big_endian(cpu)) {
>           s->info.endian = BFD_ENDIAN_BIG;
>       } else {
>           s->info.endian =  BFD_ENDIAN_LITTLE;

I would much rather remove this if statement and force cc->disas_set_info to set this value.


r~
Peter Maydell Dec. 5, 2024, 10:47 a.m. UTC | #2
On Wed, 4 Dec 2024 at 20:28, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> Rather that using the binary endianness, use the vCPU one.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  disas/disas-common.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/disas/disas-common.c b/disas/disas-common.c
> index 7377de0715c..ef91c43449e 100644
> --- a/disas/disas-common.c
> +++ b/disas/disas-common.c
> @@ -7,7 +7,6 @@
>  #include "disas/disas.h"
>  #include "disas/capstone.h"
>  #include "hw/core/cpu.h"
> -#include "exec/tswap.h"
>  #include "disas-internal.h"
>
>
> @@ -61,7 +60,7 @@ void disas_initialize_debug_target(CPUDebug *s, CPUState *cpu)
>
>      s->cpu = cpu;
>      s->info.print_address_func = print_address;
> -    if (qemu_binary_is_bigendian()) {
> +    if (cpu_datapath_is_big_endian(cpu)) {
>          s->info.endian = BFD_ENDIAN_BIG;
>      } else {
>          s->info.endian =  BFD_ENDIAN_LITTLE;
> --

This looks weird, but maybe that's just the function naming?
Instruction disassembly is instructions, not data, and the
endianness isn't necessarily the same (e.g. on Armv7 and later
instructions are always little-endian even when data is
big-endian.)

-- PMM
diff mbox series

Patch

diff --git a/disas/disas-common.c b/disas/disas-common.c
index 7377de0715c..ef91c43449e 100644
--- a/disas/disas-common.c
+++ b/disas/disas-common.c
@@ -7,7 +7,6 @@ 
 #include "disas/disas.h"
 #include "disas/capstone.h"
 #include "hw/core/cpu.h"
-#include "exec/tswap.h"
 #include "disas-internal.h"
 
 
@@ -61,7 +60,7 @@  void disas_initialize_debug_target(CPUDebug *s, CPUState *cpu)
 
     s->cpu = cpu;
     s->info.print_address_func = print_address;
-    if (qemu_binary_is_bigendian()) {
+    if (cpu_datapath_is_big_endian(cpu)) {
         s->info.endian = BFD_ENDIAN_BIG;
     } else {
         s->info.endian =  BFD_ENDIAN_LITTLE;