s390: Add testcase for "test data class/group" insns.

Patch by Maran Pakkirisamy (maranp@linux.vnet.ibm.com).
This is part of fixing BZ 307113.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13214
This commit is contained in:
Florian Krohm 2012-12-28 15:54:23 +00:00
parent 415490d305
commit 83a2d3c94d
5 changed files with 144 additions and 2 deletions

View File

@ -19,7 +19,7 @@ INSN_TESTS = clc clcle cvb cvd icm lpr tcxb lam_stam xc mvst add sub mul \
spechelper-icm-1 spechelper-icm-2 spechelper-tmll \
spechelper-tm laa
if BUILD_DFP_TESTS
INSN_TESTS += dfp-1 dfp-2 dfp-3 dfp-4
INSN_TESTS += dfp-1 dfp-2 dfp-3 dfp-4 dfptest
endif
check_PROGRAMS = $(INSN_TESTS) \
@ -38,7 +38,8 @@ EXTRA_DIST = \
dfp-1.stderr.exp dfp-1.stdout.exp dfp-1.vgtest \
dfp-2.stderr.exp dfp-2.stdout.exp dfp-2.vgtest \
dfp-3.stderr.exp dfp-3.stdout.exp dfp-3.vgtest \
dfp-4.stderr.exp dfp-4.stdout.exp dfp-4.vgtest
dfp-4.stderr.exp dfp-4.stdout.exp dfp-4.vgtest \
dfptest.stderr.exp dfptest.stdout.exp dfptest.vgtest
AM_CFLAGS += @FLAG_M64@
AM_CXXFLAGS += @FLAG_M64@

125
none/tests/s390x/dfptest.c Normal file
View File

