none/tests/fdleak_cmsg_supp.supp: Add suppressions for older glibc
[valgrind.git] / none / tests / amd64 / shrld.c
blobd77cfbdc90d89e78d0d76652b234fb335a60a15e
2 #include <stdio.h>
4 typedef unsigned long long int ULong;
6 ULong data;
7 ULong xtra;
8 ULong amt;
9 ULong flags_in;
10 ULong result;
11 ULong flags_out;
13 #define AMD64G_CC_SHIFT_O 11
14 #define AMD64G_CC_SHIFT_S 7
15 #define AMD64G_CC_SHIFT_Z 6
16 #define AMD64G_CC_SHIFT_A 4
17 #define AMD64G_CC_SHIFT_C 0
18 #define AMD64G_CC_SHIFT_P 2
20 #define AMD64G_CC_MASK_O (1 << AMD64G_CC_SHIFT_O)
21 #define AMD64G_CC_MASK_S (1 << AMD64G_CC_SHIFT_S)
22 #define AMD64G_CC_MASK_Z (1 << AMD64G_CC_SHIFT_Z)
23 #define AMD64G_CC_MASK_A (1 << AMD64G_CC_SHIFT_A)
24 #define AMD64G_CC_MASK_C (1 << AMD64G_CC_SHIFT_C)
25 #define AMD64G_CC_MASK_P (1 << AMD64G_CC_SHIFT_P)
27 #define MASK_OSZACP \
28 (AMD64G_CC_MASK_O | AMD64G_CC_MASK_S | AMD64G_CC_MASK_Z \
29 | AMD64G_CC_MASK_A | AMD64G_CC_MASK_C | AMD64G_CC_MASK_P)
31 extern void shld64 ( void );
32 asm("\n"
33 ".text\n"
34 "shld64:\n"
35 "\tpushq %rsi\n"
36 "\tpushq %r11\n"
37 "\tpushq %rcx\n"
38 "\tmovq data, %rsi\n"
39 "\tmovq xtra, %r11\n"
40 "\tmovq amt, %rcx\n"
41 "\tpushq flags_in\n"
42 "\tpopfq\n"
43 "\tshldq %cl, %r11, %rsi\n"
44 "\tmovq %rsi, result\n"
45 "\tpushfq\n"
46 "\tpopq flags_out\n"
47 "\tpopq %rcx\n"
48 "\tpopq %r11\n"
49 "\tpopq %rsi\n"
50 "\tret\n"
51 ".previous\n"
54 extern void shld32 ( void );
55 asm("\n"
56 ".text\n"
57 "shld32:\n"
58 "\tpushq %rsi\n"
59 "\tpushq %r11\n"
60 "\tpushq %rcx\n"
61 "\tmovq data, %rsi\n"
62 "\tmovq xtra, %r11\n"
63 "\tmovq amt, %rcx\n"
64 "\tpushq flags_in\n"
65 "\tpopfq\n"
66 "\tshldl %cl, %r11d, %esi\n"
67 "\tmovq %rsi, result\n"
68 "\tpushfq\n"
69 "\tpopq flags_out\n"
70 "\tpopq %rcx\n"
71 "\tpopq %r11\n"
72 "\tpopq %rsi\n"
73 "\tret\n"
74 ".previous\n"
77 extern void shld16 ( void );
78 asm("\n"
79 ".text\n"
80 "shld16:\n"
81 "\tpushq %rsi\n"
82 "\tpushq %r11\n"
83 "\tpushq %rcx\n"
84 "\tmovq data, %rsi\n"
85 "\tmovq xtra, %r11\n"
86 "\tmovq amt, %rcx\n"
87 "\tpushq flags_in\n"
88 "\tpopfq\n"
89 "\tshldw %cl, %r11w, %si\n"
90 "\tmovq %rsi, result\n"
91 "\tpushfq\n"
92 "\tpopq flags_out\n"
93 "\tpopq %rcx\n"
94 "\tpopq %r11\n"
95 "\tpopq %rsi\n"
96 "\tret\n"
97 ".previous\n"
101 extern void shrd64 ( void );
102 asm("\n"
103 ".text\n"
104 "shrd64:\n"
105 "\tpushq %rsi\n"
106 "\tpushq %r11\n"
107 "\tpushq %rcx\n"
108 "\tmovq data, %rsi\n"
109 "\tmovq xtra, %r11\n"
110 "\tmovq amt, %rcx\n"
111 "\tpushq flags_in\n"
112 "\tpopfq\n"
113 "\tshrdq %cl, %r11, %rsi\n"
114 "\tmovq %rsi, result\n"
115 "\tpushfq\n"
116 "\tpopq flags_out\n"
117 "\tpopq %rcx\n"
118 "\tpopq %r11\n"
119 "\tpopq %rsi\n"
120 "\tret\n"
121 ".previous\n"
124 extern void shrd32 ( void );
125 asm("\n"
126 ".text\n"
127 "shrd32:\n"
128 "\tpushq %rsi\n"
129 "\tpushq %r11\n"
130 "\tpushq %rcx\n"
131 "\tmovq data, %rsi\n"
132 "\tmovq xtra, %r11\n"
133 "\tmovq amt, %rcx\n"
134 "\tpushq flags_in\n"
135 "\tpopfq\n"
136 "\tshrdl %cl, %r11d, %esi\n"
137 "\tmovq %rsi, result\n"
138 "\tpushfq\n"
139 "\tpopq flags_out\n"
140 "\tpopq %rcx\n"
141 "\tpopq %r11\n"
142 "\tpopq %rsi\n"
143 "\tret\n"
144 ".previous\n"
147 extern void shrd16 ( void );
148 asm("\n"
149 ".text\n"
150 "shrd16:\n"
151 "\tpushq %rsi\n"
152 "\tpushq %r11\n"
153 "\tpushq %rcx\n"
154 "\tmovq data, %rsi\n"
155 "\tmovq xtra, %r11\n"
156 "\tmovq amt, %rcx\n"
157 "\tpushq flags_in\n"
158 "\tpopfq\n"
159 "\tshrdw %cl, %r11w, %si\n"
160 "\tmovq %rsi, result\n"
161 "\tpushfq\n"
162 "\tpopq flags_out\n"
163 "\tpopq %rcx\n"
164 "\tpopq %r11\n"
165 "\tpopq %rsi\n"
166 "\tret\n"
167 ".previous\n"
171 int main ( void )
173 int i;
174 ULong mask;
176 printf("\nleft 64\n");
177 for (i = 0; i < 260; i++) {
178 mask = MASK_OSZACP;
179 if (i > 1) mask &= ~AMD64G_CC_MASK_O;
180 if (i > 0) mask &= ~AMD64G_CC_MASK_A;
181 data = 0x1122334455667788ULL;
182 xtra = 0x3141592727182818ULL;
183 flags_in = 0ULL;
184 amt = (ULong)i;
185 shld64();
186 printf("%3d 0x%016llx 0x%llx\n", i, result, flags_out & mask);
189 printf("\nleft 32\n");
190 for (i = 0; i < 260; i++) {
191 mask = MASK_OSZACP;
192 if (i > 1) mask &= ~AMD64G_CC_MASK_O;
193 if (i > 0) mask &= ~AMD64G_CC_MASK_A;
194 data = 0x1122334455667788ULL;
195 xtra = 0x3141592727182818ULL;
196 flags_in = 0ULL;
197 amt = (ULong)i;
198 shld32();
199 printf("%3d 0x%016llx 0x%llx\n", i, result, flags_out & mask);
201 printf("\n");
203 printf("\nleft 16\n");
204 for (i = 0; i < 260; i++) {
205 mask = MASK_OSZACP;
206 if (i > 1) mask &= ~AMD64G_CC_MASK_O;
207 if (i > 0) mask &= ~AMD64G_CC_MASK_A;
208 data = 0x1122334455667788ULL;
209 xtra = 0x987654321987abcdULL;
210 flags_in = 0ULL;
211 amt = (ULong)i;
212 shld16();
213 printf("%3d 0x%016llx 0x%llx\n", i, result, flags_out & mask);
215 printf("\n");
217 printf("\nright 64\n");
218 for (i = 0; i < 260; i++) {
219 mask = MASK_OSZACP;
220 if (i > 1) mask &= ~AMD64G_CC_MASK_O;
221 if (i > 0) mask &= ~AMD64G_CC_MASK_A;
222 data = 0x1122334455667788ULL;
223 xtra = 0x3141592727182818ULL;
224 flags_in = 0ULL;
225 amt = (ULong)i;
226 shrd64();
227 printf("%3d 0x%016llx 0x%llx\n", i, result, flags_out & mask);
230 printf("\nright 32\n");
231 for (i = 0; i < 260; i++) {
232 mask = MASK_OSZACP;
233 if (i > 1) mask &= ~AMD64G_CC_MASK_O;
234 if (i > 0) mask &= ~AMD64G_CC_MASK_A;
235 data = 0x1122334455667788ULL;
236 xtra = 0x3141592727182818ULL;
237 flags_in = 0ULL;
238 amt = (ULong)i;
239 shrd32();
240 printf("%3d 0x%016llx 0x%llx\n", i, result, flags_out & mask);
242 printf("\n");
244 printf("\nright 16\n");
245 for (i = 0; i < 260; i++) {
246 mask = MASK_OSZACP;
247 if (i > 1) mask &= ~AMD64G_CC_MASK_O;
248 if (i > 0) mask &= ~AMD64G_CC_MASK_A;
249 data = 0x1122334455667788ULL;
250 xtra = 0x987654321987abcdULL;
251 flags_in = 0ULL;
252 amt = (ULong)i;
253 shrd16();
254 printf("%3d 0x%016llx 0x%llx\n", i, result, flags_out & mask);
256 printf("\n");
258 return 0;