1
{***********************************************************}
2
{ CODE GENERATOR TEST SUITE *}
3
{***********************************************************}
4
{ NODE TESTED : secondshlshr() *}
5
{***********************************************************}
6
{ PRE-REQUISITES: secondload() }
9
{ secondinline() with strings only! }
10
{ secondadd() comparison }
12
{***********************************************************}
13
{ DEFINES : FPC if target is Free Pascal compiler }
14
{***********************************************************}
16
{***********************************************************}
19
{----------------------------------------------------}
21
{ RIGHT NODE (shift count value) }
23
{ - LOC_REFERENCE / LOC_MEM }
25
{ - numeric constant }
26
{ LEFT NODE (value to shift) }
28
{ - LOC_REFERENCE / LOC_MEM }
30
{----------------------------------------------------}
31
procedure test(value, required: {$ifndef fpc}longint{$else fpc}int64{$endif fpc});
33
if value <> required then
35
writeln('Got ',value,' instead of ',required);
43
tint64record = packed record
62
int64rec : tint64record;
65
WriteLn('------------------------------ LONGINT --------------------------------');
66
{ left : LOC_REFERENCE }
67
{ right : numeric constant }
68
WriteLn('(left) : LOC_REFERENCE; (right) : ordinal constant');
70
longres := longres shl 15;
71
Write('(SHL) Value should be 32768...');
75
longres := longres shl 15;
76
Write('(SHL) Value should be -32768...');
77
test(longres, -32768);
80
longres := longres shl 33;
81
Write('(SHL) Value should be 2...');
85
longres := longres shr 15;
86
Write('(SHR) Value should be 1...');
90
longres := longres shr 15;
91
Write('(SHR) Value should be 131071...');
92
test(longres, 131071);
95
longres := longres shr 33;
96
Write('(SHR) Value should be 32767...');
99
{ left : LOC_REFERENCE }
100
{ right : LOC_REFERENCE }
101
WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REFERENCE');
106
longres:=longres shl longcnt ;
107
Write('(SHL) Value should be 1073741824...');
108
test(longres, 1073741824);
113
longres := longres shl longcnt;
114
Write('(SHL) Value should be 32768...');
115
test(longres, 32768);
119
longres := longres shl longcnt;
120
Write('(SHL) Value should be -32768...');
121
test(longres, -32768);
126
longres:=longres shr longcnt ;
127
Write('(SHR) Value should be 0...');
133
longres := longres shr longcnt;
134
Write('(SHR) Value should be 1...');
139
longres := longres shl longcnt;
140
Write('(SHR) Value should be -32768...');
141
test(longres, -32768);
143
{ left : LOC_REFERENCE }
144
{ right : LOC_REGISRER }
146
WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REGISTER');
149
longres:=longres shl bytecnt ;
150
Write('(SHL) Value should be 1073741824...');
151
test(longres, 1073741824);
156
longres := longres shl bytecnt;
157
Write('(SHL) Value should be 32768...');
158
test(longres, 32768);
162
longres := longres shl bytecnt;
163
Write('(SHL) Value should be -32768...');
164
test(longres, -32768);
169
longres:=longres shr bytecnt ;
170
Write('(SHR) Value should be 0...');
176
longres := longres shr bytecnt;
177
Write('(SHR) Value should be 1...');
182
longres := longres shr bytecnt;
183
Write('(SHR) Value should be 131071...');
184
test(longres, 131071);
186
WriteLn('(left) : LOC_REGISTER; (right) : LOC_REGISTER');
189
byteres := byteres shl bytecnt;
190
Write('(SHL) Value should be 4...');
196
byteres := byteres shr bytecnt;
197
Write('(SHR) Value should be 1...');
201
WriteLn('------------------------------ INT64 --------------------------------');
202
{ left : LOC_REFERENCE }
203
{ right : numeric constant }
204
WriteLn('(left) : LOC_REFERENCE; (right) : ordinal constant');
206
int64res := int64res shl 15;
207
Write('(SHL) Value should be 32768...');
208
test(int64res, 32768);
211
int64res := int64res shl 15;
212
Write('(SHL) Value should be -32768...');
213
test(int64res, -32768);
217
int64res := int64res shl 65;
218
Write('(SHL) Value should be 2...');
222
int64res := int64res shr 15;
223
Write('(SHR) Value should be 1...');
227
int64res := int64res shr 65;
228
Write('(SHR) Value should be 32767...');
229
test(int64res, 32767);
231
{ left : LOC_REFERENCE }
232
{ right : LOC_REFERENCE }
234
WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REFERENCE');
237
int64res:=int64res shl int64cnt ;
238
Write('(SHL) Value should be 1073741824...');
239
test(int64res, 1073741824);
244
int64res := int64res shl int64cnt;
245
Write('(SHL) Value should be 32768...');
246
test(int64res, 32768);
251
int64res := int64res shl int64cnt;
252
Write('(SHL) Value should be -32768...');
253
test(int64res, -32768);
257
int64res := int64res shl int64cnt;
258
Write('(SHL) Value should be 2 in high longint (85899345)...');
259
move(int64res,int64rec, sizeof(int64));
260
test(int64rec.highval, 2);
261
{ test(int64res, 8589934592);}
267
int64res:=int64res shr int64cnt ;
268
Write('(SHR) Value should be 0...');
269
test(int64res and $FFFFFFFF, 0);
273
int64res := int64res shr int64cnt;
274
Write('(SHR) Value should be 1...');
279
int64res := int64res shl int64cnt;
280
Write('(SHR) Value should be -32768...');
281
test(int64res, -32768);
283
{ left : LOC_REFERENCE }
284
{ right : LOC_REGISRER }
286
WriteLn('(left) : LOC_REFERENCE; (right) : LOC_REGISTER');
289
int64res:=int64res shl bytecnt ;
290
Write('(SHL) Value should be 1073741824...');
291
test(int64res, 1073741824);
296
int64res := int64res shl bytecnt;
297
Write('(SHL) Value should be 32768...');
298
test(int64res, 32768);
303
int64res := int64res shl bytecnt;
304
Write('(SHL) Value should be -32768...');
305
test(int64res, -32768);
310
int64res:=int64res shr bytecnt ;
311
Write('(SHR) Value should be 0...');
312
test(int64res and $FFFFFFFF, 0);
317
int64res := int64res shr bytecnt;
318
Write('(SHR) Value should be 1...');
323
int64res := int64res shl bytecnt;
324
Write('(SHL) Value should be 2 in high longint (85899345)...');
325
move(int64res,int64rec, sizeof(int64));
326
test(int64rec.highval, 2);
330
int64res := int64res shr bytecnt;
331
WriteLn('(SHR) Value should be 131071...',int64res);}