|
From: <sv...@va...> - 2016-02-17 20:01:06
|
Author: florian
Date: Wed Feb 17 20:00:59 2016
New Revision: 15792
Log:
s390: Fix BZ #359289, adding support for popcnt insn.
Companion patch is VEX r3210.
Patch by Andreas Arnez (ar...@li...).
Added:
trunk/none/tests/s390x/popcnt.c
trunk/none/tests/s390x/popcnt.stderr.exp
trunk/none/tests/s390x/popcnt.stdout.exp
trunk/none/tests/s390x/popcnt.vgtest
Modified:
trunk/NEWS
trunk/docs/internals/s390-opcodes.csv
trunk/none/tests/s390x/ (props changed)
trunk/none/tests/s390x/Makefile.am
trunk/none/tests/s390x/opcodes.h
trunk/tests/s390x_features.c
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Wed Feb 17 20:00:59 2016
@@ -71,6 +71,7 @@
357887 Fix a file handle leak. VG_(fclose) did not close the file
358030 support direct socket calls on x86 32bit (new in linux 4.3)
359133 Assertion 'eltSzB <= ddpa->poolSzB' failed
+359289 s390x: popcnt (B9E1) not implemented
n-i-bz Fix incorrect (or infinite loop) unwind on RHEL7 x86 32 bits
n-i-bz massif --pages-as-heap=yes does not report peak caused by mmap+munmap
Modified: trunk/docs/internals/s390-opcodes.csv
==============================================================================
--- trunk/docs/internals/s390-opcodes.csv (original)
+++ trunk/docs/internals/s390-opcodes.csv Wed Feb 17 20:00:59 2016
@@ -903,7 +903,7 @@
sgrk,"subtract 3 operands 64 bit",implemented,
slrk,"subtract logical 3 operands 32 bit",implemented,
slgrk,"subtract logical 3 operands 64 bit",implemented,
-popcnt,"population count","not implemented",
+popcnt,"population count","implemented",
rrbm,"reset reference bits multiple",N/A,"privileged instruction"
cefbra,"convert from 32 bit fixed to short bfp with rounding mode",implemented,
cdfbra,"convert from 32 bit fixed to long bfp with rounding mode",implemented,
Modified: trunk/none/tests/s390x/Makefile.am
==============================================================================
--- trunk/none/tests/s390x/Makefile.am (original)
+++ trunk/none/tests/s390x/Makefile.am Wed Feb 17 20:00:59 2016
@@ -11,7 +11,7 @@
ex_sig ex_clone cu14 cu14_1 cu41 fpconv ecag fpext_warn \
rounding-1 rounding-2 rounding-3 rounding-4 rounding-5 bfp-1 \
bfp-2 bfp-3 bfp-4 srnm srnmb comp-1 comp-2 exrl tmll tm stmg \
- ex clst mvc test_fork test_sig rounding-6 rxsbg\
+ ex clst mvc test_fork test_sig rounding-6 rxsbg popcnt \
spechelper-alr spechelper-algr \
spechelper-slr spechelper-slgr \
spechelper-cr spechelper-clr \
Modified: trunk/none/tests/s390x/opcodes.h
==============================================================================
--- trunk/none/tests/s390x/opcodes.h (original)
+++ trunk/none/tests/s390x/opcodes.h Wed Feb 17 20:00:59 2016
@@ -324,6 +324,7 @@
#define OY(r1,x2,b2,dl2,dh2) RXY_RRRD(e3,r1,x2,b2,dl2,dh2,56)
#define PFD(r1,x2,b2,dl2,dh2) RXY_URRD(e3,r1,x2,b2,dl2,dh2,36)
#define PFDRL(r1,i2) RIL_UP(c6,r1,2,i2)
+#define POPCNT(r1,r2) RRE_RR(b9e1,00,r1,r2)
#define RISBG(r1,r2,i3,i4,i5) RIE_RRUUU(ec,r1,r2,i3,i4,i5,55)
#define RNSBG(r1,r2,i3,i4,i5) RIE_RRUUU(ec,r1,r2,i3,i4,i5,54)
#define ROSBG(r1,r2,i3,i4,i5) RIE_RRUUU(ec,r1,r2,i3,i4,i5,56)
Added: trunk/none/tests/s390x/popcnt.c
==============================================================================
--- trunk/none/tests/s390x/popcnt.c (added)
+++ trunk/none/tests/s390x/popcnt.c Wed Feb 17 20:00:59 2016
@@ -0,0 +1,30 @@
+#include <stdio.h>
+#include <stdint.h>
+
+
+static void check_popcnt(uint64_t in, uint64_t expected_result,
+ int expected_cc)
+{
+ uint64_t out = ~expected_result;
+ int cc = ~expected_cc;
+
+ asm volatile(".insn rre, 0xb9e10000, %[out], %[in]\n\t"
+ "ipm %[cc]\n\t"
+ "srl %[cc],28\n\t"
+ : [cc]"=d" (cc), [out]"=d" (out)
+ : [in]"d" (in)
+ : "cc");
+ printf("popcnt %16lx -> %16lx %s cc=%d %s\n",
+ in, out, (out == expected_result ? " " : "ERR"),
+ cc, (cc == expected_cc ? " " : "ERR"));
+}
+
+int main()
+{
+ check_popcnt(0, 0, 0);
+ check_popcnt(1, 1, 1);
+ check_popcnt(0x8000000000000000ULL, 0x0100000000000000ULL, 1);
+ check_popcnt(0xffffffffffffffffULL, 0x0808080808080808ULL, 1);
+ check_popcnt(0xff427e3800556bcdULL, 0x0802060300040505ULL, 1);
+ return 0;
+}
Added: trunk/none/tests/s390x/popcnt.stderr.exp
==============================================================================
--- trunk/none/tests/s390x/popcnt.stderr.exp (added)
+++ trunk/none/tests/s390x/popcnt.stderr.exp Wed Feb 17 20:00:59 2016
@@ -0,0 +1,2 @@
+
+
Added: trunk/none/tests/s390x/popcnt.stdout.exp
==============================================================================
--- trunk/none/tests/s390x/popcnt.stdout.exp (added)
+++ trunk/none/tests/s390x/popcnt.stdout.exp Wed Feb 17 20:00:59 2016
@@ -0,0 +1,5 @@
+popcnt 0 -> 0 cc=0
+popcnt 1 -> 1 cc=1
+popcnt 8000000000000000 -> 100000000000000 cc=1
+popcnt ffffffffffffffff -> 808080808080808 cc=1
+popcnt ff427e3800556bcd -> 802060300040505 cc=1
Added: trunk/none/tests/s390x/popcnt.vgtest
==============================================================================
--- trunk/none/tests/s390x/popcnt.vgtest (added)
+++ trunk/none/tests/s390x/popcnt.vgtest Wed Feb 17 20:00:59 2016
@@ -0,0 +1 @@
+prog: popcnt
Modified: trunk/tests/s390x_features.c
==============================================================================
--- trunk/tests/s390x_features.c (original)
+++ trunk/tests/s390x_features.c Wed Feb 17 20:00:59 2016
@@ -232,6 +232,8 @@
match = facilities & FAC_BIT(42);
} else if (strcmp(feature, "s390x-pfpo") == 0 ) {
match = facilities & FAC_BIT(44);
+ } else if (strcmp(feature, "s390x-highw") == 0 ) {
+ match = facilities & FAC_BIT(45);
} else {
return 2; // Unrecognised feature.
}
|