mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 10:05:29 +00:00
mips32/64: Test case for VEX r2799.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13713
This commit is contained in:
parent
84b48d7742
commit
b4adb1bc50
@ -30,7 +30,8 @@ EXTRA_DIST = \
|
||||
mips32_dspr2.vgtest \
|
||||
unaligned_load_store.stdout.exp-LE unaligned_load_store.stdout.exp-BE \
|
||||
unaligned_load_store.stderr.exp unaligned_load_store.vgtest \
|
||||
test_fcsr.stdout.exp test_fcsr.stderr.exp test_fcsr.vgtest
|
||||
test_fcsr.stdout.exp test_fcsr.stderr.exp test_fcsr.vgtest \
|
||||
test_math.stdout.exp test_math.stderr.exp test_math.vgtest
|
||||
|
||||
check_PROGRAMS = \
|
||||
allexec \
|
||||
@ -49,7 +50,8 @@ check_PROGRAMS = \
|
||||
mips32_dsp \
|
||||
mips32_dspr2 \
|
||||
unaligned_load_store \
|
||||
test_fcsr
|
||||
test_fcsr \
|
||||
test_math
|
||||
|
||||
AM_CFLAGS += @FLAG_M32@
|
||||
AM_CXXFLAGS += @FLAG_M32@
|
||||
@ -57,3 +59,6 @@ AM_CCASFLAGS += @FLAG_M32@
|
||||
|
||||
allexec_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_NONNULL@
|
||||
bug320057_mips32_LDFLAGS = -lrt
|
||||
|
||||
# C++ tests
|
||||
test_math_SOURCES = test_math.cpp
|
||||
|
||||
115
none/tests/mips32/test_math.cpp
Normal file
115
none/tests/mips32/test_math.cpp
Normal file
@ -0,0 +1,115 @@
|
||||
#include <fenv.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static void DivideByZero() {
|
||||
// volatile to prevent compiler optimizations.
|
||||
volatile float zero = 0.0f;
|
||||
volatile float result __attribute__((unused)) = 123.0f / zero;
|
||||
}
|
||||
|
||||
int main () {
|
||||
/* Testing lrint. */
|
||||
fesetround(FE_UPWARD); // lrint/lrintf/lrintl obey the rounding mode.
|
||||
printf("fesetround(FE_UPWARD)\n");
|
||||
printf("lrint(1234.01): %ld\n", lrint(1234.01));
|
||||
printf("lrintf(1234.01f): %ld\n", lrintf(1234.01f));
|
||||
printf("lrintl(1234.01): %ld\n", lrintl(1234.01));
|
||||
fesetround(FE_TOWARDZERO); // lrint/lrintf/lrintl obey the rounding mode.
|
||||
printf("fesetround(FE_TOWARDZERO)\n");
|
||||
printf("lrint(1234.01): %ld\n", lrint(1234.01));
|
||||
printf("lrintf(1234.01f): %ld\n", lrintf(1234.01f));
|
||||
printf("lrintl(1234.01): %ld\n", lrintl(1234.01));
|
||||
fesetround(FE_UPWARD); // llrint/llrintf/llrintl obey the rounding mode.
|
||||
printf("fesetround(FE_UPWARD)\n");
|
||||
printf("llrint(1234.01): %lld\n", llrint(1234.01));
|
||||
printf("llrintf(1234.01f): %lld\n", llrintf(1234.01f));
|
||||
printf("llrintf(1234.01f): %lld\n", llrintl(1234.01));
|
||||
fesetround(FE_TOWARDZERO); // llrint/llrintf/llrintl obey the rounding mode.
|
||||
printf("fesetround(FE_TOWARDZERO)\n");
|
||||
printf("llrint(1234.01): %lld\n", llrint(1234.01));
|
||||
printf("llrintf(1234.01f): %lld\n", llrintf(1234.01f));
|
||||
printf("llrintl(1234.01): %lld\n", llrintl(1234.01));
|
||||
|
||||
/* Tesing rint. */
|
||||
fesetround(FE_UPWARD); // rint/rintf/rintl obey the rounding mode.
|
||||
printf("fesetround(FE_UPWARD)\n");
|
||||
feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
|
||||
printf("feclearexcept(FE_ALL_EXCEPT)\n");
|
||||
printf("rint(1234.0): %f\n", rint(1234.0));
|
||||
printf("(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): %d\n",
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT));
|
||||
printf("rint(1234.01): %f\n", rint(1234.01));
|
||||
printf("(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): %d\n",
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT));
|
||||
|
||||
feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
|
||||
printf("feclearexcept(FE_ALL_EXCEPT)\n");
|
||||
printf("rintf(1234.0f): %f\n", rintf(1234.0f));
|
||||
printf("(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): %d\n",
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT));
|
||||
printf("rintf(1234.01f): %f\n", rintf(1234.01f));
|
||||
printf("(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): %d\n",
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT));
|
||||
|
||||
feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
|
||||
printf("feclearexcept(FE_ALL_EXCEPT)\n");
|
||||
printf("rintl(1234.0): %Lf\n", rintl(1234.0));
|
||||
printf("(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): %d\n",
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT));
|
||||
printf("rintl(1234.01): %Lf\n", rintl(1234.01));
|
||||
printf("(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): %d\n",
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT));
|
||||
|
||||
fesetround(FE_TOWARDZERO); // rint/rintf obey the rounding mode.
|
||||
printf("fesetround(FE_TOWARDZERO)\n");
|
||||
printf("rint(1234.01): %f\n", rint(1234.01));
|
||||
printf("rintf(1234.01f): %f\n", rintf(1234.01f));
|
||||
printf("rintl(1234.01): %Lf\n", rintl(1234.01));
|
||||
|
||||
/* Testing nearbyint. */
|
||||
fesetround(FE_UPWARD); // nearbyint/nearbyintf/nearbyintl obey the rounding mode.
|
||||
printf("fesetround(FE_UPWARD)\n");
|
||||
feclearexcept(FE_ALL_EXCEPT); // nearbyint/nearbyintf/nearbyintl don't set the FE_INEXACT flag.
|
||||
printf("feclearexcept(FE_ALL_EXCEPT)\n");
|
||||
printf("nearbyint(1234.0): %f\n", nearbyint(1234.0));
|
||||
printf("nearbyint(1234.01): %f\n", nearbyint(1234.01));
|
||||
|
||||
feclearexcept(FE_ALL_EXCEPT);
|
||||
printf("feclearexcept(FE_ALL_EXCEPT)\n");
|
||||
printf("nearbyintf(1234.0f): %f\n", nearbyintf(1234.0f));
|
||||
printf("nearbyintf(1234.01f): %f\n", nearbyintf(1234.01f));
|
||||
|
||||
feclearexcept(FE_ALL_EXCEPT); // nearbyint/nearbyintf/nearbyintl don't set the FE_INEXACT flag.
|
||||
printf("feclearexcept(FE_ALL_EXCEPT)\n");
|
||||
printf("nearbyintl(1234.0f): %Lf\n", nearbyintl(1234.0f));
|
||||
printf("nearbyintl(1234.01f): %Lf\n", nearbyintl(1234.01f));
|
||||
|
||||
fesetround(FE_TOWARDZERO); // nearbyint/nearbyintf/nearbyintl obey the rounding mode.
|
||||
printf("fesetround(FE_TOWARDZERO)\n");
|
||||
printf("nearbyint(1234.01): %f\n", nearbyint(1234.01));
|
||||
printf("nearbyintf(1234.01f): %f\n", nearbyintf(1234.01f));
|
||||
printf("nearbyintl(1234.01): %Lf\n", nearbyintl(1234.01));
|
||||
|
||||
/* Test log. */
|
||||
printf("log(M_E): %lf\n", log(M_E));
|
||||
|
||||
/* Test tgamma. */
|
||||
printf("tgamma(5.0): %lf\n", tgamma(5.0));
|
||||
|
||||
/* Test cbrt. */
|
||||
printf("cbrt(27.0): %lf\n", cbrt(27.0));
|
||||
|
||||
/* Test dividing by zero. */
|
||||
// Clearing clears.
|
||||
printf("feclearexcept(FE_ALL_EXCEPT): %d\n", feclearexcept(FE_ALL_EXCEPT));
|
||||
|
||||
// Dividing by zero sets FE_DIVBYZERO.
|
||||
DivideByZero();
|
||||
int raised = fetestexcept(FE_DIVBYZERO | FE_OVERFLOW);
|
||||
printf("raised: %d\n", raised);
|
||||
|
||||
return 0;
|
||||
}
|
||||
0
none/tests/mips32/test_math.stderr.exp
Normal file
0
none/tests/mips32/test_math.stderr.exp
Normal file
55
none/tests/mips32/test_math.stdout.exp
Normal file
55
none/tests/mips32/test_math.stdout.exp
Normal file
@ -0,0 +1,55 @@
|
||||
fesetround(FE_UPWARD)
|
||||
lrint(1234.01): 1235
|
||||
lrintf(1234.01f): 1235
|
||||
lrintl(1234.01): 1235
|
||||
fesetround(FE_TOWARDZERO)
|
||||
lrint(1234.01): 1234
|
||||
lrintf(1234.01f): 1234
|
||||
lrintl(1234.01): 1234
|
||||
fesetround(FE_UPWARD)
|
||||
llrint(1234.01): 1235
|
||||
llrintf(1234.01f): 1235
|
||||
llrintf(1234.01f): 1235
|
||||
fesetround(FE_TOWARDZERO)
|
||||
llrint(1234.01): 1234
|
||||
llrintf(1234.01f): 1234
|
||||
llrintl(1234.01): 1234
|
||||
fesetround(FE_UPWARD)
|
||||
feclearexcept(FE_ALL_EXCEPT)
|
||||
rint(1234.0): 1234.000000
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): 0
|
||||
rint(1234.01): 1235.000000
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): 4
|
||||
feclearexcept(FE_ALL_EXCEPT)
|
||||
rintf(1234.0f): 1234.000000
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): 0
|
||||
rintf(1234.01f): 1235.000000
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): 4
|
||||
feclearexcept(FE_ALL_EXCEPT)
|
||||
rintl(1234.0): 1234.000000
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): 0
|
||||
rintl(1234.01): 1235.000000
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): 4
|
||||
fesetround(FE_TOWARDZERO)
|
||||
rint(1234.01): 1234.000000
|
||||
rintf(1234.01f): 1234.000000
|
||||
rintl(1234.01): 1234.000000
|
||||
fesetround(FE_UPWARD)
|
||||
feclearexcept(FE_ALL_EXCEPT)
|
||||
nearbyint(1234.0): 1234.000000
|
||||
nearbyint(1234.01): 1235.000000
|
||||
feclearexcept(FE_ALL_EXCEPT)
|
||||
nearbyintf(1234.0f): 1234.000000
|
||||
nearbyintf(1234.01f): 1235.000000
|
||||
feclearexcept(FE_ALL_EXCEPT)
|
||||
nearbyintl(1234.0f): 1234.000000
|
||||
nearbyintl(1234.01f): 1235.000000
|
||||
fesetround(FE_TOWARDZERO)
|
||||
nearbyint(1234.01): 1234.000000
|
||||
nearbyintf(1234.01f): 1234.000000
|
||||
nearbyintl(1234.01): 1234.000000
|
||||
log(M_E): 1.000000
|
||||
tgamma(5.0): 24.000000
|
||||
cbrt(27.0): 3.000000
|
||||
feclearexcept(FE_ALL_EXCEPT): 0
|
||||
raised: 32
|
||||
2
none/tests/mips32/test_math.vgtest
Normal file
2
none/tests/mips32/test_math.vgtest
Normal file
@ -0,0 +1,2 @@
|
||||
prog: test_math
|
||||
vgopts: -q
|
||||
@ -43,7 +43,8 @@ EXTRA_DIST = \
|
||||
unaligned_load_store.stderr.exp unaligned_load_store.vgtest \
|
||||
test_fcsr.stdout.exp test_fcsr.stderr.exp \
|
||||
test_fcsr.vgtest \
|
||||
const.h macro_fpu.h macro_int.h macro_load_store.h rounding_mode.h
|
||||
const.h macro_fpu.h macro_int.h macro_load_store.h rounding_mode.h \
|
||||
test_math.stdout.exp test_math.stderr.exp test_math.vgtest
|
||||
|
||||
check_PROGRAMS = \
|
||||
allexec \
|
||||
@ -67,7 +68,8 @@ check_PROGRAMS = \
|
||||
test_block_size \
|
||||
unaligned_load \
|
||||
unaligned_load_store \
|
||||
test_fcsr
|
||||
test_fcsr \
|
||||
test_math
|
||||
|
||||
AM_CFLAGS += @FLAG_M64@
|
||||
AM_CXXFLAGS += @FLAG_M64@
|
||||
@ -77,3 +79,6 @@ allexec_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_NONNULL@
|
||||
|
||||
cvm_ins_CFLAGS = $(AM_CFLAGS) -g -O0 -march=octeon
|
||||
fpu_arithmetic_CFLAGS = $(AM_CFLAGS) -lm
|
||||
|
||||
# C++ tests
|
||||
test_math_SOURCES = test_math.cpp
|
||||
|
||||
1
none/tests/mips64/test_math.cpp
Symbolic link
1
none/tests/mips64/test_math.cpp
Symbolic link
@ -0,0 +1 @@
|
||||
../mips32/test_math.cpp
|
||||
0
none/tests/mips64/test_math.stderr.exp
Normal file
0
none/tests/mips64/test_math.stderr.exp
Normal file
55
none/tests/mips64/test_math.stdout.exp
Normal file
55
none/tests/mips64/test_math.stdout.exp
Normal file
@ -0,0 +1,55 @@
|
||||
fesetround(FE_UPWARD)
|
||||
lrint(1234.01): 1235
|
||||
lrintf(1234.01f): 1235
|
||||
lrintl(1234.01): 1234
|
||||
fesetround(FE_TOWARDZERO)
|
||||
lrint(1234.01): 1234
|
||||
lrintf(1234.01f): 1234
|
||||
lrintl(1234.01): 1234
|
||||
fesetround(FE_UPWARD)
|
||||
llrint(1234.01): 1235
|
||||
llrintf(1234.01f): 1235
|
||||
llrintf(1234.01f): 1234
|
||||
fesetround(FE_TOWARDZERO)
|
||||
llrint(1234.01): 1234
|
||||
llrintf(1234.01f): 1234
|
||||
llrintl(1234.01): 1234
|
||||
fesetround(FE_UPWARD)
|
||||
feclearexcept(FE_ALL_EXCEPT)
|
||||
rint(1234.0): 1234.000000
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): 0
|
||||
rint(1234.01): 1235.000000
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): 4
|
||||
feclearexcept(FE_ALL_EXCEPT)
|
||||
rintf(1234.0f): 1234.000000
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): 0
|
||||
rintf(1234.01f): 1235.000000
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): 4
|
||||
feclearexcept(FE_ALL_EXCEPT)
|
||||
rintl(1234.0): 1234.000000
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): 0
|
||||
rintl(1234.01): 1234.000000
|
||||
(fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT): 0
|
||||
fesetround(FE_TOWARDZERO)
|
||||
rint(1234.01): 1234.000000
|
||||
rintf(1234.01f): 1234.000000
|
||||
rintl(1234.01): 1234.000000
|
||||
fesetround(FE_UPWARD)
|
||||
feclearexcept(FE_ALL_EXCEPT)
|
||||
nearbyint(1234.0): 1234.000000
|
||||
nearbyint(1234.01): 1235.000000
|
||||
feclearexcept(FE_ALL_EXCEPT)
|
||||
nearbyintf(1234.0f): 1234.000000
|
||||
nearbyintf(1234.01f): 1235.000000
|
||||
feclearexcept(FE_ALL_EXCEPT)
|
||||
nearbyintl(1234.0f): 1234.000000
|
||||
nearbyintl(1234.01f): 1234.000000
|
||||
fesetround(FE_TOWARDZERO)
|
||||
nearbyint(1234.01): 1234.000000
|
||||
nearbyintf(1234.01f): 1234.000000
|
||||
nearbyintl(1234.01): 1234.000000
|
||||
log(M_E): 1.000000
|
||||
tgamma(5.0): 24.000000
|
||||
cbrt(27.0): 3.000000
|
||||
feclearexcept(FE_ALL_EXCEPT): 0
|
||||
raised: 32
|
||||
1
none/tests/mips64/test_math.vgtest
Symbolic link
1
none/tests/mips64/test_math.vgtest
Symbolic link
@ -0,0 +1 @@
|
||||
../mips32/test_math.vgtest
|
||||
Loading…
x
Reference in New Issue
Block a user