make endian-independent unaligned memory access functions available to libhw
v3 cover make endian-independent unaligned memory access functions available to libhw
Functions like ldl_be_p and ldl_le_p are currently used only as building blocks for {ld,st}XX_p. As such, they are in cpu-all.h even though they have absolutely no dependency on the target.
In order to make them globally available, this series moves them to bswap.h instead.
An interesting part of this is that there are functions also for floating point values. Leaving them in cpu-all.h would be possible but untidy. In fact handling these is easy, but it requires to make softfloat.h target-dependent as well. This is what patch 2 does.
v2->v3:
rebase
v1->v2:
rebase, use softfloat-specialize.h instead of introducing softfloat-target.h
Paolo Bonzini (3):
move WORDS_ALIGNED to qemu-common.h
softfloat: change default nan definitions to variables move unaligned memory access functions to bswap.h
Makefile.hw | 2 +- bswap.h | 474 ++++++++++++++++++++++++++++++++++++++++++++ configure | 3 +- cpu-all.h | 446 +----------------------------------------- cpu-common.h | 4 - fpu/softfloat-specialize.h | 72 +++++++ fpu/softfloat.h | 60 +----- qemu-common.h | 4 + 8 files changed, 562 insertions(+), 503 deletions(-)
Signature · 1 line
1.7.6
PATCH v3 1/3 move WORDS_ALIGNED to qemu-common.h
This is not a CPU interface, and a configure test would not be too precise. So just add it to qemu-common.h.
--- cpu-common.h | 4 ---- qemu-common.h | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-)
cpu-common.h +0 -4
@@ -3,10 +3,6 @@/* CPU interfaces that are target indpendent. */ -#if defined(__arm__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__) || defined(__ia64__) -#define WORDS_ALIGNED -#endif -#ifdef TARGET_PHYS_ADDR_BITS #include "targphys.h" #endif
qemu-common.h +4 -0
@@ -5,6 +5,10 @@#include "compiler.h" #include "config-host.h" +#if defined(__arm__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__) || defined(__ia64__) +#define WORDS_ALIGNED +#endif +#define TFR (expr) do { if ((expr) != -1) break; } while (errno == EINTR)typedef struct QEMUTimer QEMUTimer ;
Signature · 1 line
1.7.6
PATCH v3 2/3 softfloat: change default nan definitions to variables
In reply to Paolo BonziniMost definitions in softfloat.h are really target-independent, but the file is not because it includes definitions of the default NaN values. Change those to variables to allow including softfloat.h from files that are not compiled per-target. By making them const, the compiler is allowed to optimize them into softfloat functions that use them.
--- fpu/softfloat-specialize.h | 72 ++++++++++++++++++++++++++++++++++++++++++++ fpu/softfloat.h | 60 +++++------------------------------- 2 files changed, 81 insertions(+), 51 deletions(-)
fpu/softfloat-specialize.h +72 -0
@@ -35,6 +35,78 @@ these four paragraphs for those parts of this code that are retained.=============================================================================*/ +#if defined(TARGET_MIPS ) || defined(TARGET_SH4 ) || defined(TARGET_UNICORE32 ) +#define SNAN_BIT_IS_ONE 1 +#else +#define SNAN_BIT_IS_ONE 0 +#endif + +/*---------------------------------------------------------------------------- +| The pattern for a default generated half-precision NaN. +*----------------------------------------------------------------------------*/ +#if defined(TARGET_ARM ) +const float16 float16_default_nan =const_float16 (0x7E00 ); +#elif SNAN_BIT_IS_ONE +const float16 float16_default_nan =const_float16 (0x7DFF ); +#else +const float16 float16_default_nan =const_float16 (0xFE00 ); +#endif + +/*---------------------------------------------------------------------------- +| The pattern for a default generated single-precision NaN. +*----------------------------------------------------------------------------*/ +#if defined(TARGET_SPARC ) +const float32 float32_default_nan =const_float32 (0x7FFFFFFF ); +#elif defined(TARGET_PPC ) || defined(TARGET_ARM ) || defined(TARGET_ALPHA ) +const float32 float32_default_nan =const_float32 (0x7FC00000 ); +#elif SNAN_BIT_IS_ONE +const float32 float32_default_nan =const_float32 (0x7FBFFFFF ); +#else +const float32 float32_default_nan =const_float32 (0xFFC00000 ); +#endif + +/*---------------------------------------------------------------------------- +| The pattern for a default generated double-precision NaN. +*----------------------------------------------------------------------------*/ +#if defined(TARGET_SPARC ) +const float64 float64_default_nan =const_float64 (LIT64 (0x7FFFFFFFFFFFFFFF )); +#elif defined(TARGET_PPC ) || defined(TARGET_ARM ) || defined(TARGET_ALPHA ) +const float64 float64_default_nan =const_float64 (LIT64 (0x7FF8000000000000 )); +#elif SNAN_BIT_IS_ONE +const float64 float64_default_nan =const_float64 (LIT64 (0x7FF7FFFFFFFFFFFF )); +#else +const float64 float64_default_nan =const_float64 (LIT64 (0xFFF8000000000000 )); +#endif + +/*---------------------------------------------------------------------------- +| The pattern for a default generated extended double-precision NaN. +*----------------------------------------------------------------------------*/ +#if SNAN_BIT_IS_ONE +#define floatx80_default_nan_high 0x7FFF +#define floatx80_default_nan_low LIT64( 0xBFFFFFFFFFFFFFFF ) +#else +#define floatx80_default_nan_high 0xFFFF +#define floatx80_default_nan_low LIT64( 0xC000000000000000 ) +#endif + +const floatx80 floatx80_default_nan =make_floatx80 (floatx80_default_nan_high, + floatx80_default_nan_low); + +/*---------------------------------------------------------------------------- +| The pattern for a default generated quadruple-precision NaN. The `high' and +| `low' values hold the most- and least-significant bits, respectively. +*----------------------------------------------------------------------------*/ +#if SNAN_BIT_IS_ONE +#define float128_default_nan_high LIT64( 0x7FFF7FFFFFFFFFFF ) +#define float128_default_nan_low LIT64( 0xFFFFFFFFFFFFFFFF ) +#else +#define float128_default_nan_high LIT64( 0xFFFF800000000000 ) +#define float128_default_nan_low LIT64( 0x0000000000000000 ) +#endif + +const float128 float128_default_nan =make_float128 (float128_default_nan_high, + float128_default_nan_low); +/*---------------------------------------------------------------------------- | Raises the exceptions specified by `flags'. Floating-point traps can be | defined here if desired. It is currently not possible for such a trap
fpu/softfloat.h +9 -51
109 lines not on this page · raw message
Signature · 1 line
1.7.6
PATCH v3 3/3 move unaligned memory access functions to bswap.h
In reply to Paolo BonziniThis is just code movement, and moving the fpu/ include path from target-dependent to target-independent Make variables.
--- Makefile.hw | 2 +- bswap.h | 474 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure | 3 +- cpu-all.h | 446 +------------------------------------------------------- 4 files changed, 477 insertions(+), 448 deletions(-)
Makefile.hw +1 -1
@@ -9,7 +9,7 @@ include $(SRC_PATH)/rules.mak $(call set-vpath, $(SRC_PATH):$(SRC_PATH)/hw) -QEMU_CFLAGS+=-I.. -I$(SRC_PATH)/fpu +QEMU_CFLAGS+=-I.. include $(SRC_PATH)/Makefile.objs
bswap.h +474 -0
484 lines not on this page · raw message
configure +1 -2
@@ -233,7 +233,7 @@ QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS" QEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS" -QEMU_INCLUDES="-I. -I\$(SRC_PATH)" +QEMU_INCLUDES="-I. -I\$(SRC_PATH) -I\$(SRC_PATH)/fpu" LDFLAGS="-g $LDFLAGS" # make source path absolute
@@ -3361,7 +3361,6 @@ else includes="-I\$(SRC_PATH)/tcg/\$(ARCH) $includes" fi includes="-I\$(SRC_PATH)/tcg $includes" -includes="-I\$(SRC_PATH)/fpu $includes" if test "$target_user_only" = "yes" ; then libdis_config_mak=libdis-user/config.mak
cpu-all.h +1 -445
465 lines not on this page · raw message
Signature · 1 line
1.7.6
Anthony Liguori
AppliedQuoted 11 lines · Paolo Bonzini
Functions like
ldl_be_pandldl_le_pare currently used only as building blocks for {ld,st}XX_p. As such, they are incpu-all.heven though they have absolutely no dependency on the target.In order to make them globally available, this series moves them to
bswap.hinstead.An interesting part of this is that there are functions also for floating point values. Leaving them in
cpu-all.hwould be possible but untidy. In fact handling these is easy, but it requires to makesoftfloat.htarget-dependent as well. This is what patch 2 does.
Applied. Thanks.
Regards,
Anthony Liguori
Quoted 23 lines
v2->v3:
rebase
v1->v2:
rebase, usesoftfloat-specialize.hinstead of introducingsoftfloat-target.hPaolo Bonzini (3):
moveWORDS_ALIGNEDtoqemu-common.h
softfloat: change default nan definitions to variables move unaligned memory access functions tobswap.hMakefile.hw | 2 +- bswap.h | 474 ++++++++++++++++++++++++++++++++++++++++++++ configure | 3 +- cpu-all.h | 446 +----------------------------------------- cpu-common.h | 4 - fpu/softfloat-specialize.h | 72 +++++++ fpu/softfloat.h | 60 +----- qemu-common.h | 4 + 8 files changed, 562 insertions(+), 503 deletions(-)