mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-04 02:18:37 +00:00
Patch 4 and 5 of 7, improve PPC HW capabiltiy checking.
The patch was submitted by Will Schmidt (will_schmidt@vnet.ibm.com). Patches 4 and 5 need to be applied together. Add convenience function for processing hwcap entries. Add logic to check for HTM support in compiler. Bugzilla 34979 git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15423
This commit is contained in:
parent
296ac5e8c1
commit
aa85e04a41
58
configure.ac
58
configure.ac
@ -1264,6 +1264,28 @@ AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
|
||||
[],
|
||||
[#include <pthread.h>])
|
||||
|
||||
# Convenience function. Set flags based on the existing HWCAP entries.
|
||||
# The AT_HWCAP entries are generated by glibc, and are based on
|
||||
# functions supported by the hardware/system/libc.
|
||||
# Subsequent support for whether the capability will actually be utilized
|
||||
# will also be checked against the compiler capabilities.
|
||||
# called as
|
||||
# AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
|
||||
AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
|
||||
AUXV_CHECK_FOR=$1
|
||||
AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
|
||||
if `LD_SHOW_AUXV=1 /bin/true | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}`
|
||||
then
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_SUBST([$2],[yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
AC_SUBST([$2],[])
|
||||
fi
|
||||
])
|
||||
|
||||
# gather hardware capabilities. (hardware/kernel/libc)
|
||||
AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
|
||||
|
||||
# does this compiler support -maltivec and does it have the include file
|
||||
# <altivec.h> ?
|
||||
@ -1386,6 +1408,42 @@ AC_MSG_RESULT([no])
|
||||
|
||||
AM_CONDITIONAL(HAS_ISA_2_07, test x$ac_asm_have_isa_2_07 = xyes)
|
||||
|
||||
# HTM (Hardware Transactional Memory)
|
||||
AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
|
||||
safe_CFLAGS=$CFLAGS
|
||||
CFLAGS="-mhtm -Werror"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
]], [[
|
||||
return 0;
|
||||
]])], [
|
||||
AC_MSG_RESULT([yes])
|
||||
ac_compiler_supports_htm=yes
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
ac_compiler_supports_htm=no
|
||||
])
|
||||
CFLAGS=$safe_CFLAGS
|
||||
|
||||
AC_MSG_CHECKING([if compiler can find the htm builtins])
|
||||
safe_CFLAGS=$CFLAGS
|
||||
CFLAGS="-mhtm -Werror"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
]], [[
|
||||
if (__builtin_tbegin (0))
|
||||
__builtin_tend (0);
|
||||
]])], [
|
||||
AC_MSG_RESULT([yes])
|
||||
ac_compiler_sees_htm_builtins=yes
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
ac_compiler_sees_htm_builtins=no
|
||||
])
|
||||
CFLAGS=$safe_CFLAGS
|
||||
|
||||
AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
|
||||
-a x$ac_compiler_sees_htm_builtins = xyes \
|
||||
-a x$HWCAP_HAS_HTM = xyes )
|
||||
|
||||
# Check for pthread_create@GLIBC2.0
|
||||
AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
|
||||
|
||||
|
||||
@ -99,13 +99,17 @@ DFP_FLAG =
|
||||
endif
|
||||
|
||||
if HAS_ISA_2_07
|
||||
BUILD_FLAGS_ISA_2_07 = -mhtm -mcpu=power8
|
||||
BUILD_FLAGS_ISA_2_07 = -mcpu=power8
|
||||
ISA_2_07_FLAG = -DHAS_ISA_2_07
|
||||
else
|
||||
BUILD_FLAGS_ISA_2_07 =
|
||||
ISA_2_07_FLAG =
|
||||
endif
|
||||
|
||||
if SUPPORTS_HTM
|
||||
HTM_FLAG = -mhtm -DSUPPORTS_HTM
|
||||
endif
|
||||
|
||||
jm_insns_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames \
|
||||
@FLAG_M32@ $(ALTIVEC_FLAG) $(BUILD_FLAG_ALTIVEC)
|
||||
|
||||
@ -141,9 +145,9 @@ test_isa_2_07_part1_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(ISA_
|
||||
test_isa_2_07_part2_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(ISA_2_07_FLAG) \
|
||||
@FLAG_M32@ $(BUILD_FLAGS_ISA_2_07)
|
||||
|
||||
test_tm_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(ISA_2_07_FLAG) \
|
||||
test_tm_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(HTM_FLAG) $(ISA_2_07_FLAG) \
|
||||
@FLAG_M32@ $(BUILD_FLAGS_ISA_2_07)
|
||||
test_touch_tm_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(ISA_2_07_FLAG) \
|
||||
test_touch_tm_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(HTM_FLAG) $(ISA_2_07_FLAG) \
|
||||
@FLAG_M32@ $(BUILD_FLAGS_ISA_2_07)
|
||||
|
||||
test_isa_2_06_part3_LDADD = -lm
|
||||
|
||||
@ -75,13 +75,17 @@ DFP_FLAG =
|
||||
endif
|
||||
|
||||
if HAS_ISA_2_07
|
||||
BUILD_FLAGS_ISA_2_07 = -mhtm -mcpu=power8
|
||||
BUILD_FLAGS_ISA_2_07 = -mcpu=power8
|
||||
ISA_2_07_FLAG = -DHAS_ISA_2_07
|
||||
else
|
||||
BUILD_FLAGS_ISA_2_07 =
|
||||
ISA_2_07_FLAG =
|
||||
endif
|
||||
|
||||
if SUPPORTS_HTM
|
||||
HTM_FLAG = -mhtm -DSUPPORTS_HTM
|
||||
endif
|
||||
|
||||
test_isa_2_06_part1_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(VSX_FLAG) \
|
||||
@FLAG_M64@ $(ALTIVEC_FLAG) $(BUILD_FLAG_VSX)
|
||||
|
||||
@ -114,9 +118,9 @@ test_isa_2_07_part1_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(ISA_
|
||||
test_isa_2_07_part2_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(ISA_2_07_FLAG) \
|
||||
@FLAG_M64@ $(BUILD_FLAGS_ISA_2_07)
|
||||
|
||||
test_tm_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(ISA_2_07_FLAG) \
|
||||
test_tm_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(HTM_FLAG) $(ISA_2_07_FLAG) \
|
||||
@FLAG_M64@ $(BUILD_FLAGS_ISA_2_07)
|
||||
test_touch_tm_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(ISA_2_07_FLAG) \
|
||||
test_touch_tm_CFLAGS = $(AM_CFLAGS) -Winline -Wall -O -g -mregnames $(HTM_FLAG) $(ISA_2_07_FLAG) \
|
||||
@FLAG_M64@ $(BUILD_FLAGS_ISA_2_07)
|
||||
|
||||
test_isa_2_06_part3_LDADD = -lm
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#include <stdio.h>
|
||||
#ifdef HAS_ISA_2_07
|
||||
#ifdef SUPPORTS_HTM
|
||||
int __attribute__ ((noinline)) htm_begin (int r3, int r4)
|
||||
{
|
||||
int ret;
|
||||
@ -14,10 +14,12 @@ int __attribute__ ((noinline)) htm_begin (int r3, int r4)
|
||||
#endif
|
||||
|
||||
int main (void) {
|
||||
#ifdef HAS_ISA_2_07
|
||||
#ifdef SUPPORTS_HTM
|
||||
int ret;
|
||||
ret = htm_begin (10, 20);
|
||||
printf ("ret = %d, expected = 10\n", ret);
|
||||
#else
|
||||
printf ("No HTM support.");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main (void) {
|
||||
#ifdef HAS_ISA_2_07
|
||||
#ifdef SUPPORTS_HTM
|
||||
/* Just get the compiler to generate each of the TM instructions
|
||||
* so we can verify that valgrind recognizes them.
|
||||
* For now, only the tbegin instruction does anything in valgrind.
|
||||
@ -18,6 +18,8 @@ int main (void) {
|
||||
__builtin_trechkpt (); // not recognized by early HW
|
||||
__builtin_treclaim (0); // not recognized by early HW
|
||||
__builtin_tsr (0);
|
||||
#else
|
||||
printf ("No HTM support.");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user