mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 18:13:01 +00:00
Add a test program of sorts, for XBEGIN and XTEST.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13579
This commit is contained in:
parent
b84c467aad
commit
2a8d194303
@ -79,6 +79,7 @@ EXTRA_DIST = \
|
||||
sse4-64.stdout.exp-older-glibc \
|
||||
slahf-amd64.stderr.exp slahf-amd64.stdout.exp \
|
||||
slahf-amd64.vgtest \
|
||||
tm1.vgtest tm1.stderr.exp tm1.stdout.exp \
|
||||
xadd.stderr.exp xadd.stdout.exp xadd.vgtest
|
||||
|
||||
check_PROGRAMS = \
|
||||
@ -113,7 +114,7 @@ if BUILD_VPCLMULQDQ_TESTS
|
||||
endif
|
||||
endif
|
||||
if BUILD_AVX2_TESTS
|
||||
check_PROGRAMS += avx2-1
|
||||
check_PROGRAMS += avx2-1 tm1
|
||||
endif
|
||||
if BUILD_BMI_TESTS
|
||||
check_PROGRAMS += bmi
|
||||
|
||||
62
none/tests/amd64/tm1.c
Normal file
62
none/tests/amd64/tm1.c
Normal file
@ -0,0 +1,62 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* An ultra-lame test program for RTM support, as available
|
||||
on Haswell CPUs. */
|
||||
|
||||
/* Attempt to run f(arg) as a transaction, and return a Boolean
|
||||
indicating success or otherwise. */
|
||||
|
||||
__attribute__((noinline))
|
||||
static int transactionally_apply ( void(*f)(void*), void* arg )
|
||||
{
|
||||
register int ok;
|
||||
__asm__ __volatile__(
|
||||
" xbegin .Lzzqqfail" );
|
||||
f(arg);
|
||||
__asm__ __volatile__(
|
||||
/* This is a bit tricky. If the transaction succeeds, control
|
||||
will flow to this point. If it fails, control continues at
|
||||
.Lzzqqfail, with the machine state looking the same as it did
|
||||
immediately before the xbegin was executed. */
|
||||
" xend \n\t" /* declare the transaction to be complete */
|
||||
" movl $1,%0 \n\t" /* "ok = 1" */
|
||||
" jmp .Lzzqqout \n\t" /* jump to the merge point */
|
||||
".Lzzqqfail: \n\t" /* it failed .. */
|
||||
" movl $0,%0 \n\t" /* "ok = 0" */
|
||||
".Lzzqqout: \n\t" /* this is the merge point */
|
||||
: "=r"(ok) : : "cc", "rax"
|
||||
);
|
||||
return ok;
|
||||
}
|
||||
|
||||
void testfn ( void* arg )
|
||||
{
|
||||
}
|
||||
|
||||
int main ( void )
|
||||
{
|
||||
long long int ok = transactionally_apply ( testfn, NULL );
|
||||
printf("transactionally_apply: ok = %lld (expected %d)\n", ok, 0);
|
||||
|
||||
__asm__ __volatile__(
|
||||
"movq $0, %%rax \n\t"
|
||||
"xtest \n\t"
|
||||
"setz %%al \n\t"
|
||||
"movq %%rax, %0 \n\t"
|
||||
: "=r"(ok) : : "cc","rax"
|
||||
);
|
||||
printf("xtest: rflags.Z = %lld (expected %d)\n", ok, 1);
|
||||
|
||||
/*
|
||||
printf("testing XACQUIRE / XRELEASE\n");
|
||||
int n = 0;
|
||||
__asm__ __volatile__(
|
||||
"xacquire lock incl (%0) \n\t"
|
||||
"xrelease lock decl (%0) \n\t"
|
||||
: : "r"(&n) : "cc", "memory"
|
||||
);
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
2
none/tests/amd64/tm1.stderr.exp
Normal file
2
none/tests/amd64/tm1.stderr.exp
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
2
none/tests/amd64/tm1.stdout.exp
Normal file
2
none/tests/amd64/tm1.stdout.exp
Normal file
@ -0,0 +1,2 @@
|
||||
transactionally_apply: ok = 0 (expected 0)
|
||||
xtest: rflags.Z = 1 (expected 1)
|
||||
2
none/tests/amd64/tm1.vgtest
Normal file
2
none/tests/amd64/tm1.vgtest
Normal file
@ -0,0 +1,2 @@
|
||||
prog: tm1
|
||||
prereq: test -x tm1 && ../../../tests/x86_amd64_features amd64-avx
|
||||
Loading…
x
Reference in New Issue
Block a user