@ -0,0 +1,125 @@
#include <math.h>
#include <stdio.h>
/* Following macros adopted from dfp/math.h from libdfp */
#define DEC_INFINITY __builtin_infd64()
#define DEC_NAN (0.0DF * DEC_INFINITY)
/* Following instructions are tested:
test data class tests for
_Decimal32 - TDCET
_Decimal64 - TDCDT
_decimal128 - TDCXT
test data group tests for
_Decimal32 - TDGET
_Decimal64 - TDGDT
_decimal128 - TDGXT
*/
#define TEST_128(opcode, d, n) \
({ \
int match; \
_Decimal128 f = d; \
long long num = n; \
asm volatile(opcode ", %1,0(%2)\n" \
"ipm %0\n" \
"srl %0,28\n" \
: "=d" (match) : "f" (f), "a" (num) : "cc"); \
match; \
})
#define TEST_64(opcode, d, n) \
({ \
int match; \
_Decimal64 f = d; \
long long num = n; \
asm volatile(opcode ", %1,0(%2)\n" \
"ipm %0\n" \
"srl %0,28\n" \
: "=d" (match) : "f" (f), "a" (num) : "cc"); \
match; \
})
#define TEST_32(opcode, d, n) \
({ \
int match; \
_Decimal32 f = d; \
long long num = n; \
asm volatile(opcode ", %1,0(%2)\n" \
"ipm %0\n" \
"srl %0,28\n" \
: "=d" (match) : "f" (f), "a" (num) : "cc"); \
match; \
})
int main()
{
int i;
/* The right most 12 bits 52:63 of the second operand are set and tested */
for (i = 0; i < 12; i++) {
/* DFP 128 bit - TDCXT */
printf("%d", TEST_128(".insn rxe, 0xed0000000058", +0.0DF, 1UL<<i));
printf("%d", TEST_128(".insn rxe, 0xed0000000058", -0.0DF, 1UL<<i));
printf("%d", TEST_128(".insn rxe, 0xed0000000058", +2.2DF, 1UL<<i));
printf("%d", TEST_128(".insn rxe, 0xed0000000058", -2.2DF, 1UL<<i));
printf("%d", TEST_128(".insn rxe, 0xed0000000058",+DEC_INFINITY,1UL<<i));
printf("%d", TEST_128(".insn rxe, 0xed0000000058",-DEC_INFINITY,1UL<<i));
printf("%d", TEST_128(".insn rxe, 0xed0000000058", +DEC_NAN, 1UL<<i));
printf("%d", TEST_128(".insn rxe, 0xed0000000058", -DEC_NAN, 1UL<<i));
/* DFP 128 bit - TDGXT */
printf("%d", TEST_128(".insn rxe, 0xed0000000059", +0.0DF, 1UL<<i));
printf("%d", TEST_128(".insn rxe, 0xed0000000059", -0.0DF, 1UL<<i));
printf("%d", TEST_128(".insn rxe, 0xed0000000059", +2.2DF, 1UL<<i));
printf("%d", TEST_128(".insn rxe, 0xed0000000059", -2.2DF, 1UL<<i));
printf("%d", TEST_128(".insn rxe, 0xed0000000059",+DEC_INFINITY,1UL<<i));
printf("%d", TEST_128(".insn rxe, 0xed0000000059",-DEC_INFINITY,1UL<<i));
printf("%d", TEST_128(".insn rxe, 0xed0000000059", +DEC_NAN, 1UL<<i));
printf("%d", TEST_128(".insn rxe, 0xed0000000059", -DEC_NAN, 1UL<<i));
/* DFP 64 bit - TDCDT */
printf("%d", TEST_64(".insn rxe, 0xed0000000054", +0.0DF, 1UL<<i));
printf("%d", TEST_64(".insn rxe, 0xed0000000054", -0.0DF, 1UL<<i));
printf("%d", TEST_64(".insn rxe, 0xed0000000054", +2.2DF, 1UL<<i));
printf("%d", TEST_64(".insn rxe, 0xed0000000054", -2.2DF, 1UL<<i));
printf("%d", TEST_64(".insn rxe, 0xed0000000054",+DEC_INFINITY,1UL<<i));
printf("%d", TEST_64(".insn rxe, 0xed0000000054",-DEC_INFINITY,1UL<<i));
printf("%d", TEST_64(".insn rxe, 0xed0000000054", +DEC_NAN, 1UL<<i));
printf("%d", TEST_64(".insn rxe, 0xed0000000054", -DEC_NAN, 1UL<<i));
/* DFP 64 bit - TDGDT */
printf("%d", TEST_64(".insn rxe, 0xed0000000055", +0.0DF, 1UL<<i));
printf("%d", TEST_64(".insn rxe, 0xed0000000055", -0.0DF, 1UL<<i));
printf("%d", TEST_64(".insn rxe, 0xed0000000055", +2.2DF, 1UL<<i));
printf("%d", TEST_64(".insn rxe, 0xed0000000055", -2.2DF, 1UL<<i));
printf("%d", TEST_64(".insn rxe, 0xed0000000055",+DEC_INFINITY,1UL<<i));
printf("%d", TEST_64(".insn rxe, 0xed0000000055",-DEC_INFINITY,1UL<<i));
printf("%d", TEST_64(".insn rxe, 0xed0000000055", +DEC_NAN, 1UL<<i));
printf("%d", TEST_64(".insn rxe, 0xed0000000055", -DEC_NAN, 1UL<<i));
/* DFP 32 bit - TDCET */
printf("%d", TEST_32(".insn rxe, 0xed0000000050", +0.0DF, 1UL<<i));
printf("%d", TEST_32(".insn rxe, 0xed0000000050", -0.0DF, 1UL<<i));
printf("%d", TEST_32(".insn rxe, 0xed0000000050", +2.2DF, 1UL<<i));
printf("%d", TEST_32(".insn rxe, 0xed0000000050", -2.2DF, 1UL<<i));
printf("%d", TEST_32(".insn rxe, 0xed0000000050",+DEC_INFINITY,1UL<<i));
printf("%d", TEST_32(".insn rxe, 0xed0000000050",-DEC_INFINITY,1UL<<i));
printf("%d", TEST_32(".insn rxe, 0xed0000000050", +DEC_NAN, 1UL<<i));
printf("%d", TEST_32(".insn rxe, 0xed0000000050", -DEC_NAN, 1UL<<i));
/* DFP 32 bit - TDGET */
printf("%d", TEST_32(".insn rxe, 0xed0000000051", +0.0DF, 1UL<<i));
printf("%d", TEST_32(".insn rxe, 0xed0000000051", -0.0DF, 1UL<<i));
printf("%d", TEST_32(".insn rxe, 0xed0000000051", +2.2DF, 1UL<<i));
printf("%d", TEST_32(".insn rxe, 0xed0000000051", -2.2DF, 1UL<<i));
printf("%d", TEST_32(".insn rxe, 0xed0000000051",+DEC_INFINITY,1UL<<i));
printf("%d", TEST_32(".insn rxe, 0xed0000000051",-DEC_INFINITY,1UL<<i));
printf("%d", TEST_32(".insn rxe, 0xed0000000051", +DEC_NAN, 1UL<<i));
printf("%d", TEST_32(".insn rxe, 0xed0000000051", -DEC_NAN, 1UL<<i));
printf("\n");
}
return 0;
}

View File

@ -0,0 +1,2 @@

View File

@ -0,0 +1,12 @@
000000000000010100000000000001010000000000000101
000000000000101000000000000010100000000000001010
000000010000000000000001000000000000000100000000
000000100000000000000010000000000000001000000000
000001000001000000000100000100000000010000010000
000010000010000000001000001000000000100000100000
000100000000000000010000000000000001000000000000
001000000000000000100000000000000010000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
010000000100000001000000010000000100000001000000
100000001000000010000000100000001000000010000000

View File

@ -0,0 +1,2 @@
prog: dfptest
prereq: test -e dfptest && ../../../tests/s390x_features s390x-dfp