overall: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
Subsystems (3)
cover overall: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
Replace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
Philippe Mathieu-Daudé (16):
linux-user/arm: Checkpatch style cleanups
linux-user/arm: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
ui: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
net: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
disas: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check hw/core/loader: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check hw/display: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check hw/virtio: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check target/alpha: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check target/arm: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check target/mips: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check target/ppc: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check target/riscv: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check target/s390x: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check target/sparc: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check util/bitmap: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
include/hw/virtio/virtio-access.h | 6 +- include/hw/virtio/virtio-gpu-bswap.h | 6 +- target/arm/cpu.h | 8 +- target/arm/tcg/translate-a64.h | 5 +- disas/disas-host.c | 6 +- hw/core/loader.c | 5 +- hw/display/artist.c | 12 +- hw/display/vga.c | 20 +- hw/display/virtio-gpu-gl.c | 8 +- hw/display/virtio-gpu-rutabaga.c | 8 +- hw/virtio/vhost.c | 7 +- linux-user/arm/nwfpe/double_cpdo.c | 12 +- linux-user/arm/nwfpe/fpa11_cpdt.c | 77 +- net/net.c | 14 +- target/alpha/translate.c | 11 +- target/arm/tcg/sve_helper.c | 10 +- target/arm/tcg/translate-sve.c | 22 +- target/arm/tcg/translate-vfp.c | 8 +- target/arm/tcg/translate.c | 6 +- target/mips/tcg/msa_helper.c | 889 ++++++++++++------------ target/ppc/arch_dump.c | 9 +- target/ppc/int_helper.c | 28 +- target/ppc/kvm.c | 25 +- target/riscv/vector_helper.c | 32 +- target/s390x/tcg/translate.c | 6 +- target/sparc/vis_helper.c | 18 +- ui/vdagent.c | 16 +- ui/vnc.c | 6 +- util/bitmap.c | 19 +- target/ppc/translate/vmx-impl.c.inc | 14 +- target/ppc/translate/vsx-impl.c.inc | 6 +- target/riscv/insn_trans/trans_rvv.c.inc | 16 +- target/s390x/tcg/translate_vx.c.inc | 6 +- tcg/ppc/tcg-target.c.inc | 24 +- 34 files changed, 656 insertions(+), 709 deletions(-)
Signature · 1 line
2.51.0
PATCH 1/16 linux-user/arm: Checkpatch style cleanups
Update style in a pair of methods we are going to modify in the following commit. No functional change.
--- linux-user/arm/nwfpe/fpa11_cpdt.c | 66 ++++++++++++++++--------------- 1 file changed, 35 insertions(+), 31 deletions(-)
linux-user/arm/nwfpe/fpa11_cpdt.c +35 -31
@@ -40,18 +40,18 @@ void loadSingle(const unsigned int Fn, target_ulong addr)static inline void loadDouble (const unsigned int Fn,target_ulong addr) { -FPA11 *fpa11 =GET_FPA11 (); -unsigned int *p; - p = (unsigned int *)&fpa11->fpreg[Fn].fDouble; - fpa11->fType[Fn] = typeDouble; +FPA11 *fpa11 =GET_FPA11 (); +unsigned int *p; + p = (unsigned int *)&fpa11->fpreg[Fn].fDouble; + fpa11->fType[Fn] = typeDouble;#if HOST_BIG_ENDIAN -/* FIXME - handle failure of get_user() */ -get_user_u32 (p[0 ], addr);/* sign & exponent */ -get_user_u32 (p[1 ], addr +4 ); +/* FIXME - handle failure of get_user() */ +get_user_u32 (p[0 ], addr);/* sign & exponent */ +get_user_u32 (p[1 ], addr +4 );#else -/* FIXME - handle failure of get_user() */ -get_user_u32 (p[0 ], addr +4 ); -get_user_u32 (p[1 ], addr);/* sign & exponent */ +/* FIXME - handle failure of get_user() */ +get_user_u32 (p[0 ], addr +4 ); +get_user_u32 (p[1 ], addr);/* sign & exponent */ #endif }
@@ -108,16 +108,18 @@ void storeSingle(const unsigned int Fn, target_ulong addr) {FPA11 *fpa11 =GET_FPA11 ();float32 val; - registerunsigned int *p = (unsigned int *)&val; + registerunsigned int *p = (unsigned int *)&val;switch (fpa11->fType[Fn]) {case typeDouble: - val =float64_to_float32 (fpa11->fpreg[Fn].fDouble, &fpa11->fp_status); + val =float64_to_float32 (fpa11->fpreg[Fn].fDouble, + &fpa11->fp_status);break ;case typeExtended: - val =floatx80_to_float32 (fpa11->fpreg[Fn].fExtended, &fpa11->fp_status); + val =floatx80_to_float32 (fpa11->fpreg[Fn].fExtended, + &fpa11->fp_status);break ;default : val = fpa11->fpreg[Fn].fSingle;
@@ -130,29 +132,31 @@ void storeSingle(const unsigned int Fn, target_ulong addr)static inline void storeDouble (const unsigned int Fn,target_ulong addr) { -FPA11 *fpa11 =GET_FPA11 (); -float64 val; - registerunsigned int *p = (unsigned int *)&val; +FPA11 *fpa11 =GET_FPA11 (); +float64 val; + registerunsigned int *p = (unsigned int *)&val; -switch (fpa11->fType[Fn]) - { -case typeSingle: - val =float32_to_float64 (fpa11->fpreg[Fn].fSingle, &fpa11->fp_status); -break ; +switch (fpa11->fType[Fn]) { +case typeSingle: + val =float32_to_float64 (fpa11->fpreg[Fn].fSingle, + &fpa11->fp_status); +break ; -case typeExtended: - val =floatx80_to_float64 (fpa11->fpreg[Fn].fExtended, &fpa11->fp_status); -break ; +case typeExtended: + val =floatx80_to_float64 (fpa11->fpreg[Fn].fExtended, + &fpa11->fp_status); +break ; -default : val = fpa11->fpreg[Fn].fDouble; - } -/* FIXME - handle put_user() failures */ +default : + val = fpa11->fpreg[Fn].fDouble; + } +/* FIXME - handle put_user() failures */ #if HOST_BIG_ENDIAN -put_user_u32 (p[0 ], addr);/* msw */ -put_user_u32 (p[1 ], addr +4 );/* lsw */ +put_user_u32 (p[0 ], addr);/* msw */ +put_user_u32 (p[1 ], addr +4 );/* lsw */ #else -put_user_u32 (p[1 ], addr);/* msw */ -put_user_u32 (p[0 ], addr +4 );/* lsw */ +put_user_u32 (p[1 ], addr);/* msw */ +put_user_u32 (p[0 ], addr +4 );/* lsw */ #endif }
Signature · 1 line
2.51.0
PATCH 2/16 linux-user/arm: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
In reply to Philippe Mathieu-DaudéReplace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
--- linux-user/arm/nwfpe/double_cpdo.c | 12 ++---------- linux-user/arm/nwfpe/fpa11_cpdt.c | 29 ++++++++++++++--------------- 2 files changed, 16 insertions(+), 25 deletions(-)
linux-user/arm/nwfpe/double_cpdo.c +2 -10
@@ -150,11 +150,7 @@ unsigned int DoubleCPDO(const unsigned int opcode)case MNF_CODE : {unsigned int *p = (unsigned int *)&rFm; -#if HOST_BIG_ENDIAN - p[0 ] ^=0x80000000 ; -#else - p[1 ] ^=0x80000000 ; -#endif + p[!HOST_BIG_ENDIAN ] ^=0x80000000 ; fpa11->fpreg[Fd].fDouble = rFm; }break ;
@@ -162,11 +158,7 @@ unsigned int DoubleCPDO(const unsigned int opcode)case ABS_CODE : {unsigned int *p = (unsigned int *)&rFm; -#if HOST_BIG_ENDIAN - p[0 ] &=0x7fffffff ; -#else - p[1 ] &=0x7fffffff ; -#endif + p[!HOST_BIG_ENDIAN ] &=0x7fffffff ; fpa11->fpreg[Fd].fDouble = rFm; }break ;
linux-user/arm/nwfpe/fpa11_cpdt.c +14 -15
@@ -44,15 +44,14 @@ void loadDouble(const unsigned int Fn, target_ulong addr)unsigned int *p; p = (unsigned int *)&fpa11->fpreg[Fn].fDouble; fpa11->fType[Fn] = typeDouble; -#if HOST_BIG_ENDIAN /* FIXME - handle failure of get_user() */ -get_user_u32 (p[0 ], addr);/* sign & exponent */ -get_user_u32 (p[1 ], addr +4 ); -#else -/* FIXME - handle failure of get_user() */ -get_user_u32 (p[0 ], addr +4 ); -get_user_u32 (p[1 ], addr);/* sign & exponent */ -#endif +if (HOST_BIG_ENDIAN ) { +get_user_u32 (p[0 ], addr);/* sign & exponent */ +get_user_u32 (p[1 ], addr +4 ); + }else { +get_user_u32 (p[0 ], addr +4 ); +get_user_u32 (p[1 ], addr);/* sign & exponent */ + } } static inline
@@ -151,13 +150,13 @@ void storeDouble(const unsigned int Fn, target_ulong addr) val = fpa11->fpreg[Fn].fDouble; }/* FIXME - handle put_user() failures */ -#if HOST_BIG_ENDIAN -put_user_u32 (p[0 ], addr);/* msw */ -put_user_u32 (p[1 ], addr +4 );/* lsw */ -#else -put_user_u32 (p[1 ], addr);/* msw */ -put_user_u32 (p[0 ], addr +4 );/* lsw */ -#endif +if (HOST_BIG_ENDIAN ) { +put_user_u32 (p[0 ], addr);/* msw */ +put_user_u32 (p[1 ], addr +4 );/* lsw */ + }else { +put_user_u32 (p[1 ], addr);/* msw */ +put_user_u32 (p[0 ], addr +4 );/* lsw */ + } } static inline
Signature · 1 line
2.51.0
PATCH 3/16 ui: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
In reply to Philippe Mathieu-DaudéReplace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
--- ui/vdagent.c | 16 ++++++++-------- ui/vnc.c | 6 +----- 2 files changed, 9 insertions(+), 13 deletions(-)
ui/vdagent.c +8 -8
@@ -660,14 +660,14 @@ static void vdagent_chr_open(Chardev *chr,VDAgentChardev *vd =QEMU_VDAGENT_CHARDEV (chr);ChardevQemuVDAgent *cfg = backend->u.qemu_vdagent.data; -#if HOST_BIG_ENDIAN -/* -* TODO: vdagent protocol is defined to be LE, -* so we have to byteswap everything on BE hosts. -*/ -error_setg (errp,"vdagent is not supported on bigendian hosts" ); -return ; -#endif +if (HOST_BIG_ENDIAN ) { +/* +* TODO: vdagent protocol is defined to be LE, +* so we have to byteswap everything on BE hosts. +*/ +error_setg (errp,"vdagent is not supported on bigendian hosts" ); +return ; + } vd->mouse =VDAGENT_MOUSE_DEFAULT ;if (cfg->has_mouse) {
ui/vnc.c +1 -5
@@ -2348,11 +2348,7 @@ static void pixel_format_message (VncState *vs) {vnc_write_u8 (vs, vs->client_pf.bits_per_pixel);/* bits-per-pixel */ vnc_write_u8 (vs, vs->client_pf.depth);/* depth */ -#if HOST_BIG_ENDIAN -vnc_write_u8 (vs,1 );/* big-endian-flag */ -#else -vnc_write_u8 (vs,0 );/* big-endian-flag */ -#endif +vnc_write_u8 (vs,HOST_BIG_ENDIAN );/* big-endian-flag */ vnc_write_u8 (vs,1 );/* true-color-flag */ vnc_write_u16 (vs, vs->client_pf.rmax);/* red-max */ vnc_write_u16 (vs, vs->client_pf.gmax);/* green-max */
Signature · 1 line
2.51.0
Re: [PATCH 03/16] ui: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
Quoted 8 lines · Philippe Mathieu-Daudé
Replace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 53 lines
--- ui/vdagent.c | 16 ++++++++-------- ui/vnc.c | 6 +----- 2 files changed, 9 insertions(+), 13 deletions(-)ui/vdagent.c +8
-8@@ -660,14 +660,14 @@ static void vdagent_chr_open(Chardev *chr,VDAgentChardev *vd =QEMU_VDAGENT_CHARDEV (chr);ChardevQemuVDAgent *cfg = backend->u.qemu_vdagent.data; -#if HOST_BIG_ENDIAN -/* -* TODO: vdagent protocol is defined to be LE, -* so we have to byteswap everything on BE hosts. -*/ -error_setg (errp,"vdagent is not supported on bigendian hosts" ); -return ; -#endif +if (HOST_BIG_ENDIAN ) { +/* +* TODO: vdagent protocol is defined to be LE, +* so we have to byteswap everything on BE hosts. +*/ +error_setg (errp,"vdagent is not supported on bigendian hosts" ); +return ; + } vd->mouse =VDAGENT_MOUSE_DEFAULT ;if (cfg->has_mouse) {ui/vnc.c +1
-6@@ -2348,11 +2348,7 @@ static void pixel_format_message (VncState *vs) {vnc_write_u8 (vs, vs->client_pf.bits_per_pixel);/* bits-per-pixel */ vnc_write_u8 (vs, vs->client_pf.depth);/* depth */ -#if HOST_BIG_ENDIAN -vnc_write_u8 (vs,1 );/* big-endian-flag */ -#else -vnc_write_u8 (vs,0 );/* big-endian-flag */ -#endif +vnc_write_u8 (vs,HOST_BIG_ENDIAN );/* big-endian-flag */ vnc_write_u8 (vs,1 );/* true-color-flag */ vnc_write_u16 (vs, vs->client_pf.rmax);/* red-max */ vnc_write_u16 (vs, vs->client_pf.gmax);/* green-max */ --2.51.0
PATCH 4/16 net: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
In reply to Philippe Mathieu-DaudéReplace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
--- net/net.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
net/net.c +6 -8
@@ -593,28 +593,26 @@ bool qemu_get_vnet_hash_supported_types(NetClientState *nc, uint32_t *types)int qemu_set_vnet_le (NetClientState *nc,bool is_le) { -#if HOST_BIG_ENDIAN +if (!HOST_BIG_ENDIAN ) { +return 0 ; + }if (!nc || !nc->info->set_vnet_le) {return -ENOSYS ; }return nc->info->set_vnet_le (nc, is_le); -#else -return 0 ; -#endif }int qemu_set_vnet_be (NetClientState *nc,bool is_be) { -#if HOST_BIG_ENDIAN -return 0 ; -#else +if (HOST_BIG_ENDIAN ) { +return 0 ; + }if (!nc || !nc->info->set_vnet_be) {return -ENOSYS ; }return nc->info->set_vnet_be (nc, is_be); -#endif }int qemu_can_receive_packet (NetClientState *nc)
Signature · 1 line
2.51.0
PATCH 5/16 disas: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
In reply to Philippe Mathieu-DaudéReplace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
--- disas/disas-host.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
disas/disas-host.c +1 -5
@@ -37,11 +37,7 @@ static void initialize_debug_host(CPUDebug *s) s->info.read_memory_func = host_read_memory; s->info.print_address_func = host_print_address; -#if HOST_BIG_ENDIAN - s->info.endian =BFD_ENDIAN_BIG ; -#else - s->info.endian =BFD_ENDIAN_LITTLE ; -#endif + s->info.endian =HOST_BIG_ENDIAN ?BFD_ENDIAN_BIG :BFD_ENDIAN_LITTLE ;#if defined(CONFIG_TCG_INTERPRETER ) s->info.print_insn = print_insn_tci;#elif defined(__i386__)
Signature · 1 line
2.51.0
PATCH 6/16 hw/core/loader: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
In reply to Philippe Mathieu-DaudéReplace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
--- hw/core/loader.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/core/loader.c +3 -2
@@ -491,7 +491,9 @@ ssize_t load_elf_ram_sym(const char *filename,static void bswap_uboot_header (uboot_image_header_t *hdr) { -#if !HOST_BIG_ENDIAN +if (HOST_BIG_ENDIAN ) { +return ; + }bswap32s (&hdr->ih_magic);bswap32s (&hdr->ih_hcrc);bswap32s (&hdr->ih_time);
@@ -499,7 +501,6 @@ static void bswap_uboot_header(uboot_image_header_t *hdr)bswap32s (&hdr->ih_load);bswap32s (&hdr->ih_ep);bswap32s (&hdr->ih_dcrc); -#endif }
Signature · 1 line
2.51.0
Re: [PATCH 06/16] hw/core/loader: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
Quoted 8 lines · Philippe Mathieu-Daudé
Replace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 31 lines
--- hw/core/loader.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)hw/core/loader.c +3
-3@@ -491,7 +491,9 @@ ssize_t load_elf_ram_sym(const char *filename,static void bswap_uboot_header (uboot_image_header_t *hdr) { -#if !HOST_BIG_ENDIAN +if (HOST_BIG_ENDIAN ) { +return ; + }bswap32s (&hdr->ih_magic);bswap32s (&hdr->ih_hcrc);bswap32s (&hdr->ih_time);@@ -499,7 +501,6 @@ static void bswap_uboot_header(uboot_image_header_t *hdr)bswap32s (&hdr->ih_load);bswap32s (&hdr->ih_ep);bswap32s (&hdr->ih_dcrc); -#endif } --2.51.0
PATCH 7/16 hw/display: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
In reply to Philippe Mathieu-DaudéReplace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
--- include/hw/virtio/virtio-gpu-bswap.h | 6 +++--- hw/display/artist.c | 12 ++++++------ hw/display/vga.c | 20 ++++++++------------ hw/display/virtio-gpu-gl.c | 8 ++++---- hw/display/virtio-gpu-rutabaga.c | 8 ++++---- 5 files changed, 25 insertions(+), 29 deletions(-)
include/hw/virtio/virtio-gpu-bswap.h +3 -3
@@ -29,7 +29,9 @@ virtio_gpu_ctrl_hdr_bswap(struct virtio_gpu_ctrl_hdr *hdr)static inline void virtio_gpu_bswap_32 (void *ptr,size_t size) { -#if HOST_BIG_ENDIAN +if (!HOST_BIG_ENDIAN ) { +return ; + }size_t i;struct virtio_gpu_ctrl_hdr *hdr = (struct virtio_gpu_ctrl_hdr *) ptr;
@@ -41,8 +43,6 @@ virtio_gpu_bswap_32(void *ptr, size_t size)le32_to_cpus ((uint32_t *)(ptr + i)); i = i +sizeof (uint32_t ); } - -#endif } static inline void
hw/display/artist.c +6 -6
@@ -738,9 +738,9 @@ static void combine_write_reg(hwaddr addr, uint64_t val, int size, void *out)* FIXME: is there a qemu helper for this? */ -#if !HOST_BIG_ENDIAN - addr ^=3 ; -#endif +if (!HOST_BIG_ENDIAN ) { + addr ^=3 ; + }switch (size) {case 1 :
@@ -1132,9 +1132,9 @@ static uint64_t combine_read_reg(hwaddr addr, int size, void *in)* FIXME: is there a qemu helper for this? */ -#if !HOST_BIG_ENDIAN - addr ^=3 ; -#endif +if (!HOST_BIG_ENDIAN ) { + addr ^=3 ; + }switch (size) {case 1 :
hw/display/vga.c +8 -12
@@ -1307,13 +1307,13 @@ static void vga_draw_text(VGACommonState *s, int full_update)if (cx > cx_max) cx_max = cx; *ch_attr_ptr = ch_attr; -#if HOST_BIG_ENDIAN - ch = ch_attr >>8 ; - cattr = ch_attr &0xff ; -#else - ch = ch_attr &0xff ; - cattr = ch_attr >>8 ; -#endif +if (HOST_BIG_ENDIAN ) { + ch = ch_attr >>8 ; + cattr = ch_attr &0xff ; + }else { + ch = ch_attr &0xff ; + cattr = ch_attr >>8 ; + } font_ptr = font_base[(cattr >>3 ) &1 ]; font_ptr +=32 *4 * ch; bgcol = palette[cattr >>4 ];
@@ -1489,11 +1489,7 @@ static void vga_draw_graphic(VGACommonState *s, int full_update)vga_draw_line_func *vga_draw_line =NULL ;bool allocate_surface, force_shadow = false;pixman_format_code_t format; -#if HOST_BIG_ENDIAN -bool byteswap = !s->big_endian_fb; -#else -bool byteswap = s->big_endian_fb; -#endif +bool byteswap = s->big_endian_fb ^HOST_BIG_ENDIAN ; full_update |=update_basic_params (s);
hw/display/virtio-gpu-gl.c +4 -4
@@ -123,10 +123,10 @@ static void virtio_gpu_gl_device_realize(DeviceState *qdev, Error **errp)ERRP_GUARD ();VirtIOGPU *g =VIRTIO_GPU (qdev); -#if HOST_BIG_ENDIAN -error_setg (errp,"virgl is not supported on bigendian platforms" ); -return ; -#endif +if (HOST_BIG_ENDIAN ) { +error_setg (errp,"virgl is not supported on bigendian platforms" ); +return ; + }if (!object_resolve_path_type ("" ,TYPE_VIRTIO_GPU_GL ,NULL )) {error_setg (errp,"at most one %s device is permitted" ,TYPE_VIRTIO_GPU_GL );
hw/display/virtio-gpu-rutabaga.c +4 -4
@@ -1074,10 +1074,10 @@ static void virtio_gpu_rutabaga_realize(DeviceState *qdev, Error **errp)VirtIOGPUBase *bdev =VIRTIO_GPU_BASE (qdev);VirtIOGPU *gpudev =VIRTIO_GPU (qdev); -#if HOST_BIG_ENDIAN -error_setg (errp,"rutabaga is not supported on bigendian platforms" ); -return ; -#endif +if (HOST_BIG_ENDIAN ) { +error_setg (errp,"rutabaga is not supported on bigendian platforms" ); +return ; + }if (!virtio_gpu_rutabaga_init (gpudev, errp)) {return ;
Signature · 1 line
2.51.0
Re: [PATCH 07/16] hw/display: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
Quoted 7 lines · Philippe Mathieu-Daudé
Replace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
PATCH 8/16 hw/virtio: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
In reply to Philippe Mathieu-DaudéReplace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
--- include/hw/virtio/virtio-access.h | 6 +----- hw/virtio/vhost.c | 7 +++---- 2 files changed, 4 insertions(+), 9 deletions(-)
include/hw/virtio/virtio-access.h +1 -5
@@ -149,11 +149,7 @@ static inline uint64_t virtio_ldq_p(VirtIODevice *vdev, const void *ptr)static inline uint16_t virtio_tswap16 (VirtIODevice *vdev,uint16_t s) { -#if HOST_BIG_ENDIAN -return virtio_access_is_big_endian (vdev) ? s :bswap16 (s); -#else -return virtio_access_is_big_endian (vdev) ?bswap16 (s) : s; -#endif +return HOST_BIG_ENDIAN ^virtio_access_is_big_endian (vdev) ? s :bswap16 (s); } static inline uint16_t virtio_lduw_phys_cached(VirtIODevice *vdev,
hw/virtio/vhost.c +3 -4
@@ -1168,11 +1168,10 @@ static inline bool vhost_needs_vring_endian(VirtIODevice *vdev)if (virtio_vdev_has_feature (vdev,VIRTIO_F_VERSION_1 )) {return false; } -#if HOST_BIG_ENDIAN -return vdev->device_endian ==VIRTIO_DEVICE_ENDIAN_LITTLE ; -#else +if (HOST_BIG_ENDIAN ) { +return vdev->device_endian ==VIRTIO_DEVICE_ENDIAN_LITTLE ; + }return vdev->device_endian ==VIRTIO_DEVICE_ENDIAN_BIG ; -#endif } static int vhost_virtqueue_set_vring_endian_legacy(struct vhost_dev *dev,
Signature · 1 line
2.51.0
Re: [PATCH 08/16] hw/virtio: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
Quoted 17 lines · Philippe Mathieu-Daudé
Replace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/virtio/virtio-access.h | 6 +----- hw/virtio/vhost.c | 7 +++---- 2 files changed, 4 insertions(+), 9 deletions(-)include/hw/virtio/virtio-access.h +0
-0
include/hw/virtio/virtio-access.h static inline uint64_t virtio_ldq_p(VirtIODevice *vdev, const void *ptr) · line 152
Quoted 9 lines
include/hw/virtio/virtio-access.h +1
-5@@ -149,11 +149,7 @@ static inline uint64_t virtio_ldq_p(VirtIODevice *vdev, const void *ptr)static inline uint16_t virtio_tswap16 (VirtIODevice *vdev,uint16_t s) { -#if HOST_BIG_ENDIAN -return virtio_access_is_big_endian (vdev) ? s :bswap16 (s); -#else -return virtio_access_is_big_endian (vdev) ?bswap16 (s) : s; -#endif +return HOST_BIG_ENDIAN ^virtio_access_is_big_endian (vdev) ? s :bswap16 (s);
This patch breaks virtio devices(at least input/net devices) on s390x. I am not sure if ^ is the right check here? Changing the logic back to how it was fixes it for me.
Thanks
Farhan
Quoted 22 lines
include/hw/virtio/virtio-access.h +0
-0} static inline uint16_t virtio_lduw_phys_cached(VirtIODevice *vdev,hw/virtio/vhost.c +3
-4@@ -1168,11 +1168,10 @@ static inline bool vhost_needs_vring_endian(VirtIODevice *vdev)if (virtio_vdev_has_feature (vdev,VIRTIO_F_VERSION_1 )) {return false; } -#if HOST_BIG_ENDIAN -return vdev->device_endian ==VIRTIO_DEVICE_ENDIAN_LITTLE ; -#else +if (HOST_BIG_ENDIAN ) { +return vdev->device_endian ==VIRTIO_DEVICE_ENDIAN_LITTLE ; + }return vdev->device_endian ==VIRTIO_DEVICE_ENDIAN_BIG ; -#endif } static int vhost_virtqueue_set_vring_endian_legacy(struct vhost_dev *dev,
Re: [PATCH 08/16] hw/virtio: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
Hi Philippe Mathieu-Daudé
According to my test result this change introduced a minor bug, qemu output error messages "qemu-system-x86_64: virtio-blk missing headers" reproduced command:/usr/local/bin/qemu-system-x86_64 -M q35 -m 8G -smp 8 -cpu host -enable-kvm -device VGA,bus=pcie.0,addr=0x2 -drive file=///home/fedora-40.qcow2,media=disk,if=virtio -device virtio-net-pci,mac=00:11:22:33:44:00,netdev=netdev1,id=net1,bus=pcie.0,addr=0x7
-netdev tap,id=netdev1,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown
-vnc :0 -monitor stdio
QEMU 10.1.50 monitor - type 'help' for more information
(qemu) qemu-system-x86_64: virtio-blk missing headers
Thanks
Lei
Quoted 61 lines · Farhan Ali
Quoted 17 lines · Philippe Mathieu-Daudé
Replace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/virtio/virtio-access.h | 6 +----- hw/virtio/vhost.c | 7 +++---- 2 files changed, 4 insertions(+), 9 deletions(-)include/hw/virtio/virtio-access.h +0
-0include/hw/virtio/virtio-access.h static inline uint64_t virtio_ldq_p(VirtIODevice *vdev, const void *ptr) · line 152
Quoted 9 lines
include/hw/virtio/virtio-access.h +1
-5@@ -149,11 +149,7 @@ static inline uint64_t virtio_ldq_p(VirtIODevice *vdev, const void *ptr)static inline uint16_t virtio_tswap16 (VirtIODevice *vdev,uint16_t s) { -#if HOST_BIG_ENDIAN -return virtio_access_is_big_endian (vdev) ? s :bswap16 (s); -#else -return virtio_access_is_big_endian (vdev) ?bswap16 (s) : s; -#endif +return HOST_BIG_ENDIAN ^virtio_access_is_big_endian (vdev) ? s :bswap16 (s);This patch breaks virtio devices(at least input/net devices) on s390x. I am not sure if ^ is the right check here? Changing the logic back to how it was fixes it for me.
Thanks
Farhan
Quoted 22 lines
include/hw/virtio/virtio-access.h +0
-0} static inline uint16_t virtio_lduw_phys_cached(VirtIODevice *vdev,hw/virtio/vhost.c +3
-4@@ -1168,11 +1168,10 @@ static inline bool vhost_needs_vring_endian(VirtIODevice *vdev)if (virtio_vdev_has_feature (vdev,VIRTIO_F_VERSION_1 )) {return false; } -#if HOST_BIG_ENDIAN -return vdev->device_endian ==VIRTIO_DEVICE_ENDIAN_LITTLE ; -#else +if (HOST_BIG_ENDIAN ) { +return vdev->device_endian ==VIRTIO_DEVICE_ENDIAN_LITTLE ; + }return vdev->device_endian ==VIRTIO_DEVICE_ENDIAN_BIG ; -#endif } static int vhost_virtqueue_set_vring_endian_legacy(struct vhost_dev *dev,
PATCH 9/16 target/alpha: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
In reply to Philippe Mathieu-DaudéReplace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
--- target/alpha/translate.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
target/alpha/translate.c +6 -5
@@ -235,11 +235,12 @@ static TCGv dest_fpr(DisasContext *ctx, unsigned reg)static int get_flag_ofs (unsigned shift) {int ofs = offsetof(CPUAlphaState , flags); -#if HOST_BIG_ENDIAN - ofs +=3 - (shift /8 ); -#else - ofs += shift /8 ; -#endif + +if (HOST_BIG_ENDIAN ) { + ofs +=3 - (shift /8 ); + }else { + ofs += shift /8 ; + }return ofs; }
Signature · 1 line
2.51.0
PATCH 10/16 target/arm: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
In reply to Philippe Mathieu-DaudéReplace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
--- target/arm/cpu.h | 8 ++++---- target/arm/tcg/translate-a64.h | 5 ++--- target/arm/tcg/sve_helper.c | 10 ++-------- target/arm/tcg/translate-sve.c | 22 +++++++++++----------- target/arm/tcg/translate-vfp.c | 8 +------- target/arm/tcg/translate.c | 6 +++--- 6 files changed, 23 insertions(+), 36 deletions(-)
target/arm/cpu.h +4 -4
@@ -1249,17 +1249,17 @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask);*/ static inline uint64_t *sve_bswap64 (uint64_t *dst,uint64_t *src,int nr) { -#if HOST_BIG_ENDIAN int i; +if (!HOST_BIG_ENDIAN ) { +return src; + } +for (i =0 ; i < nr; ++i) { dst[i] =bswap64 (src[i]); }return dst; -#else -return src; -#endif }void aarch64_sync_32_to_64 (CPUARMState *env);
target/arm/tcg/translate-a64.h +2 -3
@@ -82,7 +82,7 @@ static inline int vec_reg_offset(DisasContext *s, int regno, {int element_size =1 << size;int offs = element * element_size; -#if HOST_BIG_ENDIAN +/* This is complicated slightly because vfp.zregs[n].d[0] is * still the lowest and vfp.zregs[n].d[15] the highest of the * 256 byte vector, even on big endian systems.
@@ -97,10 +97,9 @@ static inline int vec_reg_offset(DisasContext *s, int regno,* operations will have to special case loading and storing from * the zregs array. */ -if (element_size <8 ) { +if (HOST_BIG_ENDIAN && element_size <8 ) { offs ^=8 - element_size; } -#endif offs += offsetof(CPUARMState, vfp.zregs[regno]);assert_fp_access_checked (s);return offs;
target/arm/tcg/sve_helper.c +2 -8
@@ -2861,12 +2861,9 @@ static void swap_memmove(void *vd, void *vs, size_t n) {uintptr_t d = (uintptr_t )vd;uintptr_t s = (uintptr_t )vs; -uintptr_t o = (d | s | n) &7 ; +uintptr_t o =HOST_BIG_ENDIAN ? (d | s | n) &7 :0 ;size_t i; -#if !HOST_BIG_ENDIAN - o =0 ; -#endif switch (o) {case 0 :memmove (vd, vs, n);
@@ -2918,7 +2915,7 @@ static void swap_memmove(void *vd, void *vs, size_t n)static void swap_memzero (void *vd,size_t n) {uintptr_t d = (uintptr_t )vd; -uintptr_t o = (d | n) &7 ; +uintptr_t o =HOST_BIG_ENDIAN ? (d | n) &7 :0 ;size_t i;/* Usually, the first bit of a predicate is set, so N is 0. */
@@ -2926,9 +2923,6 @@ static void swap_memzero(void *vd, size_t n)return ; } -#if !HOST_BIG_ENDIAN - o =0 ; -#endif switch (o) {case 0 :memset (vd,0 , n);
target/arm/tcg/translate-sve.c +11 -11
@@ -2770,12 +2770,12 @@ static TCGv_i64 load_last_active(DisasContext *s, TCGv_i32 last,* The final adjustment for the vector register base * is added via constant offset to the load. */ -#if HOST_BIG_ENDIAN -/* Adjust for element ordering. See vec_reg_offset. */ -if (esz <3 ) { -tcg_gen_xori_i32 (last, last,8 - (1 << esz)); +if (HOST_BIG_ENDIAN ) { +/* Adjust for element ordering. See vec_reg_offset. */ +if (esz <3 ) { +tcg_gen_xori_i32 (last, last,8 - (1 << esz)); + } } -#endif tcg_gen_ext_i32_ptr (p, last);tcg_gen_add_ptr (p, p, tcg_env);
@@ -5394,9 +5394,9 @@ static void do_ldrq(DisasContext *s, int zt, int pg, TCGv_i64 addr, int dtype)* for this load operation. */ TCGv_i64 tmp =tcg_temp_new_i64 (); -#if HOST_BIG_ENDIAN - poff +=6 ; -#endif +if (HOST_BIG_ENDIAN ) { + poff +=6 ; + }tcg_gen_ld16u_i64 (tmp, tcg_env, poff); poff = offsetof(CPUARMState, vfp.preg_tmp);
@@ -5478,9 +5478,9 @@ static void do_ldro(DisasContext *s, int zt, int pg, TCGv_i64 addr, int dtype)* for this load operation. */ TCGv_i64 tmp =tcg_temp_new_i64 (); -#if HOST_BIG_ENDIAN - poff +=4 ; -#endif +if (HOST_BIG_ENDIAN ) { + poff +=4 ; + }tcg_gen_ld32u_i64 (tmp, tcg_env, poff); poff = offsetof(CPUARMState, vfp.preg_tmp);
target/arm/tcg/translate-vfp.c +1 -7
@@ -95,15 +95,9 @@ uint64_t vfp_expand_imm(int size, uint8_t imm8)static inline long vfp_f16_offset (unsigned reg,bool top) {long offs =vfp_reg_offset (false, reg); -#if HOST_BIG_ENDIAN -if (!top) { +if (top ^HOST_BIG_ENDIAN ) { offs +=2 ; } -#else -if (top) { - offs +=2 ; - } -#endif return offs; }
target/arm/tcg/translate.c +3 -3
@@ -1148,15 +1148,15 @@ long neon_element_offset(int reg, int element, MemOp memop) {int element_size =1 << (memop &MO_SIZE );int ofs = element * element_size; -#if HOST_BIG_ENDIAN +/* * Calculate the offset assuming fully little-endian, * then XOR to account for the order of the 8-byte units. */ -if (element_size <8 ) { +if (HOST_BIG_ENDIAN && element_size <8 ) { ofs ^=8 - element_size; } -#endif +return neon_full_reg_offset (reg) + ofs; }
Signature · 1 line
2.51.0
PATCH 11/16 target/mips: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
In reply to Philippe Mathieu-DaudéReplace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
--- target/mips/tcg/msa_helper.c | 889 +++++++++++++++++------------------ 1 file changed, 444 insertions(+), 445 deletions(-)
target/mips/tcg/msa_helper.c +444 -445
@@ -4148,41 +4148,41 @@ void helper_msa_ilvev_b(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->b[8 ] = pws->b[9 ]; - pwd->b[9 ] = pwt->b[9 ]; - pwd->b[10 ] = pws->b[11 ]; - pwd->b[11 ] = pwt->b[11 ]; - pwd->b[12 ] = pws->b[13 ]; - pwd->b[13 ] = pwt->b[13 ]; - pwd->b[14 ] = pws->b[15 ]; - pwd->b[15 ] = pwt->b[15 ]; - pwd->b[0 ] = pws->b[1 ]; - pwd->b[1 ] = pwt->b[1 ]; - pwd->b[2 ] = pws->b[3 ]; - pwd->b[3 ] = pwt->b[3 ]; - pwd->b[4 ] = pws->b[5 ]; - pwd->b[5 ] = pwt->b[5 ]; - pwd->b[6 ] = pws->b[7 ]; - pwd->b[7 ] = pwt->b[7 ]; -#else - pwd->b[15 ] = pws->b[14 ]; - pwd->b[14 ] = pwt->b[14 ]; - pwd->b[13 ] = pws->b[12 ]; - pwd->b[12 ] = pwt->b[12 ]; - pwd->b[11 ] = pws->b[10 ]; - pwd->b[10 ] = pwt->b[10 ]; - pwd->b[9 ] = pws->b[8 ]; - pwd->b[8 ] = pwt->b[8 ]; - pwd->b[7 ] = pws->b[6 ]; - pwd->b[6 ] = pwt->b[6 ]; - pwd->b[5 ] = pws->b[4 ]; - pwd->b[4 ] = pwt->b[4 ]; - pwd->b[3 ] = pws->b[2 ]; - pwd->b[2 ] = pwt->b[2 ]; - pwd->b[1 ] = pws->b[0 ]; - pwd->b[0 ] = pwt->b[0 ]; -#endif +if (HOST_BIG_ENDIAN ) { + pwd->b[8 ] = pws->b[9 ]; + pwd->b[9 ] = pwt->b[9 ]; + pwd->b[10 ] = pws->b[11 ]; + pwd->b[11 ] = pwt->b[11 ]; + pwd->b[12 ] = pws->b[13 ]; + pwd->b[13 ] = pwt->b[13 ]; + pwd->b[14 ] = pws->b[15 ]; + pwd->b[15 ] = pwt->b[15 ]; + pwd->b[0 ] = pws->b[1 ]; + pwd->b[1 ] = pwt->b[1 ]; + pwd->b[2 ] = pws->b[3 ]; + pwd->b[3 ] = pwt->b[3 ]; + pwd->b[4 ] = pws->b[5 ]; + pwd->b[5 ] = pwt->b[5 ]; + pwd->b[6 ] = pws->b[7 ]; + pwd->b[7 ] = pwt->b[7 ]; + }else { + pwd->b[15 ] = pws->b[14 ]; + pwd->b[14 ] = pwt->b[14 ]; + pwd->b[13 ] = pws->b[12 ]; + pwd->b[12 ] = pwt->b[12 ]; + pwd->b[11 ] = pws->b[10 ]; + pwd->b[10 ] = pwt->b[10 ]; + pwd->b[9 ] = pws->b[8 ]; + pwd->b[8 ] = pwt->b[8 ]; + pwd->b[7 ] = pws->b[6 ]; + pwd->b[6 ] = pwt->b[6 ]; + pwd->b[5 ] = pws->b[4 ]; + pwd->b[4 ] = pwt->b[4 ]; + pwd->b[3 ] = pws->b[2 ]; + pwd->b[2 ] = pwt->b[2 ]; + pwd->b[1 ] = pws->b[0 ]; + pwd->b[0 ] = pwt->b[0 ]; + } } void helper_msa_ilvev_h(CPUMIPSState *env,
@@ -4192,25 +4192,25 @@ void helper_msa_ilvev_h(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->h[4 ] = pws->h[5 ]; - pwd->h[5 ] = pwt->h[5 ]; - pwd->h[6 ] = pws->h[7 ]; - pwd->h[7 ] = pwt->h[7 ]; - pwd->h[0 ] = pws->h[1 ]; - pwd->h[1 ] = pwt->h[1 ]; - pwd->h[2 ] = pws->h[3 ]; - pwd->h[3 ] = pwt->h[3 ]; -#else - pwd->h[7 ] = pws->h[6 ]; - pwd->h[6 ] = pwt->h[6 ]; - pwd->h[5 ] = pws->h[4 ]; - pwd->h[4 ] = pwt->h[4 ]; - pwd->h[3 ] = pws->h[2 ]; - pwd->h[2 ] = pwt->h[2 ]; - pwd->h[1 ] = pws->h[0 ]; - pwd->h[0 ] = pwt->h[0 ]; -#endif +if (HOST_BIG_ENDIAN ) { + pwd->h[4 ] = pws->h[5 ]; + pwd->h[5 ] = pwt->h[5 ]; + pwd->h[6 ] = pws->h[7 ]; + pwd->h[7 ] = pwt->h[7 ]; + pwd->h[0 ] = pws->h[1 ]; + pwd->h[1 ] = pwt->h[1 ]; + pwd->h[2 ] = pws->h[3 ]; + pwd->h[3 ] = pwt->h[3 ]; + }else { + pwd->h[7 ] = pws->h[6 ]; + pwd->h[6 ] = pwt->h[6 ]; + pwd->h[5 ] = pws->h[4 ]; + pwd->h[4 ] = pwt->h[4 ]; + pwd->h[3 ] = pws->h[2 ]; + pwd->h[2 ] = pwt->h[2 ]; + pwd->h[1 ] = pws->h[0 ]; + pwd->h[0 ] = pwt->h[0 ]; + } } void helper_msa_ilvev_w(CPUMIPSState *env,
@@ -4220,17 +4220,17 @@ void helper_msa_ilvev_w(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->w[2 ] = pws->w[3 ]; - pwd->w[3 ] = pwt->w[3 ]; - pwd->w[0 ] = pws->w[1 ]; - pwd->w[1 ] = pwt->w[1 ]; -#else - pwd->w[3 ] = pws->w[2 ]; - pwd->w[2 ] = pwt->w[2 ]; - pwd->w[1 ] = pws->w[0 ]; - pwd->w[0 ] = pwt->w[0 ]; -#endif +if (HOST_BIG_ENDIAN ) { + pwd->w[2 ] = pws->w[3 ]; + pwd->w[3 ] = pwt->w[3 ]; + pwd->w[0 ] = pws->w[1 ]; + pwd->w[1 ] = pwt->w[1 ]; + }else { + pwd->w[3 ] = pws->w[2 ]; + pwd->w[2 ] = pwt->w[2 ]; + pwd->w[1 ] = pws->w[0 ]; + pwd->w[0 ] = pwt->w[0 ]; + } } void helper_msa_ilvev_d(CPUMIPSState *env,
@@ -4252,41 +4252,41 @@ void helper_msa_ilvod_b(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->b[7 ] = pwt->b[6 ]; - pwd->b[6 ] = pws->b[6 ]; - pwd->b[5 ] = pwt->b[4 ]; - pwd->b[4 ] = pws->b[4 ]; - pwd->b[3 ] = pwt->b[2 ]; - pwd->b[2 ] = pws->b[2 ]; - pwd->b[1 ] = pwt->b[0 ]; - pwd->b[0 ] = pws->b[0 ]; - pwd->b[15 ] = pwt->b[14 ]; - pwd->b[14 ] = pws->b[14 ]; - pwd->b[13 ] = pwt->b[12 ]; - pwd->b[12 ] = pws->b[12 ]; - pwd->b[11 ] = pwt->b[10 ]; - pwd->b[10 ] = pws->b[10 ]; - pwd->b[9 ] = pwt->b[8 ]; - pwd->b[8 ] = pws->b[8 ]; -#else - pwd->b[0 ] = pwt->b[1 ]; - pwd->b[1 ] = pws->b[1 ]; - pwd->b[2 ] = pwt->b[3 ]; - pwd->b[3 ] = pws->b[3 ]; - pwd->b[4 ] = pwt->b[5 ]; - pwd->b[5 ] = pws->b[5 ]; - pwd->b[6 ] = pwt->b[7 ]; - pwd->b[7 ] = pws->b[7 ]; - pwd->b[8 ] = pwt->b[9 ]; - pwd->b[9 ] = pws->b[9 ]; - pwd->b[10 ] = pwt->b[11 ]; - pwd->b[11 ] = pws->b[11 ]; - pwd->b[12 ] = pwt->b[13 ]; - pwd->b[13 ] = pws->b[13 ]; - pwd->b[14 ] = pwt->b[15 ]; - pwd->b[15 ] = pws->b[15 ]; -#endif +if (HOST_BIG_ENDIAN ) { + pwd->b[7 ] = pwt->b[6 ]; + pwd->b[6 ] = pws->b[6 ]; + pwd->b[5 ] = pwt->b[4 ]; + pwd->b[4 ] = pws->b[4 ]; + pwd->b[3 ] = pwt->b[2 ]; + pwd->b[2 ] = pws->b[2 ]; + pwd->b[1 ] = pwt->b[0 ]; + pwd->b[0 ] = pws->b[0 ]; + pwd->b[15 ] = pwt->b[14 ]; + pwd->b[14 ] = pws->b[14 ]; + pwd->b[13 ] = pwt->b[12 ]; + pwd->b[12 ] = pws->b[12 ]; + pwd->b[11 ] = pwt->b[10 ]; + pwd->b[10 ] = pws->b[10 ]; + pwd->b[9 ] = pwt->b[8 ]; + pwd->b[8 ] = pws->b[8 ]; + }else { + pwd->b[0 ] = pwt->b[1 ]; + pwd->b[1 ] = pws->b[1 ]; + pwd->b[2 ] = pwt->b[3 ]; + pwd->b[3 ] = pws->b[3 ]; + pwd->b[4 ] = pwt->b[5 ]; + pwd->b[5 ] = pws->b[5 ]; + pwd->b[6 ] = pwt->b[7 ]; + pwd->b[7 ] = pws->b[7 ]; + pwd->b[8 ] = pwt->b[9 ]; + pwd->b[9 ] = pws->b[9 ]; + pwd->b[10 ] = pwt->b[11 ]; + pwd->b[11 ] = pws->b[11 ]; + pwd->b[12 ] = pwt->b[13 ]; + pwd->b[13 ] = pws->b[13 ]; + pwd->b[14 ] = pwt->b[15 ]; + pwd->b[15 ] = pws->b[15 ]; + } } void helper_msa_ilvod_h(CPUMIPSState *env,
@@ -4296,25 +4296,25 @@ void helper_msa_ilvod_h(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->h[3 ] = pwt->h[2 ]; - pwd->h[2 ] = pws->h[2 ]; - pwd->h[1 ] = pwt->h[0 ]; - pwd->h[0 ] = pws->h[0 ]; - pwd->h[7 ] = pwt->h[6 ]; - pwd->h[6 ] = pws->h[6 ]; - pwd->h[5 ] = pwt->h[4 ]; - pwd->h[4 ] = pws->h[4 ]; -#else - pwd->h[0 ] = pwt->h[1 ]; - pwd->h[1 ] = pws->h[1 ]; - pwd->h[2 ] = pwt->h[3 ]; - pwd->h[3 ] = pws->h[3 ]; - pwd->h[4 ] = pwt->h[5 ]; - pwd->h[5 ] = pws->h[5 ]; - pwd->h[6 ] = pwt->h[7 ]; - pwd->h[7 ] = pws->h[7 ]; -#endif +if (HOST_BIG_ENDIAN ) { + pwd->h[3 ] = pwt->h[2 ]; + pwd->h[2 ] = pws->h[2 ]; + pwd->h[1 ] = pwt->h[0 ]; + pwd->h[0 ] = pws->h[0 ]; + pwd->h[7 ] = pwt->h[6 ]; + pwd->h[6 ] = pws->h[6 ]; + pwd->h[5 ] = pwt->h[4 ]; + pwd->h[4 ] = pws->h[4 ]; + }else { + pwd->h[0 ] = pwt->h[1 ]; + pwd->h[1 ] = pws->h[1 ]; + pwd->h[2 ] = pwt->h[3 ]; + pwd->h[3 ] = pws->h[3 ]; + pwd->h[4 ] = pwt->h[5 ]; + pwd->h[5 ] = pws->h[5 ]; + pwd->h[6 ] = pwt->h[7 ]; + pwd->h[7 ] = pws->h[7 ]; + } } void helper_msa_ilvod_w(CPUMIPSState *env,
@@ -4324,17 +4324,17 @@ void helper_msa_ilvod_w(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->w[1 ] = pwt->w[0 ]; - pwd->w[0 ] = pws->w[0 ]; - pwd->w[3 ] = pwt->w[2 ]; - pwd->w[2 ] = pws->w[2 ]; -#else - pwd->w[0 ] = pwt->w[1 ]; - pwd->w[1 ] = pws->w[1 ]; - pwd->w[2 ] = pwt->w[3 ]; - pwd->w[3 ] = pws->w[3 ]; -#endif +if (HOST_BIG_ENDIAN ) { + pwd->w[1 ] = pwt->w[0 ]; + pwd->w[0 ] = pws->w[0 ]; + pwd->w[3 ] = pwt->w[2 ]; + pwd->w[2 ] = pws->w[2 ]; + }else { + pwd->w[0 ] = pwt->w[1 ]; + pwd->w[1 ] = pws->w[1 ]; + pwd->w[2 ] = pwt->w[3 ]; + pwd->w[3 ] = pws->w[3 ]; + } } void helper_msa_ilvod_d(CPUMIPSState *env,
@@ -4356,41 +4356,41 @@ void helper_msa_ilvl_b(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->b[7 ] = pwt->b[15 ]; - pwd->b[6 ] = pws->b[15 ]; - pwd->b[5 ] = pwt->b[14 ]; - pwd->b[4 ] = pws->b[14 ]; - pwd->b[3 ] = pwt->b[13 ]; - pwd->b[2 ] = pws->b[13 ]; - pwd->b[1 ] = pwt->b[12 ]; - pwd->b[0 ] = pws->b[12 ]; - pwd->b[15 ] = pwt->b[11 ]; - pwd->b[14 ] = pws->b[11 ]; - pwd->b[13 ] = pwt->b[10 ]; - pwd->b[12 ] = pws->b[10 ]; - pwd->b[11 ] = pwt->b[9 ]; - pwd->b[10 ] = pws->b[9 ]; - pwd->b[9 ] = pwt->b[8 ]; - pwd->b[8 ] = pws->b[8 ]; -#else - pwd->b[0 ] = pwt->b[8 ]; - pwd->b[1 ] = pws->b[8 ]; - pwd->b[2 ] = pwt->b[9 ]; - pwd->b[3 ] = pws->b[9 ]; - pwd->b[4 ] = pwt->b[10 ]; - pwd->b[5 ] = pws->b[10 ]; - pwd->b[6 ] = pwt->b[11 ]; - pwd->b[7 ] = pws->b[11 ]; - pwd->b[8 ] = pwt->b[12 ]; - pwd->b[9 ] = pws->b[12 ]; - pwd->b[10 ] = pwt->b[13 ]; - pwd->b[11 ] = pws->b[13 ]; - pwd->b[12 ] = pwt->b[14 ]; - pwd->b[13 ] = pws->b[14 ]; - pwd->b[14 ] = pwt->b[15 ]; - pwd->b[15 ] = pws->b[15 ]; -#endif +if (HOST_BIG_ENDIAN ) { + pwd->b[7 ] = pwt->b[15 ]; + pwd->b[6 ] = pws->b[15 ]; + pwd->b[5 ] = pwt->b[14 ]; + pwd->b[4 ] = pws->b[14 ]; + pwd->b[3 ] = pwt->b[13 ]; + pwd->b[2 ] = pws->b[13 ]; + pwd->b[1 ] = pwt->b[12 ]; + pwd->b[0 ] = pws->b[12 ]; + pwd->b[15 ] = pwt->b[11 ]; + pwd->b[14 ] = pws->b[11 ]; + pwd->b[13 ] = pwt->b[10 ]; + pwd->b[12 ] = pws->b[10 ]; + pwd->b[11 ] = pwt->b[9 ]; + pwd->b[10 ] = pws->b[9 ]; + pwd->b[9 ] = pwt->b[8 ]; + pwd->b[8 ] = pws->b[8 ]; + }else { + pwd->b[0 ] = pwt->b[8 ]; + pwd->b[1 ] = pws->b[8 ]; + pwd->b[2 ] = pwt->b[9 ]; + pwd->b[3 ] = pws->b[9 ]; + pwd->b[4 ] = pwt->b[10 ]; + pwd->b[5 ] = pws->b[10 ]; + pwd->b[6 ] = pwt->b[11 ]; + pwd->b[7 ] = pws->b[11 ]; + pwd->b[8 ] = pwt->b[12 ]; + pwd->b[9 ] = pws->b[12 ]; + pwd->b[10 ] = pwt->b[13 ]; + pwd->b[11 ] = pws->b[13 ]; + pwd->b[12 ] = pwt->b[14 ]; + pwd->b[13 ] = pws->b[14 ]; + pwd->b[14 ] = pwt->b[15 ]; + pwd->b[15 ] = pws->b[15 ]; + } } void helper_msa_ilvl_h(CPUMIPSState *env,
@@ -4400,25 +4400,25 @@ void helper_msa_ilvl_h(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->h[3 ] = pwt->h[7 ]; - pwd->h[2 ] = pws->h[7 ]; - pwd->h[1 ] = pwt->h[6 ]; - pwd->h[0 ] = pws->h[6 ]; - pwd->h[7 ] = pwt->h[5 ]; - pwd->h[6 ] = pws->h[5 ]; - pwd->h[5 ] = pwt->h[4 ]; - pwd->h[4 ] = pws->h[4 ]; -#else - pwd->h[0 ] = pwt->h[4 ]; - pwd->h[1 ] = pws->h[4 ]; - pwd->h[2 ] = pwt->h[5 ]; - pwd->h[3 ] = pws->h[5 ]; - pwd->h[4 ] = pwt->h[6 ]; - pwd->h[5 ] = pws->h[6 ]; - pwd->h[6 ] = pwt->h[7 ]; - pwd->h[7 ] = pws->h[7 ]; -#endif +if (HOST_BIG_ENDIAN ) { + pwd->h[3 ] = pwt->h[7 ]; + pwd->h[2 ] = pws->h[7 ]; + pwd->h[1 ] = pwt->h[6 ]; + pwd->h[0 ] = pws->h[6 ]; + pwd->h[7 ] = pwt->h[5 ]; + pwd->h[6 ] = pws->h[5 ]; + pwd->h[5 ] = pwt->h[4 ]; + pwd->h[4 ] = pws->h[4 ]; + }else { + pwd->h[0 ] = pwt->h[4 ]; + pwd->h[1 ] = pws->h[4 ]; + pwd->h[2 ] = pwt->h[5 ]; + pwd->h[3 ] = pws->h[5 ]; + pwd->h[4 ] = pwt->h[6 ]; + pwd->h[5 ] = pws->h[6 ]; + pwd->h[6 ] = pwt->h[7 ]; + pwd->h[7 ] = pws->h[7 ]; + } } void helper_msa_ilvl_w(CPUMIPSState *env,
@@ -4428,17 +4428,17 @@ void helper_msa_ilvl_w(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->w[1 ] = pwt->w[3 ]; - pwd->w[0 ] = pws->w[3 ]; - pwd->w[3 ] = pwt->w[2 ]; - pwd->w[2 ] = pws->w[2 ]; -#else - pwd->w[0 ] = pwt->w[2 ]; - pwd->w[1 ] = pws->w[2 ]; - pwd->w[2 ] = pwt->w[3 ]; - pwd->w[3 ] = pws->w[3 ]; -#endif +if (HOST_BIG_ENDIAN ) { + pwd->w[1 ] = pwt->w[3 ]; + pwd->w[0 ] = pws->w[3 ]; + pwd->w[3 ] = pwt->w[2 ]; + pwd->w[2 ] = pws->w[2 ]; + }else { + pwd->w[0 ] = pwt->w[2 ]; + pwd->w[1 ] = pws->w[2 ]; + pwd->w[2 ] = pwt->w[3 ]; + pwd->w[3 ] = pws->w[3 ]; + } } void helper_msa_ilvl_d(CPUMIPSState *env,
@@ -4460,41 +4460,41 @@ void helper_msa_ilvr_b(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->b[8 ] = pws->b[0 ]; - pwd->b[9 ] = pwt->b[0 ]; - pwd->b[10 ] = pws->b[1 ]; - pwd->b[11 ] = pwt->b[1 ]; - pwd->b[12 ] = pws->b[2 ]; - pwd->b[13 ] = pwt->b[2 ]; - pwd->b[14 ] = pws->b[3 ]; - pwd->b[15 ] = pwt->b[3 ]; - pwd->b[0 ] = pws->b[4 ]; - pwd->b[1 ] = pwt->b[4 ]; - pwd->b[2 ] = pws->b[5 ]; - pwd->b[3 ] = pwt->b[5 ]; - pwd->b[4 ] = pws->b[6 ]; - pwd->b[5 ] = pwt->b[6 ]; - pwd->b[6 ] = pws->b[7 ]; - pwd->b[7 ] = pwt->b[7 ]; -#else - pwd->b[15 ] = pws->b[7 ]; - pwd->b[14 ] = pwt->b[7 ]; - pwd->b[13 ] = pws->b[6 ]; - pwd->b[12 ] = pwt->b[6 ]; - pwd->b[11 ] = pws->b[5 ]; - pwd->b[10 ] = pwt->b[5 ]; - pwd->b[9 ] = pws->b[4 ]; - pwd->b[8 ] = pwt->b[4 ]; - pwd->b[7 ] = pws->b[3 ]; - pwd->b[6 ] = pwt->b[3 ]; - pwd->b[5 ] = pws->b[2 ]; - pwd->b[4 ] = pwt->b[2 ]; - pwd->b[3 ] = pws->b[1 ]; - pwd->b[2 ] = pwt->b[1 ]; - pwd->b[1 ] = pws->b[0 ]; - pwd->b[0 ] = pwt->b[0 ]; -#endif +if (HOST_BIG_ENDIAN ) { + pwd->b[8 ] = pws->b[0 ]; + pwd->b[9 ] = pwt->b[0 ]; + pwd->b[10 ] = pws->b[1 ]; + pwd->b[11 ] = pwt->b[1 ]; + pwd->b[12 ] = pws->b[2 ]; + pwd->b[13 ] = pwt->b[2 ]; + pwd->b[14 ] = pws->b[3 ]; + pwd->b[15 ] = pwt->b[3 ]; + pwd->b[0 ] = pws->b[4 ]; + pwd->b[1 ] = pwt->b[4 ]; + pwd->b[2 ] = pws->b[5 ]; + pwd->b[3 ] = pwt->b[5 ]; + pwd->b[4 ] = pws->b[6 ]; + pwd->b[5 ] = pwt->b[6 ]; + pwd->b[6 ] = pws->b[7 ]; + pwd->b[7 ] = pwt->b[7 ]; + }else { + pwd->b[15 ] = pws->b[7 ]; + pwd->b[14 ] = pwt->b[7 ]; + pwd->b[13 ] = pws->b[6 ]; + pwd->b[12 ] = pwt->b[6 ]; + pwd->b[11 ] = pws->b[5 ]; + pwd->b[10 ] = pwt->b[5 ]; + pwd->b[9 ] = pws->b[4 ]; + pwd->b[8 ] = pwt->b[4 ]; + pwd->b[7 ] = pws->b[3 ]; + pwd->b[6 ] = pwt->b[3 ]; + pwd->b[5 ] = pws->b[2 ]; + pwd->b[4 ] = pwt->b[2 ]; + pwd->b[3 ] = pws->b[1 ]; + pwd->b[2 ] = pwt->b[1 ]; + pwd->b[1 ] = pws->b[0 ]; + pwd->b[0 ] = pwt->b[0 ]; + } } void helper_msa_ilvr_h(CPUMIPSState *env,
@@ -4504,25 +4504,25 @@ void helper_msa_ilvr_h(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->h[4 ] = pws->h[0 ]; - pwd->h[5 ] = pwt->h[0 ]; - pwd->h[6 ] = pws->h[1 ]; - pwd->h[7 ] = pwt->h[1 ]; - pwd->h[0 ] = pws->h[2 ]; - pwd->h[1 ] = pwt->h[2 ]; - pwd->h[2 ] = pws->h[3 ]; - pwd->h[3 ] = pwt->h[3 ]; -#else - pwd->h[7 ] = pws->h[3 ]; - pwd->h[6 ] = pwt->h[3 ]; - pwd->h[5 ] = pws->h[2 ]; - pwd->h[4 ] = pwt->h[2 ]; - pwd->h[3 ] = pws->h[1 ]; - pwd->h[2 ] = pwt->h[1 ]; - pwd->h[1 ] = pws->h[0 ]; - pwd->h[0 ] = pwt->h[0 ]; -#endif +if (HOST_BIG_ENDIAN ) { + pwd->h[4 ] = pws->h[0 ]; + pwd->h[5 ] = pwt->h[0 ]; + pwd->h[6 ] = pws->h[1 ]; + pwd->h[7 ] = pwt->h[1 ]; + pwd->h[0 ] = pws->h[2 ]; + pwd->h[1 ] = pwt->h[2 ]; + pwd->h[2 ] = pws->h[3 ]; + pwd->h[3 ] = pwt->h[3 ]; + }else { + pwd->h[7 ] = pws->h[3 ]; + pwd->h[6 ] = pwt->h[3 ]; + pwd->h[5 ] = pws->h[2 ]; + pwd->h[4 ] = pwt->h[2 ]; + pwd->h[3 ] = pws->h[1 ]; + pwd->h[2 ] = pwt->h[1 ]; + pwd->h[1 ] = pws->h[0 ]; + pwd->h[0 ] = pwt->h[0 ]; + } } void helper_msa_ilvr_w(CPUMIPSState *env,
@@ -4532,17 +4532,17 @@ void helper_msa_ilvr_w(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->w[2 ] = pws->w[0 ]; - pwd->w[3 ] = pwt->w[0 ]; - pwd->w[0 ] = pws->w[1 ]; - pwd->w[1 ] = pwt->w[1 ]; -#else - pwd->w[3 ] = pws->w[1 ]; - pwd->w[2 ] = pwt->w[1 ]; - pwd->w[1 ] = pws->w[0 ]; - pwd->w[0 ] = pwt->w[0 ]; -#endif +if (HOST_BIG_ENDIAN ) { + pwd->w[2 ] = pws->w[0 ]; + pwd->w[3 ] = pwt->w[0 ]; + pwd->w[0 ] = pws->w[1 ]; + pwd->w[1 ] = pwt->w[1 ]; + }else { + pwd->w[3 ] = pws->w[1 ]; + pwd->w[2 ] = pwt->w[1 ]; + pwd->w[1 ] = pws->w[0 ]; + pwd->w[0 ] = pwt->w[0 ]; + } } void helper_msa_ilvr_d(CPUMIPSState *env,
@@ -4663,41 +4663,41 @@ void helper_msa_pckev_b(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->b[8 ] = pws->b[9 ]; - pwd->b[10 ] = pws->b[13 ]; - pwd->b[12 ] = pws->b[1 ]; - pwd->b[14 ] = pws->b[5 ]; - pwd->b[0 ] = pwt->b[9 ]; - pwd->b[2 ] = pwt->b[13 ]; - pwd->b[4 ] = pwt->b[1 ]; - pwd->b[6 ] = pwt->b[5 ]; - pwd->b[9 ] = pws->b[11 ]; - pwd->b[13 ] = pws->b[3 ]; - pwd->b[1 ] = pwt->b[11 ]; - pwd->b[5 ] = pwt->b[3 ]; - pwd->b[11 ] = pws->b[15 ]; - pwd->b[3 ] = pwt->b[15 ]; - pwd->b[15 ] = pws->b[7 ]; - pwd->b[7 ] = pwt->b[7 ]; -#else - pwd->b[15 ] = pws->b[14 ]; - pwd->b[13 ] = pws->b[10 ]; - pwd->b[11 ] = pws->b[6 ]; - pwd->b[9 ] = pws->b[2 ]; - pwd->b[7 ] = pwt->b[14 ]; - pwd->b[5 ] = pwt->b[10 ]; - pwd->b[3 ] = pwt->b[6 ]; - pwd->b[1 ] = pwt->b[2 ]; - pwd->b[14 ] = pws->b[12 ]; - pwd->b[10 ] = pws->b[4 ]; - pwd->b[6 ] = pwt->b[12 ]; - pwd->b[2 ] = pwt->b[4 ]; - pwd->b[12 ] = pws->b[8 ]; - pwd->b[4 ] = pwt->b[8 ]; - pwd->b[8 ] = pws->b[0 ]; - pwd->b[0 ] = pwt->b[0 ]; -#endif +if (HOST_BIG_ENDIAN ) { + pwd->b[8 ] = pws->b[9 ]; + pwd->b[10 ] = pws->b[13 ]; + pwd->b[12 ] = pws->b[1 ]; + pwd->b[14 ] = pws->b[5 ]; + pwd->b[0 ] = pwt->b[9 ]; + pwd->b[2 ] = pwt->b[13 ]; + pwd->b[4 ] = pwt->b[1 ]; + pwd->b[6 ] = pwt->b[5 ]; + pwd->b[9 ] = pws->b[11 ]; + pwd->b[13 ] = pws->b[3 ]; + pwd->b[1 ] = pwt->b[11 ]; + pwd->b[5 ] = pwt->b[3 ]; + pwd->b[11 ] = pws->b[15 ]; + pwd->b[3 ] = pwt->b[15 ]; + pwd->b[15 ] = pws->b[7 ]; + pwd->b[7 ] = pwt->b[7 ]; + }else { + pwd->b[15 ] = pws->b[14 ]; + pwd->b[13 ] = pws->b[10 ]; + pwd->b[11 ] = pws->b[6 ]; + pwd->b[9 ] = pws->b[2 ]; + pwd->b[7 ] = pwt->b[14 ]; + pwd->b[5 ] = pwt->b[10 ]; + pwd->b[3 ] = pwt->b[6 ]; + pwd->b[1 ] = pwt->b[2 ]; + pwd->b[14 ] = pws->b[12 ]; + pwd->b[10 ] = pws->b[4 ]; + pwd->b[6 ] = pwt->b[12 ]; + pwd->b[2 ] = pwt->b[4 ]; + pwd->b[12 ] = pws->b[8 ]; + pwd->b[4 ] = pwt->b[8 ]; + pwd->b[8 ] = pws->b[0 ]; + pwd->b[0 ] = pwt->b[0 ]; + } } void helper_msa_pckev_h(CPUMIPSState *env,
@@ -4707,25 +4707,25 @@ void helper_msa_pckev_h(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->h[4 ] = pws->h[5 ]; - pwd->h[6 ] = pws->h[1 ]; - pwd->h[0 ] = pwt->h[5 ]; - pwd->h[2 ] = pwt->h[1 ]; - pwd->h[5 ] = pws->h[7 ]; - pwd->h[1 ] = pwt->h[7 ]; - pwd->h[7 ] = pws->h[3 ]; - pwd->h[3 ] = pwt->h[3 ]; -#else - pwd->h[7 ] = pws->h[6 ]; - pwd->h[5 ] = pws->h[2 ]; - pwd->h[3 ] = pwt->h[6 ]; - pwd->h[1 ] = pwt->h[2 ]; - pwd->h[6 ] = pws->h[4 ]; - pwd->h[2 ] = pwt->h[4 ]; - pwd->h[4 ] = pws->h[0 ]; - pwd->h[0 ] = pwt->h[0 ]; -#endif +if (HOST_BIG_ENDIAN ) { + pwd->h[4 ] = pws->h[5 ]; + pwd->h[6 ] = pws->h[1 ]; + pwd->h[0 ] = pwt->h[5 ]; + pwd->h[2 ] = pwt->h[1 ]; + pwd->h[5 ] = pws->h[7 ]; + pwd->h[1 ] = pwt->h[7 ]; + pwd->h[7 ] = pws->h[3 ]; + pwd->h[3 ] = pwt->h[3 ]; + }else { + pwd->h[7 ] = pws->h[6 ]; + pwd->h[5 ] = pws->h[2 ]; + pwd->h[3 ] = pwt->h[6 ]; + pwd->h[1 ] = pwt->h[2 ]; + pwd->h[6 ] = pws->h[4 ]; + pwd->h[2 ] = pwt->h[4 ]; + pwd->h[4 ] = pws->h[0 ]; + pwd->h[0 ] = pwt->h[0 ]; + } } void helper_msa_pckev_w(CPUMIPSState *env,
@@ -4735,17 +4735,17 @@ void helper_msa_pckev_w(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->w[2 ] = pws->w[3 ]; - pwd->w[0 ] = pwt->w[3 ]; - pwd->w[3 ] = pws->w[1 ]; - pwd->w[1 ] = pwt->w[1 ]; -#else - pwd->w[3 ] = pws->w[2 ]; - pwd->w[1 ] = pwt->w[2 ]; - pwd->w[2 ] = pws->w[0 ]; - pwd->w[0 ] = pwt->w[0 ]; -#endif +if (HOST_BIG_ENDIAN ) { + pwd->w[2 ] = pws->w[3 ]; + pwd->w[0 ] = pwt->w[3 ]; + pwd->w[3 ] = pws->w[1 ]; + pwd->w[1 ] = pwt->w[1 ]; + }else { + pwd->w[3 ] = pws->w[2 ]; + pwd->w[1 ] = pwt->w[2 ]; + pwd->w[2 ] = pws->w[0 ]; + pwd->w[0 ] = pwt->w[0 ]; + } } void helper_msa_pckev_d(CPUMIPSState *env,
@@ -4767,42 +4767,41 @@ void helper_msa_pckod_b(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->b[7 ] = pwt->b[6 ]; - pwd->b[5 ] = pwt->b[2 ]; - pwd->b[3 ] = pwt->b[14 ]; - pwd->b[1 ] = pwt->b[10 ]; - pwd->b[15 ] = pws->b[6 ]; - pwd->b[13 ] = pws->b[2 ]; - pwd->b[11 ] = pws->b[14 ]; - pwd->b[9 ] = pws->b[10 ]; - pwd->b[6 ] = pwt->b[4 ]; - pwd->b[2 ] = pwt->b[12 ]; - pwd->b[14 ] = pws->b[4 ]; - pwd->b[10 ] = pws->b[12 ]; - pwd->b[4 ] = pwt->b[0 ]; - pwd->b[12 ] = pws->b[0 ]; - pwd->b[0 ] = pwt->b[8 ]; - pwd->b[8 ] = pws->b[8 ]; -#else - pwd->b[0 ] = pwt->b[1 ]; - pwd->b[2 ] = pwt->b[5 ]; - pwd->b[4 ] = pwt->b[9 ]; - pwd->b[6 ] = pwt->b[13 ]; - pwd->b[8 ] = pws->b[1 ]; - pwd->b[10 ] = pws->b[5 ]; - pwd->b[12 ] = pws->b[9 ]; - pwd->b[14 ] = pws->b[13 ]; - pwd->b[1 ] = pwt->b[3 ]; - pwd->b[5 ] = pwt->b[11 ]; - pwd->b[9 ] = pws->b[3 ]; - pwd->b[13 ] = pws->b[11 ]; - pwd->b[3 ] = pwt->b[7 ]; - pwd->b[11 ] = pws->b[7 ]; - pwd->b[7 ] = pwt->b[15 ]; - pwd->b[15 ] = pws->b[15 ]; -#endif - +if (HOST_BIG_ENDIAN ) { + pwd->b[7 ] = pwt->b[6 ]; + pwd->b[5 ] = pwt->b[2 ]; + pwd->b[3 ] = pwt->b[14 ]; + pwd->b[1 ] = pwt->b[10 ]; + pwd->b[15 ] = pws->b[6 ]; + pwd->b[13 ] = pws->b[2 ]; + pwd->b[11 ] = pws->b[14 ]; + pwd->b[9 ] = pws->b[10 ]; + pwd->b[6 ] = pwt->b[4 ]; + pwd->b[2 ] = pwt->b[12 ]; + pwd->b[14 ] = pws->b[4 ]; + pwd->b[10 ] = pws->b[12 ]; + pwd->b[4 ] = pwt->b[0 ]; + pwd->b[12 ] = pws->b[0 ]; + pwd->b[0 ] = pwt->b[8 ]; + pwd->b[8 ] = pws->b[8 ]; + }else { + pwd->b[0 ] = pwt->b[1 ]; + pwd->b[2 ] = pwt->b[5 ]; + pwd->b[4 ] = pwt->b[9 ]; + pwd->b[6 ] = pwt->b[13 ]; + pwd->b[8 ] = pws->b[1 ]; + pwd->b[10 ] = pws->b[5 ]; + pwd->b[12 ] = pws->b[9 ]; + pwd->b[14 ] = pws->b[13 ]; + pwd->b[1 ] = pwt->b[3 ]; + pwd->b[5 ] = pwt->b[11 ]; + pwd->b[9 ] = pws->b[3 ]; + pwd->b[13 ] = pws->b[11 ]; + pwd->b[3 ] = pwt->b[7 ]; + pwd->b[11 ] = pws->b[7 ]; + pwd->b[7 ] = pwt->b[15 ]; + pwd->b[15 ] = pws->b[15 ]; + } } void helper_msa_pckod_h(CPUMIPSState *env,
@@ -4812,25 +4811,25 @@ void helper_msa_pckod_h(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->h[3 ] = pwt->h[2 ]; - pwd->h[1 ] = pwt->h[6 ]; - pwd->h[7 ] = pws->h[2 ]; - pwd->h[5 ] = pws->h[6 ]; - pwd->h[2 ] = pwt->h[0 ]; - pwd->h[6 ] = pws->h[0 ]; - pwd->h[0 ] = pwt->h[4 ]; - pwd->h[4 ] = pws->h[4 ]; -#else - pwd->h[0 ] = pwt->h[1 ]; - pwd->h[2 ] = pwt->h[5 ]; - pwd->h[4 ] = pws->h[1 ]; - pwd->h[6 ] = pws->h[5 ]; - pwd->h[1 ] = pwt->h[3 ]; - pwd->h[5 ] = pws->h[3 ]; - pwd->h[3 ] = pwt->h[7 ]; - pwd->h[7 ] = pws->h[7 ]; -#endif +if (HOST_BIG_ENDIAN ) { + pwd->h[3 ] = pwt->h[2 ]; + pwd->h[1 ] = pwt->h[6 ]; + pwd->h[7 ] = pws->h[2 ]; + pwd->h[5 ] = pws->h[6 ]; + pwd->h[2 ] = pwt->h[0 ]; + pwd->h[6 ] = pws->h[0 ]; + pwd->h[0 ] = pwt->h[4 ]; + pwd->h[4 ] = pws->h[4 ]; + }else { + pwd->h[0 ] = pwt->h[1 ]; + pwd->h[2 ] = pwt->h[5 ]; + pwd->h[4 ] = pws->h[1 ]; + pwd->h[6 ] = pws->h[5 ]; + pwd->h[1 ] = pwt->h[3 ]; + pwd->h[5 ] = pws->h[3 ]; + pwd->h[3 ] = pwt->h[7 ]; + pwd->h[7 ] = pws->h[7 ]; + } } void helper_msa_pckod_w(CPUMIPSState *env,
@@ -4840,17 +4839,17 @@ void helper_msa_pckod_w(CPUMIPSState *env,wr_t *pws = &(env->active_fpu.fpr[ws].wr);wr_t *pwt = &(env->active_fpu.fpr[wt].wr); -#if HOST_BIG_ENDIAN - pwd->w[1 ] = pwt->w[0 ]; - pwd->w[3 ] = pws->w[0 ]; - pwd->w[0 ] = pwt->w[2 ]; - pwd->w[2 ] = pws->w[2 ]; -#else - pwd->w[0 ] = pwt->w[1 ]; - pwd->w[2 ] = pws->w[1 ]; - pwd->w[1 ] = pwt->w[3 ]; - pwd->w[3 ] = pws->w[3 ]; -#endif +if (HOST_BIG_ENDIAN ) { + pwd->w[1 ] = pwt->w[0 ]; + pwd->w[3 ] = pws->w[0 ]; + pwd->w[0 ] = pwt->w[2 ]; + pwd->w[2 ] = pws->w[2 ]; + }else { + pwd->w[0 ] = pwt->w[1 ]; + pwd->w[2 ] = pws->w[1 ]; + pwd->w[1 ] = pwt->w[3 ]; + pwd->w[3 ] = pws->w[3 ]; + } } void helper_msa_pckod_d(CPUMIPSState *env,
@@ -5928,13 +5927,13 @@ void helper_msa_copy_s_b(CPUMIPSState *env, uint32_t rd, uint32_t ws, uint32_t n) { n %=16 ; -#if HOST_BIG_ENDIAN -if (n <8 ) { - n =8 - n -1 ; - }else { - n =24 - n -1 ; +if (HOST_BIG_ENDIAN ) { +if (n <8 ) { + n =8 - n -1 ; + }else { + n =24 - n -1 ; + } } -#endif env->active_tc.gpr[rd] = (int8_t )env->active_fpu.fpr[ws].wr.b[n]; }
@@ -5942,13 +5941,13 @@ void helper_msa_copy_s_h(CPUMIPSState *env, uint32_t rd, uint32_t ws, uint32_t n) { n %=8 ; -#if HOST_BIG_ENDIAN -if (n <4 ) { - n =4 - n -1 ; - }else { - n =12 - n -1 ; +if (HOST_BIG_ENDIAN ) { +if (n <4 ) { + n =4 - n -1 ; + }else { + n =12 - n -1 ; + } } -#endif env->active_tc.gpr[rd] = (int16_t )env->active_fpu.fpr[ws].wr.h[n]; }
@@ -5956,13 +5955,13 @@ void helper_msa_copy_s_w(CPUMIPSState *env, uint32_t rd, uint32_t ws, uint32_t n) { n %=4 ; -#if HOST_BIG_ENDIAN -if (n <2 ) { - n =2 - n -1 ; - }else { - n =6 - n -1 ; +if (HOST_BIG_ENDIAN ) { +if (n <2 ) { + n =2 - n -1 ; + }else { + n =6 - n -1 ; + } } -#endif env->active_tc.gpr[rd] = (int32_t )env->active_fpu.fpr[ws].wr.w[n]; }
@@ -5977,13 +5976,13 @@ void helper_msa_copy_u_b(CPUMIPSState *env, uint32_t rd, uint32_t ws, uint32_t n) { n %=16 ; -#if HOST_BIG_ENDIAN -if (n <8 ) { - n =8 - n -1 ; - }else { - n =24 - n -1 ; +if (HOST_BIG_ENDIAN ) { +if (n <8 ) { + n =8 - n -1 ; + }else { + n =24 - n -1 ; + } } -#endif env->active_tc.gpr[rd] = (uint8_t )env->active_fpu.fpr[ws].wr.b[n]; }
@@ -5991,13 +5990,13 @@ void helper_msa_copy_u_h(CPUMIPSState *env, uint32_t rd, uint32_t ws, uint32_t n) { n %=8 ; -#if HOST_BIG_ENDIAN -if (n <4 ) { - n =4 - n -1 ; - }else { - n =12 - n -1 ; +if (HOST_BIG_ENDIAN ) { +if (n <4 ) { + n =4 - n -1 ; + }else { + n =12 - n -1 ; + } } -#endif env->active_tc.gpr[rd] = (uint16_t )env->active_fpu.fpr[ws].wr.h[n]; }
@@ -6005,13 +6004,13 @@ void helper_msa_copy_u_w(CPUMIPSState *env, uint32_t rd, uint32_t ws, uint32_t n) { n %=4 ; -#if HOST_BIG_ENDIAN -if (n <2 ) { - n =2 - n -1 ; - }else { - n =6 - n -1 ; +if (HOST_BIG_ENDIAN ) { +if (n <2 ) { + n =2 - n -1 ; + }else { + n =6 - n -1 ; + } } -#endif env->active_tc.gpr[rd] = (uint32_t )env->active_fpu.fpr[ws].wr.w[n]; }
@@ -6021,13 +6020,13 @@ void helper_msa_insert_b(CPUMIPSState *env, uint32_t wd,wr_t *pwd = &(env->active_fpu.fpr[wd].wr);target_ulong rs = env->active_tc.gpr[rs_num]; n %=16 ; -#if HOST_BIG_ENDIAN -if (n <8 ) { - n =8 - n -1 ; - }else { - n =24 - n -1 ; +if (HOST_BIG_ENDIAN ) { +if (n <8 ) { + n =8 - n -1 ; + }else { + n =24 - n -1 ; + } } -#endif pwd->b[n] = (int8_t )rs; }
@@ -6037,13 +6036,13 @@ void helper_msa_insert_h(CPUMIPSState *env, uint32_t wd,wr_t *pwd = &(env->active_fpu.fpr[wd].wr);target_ulong rs = env->active_tc.gpr[rs_num]; n %=8 ; -#if HOST_BIG_ENDIAN -if (n <4 ) { - n =4 - n -1 ; - }else { - n =12 - n -1 ; +if (HOST_BIG_ENDIAN ) { +if (n <4 ) { + n =4 - n -1 ; + }else { + n =12 - n -1 ; + } } -#endif pwd->h[n] = (int16_t )rs; }
@@ -6053,13 +6052,13 @@ void helper_msa_insert_w(CPUMIPSState *env, uint32_t wd,wr_t *pwd = &(env->active_fpu.fpr[wd].wr);target_ulong rs = env->active_tc.gpr[rs_num]; n %=4 ; -#if HOST_BIG_ENDIAN -if (n <2 ) { - n =2 - n -1 ; - }else { - n =6 - n -1 ; +if (HOST_BIG_ENDIAN ) { +if (n <2 ) { + n =2 - n -1 ; + }else { + n =6 - n -1 ; + } } -#endif pwd->w[n] = (int32_t )rs; }
Signature · 1 line
2.51.0
PATCH 12/16 target/ppc: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
In reply to Philippe Mathieu-DaudéReplace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
--- target/ppc/arch_dump.c | 9 ++------- target/ppc/int_helper.c | 28 ++++++++++++++-------------- target/ppc/kvm.c | 25 +++++++++---------------- target/ppc/translate/vmx-impl.c.inc | 14 +++++++------- target/ppc/translate/vsx-impl.c.inc | 6 +++--- tcg/ppc/tcg-target.c.inc | 24 ++++++++++++------------ 6 files changed, 47 insertions(+), 59 deletions(-)
target/ppc/arch_dump.c +2 -7
@@ -158,21 +158,16 @@ static void ppc_write_elf_vmxregset(NoteFuncArg *arg, PowerPCCPU *cpu, int id)struct PPCElfVmxregset *vmxregset;Note *note = &arg->note;DumpState *s = arg->state; +const int host_data_order =HOST_BIG_ENDIAN ?ELFDATA2MSB :ELFDATA2LSB ; +const bool needs_byteswap = s->dump_info.d_endian == host_data_order; note->hdr.n_type =cpu_to_dump32 (s,NT_PPC_VMX ); vmxregset = ¬e->contents.vmxregset;memset (vmxregset,0 ,sizeof (*vmxregset));for (i =0 ; i <32 ; i++) { -bool needs_byteswap;ppc_avr_t *avr =cpu_avr_ptr (&cpu->env, i); -#if HOST_BIG_ENDIAN - needs_byteswap = s->dump_info.d_endian ==ELFDATA2LSB ; -#else - needs_byteswap = s->dump_info.d_endian ==ELFDATA2MSB ; -#endif -if (needs_byteswap) { vmxregset->avr[i].u64[0 ] =bswap64 (avr->u64[1 ]); vmxregset->avr[i].u64[1 ] =bswap64 (avr->u64[0 ]);
target/ppc/int_helper.c +14 -14
@@ -1678,13 +1678,13 @@ void helper_vslo(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) {int sh = (b->VsrB (0xf ) >>3 ) &0xf ; -#if HOST_BIG_ENDIAN -memmove (&r->u8[0 ], &a->u8[sh],16 - sh); -memset (&r->u8[16 - sh],0 , sh); -#else -memmove (&r->u8[sh], &a->u8[0 ],16 - sh); -memset (&r->u8[0 ],0 , sh); -#endif +if (HOST_BIG_ENDIAN ) { +memmove (&r->u8[0 ], &a->u8[sh],16 - sh); +memset (&r->u8[16 - sh],0 , sh); + }else { +memmove (&r->u8[sh], &a->u8[0 ],16 - sh); +memset (&r->u8[0 ],0 , sh); + } }#if HOST_BIG_ENDIAN
@@ -1898,13 +1898,13 @@ void helper_vsro(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) {int sh = (b->VsrB (0xf ) >>3 ) &0xf ; -#if HOST_BIG_ENDIAN -memmove (&r->u8[sh], &a->u8[0 ],16 - sh); -memset (&r->u8[0 ],0 , sh); -#else -memmove (&r->u8[0 ], &a->u8[sh],16 - sh); -memset (&r->u8[16 - sh],0 , sh); -#endif +if (HOST_BIG_ENDIAN ) { +memmove (&r->u8[sh], &a->u8[0 ],16 - sh); +memset (&r->u8[0 ],0 , sh); + }else { +memmove (&r->u8[0 ], &a->u8[sh],16 - sh); +memset (&r->u8[16 - sh],0 , sh); + } }void helper_vsumsws (CPUPPCState *env,ppc_avr_t *r,ppc_avr_t *a,ppc_avr_t *b)
target/ppc/kvm.c +9 -16
@@ -651,13 +651,13 @@ static int kvm_put_fp(CPUState *cs)uint64_t *fpr =cpu_fpr_ptr (env, i);uint64_t *vsrl =cpu_vsrl_ptr (env, i); -#if HOST_BIG_ENDIAN - vsr[0 ] =float64_val (*fpr); - vsr[1 ] = *vsrl; -#else - vsr[0 ] = *vsrl; - vsr[1 ] =float64_val (*fpr); -#endif +if (HOST_BIG_ENDIAN ) { + vsr[0 ] =float64_val (*fpr); + vsr[1 ] = *vsrl; + }else { + vsr[0 ] = *vsrl; + vsr[1 ] =float64_val (*fpr); + } reg.addr = (uintptr_t ) &vsr; reg.id = vsx ?KVM_REG_PPC_VSR (i) :KVM_REG_PPC_FPR (i);
@@ -728,17 +728,10 @@ static int kvm_get_fp(CPUState *cs) strerror(errno));return ret; }else { -#if HOST_BIG_ENDIAN - *fpr = vsr[0 ]; + *fpr = vsr[!HOST_BIG_ENDIAN ];if (vsx) { - *vsrl = vsr[1 ]; + *vsrl = vsr[HOST_BIG_ENDIAN ]; } -#else - *fpr = vsr[1 ]; -if (vsx) { - *vsrl = vsr[0 ]; - } -#endif } } }
target/ppc/translate/vmx-impl.c.inc +7 -7
@@ -134,9 +134,9 @@ static void gen_mtvscr(DisasContext *ctx) val = tcg_temp_new_i32(); bofs = avr_full_offset(rB(ctx->opcode)); -#if HOST_BIG_ENDIAN - bofs += 3 * 4; -#endif + if (HOST_BIG_ENDIAN) { + bofs += 3 * 4; + } tcg_gen_ld_i32(val, tcg_env, bofs); gen_helper_mtvscr(tcg_env, val);
@@ -1528,10 +1528,10 @@ static void gen_vsplt(DisasContext *ctx, int vece) /* Experimental testing shows that hardware masks the immediate. */ bofs += (uimm << vece) & 15; -#if !HOST_BIG_ENDIAN - bofs ^= 15; - bofs &= ~((1 << vece) - 1); -#endif + if (!HOST_BIG_ENDIAN) { + bofs ^= 15; + bofs &= ~((1 << vece) - 1); + } tcg_gen_gvec_dup_mem(vece, dofs, bofs, 16, 16); }
target/ppc/translate/vsx-impl.c.inc +3 -3
@@ -1642,9 +1642,9 @@ static bool trans_XXSPLTW(DisasContext *ctx, arg_XX2_uim *a) tofs = vsr_full_offset(a->xt); bofs = vsr_full_offset(a->xb); bofs += a->uim << MO_32; -#if !HOST_BIG_ENDIAN - bofs ^= 8 | 4; -#endif + if (!HOST_BIG_ENDIAN) { + bofs ^= 8 | 4; + } tcg_gen_gvec_dup_mem(MO_32, tofs, bofs, 16, 16); return true;
tcg/ppc/tcg-target.c.inc +12 -12
@@ -3951,9 +3951,9 @@ static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, tcg_out_mem_long(s, 0, LVEBX, out, base, offset); } elt = extract32(offset, 0, 4); -#if !HOST_BIG_ENDIAN - elt ^= 15; -#endif + if (!HOST_BIG_ENDIAN) { + elt ^= 15; + } tcg_out32(s, VSPLTB | VRT(out) | VRB(out) | (elt << 16)); break; case MO_16:
@@ -3964,9 +3964,9 @@ static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, tcg_out_mem_long(s, 0, LVEHX, out, base, offset); } elt = extract32(offset, 1, 3); -#if !HOST_BIG_ENDIAN - elt ^= 7; -#endif + if (!HOST_BIG_ENDIAN) { + elt ^= 7; + } tcg_out32(s, VSPLTH | VRT(out) | VRB(out) | (elt << 16)); break; case MO_32:
@@ -3977,9 +3977,9 @@ static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, tcg_debug_assert((offset & 3) == 0); tcg_out_mem_long(s, 0, LVEWX, out, base, offset); elt = extract32(offset, 2, 2); -#if !HOST_BIG_ENDIAN - elt ^= 3; -#endif + if (!HOST_BIG_ENDIAN) { + elt ^= 3; + } tcg_out32(s, VSPLTW | VRT(out) | VRB(out) | (elt << 16)); break; case MO_64:
@@ -3991,9 +3991,9 @@ static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, tcg_out_mem_long(s, 0, LVX, out, base, offset & -16); tcg_out_vsldoi(s, TCG_VEC_TMP1, out, out, 8); elt = extract32(offset, 3, 1); -#if !HOST_BIG_ENDIAN - elt = !elt; -#endif + if (!HOST_BIG_ENDIAN) { + elt = !elt; + } if (elt) { tcg_out_vsldoi(s, out, out, TCG_VEC_TMP1, 8); } else {
Signature · 1 line
2.51.0
Re: [PATCH 12/16] target/ppc: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
Quoted 21 lines · Philippe Mathieu-Daudé
Replace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/ppc/arch_dump.c | 9 ++------- target/ppc/int_helper.c | 28 ++++++++++++++-------------- target/ppc/kvm.c | 25 +++++++++---------------- target/ppc/translate/vmx-impl.c.inc | 14 +++++++------- target/ppc/translate/vsx-impl.c.inc | 6 +++--- tcg/ppc/tcg-target.c.inc | 24 ++++++++++++------------ 6 files changed, 47 insertions(+), 59 deletions(-)target/ppc/arch_dump.c +0
-0
target/ppc/arch_dump.c static void ppc_write_elf_vmxregset(NoteFuncArg *arg, PowerPCCPU *cpu, int id) · line 161
Quoted 4 lines
target/ppc/arch_dump.c +1
-0@@ -158,21 +158,16 @@ static void ppc_write_elf_vmxregset(NoteFuncArg *arg, PowerPCCPU *cpu, int id)struct PPCElfVmxregset *vmxregset;Note *note = &arg->note;DumpState *s = arg->state; +const int host_data_order =HOST_BIG_ENDIAN ?ELFDATA2MSB :ELFDATA2LSB ;
I think the order of return values of ternary op needs to be swapped.
HOST_BIG_ENDIAN ? ELFDATA2LSB : ELFDATA2MSB;
Otherwise, looks fine. With that fixed:
Quoted 215 lines
target/ppc/arch_dump.c +1
-7+const bool needs_byteswap = s->dump_info.d_endian == host_data_order; note->hdr.n_type =cpu_to_dump32 (s,NT_PPC_VMX ); vmxregset = ¬e->contents.vmxregset;memset (vmxregset,0 ,sizeof (*vmxregset));for (i =0 ; i <32 ; i++) { -bool needs_byteswap;ppc_avr_t *avr =cpu_avr_ptr (&cpu->env, i); -#if HOST_BIG_ENDIAN - needs_byteswap = s->dump_info.d_endian ==ELFDATA2LSB ; -#else - needs_byteswap = s->dump_info.d_endian ==ELFDATA2MSB ; -#endif -if (needs_byteswap) { vmxregset->avr[i].u64[0 ] =bswap64 (avr->u64[1 ]); vmxregset->avr[i].u64[1 ] =bswap64 (avr->u64[0 ]);target/ppc/int_helper.c +14
-14@@ -1678,13 +1678,13 @@ void helper_vslo(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) {int sh = (b->VsrB (0xf ) >>3 ) &0xf ; -#if HOST_BIG_ENDIAN -memmove (&r->u8[0 ], &a->u8[sh],16 - sh); -memset (&r->u8[16 - sh],0 , sh); -#else -memmove (&r->u8[sh], &a->u8[0 ],16 - sh); -memset (&r->u8[0 ],0 , sh); -#endif +if (HOST_BIG_ENDIAN ) { +memmove (&r->u8[0 ], &a->u8[sh],16 - sh); +memset (&r->u8[16 - sh],0 , sh); + }else { +memmove (&r->u8[sh], &a->u8[0 ],16 - sh); +memset (&r->u8[0 ],0 , sh); + } }#if HOST_BIG_ENDIAN @@ -1898,13 +1898,13 @@ void helper_vsro(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) {int sh = (b->VsrB (0xf ) >>3 ) &0xf ; -#if HOST_BIG_ENDIAN -memmove (&r->u8[sh], &a->u8[0 ],16 - sh); -memset (&r->u8[0 ],0 , sh); -#else -memmove (&r->u8[0 ], &a->u8[sh],16 - sh); -memset (&r->u8[16 - sh],0 , sh); -#endif +if (HOST_BIG_ENDIAN ) { +memmove (&r->u8[sh], &a->u8[0 ],16 - sh); +memset (&r->u8[0 ],0 , sh); + }else { +memmove (&r->u8[0 ], &a->u8[sh],16 - sh); +memset (&r->u8[16 - sh],0 , sh); + } }void helper_vsumsws (CPUPPCState *env,ppc_avr_t *r,ppc_avr_t *a,ppc_avr_t *b)target/ppc/kvm.c +9
-16@@ -651,13 +651,13 @@ static int kvm_put_fp(CPUState *cs)uint64_t *fpr =cpu_fpr_ptr (env, i);uint64_t *vsrl =cpu_vsrl_ptr (env, i); -#if HOST_BIG_ENDIAN - vsr[0 ] =float64_val (*fpr); - vsr[1 ] = *vsrl; -#else - vsr[0 ] = *vsrl; - vsr[1 ] =float64_val (*fpr); -#endif +if (HOST_BIG_ENDIAN ) { + vsr[0 ] =float64_val (*fpr); + vsr[1 ] = *vsrl; + }else { + vsr[0 ] = *vsrl; + vsr[1 ] =float64_val (*fpr); + } reg.addr = (uintptr_t ) &vsr; reg.id = vsx ?KVM_REG_PPC_VSR (i) :KVM_REG_PPC_FPR (i);@@ -728,17 +728,10 @@ static int kvm_get_fp(CPUState *cs) strerror(errno));return ret; }else { -#if HOST_BIG_ENDIAN - *fpr = vsr[0 ]; + *fpr = vsr[!HOST_BIG_ENDIAN ];if (vsx) { - *vsrl = vsr[1 ]; + *vsrl = vsr[HOST_BIG_ENDIAN ]; } -#else - *fpr = vsr[1 ]; -if (vsx) { - *vsrl = vsr[0 ]; - } -#endif } } }target/ppc/translate/vmx-impl.c.inc +7
-7@@ -134,9 +134,9 @@ static void gen_mtvscr(DisasContext *ctx) val = tcg_temp_new_i32(); bofs = avr_full_offset(rB(ctx->opcode)); -#if HOST_BIG_ENDIAN - bofs += 3 * 4; -#endif + if (HOST_BIG_ENDIAN) { + bofs += 3 * 4; + } tcg_gen_ld_i32(val, tcg_env, bofs); gen_helper_mtvscr(tcg_env, val);@@ -1528,10 +1528,10 @@ static void gen_vsplt(DisasContext *ctx, int vece) /* Experimental testing shows that hardware masks the immediate. */ bofs += (uimm << vece) & 15; -#if !HOST_BIG_ENDIAN - bofs ^= 15; - bofs &= ~((1 << vece) - 1); -#endif + if (!HOST_BIG_ENDIAN) { + bofs ^= 15; + bofs &= ~((1 << vece) - 1); + } tcg_gen_gvec_dup_mem(vece, dofs, bofs, 16, 16); }target/ppc/translate/vsx-impl.c.inc +3
-3@@ -1642,9 +1642,9 @@ static bool trans_XXSPLTW(DisasContext *ctx, arg_XX2_uim *a) tofs = vsr_full_offset(a->xt); bofs = vsr_full_offset(a->xb); bofs += a->uim << MO_32; -#if !HOST_BIG_ENDIAN - bofs ^= 8 | 4; -#endif + if (!HOST_BIG_ENDIAN) { + bofs ^= 8 | 4; + } tcg_gen_gvec_dup_mem(MO_32, tofs, bofs, 16, 16); return true;tcg/ppc/tcg-target.c.inc +12
-12@@ -3951,9 +3951,9 @@ static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, tcg_out_mem_long(s, 0, LVEBX, out, base, offset); } elt = extract32(offset, 0, 4); -#if !HOST_BIG_ENDIAN - elt ^= 15; -#endif + if (!HOST_BIG_ENDIAN) { + elt ^= 15; + } tcg_out32(s, VSPLTB | VRT(out) | VRB(out) | (elt << 16)); break; case MO_16:@@ -3964,9 +3964,9 @@ static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, tcg_out_mem_long(s, 0, LVEHX, out, base, offset); } elt = extract32(offset, 1, 3); -#if !HOST_BIG_ENDIAN - elt ^= 7; -#endif + if (!HOST_BIG_ENDIAN) { + elt ^= 7; + } tcg_out32(s, VSPLTH | VRT(out) | VRB(out) | (elt << 16)); break; case MO_32:@@ -3977,9 +3977,9 @@ static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, tcg_debug_assert((offset & 3) == 0); tcg_out_mem_long(s, 0, LVEWX, out, base, offset); elt = extract32(offset, 2, 2); -#if !HOST_BIG_ENDIAN - elt ^= 3; -#endif + if (!HOST_BIG_ENDIAN) { + elt ^= 3; + } tcg_out32(s, VSPLTW | VRT(out) | VRB(out) | (elt << 16)); break; case MO_64:@@ -3991,9 +3991,9 @@ static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, tcg_out_mem_long(s, 0, LVX, out, base, offset & -16); tcg_out_vsldoi(s, TCG_VEC_TMP1, out, out, 8); elt = extract32(offset, 3, 1); -#if !HOST_BIG_ENDIAN - elt = !elt; -#endif + if (!HOST_BIG_ENDIAN) { + elt = !elt; + } if (elt) { tcg_out_vsldoi(s, out, out, TCG_VEC_TMP1, 8); } else {
Re: [PATCH 12/16] target/ppc: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
Quoted 33 lines · Harsh Prateek Bora
Quoted 21 lines · Philippe Mathieu-Daudé
Replace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
target/ppc/arch_dump.c | 9 ++------- target/ppc/int_helper.c | 28 ++++++++++++++-------------- target/ppc/kvm.c | 25 +++++++++---------------- target/ppc/translate/vmx-impl.c.inc | 14 +++++++------- target/ppc/translate/vsx-impl.c.inc | 6 +++--- tcg/ppc/tcg-target.c.inc | 24 ++++++++++++------------6 files changed, 47 insertions(+), 59 deletions(-)target/ppc/arch_dump.c +0
-0target/ppc/arch_dump.c static void ppc_write_elf_vmxregset(NoteFuncArg · line 163
Quoted 6 lines
target/ppc/arch_dump.c +1
-0@@ -158,21 +158,16 @@ static void ppc_write_elf_vmxregset(NoteFuncArg *arg, PowerPCCPU *cpu, int id) struct PPCElfVmxregset *vmxregset; Note *note = &arg->note; DumpState *s = arg->state; + const int host_data_order = HOST_BIG_ENDIAN ? ELFDATA2MSB :ELFDATA2LSB ;I think the order of return values of ternary op needs to be swapped.
Quoted 8 lines
HOST_BIG_ENDIAN? ELFDATA2LSB : ELFDATA2MSB;Otherwise, looks fine. With that fixed:
Reviewed-by Harsh Prateek Bora <[email protected]>Quoted 2 lines
target/ppc/arch_dump.c +1
-0+ const bool needs_byteswap = s->dump_info.d_endian == host_data_order;
Or, a better fix would be to change == to != ?
Quoted 209 lines
Quoted 208 lines
target/ppc/arch_dump.c +0
-7note->hdr.n_type = cpu_to_dump32(s, NT_PPC_VMX); vmxregset = ¬e->contents.vmxregset; memset(vmxregset, 0, sizeof(*vmxregset)); for (i = 0; i < 32; i++) { - bool needs_byteswap; ppc_avr_t *avr = cpu_avr_ptr(&cpu->env, i); -#if HOST_BIG_ENDIAN - needs_byteswap = s->dump_info.d_endian == ELFDATA2LSB; -#else - needs_byteswap = s->dump_info.d_endian == ELFDATA2MSB; -#endif - if (needs_byteswap) { vmxregset->avr[i].u64[0] = bswap64(avr->u64[1]); vmxregset->avr[i].u64[1] = bswap64(avr->u64[0]);target/ppc/int_helper.c +14
-14@@ -1678,13 +1678,13 @@ void helper_vslo(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) { int sh = (b->VsrB(0xf) >> 3) & 0xf; -#if HOST_BIG_ENDIAN - memmove(&r->u8[0], &a->u8[sh], 16 - sh); - memset(&r->u8[16 - sh], 0, sh); -#else - memmove(&r->u8[sh], &a->u8[0], 16 - sh); - memset(&r->u8[0], 0, sh); -#endif + if (HOST_BIG_ENDIAN) { + memmove(&r->u8[0], &a->u8[sh], 16 - sh); + memset(&r->u8[16 - sh], 0, sh); + } else { + memmove(&r->u8[sh], &a->u8[0], 16 - sh); + memset(&r->u8[0], 0, sh); + } } #if HOST_BIG_ENDIAN@@ -1898,13 +1898,13 @@ void helper_vsro(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b) { int sh = (b->VsrB(0xf) >> 3) & 0xf; -#if HOST_BIG_ENDIAN - memmove(&r->u8[sh], &a->u8[0], 16 - sh); - memset(&r->u8[0], 0, sh); -#else - memmove(&r->u8[0], &a->u8[sh], 16 - sh); - memset(&r->u8[16 - sh], 0, sh); -#endif + if (HOST_BIG_ENDIAN) { + memmove(&r->u8[sh], &a->u8[0], 16 - sh); + memset(&r->u8[0], 0, sh); + } else { + memmove(&r->u8[0], &a->u8[sh], 16 - sh); + memset(&r->u8[16 - sh], 0, sh); + } } void helper_vsumsws(CPUPPCState *env, ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)target/ppc/kvm.c +9
-16@@ -651,13 +651,13 @@ static int kvm_put_fp(CPUState *cs) uint64_t *fpr = cpu_fpr_ptr(env, i); uint64_t *vsrl = cpu_vsrl_ptr(env, i); -#if HOST_BIG_ENDIAN - vsr[0] = float64_val(*fpr); - vsr[1] = *vsrl; -#else - vsr[0] = *vsrl; - vsr[1] = float64_val(*fpr); -#endif + if (HOST_BIG_ENDIAN) { + vsr[0] = float64_val(*fpr); + vsr[1] = *vsrl; + } else { + vsr[0] = *vsrl; + vsr[1] = float64_val(*fpr); + } reg.addr = (uintptr_t) &vsr; reg.id = vsx ? KVM_REG_PPC_VSR(i) : KVM_REG_PPC_FPR(i);@@ -728,17 +728,10 @@ static int kvm_get_fp(CPUState *cs) strerror(errno)); return ret; } else { -#if HOST_BIG_ENDIAN - *fpr = vsr[0]; + *fpr = vsr[!HOST_BIG_ENDIAN]; if (vsx) { - *vsrl = vsr[1]; + *vsrl = vsr[HOST_BIG_ENDIAN]; } -#else - *fpr = vsr[1]; - if (vsx) { - *vsrl = vsr[0]; - } -#endif } } }target/ppc/translate/vmx-impl.c.inc +7
-7@@ -134,9 +134,9 @@ static void gen_mtvscr(DisasContext *ctx) val = tcg_temp_new_i32(); bofs = avr_full_offset(rB(ctx->opcode)); -#if HOST_BIG_ENDIAN - bofs += 3 * 4; -#endif + if (HOST_BIG_ENDIAN) { + bofs += 3 * 4; + } tcg_gen_ld_i32(val, tcg_env, bofs); gen_helper_mtvscr(tcg_env, val);@@ -1528,10 +1528,10 @@ static void gen_vsplt(DisasContext *ctx, int vece) /* Experimental testing shows that hardware masks the immediate. */ bofs += (uimm << vece) & 15; -#if !HOST_BIG_ENDIAN - bofs ^= 15; - bofs &= ~((1 << vece) - 1); -#endif + if (!HOST_BIG_ENDIAN) { + bofs ^= 15; + bofs &= ~((1 << vece) - 1); + } tcg_gen_gvec_dup_mem(vece, dofs, bofs, 16, 16); }target/ppc/translate/vsx-impl.c.inc +3
-3@@ -1642,9 +1642,9 @@ static bool trans_XXSPLTW(DisasContext *ctx, arg_XX2_uim *a) tofs = vsr_full_offset(a->xt); bofs = vsr_full_offset(a->xb); bofs += a->uim << MO_32; -#if !HOST_BIG_ENDIAN - bofs ^= 8 | 4; -#endif + if (!HOST_BIG_ENDIAN) { + bofs ^= 8 | 4; + } tcg_gen_gvec_dup_mem(MO_32, tofs, bofs, 16, 16); return true;tcg/ppc/tcg-target.c.inc +3
-3@@ -3951,9 +3951,9 @@ static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, tcg_out_mem_long(s, 0, LVEBX, out, base, offset); } elt = extract32(offset, 0, 4); -#if !HOST_BIG_ENDIAN - elt ^= 15; -#endif + if (!HOST_BIG_ENDIAN) { + elt ^= 15; + } tcg_out32(s, VSPLTB | VRT(out) | VRB(out) | (elt << 16)); break;case
MO_16:tcg/ppc/tcg-target.c.inc +3
-3@@ -3964,9 +3964,9 @@ static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, tcg_out_mem_long(s, 0, LVEHX, out, base, offset); } elt = extract32(offset, 1, 3); -#if !HOST_BIG_ENDIAN - elt ^= 7; -#endif + if (!HOST_BIG_ENDIAN) { + elt ^= 7; + } tcg_out32(s, VSPLTH | VRT(out) | VRB(out) | (elt << 16)); break;case
MO_32:tcg/ppc/tcg-target.c.inc +3
-3@@ -3977,9 +3977,9 @@ static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, tcg_debug_assert((offset & 3) == 0); tcg_out_mem_long(s, 0, LVEWX, out, base, offset); elt = extract32(offset, 2, 2); -#if !HOST_BIG_ENDIAN - elt ^= 3; -#endif + if (!HOST_BIG_ENDIAN) { + elt ^= 3; + } tcg_out32(s, VSPLTW | VRT(out) | VRB(out) | (elt << 16)); break;case
MO_64:tcg/ppc/tcg-target.c.inc +3
-3@@ -3991,9 +3991,9 @@ static bool tcg_out_dupm_vec(TCGContext *s, TCGType type, unsigned vece, tcg_out_mem_long(s, 0, LVX, out, base, offset & -16); tcg_out_vsldoi(s, TCG_VEC_TMP1, out, out, 8); elt = extract32(offset, 3, 1); -#if !HOST_BIG_ENDIAN - elt = !elt; -#endif + if (!HOST_BIG_ENDIAN) { + elt = !elt; + } if (elt) { tcg_out_vsldoi(s, out, out, TCG_VEC_TMP1, 8);} else {
PATCH 13/16 target/riscv: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
In reply to Philippe Mathieu-DaudéReplace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
--- target/riscv/vector_helper.c | 32 ++++++++++++------------- target/riscv/insn_trans/trans_rvv.c.inc | 16 ++++++------- 2 files changed, 24 insertions(+), 24 deletions(-)
target/riscv/vector_helper.c +16 -16
@@ -235,26 +235,26 @@ vext_continuous_ldst_host(CPURISCVState *env, vext_ldst_elem_fn_host *ldst_host, void *vd, uint32_t evl, uint32_t reg_start, void *host, uint32_t esz, bool is_load) { -#if HOST_BIG_ENDIAN - for (; reg_start < evl; reg_start++, host += esz) { -ldst_host (vd, reg_start, host); - } -#else -if (esz ==1 ) { -uint32_t byte_offset = reg_start * esz; -uint32_t size = (evl - reg_start) * esz; - -if (is_load) { -memcpy (vd + byte_offset, host, size); - }else { -memcpy (host, vd + byte_offset, size); - } - }else { + if (HOST_BIG_ENDIAN) { for (; reg_start < evl; reg_start++, host += esz) {ldst_host (vd, reg_start, host); } + } else { +if (esz ==1 ) { +uint32_t byte_offset = reg_start * esz; +uint32_t size = (evl - reg_start) * esz; + +if (is_load) { +memcpy (vd + byte_offset, host, size); + }else { +memcpy (host, vd + byte_offset, size); + } + }else { +for (; reg_start < evl; reg_start++, host += esz) { +ldst_host (vd, reg_start, host); + } + } } -#endif } static void vext_set_tail_elems_1s(target_ulong vl, void *vd,
target/riscv/insn_trans/trans_rvv.c.inc +8 -8
@@ -3351,19 +3351,19 @@ static void load_element(TCGv_i64 dest, TCGv_ptr base, /* offset of the idx element with base register r */ static uint32_t endian_ofs(DisasContext *s, int r, int idx) { -#if HOST_BIG_ENDIAN - return vreg_ofs(s, r) + ((idx ^ (7 >> s->sew)) << s->sew); -#else - return vreg_ofs(s, r) + (idx << s->sew); -#endif + if (HOST_BIG_ENDIAN) { + return vreg_ofs(s, r) + ((idx ^ (7 >> s->sew)) << s->sew); + } else { + return vreg_ofs(s, r) + (idx << s->sew); + } } /* adjust the index according to the endian */ static void endian_adjust(TCGv_i32 ofs, int sew) { -#if HOST_BIG_ENDIAN - tcg_gen_xori_i32(ofs, ofs, 7 >> sew); -#endif + if (HOST_BIG_ENDIAN) { + tcg_gen_xori_i32(ofs, ofs, 7 >> sew); + } } /* Load idx >= VLMAX ? 0 : vreg[idx] */
Signature · 1 line
2.51.0
Re: [PATCH 13/16] target/riscv: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
Quoted 8 lines · Philippe Mathieu-Daudé
Replace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Alistair
Quoted 88 lines
--- target/riscv/vector_helper.c | 32 ++++++++++++------------- target/riscv/insn_trans/trans_rvv.c.inc | 16 ++++++------- 2 files changed, 24 insertions(+), 24 deletions(-)target/riscv/vector_helper.c +16
-16@@ -235,26 +235,26 @@ vext_continuous_ldst_host(CPURISCVState *env, vext_ldst_elem_fn_host *ldst_host, void *vd, uint32_t evl, uint32_t reg_start, void *host, uint32_t esz, bool is_load) { -#if HOST_BIG_ENDIAN - for (; reg_start < evl; reg_start++, host += esz) { -ldst_host (vd, reg_start, host); - } -#else -if (esz ==1 ) { -uint32_t byte_offset = reg_start * esz; -uint32_t size = (evl - reg_start) * esz; - -if (is_load) { -memcpy (vd + byte_offset, host, size); - }else { -memcpy (host, vd + byte_offset, size); - } - }else { + if (HOST_BIG_ENDIAN) { for (; reg_start < evl; reg_start++, host += esz) {ldst_host (vd, reg_start, host); } + } else { +if (esz ==1 ) { +uint32_t byte_offset = reg_start * esz; +uint32_t size = (evl - reg_start) * esz; + +if (is_load) { +memcpy (vd + byte_offset, host, size); + }else { +memcpy (host, vd + byte_offset, size); + } + }else { +for (; reg_start < evl; reg_start++, host += esz) { +ldst_host (vd, reg_start, host); + } + } } -#endif } static void vext_set_tail_elems_1s(target_ulong vl, void *vd,target/riscv/insn_trans/trans_rvv.c.inc +8
-9@@ -3351,19 +3351,19 @@ static void load_element(TCGv_i64 dest, TCGv_ptr base, /* offset of the idx element with base register r */ static uint32_t endian_ofs(DisasContext *s, int r, int idx) { -#if HOST_BIG_ENDIAN - return vreg_ofs(s, r) + ((idx ^ (7 >> s->sew)) << s->sew); -#else - return vreg_ofs(s, r) + (idx << s->sew); -#endif + if (HOST_BIG_ENDIAN) { + return vreg_ofs(s, r) + ((idx ^ (7 >> s->sew)) << s->sew); + } else { + return vreg_ofs(s, r) + (idx << s->sew); + } } /* adjust the index according to the endian */ static void endian_adjust(TCGv_i32 ofs, int sew) { -#if HOST_BIG_ENDIAN - tcg_gen_xori_i32(ofs, ofs, 7 >> sew); -#endif + if (HOST_BIG_ENDIAN) { + tcg_gen_xori_i32(ofs, ofs, 7 >> sew); + } } /* Load idx >= VLMAX ? 0 : vreg[idx] */ --2.51.0
PATCH 14/16 target/s390x: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
In reply to Philippe Mathieu-DaudéReplace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
--- target/s390x/tcg/translate.c | 6 +++--- target/s390x/tcg/translate_vx.c.inc | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
target/s390x/tcg/translate.c +3 -3
@@ -258,9 +258,9 @@ static inline int vec_reg_offset(uint8_t reg, uint8_t enr, MemOp es)* 16 byte operations to handle it in a special way. */ g_assert (es <=MO_64 ); -#if !HOST_BIG_ENDIAN - offs ^= (8 - bytes); -#endif +if (!HOST_BIG_ENDIAN ) { + offs ^= (8 - bytes); + }return offs +vec_full_reg_offset (reg); }
target/s390x/tcg/translate_vx.c.inc +3 -3
@@ -175,9 +175,9 @@ static void get_vec_element_ptr_i64(TCGv_ptr ptr, uint8_t reg, TCGv_i64 enr, /* convert it to an element offset relative to tcg_env (vec_reg_offset() */ tcg_gen_shli_i64(tmp, tmp, es); -#if !HOST_BIG_ENDIAN - tcg_gen_xori_i64(tmp, tmp, 8 - NUM_VEC_ELEMENT_BYTES(es)); -#endif + if (!HOST_BIG_ENDIAN) { + tcg_gen_xori_i64(tmp, tmp, 8 - NUM_VEC_ELEMENT_BYTES(es)); + } tcg_gen_addi_i64(tmp, tmp, vec_full_reg_offset(reg)); /* generate the final ptr by adding tcg_env */
Signature · 1 line
2.51.0
Re: [PATCH 14/16] target/s390x: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
Quoted 8 lines · Philippe Mathieu-Daudé
Replace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Signature · 3 lines
Cheers David / dhildenb
PATCH 15/16 target/sparc: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
In reply to Philippe Mathieu-DaudéReplace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
--- target/sparc/vis_helper.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
target/sparc/vis_helper.c +9 -9
@@ -462,15 +462,15 @@ uint64_t helper_bshuffle(uint64_t gsr, uint64_t src1, uint64_t src2)uint32_t i, mask, host;/* Set up S such that we can index across all of the bytes. */ -#if HOST_BIG_ENDIAN - s.ll[0 ] = src1; - s.ll[1 ] = src2; - host =0 ; -#else - s.ll[1 ] = src1; - s.ll[0 ] = src2; - host =15 ; -#endif +if (HOST_BIG_ENDIAN ) { + s.ll[0 ] = src1; + s.ll[1 ] = src2; + host =0 ; + }else { + s.ll[1 ] = src1; + s.ll[0 ] = src2; + host =15 ; + } mask = gsr >>32 ;for (i =0 ; i <8 ; ++i) {
Signature · 1 line
2.51.0
PATCH 16/16 util/bitmap: Replace HOST_BIG_ENDIAN #ifdef with runtime if() check
In reply to Philippe Mathieu-DaudéReplace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
--- util/bitmap.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
util/bitmap.c +7 -12
@@ -421,19 +421,14 @@ static void bitmap_to_from_le(unsigned long *dst, {long len =BITS_TO_LONGS (nbits); -#if HOST_BIG_ENDIAN -long index; - -for (index =0 ; index < len; index++) { -# if HOST_LONG_BITS ==64 - dst[index] =bswap64 (src[index]); -# else - dst[index] =bswap32 (src[index]); -# endif +if (HOST_BIG_ENDIAN ) { +for (long index =0 ; index < len; index++) { + dst[index] = (HOST_LONG_BITS ==64 ) ?bswap64 (src[index]) + :bswap32 (src[index]); + } + }else { +memcpy (dst, src, len *sizeof (unsigned long )); } -#else -memcpy (dst, src, len *sizeof (unsigned long )); -#endif } void bitmap_from_le(unsigned long *dst, const unsigned long *src,
Signature · 1 line
2.51.0
Paolo Bonzini
maintainerQuoted 5 lines · Philippe Mathieu-Daudé
Replace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
No need to repost (and I didn't review), but please change throughout the commit message to mention a *compile-time* if() check. The code for the wrong endianness will not make it past compilation, and mentioning runtime checks left me wondering if you had mistaken HOST for TARGET.
Thanks,
Paolo
Quoted 54 lines
Philippe Mathieu-Daudé (16):
linux-user/arm: Checkpatch style cleanups
linux-user/arm: ReplaceHOST_BIG_ENDIAN#ifdef with runtimeif()check
ui: ReplaceHOST_BIG_ENDIAN#ifdef with runtimeif()check
net: ReplaceHOST_BIG_ENDIAN#ifdef with runtimeif()check
disas: ReplaceHOST_BIG_ENDIAN#ifdef with runtimeif()check hw/core/loader: ReplaceHOST_BIG_ENDIAN#ifdef with runtimeif()check hw/display: ReplaceHOST_BIG_ENDIAN#ifdef with runtimeif()check hw/virtio: ReplaceHOST_BIG_ENDIAN#ifdef with runtimeif()check target/alpha: ReplaceHOST_BIG_ENDIAN#ifdef with runtimeif()check target/arm: ReplaceHOST_BIG_ENDIAN#ifdef with runtimeif()check target/mips: ReplaceHOST_BIG_ENDIAN#ifdef with runtimeif()check target/ppc: ReplaceHOST_BIG_ENDIAN#ifdef with runtimeif()check target/riscv: ReplaceHOST_BIG_ENDIAN#ifdef with runtimeif()check target/s390x: ReplaceHOST_BIG_ENDIAN#ifdef with runtimeif()check target/sparc: ReplaceHOST_BIG_ENDIAN#ifdef with runtimeif()check util/bitmap: ReplaceHOST_BIG_ENDIAN#ifdef with runtimeif()checkinclude/hw/virtio/virtio-access.h | 6 +- include/hw/virtio/virtio-gpu-bswap.h | 6 +- target/arm/cpu.h | 8 +- target/arm/tcg/translate-a64.h | 5 +- disas/disas-host.c | 6 +- hw/core/loader.c | 5 +- hw/display/artist.c | 12 +- hw/display/vga.c | 20 +- hw/display/virtio-gpu-gl.c | 8 +- hw/display/virtio-gpu-rutabaga.c | 8 +- hw/virtio/vhost.c | 7 +- linux-user/arm/nwfpe/double_cpdo.c | 12 +- linux-user/arm/nwfpe/fpa11_cpdt.c | 77 +- net/net.c | 14 +- target/alpha/translate.c | 11 +- target/arm/tcg/sve_helper.c | 10 +- target/arm/tcg/translate-sve.c | 22 +- target/arm/tcg/translate-vfp.c | 8 +- target/arm/tcg/translate.c | 6 +- target/mips/tcg/msa_helper.c | 889 ++++++++++++------------ target/ppc/arch_dump.c | 9 +- target/ppc/int_helper.c | 28 +- target/ppc/kvm.c | 25 +- target/riscv/vector_helper.c | 32 +- target/s390x/tcg/translate.c | 6 +- target/sparc/vis_helper.c | 18 +- ui/vdagent.c | 16 +- ui/vnc.c | 6 +- util/bitmap.c | 19 +- target/ppc/translate/vmx-impl.c.inc | 14 +- target/ppc/translate/vsx-impl.c.inc | 6 +- target/riscv/insn_trans/trans_rvv.c.inc | 16 +- target/s390x/tcg/translate_vx.c.inc | 6 +- tcg/ppc/tcg-target.c.inc | 24 +- 34 files changed, 656 insertions(+), 709 deletions(-)
Quoted 8 lines · Paolo Bonzini
Quoted 5 lines · Philippe Mathieu-Daudé
Replace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
No functional change intended.
No need to repost (and I didn't review), but please change throughout the commit message to mention a *compile-time*
if()check. The code for the wrong endianness will not make it past compilation, and mentioning runtime checks left me wondering if you had mistaken HOST for TARGET.
I want HOST, and hope the changes are correct: I meant to express the code is elided by the compiler, indeed not at *runtime* 🤦 I'll reword the commit description. Thanks for catching this.
Quoted 4 lines
Thanks,
Paolo
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Paolo Bonzini
Quoted 4 lines · Philippe Mathieu-Daudé
Replace compile-time #ifdef with a runtime check to ensure all code paths are built and tested. This reduces build-time configuration complexity and improves maintainability.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
No functional change intended.
No need to repost (and I didn't review), but please change throughout the commit message to mention a *compile-time*
if()check. The code for the wrong endianness will not make it past compilation, and mentioning runtime checks left me wondering if you had mistaken HOST for TARGET.I want HOST, and hope the changes are correct: I meant to express the code is elided by the compiler, indeed not at *runtime* 🤦 I'll reword the commit description. Thanks for catching this.
What about:
Replace preprocessor-time #ifdef with a compile-time check to ensure all code paths are built and tested. This reduces build-time configuration complexity and simplifies code maintainability.
?