From 025bdca23b2fca0dd68b6077426500237aee85c5 Mon Sep 17 00:00:00 2001 From: Carl Love Date: Thu, 12 Nov 2020 15:18:23 -0600 Subject: [PATCH] PowerPC, fix for conv_f16_to_double xscvhpdp assembler code The previous commit: commit eb82a294573d15c1be663673d55b559a82ca29d3 Author: Julian Seward Date: Tue Nov 10 21:10:48 2020 +0100 Add a missing ifdef, whose absence caused build breakage on non-POWER targets. fixed the compile issue in conv_f16_to_double() where non-Power platforms do not support the power xscvhpdp assembly instructions. The instruction is supported by ISA 3.0 platforms. Older Power platforms still fail to compile with the assembly instruction. This patch fixes the if def for power systems that do not support ISA 3.0. --- Makefile.all.am | 9 ++++++++- VEX/priv/guest_ppc_helpers.c | 2 +- configure.ac | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Makefile.all.am b/Makefile.all.am index 6d88670e05..1b65366715 100644 --- a/Makefile.all.am +++ b/Makefile.all.am @@ -123,6 +123,13 @@ AM_CFLAGS_BASE = \ -fno-strict-aliasing \ -fno-builtin +# Power ISA flag for use by guest_ppc_helpers.c +if HAS_XSCVHPDP +ISA_3_0_BUILD_FLAG = -DHAS_XSCVHPDP +else +ISA_3_0_BUILD_FLAG = +endif + if COMPILER_IS_CLANG AM_CFLAGS_BASE += -Wno-cast-align -Wno-self-assign \ -Wno-tautological-compare @@ -203,7 +210,7 @@ AM_CFLAGS_PSO_PPC64BE_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) $(AM_CFLAGS_PSO_BASE) AM_CCASFLAGS_PPC64BE_LINUX = @FLAG_M64@ -g AM_FLAG_M3264_PPC64LE_LINUX = @FLAG_M64@ -AM_CFLAGS_PPC64LE_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) +AM_CFLAGS_PPC64LE_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) $(ISA_3_0_BUILD_FLAG) AM_CFLAGS_PSO_PPC64LE_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) $(AM_CFLAGS_PSO_BASE) AM_CCASFLAGS_PPC64LE_LINUX = @FLAG_M64@ -g diff --git a/VEX/priv/guest_ppc_helpers.c b/VEX/priv/guest_ppc_helpers.c index ac4d7044a8..d2410d9537 100644 --- a/VEX/priv/guest_ppc_helpers.c +++ b/VEX/priv/guest_ppc_helpers.c @@ -1112,7 +1112,7 @@ static ULong reinterpret_double_as_long( Double input ) static Double conv_f16_to_double( ULong input ) { -# if defined(__powerpc__) +# if defined (HAS_XSCVHPDP) // This all seems to be very alignment sensitive?? __attribute__ ((aligned (64))) ULong src; __attribute__ ((aligned (64))) Double result; diff --git a/configure.ac b/configure.ac index f01dbff7fc..b837872918 100755 --- a/configure.ac +++ b/configure.ac @@ -1640,6 +1640,20 @@ ac_asm_have_isa_3_00=no AC_MSG_RESULT([no]) ]) +# xscvhpdp checking +AC_MSG_CHECKING([that assembler knows xscvhpdp ]) + +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +]], [[ + __asm__ __volatile__("xscvhpdp 1,2 "); +]])], [ +ac_asm_have_xscvhpdp=yes +AC_MSG_RESULT([yes]) +], [ +ac_asm_have_xscvhpdp=no +AC_MSG_RESULT([no]) +]) + # isa 3.01 checking AC_MSG_CHECKING([that assembler knows ISA 3.1 ]) @@ -1658,6 +1672,8 @@ AC_MSG_RESULT([no]) AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \ -a x$HWCAP_HAS_ISA_3_00 = xyes]) +AM_CONDITIONAL(HAS_XSCVHPDP, [test x$ac_asm_have_xscvhpdp = xyes]) + AM_CONDITIONAL(HAS_ISA_3_1, [test x$ac_asm_have_isa_3_1 = xyes \ -a x$HWCAP_HAS_ISA_3_1 = xyes]) -- 2.47.3