Revision d57c4e01 tests/test-i386-shift.h

b/tests/test-i386-shift.h
4 4
#define exec_opw glue(glue(exec_, OP), w)
5 5
#define exec_opb glue(glue(exec_, OP), b)
6 6

  
7
#define EXECSHIFT(size, res, s1, flags) \
7
#ifndef OP_SHIFTD
8

  
9
#ifdef OP_NOBYTE
10
#define EXECSHIFT(size, res, s1, s2, flags) \
11
    asm ("push %4\n\t"\
12
         "popf\n\t"\
13
         stringify(OP) size " %" size "2, %" size "0\n\t" \
14
         "pushf\n\t"\
15
         "popl %1\n\t"\
16
         : "=g" (res), "=g" (flags)\
17
         : "r" (s1), "0" (res), "1" (flags));
18
#else
19
#define EXECSHIFT(size, res, s1, s2, flags) \
8 20
    asm ("push %4\n\t"\
9 21
         "popf\n\t"\
10 22
         stringify(OP) size " %%cl, %" size "0\n\t" \
......
12 24
         "popl %1\n\t"\
13 25
         : "=q" (res), "=g" (flags)\
14 26
         : "c" (s1), "0" (res), "1" (flags));
27
#endif
15 28

  
16
void exec_opl(int s0, int s1, int iflags)
29
void exec_opl(int s2, int s0, int s1, int iflags)
17 30
{
18 31
    int res, flags;
19 32
    res = s0;
20 33
    flags = iflags;
21
    EXECSHIFT("", res, s1, flags);
34
    EXECSHIFT("", res, s1, s2, flags);
22 35
    /* overflow is undefined if count != 1 */
23 36
    if (s1 != 1)
24 37
      flags &= ~CC_O;
......
26 39
           stringify(OP) "l", s0, s1, res, iflags, flags & CC_MASK);
27 40
}
28 41

  
29
void exec_opw(int s0, int s1, int iflags)
42
void exec_opw(int s2, int s0, int s1, int iflags)
30 43
{
31 44
    int res, flags;
32 45
    res = s0;
33 46
    flags = iflags;
34
    EXECSHIFT("w", res, s1, flags);
47
    EXECSHIFT("w", res, s1, s2, flags);
35 48
    /* overflow is undefined if count != 1 */
36 49
    if (s1 != 1)
37 50
      flags &= ~CC_O;
......
39 52
           stringify(OP) "w", s0, s1, res, iflags, flags & CC_MASK);
40 53
}
41 54

  
55
#else
56
#define EXECSHIFT(size, res, s1, s2, flags) \
57
    asm ("push %4\n\t"\
58
         "popf\n\t"\
59
         stringify(OP) size " %%cl, %" size "5, %" size "0\n\t" \
60
         "pushf\n\t"\
61
         "popl %1\n\t"\
62
         : "=g" (res), "=g" (flags)\
63
         : "c" (s1), "0" (res), "1" (flags), "r" (s2));
64

  
65
void exec_opl(int s2, int s0, int s1, int iflags)
66
{
67
    int res, flags;
68
    res = s0;
69
    flags = iflags;
70
    EXECSHIFT("", res, s1, s2, flags);
71
    /* overflow is undefined if count != 1 */
72
    if (s1 != 1)
73
      flags &= ~CC_O;
74
    printf("%-10s A=%08x B=%08x C=%08x R=%08x CCIN=%04x CC=%04x\n",
75
           stringify(OP) "l", s0, s2, s1, res, iflags, flags & CC_MASK);
76
}
77

  
78
void exec_opw(int s2, int s0, int s1, int iflags)
79
{
80
    int res, flags;
81
    res = s0;
82
    flags = iflags;
83
    EXECSHIFT("w", res, s1, s2, flags);
84
    /* overflow is undefined if count != 1 */
85
    if (s1 != 1)
86
      flags &= ~CC_O;
87
    printf("%-10s A=%08x B=%08x C=%08x R=%08x CCIN=%04x CC=%04x\n",
88
           stringify(OP) "w", s0, s2, s1, res, iflags, flags & CC_MASK);
89
}
90

  
91
#endif
92

  
93
#ifndef OP_NOBYTE
42 94
void exec_opb(int s0, int s1, int iflags)
43 95
{
44 96
    int res, flags;
45 97
    res = s0;
46 98
    flags = iflags;
47
    EXECSHIFT("b", res, s1, flags);
99
    EXECSHIFT("b", res, s1, 0, flags);
48 100
    /* overflow is undefined if count != 1 */
49 101
    if (s1 != 1)
50 102
      flags &= ~CC_O;
51 103
    printf("%-10s A=%08x B=%08x R=%08x CCIN=%04x CC=%04x\n",
52 104
           stringify(OP) "b", s0, s1, res, iflags, flags & CC_MASK);
53 105
}
106
#endif
54 107

  
55
void exec_op(int s0, int s1)
108
void exec_op(int s2, int s0, int s1)
56 109
{
57
    exec_opl(s0, s1, 0);
58
    exec_opw(s0, s1, 0);
110
    exec_opl(s2, s0, s1, 0);
111
    exec_opw(s2, s0, s1, 0);
112
#ifndef OP_NOBYTE
59 113
    exec_opb(s0, s1, 0);
114
#endif
60 115
#ifdef OP_CC
61
    exec_opl(s0, s1, CC_C);
62
    exec_opw(s0, s1, CC_C);
116
    exec_opl(s2, s0, s1, CC_C);
117
    exec_opw(s2, s0, s1, CC_C);
63 118
    exec_opb(s0, s1, CC_C);
64 119
#endif
65 120
}
......
68 123
{
69 124
    int i;
70 125
    for(i = 0; i < 32; i++)
71
        exec_op(0x12345678, i);
126
        exec_op(0x21ad3d34, 0x12345678, i);
72 127
    for(i = 0; i < 32; i++)
73
        exec_op(0x82345678, i);
128
        exec_op(0x813f3421, 0x82345678, i);
74 129
}
75 130

  
76 131
void *glue(_test_, OP) __init_call = glue(test_, OP);
77 132

  
78 133
#undef OP
79 134
#undef OP_CC
135
#undef OP_SHIFTD
136
#undef OP_NOBYTE
137
#undef EXECSHIFT
138

  

Also available in: Unified diff