aboutsummaryrefslogtreecommitdiff
path: root/tests/tcg/s390x/chrl.c
blob: b1c3a1c56173b747c6347d8e8f9f0e86ad80a4dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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;
}