aboutsummaryrefslogtreecommitdiff
path: root/tests/tcg/s390x/chrl.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tcg/s390x/chrl.c')
-rw-r--r--tests/tcg/s390x/chrl.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/tcg/s390x/chrl.c b/tests/tcg/s390x/chrl.c
new file mode 100644
index 0000000..b1c3a1c
--- /dev/null
+++ b/tests/tcg/s390x/chrl.c
@@ -0,0 +1,80 @@
+#include <stdlib.h>
+#include <assert.h>
+#include <stdint.h>
+
+static void test_chrl(void)
+{
+ uint32_t program_mask, cc;
+
+ asm volatile (
+ ".pushsection .rodata\n"
+ "0:\n\t"
+ ".short 1, 0x8000\n\t"
+ ".popsection\n\t"
+
+ "chrl %[r], 0b\n\t"
+ "ipm %[program_mask]\n"
+ : [program_mask] "=r" (program_mask)
+ : [r] "r" (1)
+ );
+
+ cc = program_mask >> 28;
+ assert(!cc);
+
+ asm volatile (
+ ".pushsection .rodata\n"
+ "0:\n\t"
+ ".short -1, 0x8000\n\t"
+ ".popsection\n\t"
+
+ "chrl %[r], 0b\n\t"
+ "ipm %[program_mask]\n"
+ : [program_mask] "=r" (program_mask)
+ : [r] "r" (-1)
+ );
+
+ cc = program_mask >> 28;
+ assert(!cc);
+}
+
+static void test_cghrl(void)
+{
+ uint32_t program_mask, cc;
+
+ asm volatile (
+ ".pushsection .rodata\n"
+ "0:\n\t"
+ ".short 1, 0x8000, 0, 0\n\t"
+ ".popsection\n\t"
+
+ "cghrl %[r], 0b\n\t"
+ "ipm %[program_mask]\n"
+ : [program_mask] "=r" (program_mask)
+ : [r] "r" (1L)
+ );
+
+ cc = program_mask >> 28;
+ assert(!cc);
+
+ asm volatile (
+ ".pushsection .rodata\n"
+ "0:\n\t"
+ ".short -1, 0x8000, 0, 0\n\t"
+ ".popsection\n\t"
+
+ "cghrl %[r], 0b\n\t"
+ "ipm %[program_mask]\n"
+ : [program_mask] "=r" (program_mask)
+ : [r] "r" (-1L)
+ );
+
+ cc = program_mask >> 28;
+ assert(!cc);
+}
+
+int main(void)
+{
+ test_chrl();
+ test_cghrl();
+ return EXIT_SUCCESS;
+}