]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
tests/tcg/s390x: Test LARL with a large offset
authorIlya Leoshkevich <iii@linux.ibm.com>
Tue, 4 Jul 2023 08:12:33 +0000 (10:12 +0200)
committerThomas Huth <thuth@redhat.com>
Mon, 10 Jul 2023 13:34:24 +0000 (15:34 +0200)
Add a small test to prevent regressions.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Acked-by: David Hildenbrand <david@redhat.com>
Message-Id: <20230704081506.276055-10-iii@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
tests/tcg/s390x/Makefile.target
tests/tcg/s390x/larl.c [new file with mode: 0644]

index 2ef22c88d95764647ecc7dba02d4e35f5623a1fc..dbf64c991e989fd4bfb3e39c6675ebdaf33585be 100644 (file)
@@ -37,6 +37,7 @@ TESTS+=ex-relative-long
 TESTS+=ex-branch
 TESTS+=mxdb
 TESTS+=epsw
+TESTS+=larl
 
 cdsg: CFLAGS+=-pthread
 cdsg: LDFLAGS+=-pthread
diff --git a/tests/tcg/s390x/larl.c b/tests/tcg/s390x/larl.c
new file mode 100644 (file)
index 0000000..7c95f89
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Test the LARL instruction.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#include <stdlib.h>
+
+int main(void)
+{
+    long algfi = (long)main;
+    long larl;
+
+    /*
+     * The compiler may emit larl for the C addition, so compute the expected
+     * value using algfi.
+     */
+    asm("algfi %[r],0xd0000000" : [r] "+r" (algfi) : : "cc");
+    asm("larl %[r],main+0xd0000000" : [r] "=r" (larl));
+
+    return algfi == larl ? EXIT_SUCCESS : EXIT_FAILURE;
+}