Add a small test to prevent regressions.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
v1 -> v2: CC: qemu-devel@nongnu.org.
Check that upper bytes are not modified.
tests/tcg/s390x/Makefile.target | 1 +
tests/tcg/s390x/load-store-reversed.c | 46 +++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
create mode 100644 tests/tcg/s390x/load-store-reversed.c
diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
index 0ca030ded01..fe1fba3de2f 100644
--- a/tests/tcg/s390x/Makefile.target
+++ b/tests/tcg/s390x/Makefile.target
@@ -50,6 +50,7 @@ TESTS+=cvb
TESTS+=ts
TESTS+=ex-smc
TESTS+=divide-to-integer
+TESTS+=load-store-reversed
cdsg: CFLAGS+=-pthread
cdsg: LDFLAGS+=-pthread
diff --git a/tests/tcg/s390x/load-store-reversed.c b/tests/tcg/s390x/load-store-reversed.c
new file mode 100644
index 00000000000..bcc6b98dd3b
--- /dev/null
+++ b/tests/tcg/s390x/load-store-reversed.c
@@ -0,0 +1,46 @@
+/*
+ * Test the LOAD REVERSED and STORE REVERSED instructions.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include <assert.h>
+#include <stdlib.h>
+
+int main(void)
+{
+ long i = 0x123456789abcdefULL, o;
+
+ o = i;
+ asm("lrvr %0,%1" : "+r" (o) : "r" (i));
+ assert(o == 0x1234567efcdab89ULL);
+
+ o = i;
+ asm("lrvgr %0,%1" : "+r" (o) : "r" (i));
+ assert(o == 0xefcdab8967452301ULL);
+
+ o = i;
+ asm("lrvh %0,%1" : "=r" (o) : "T" (i));
+ assert(o == 0x123456789ab2301ULL);
+
+ o = i;
+ asm("lrv %0,%1" : "=r" (o) : "T" (i));
+ assert(o == 0x123456767452301ULL);
+
+ o = i;
+ asm("lrvg %0,%1" : "=r" (o) : "T" (i));
+ assert(o == 0xefcdab8967452301ULL);
+
+ o = i;
+ asm("strvh %1,%0" : "=T" (o) : "r" (i));
+ assert(o == 0xefcd456789abcdefULL);
+
+ o = i;
+ asm("strv %1,%0" : "=T" (o) : "r" (i));
+ assert(o == 0xefcdab8989abcdefULL);
+
+ o = i;
+ asm("strvg %1,%0" : "=T" (o) : "r" (i));
+ assert(o == 0xefcdab8967452301ULL);
+
+ return EXIT_SUCCESS;
+}
--
2.55.0