From: Florian Krohm Date: Fri, 28 Dec 2012 15:54:23 +0000 (+0000) Subject: s390: Add testcase for "test data class/group" insns. X-Git-Tag: svn/VALGRIND_3_9_0~466 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83a2d3c94d5ef5f18cfccea33c541f3063e9d570;p=thirdparty%2Fvalgrind.git 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 --- diff --git a/none/tests/s390x/Makefile.am b/none/tests/s390x/Makefile.am index 9577b3fcb0..9ad60c1788 100644 --- a/none/tests/s390x/Makefile.am +++ b/none/tests/s390x/Makefile.am @@ -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@ diff --git a/none/tests/s390x/dfptest.c b/none/tests/s390x/dfptest.c new file mode 100644 index 0000000000..f1b383a7b8 --- /dev/null +++ b/none/tests/s390x/dfptest.c @@ -0,0 +1,125 @@ +#include +#include + +/* 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<