1
{****************************************************************}
2
{ CODE GENERATOR TEST PROGRAM }
3
{****************************************************************}
4
{ NODE TESTED : secondsubscriptn(), partial secondload() }
5
{****************************************************************}
6
{ PRE-REQUISITES: secondload() }
8
{****************************************************************}
9
{ DEFINES: VERBOSE = Write test information to screen }
10
{ FPC = Target is FreePascal compiler }
11
{****************************************************************}
16
{****************************************************************}
22
type smallint = integer;
25
{ Should be equal to the maximum offset possible in indirect addressing
26
mode with displacement. (CPU SPECIFIC) }
34
{ These different alignments are described in the PowerPC ABI
35
supplement, they should represent most possible cases.
66
tlevel1rec_big = record
67
fill : array[1..MAX_DISP] of byte;
71
tlevel2rec_big = record
72
fill : array[1..MAX_DISP] of byte;
79
tlevel3rec_big = record
80
fill : array[1..MAX_DISP] of byte;
85
tlevel4rec_big = record
86
fill : array[1..MAX_DISP] of byte;
92
tlevel5rec_big = record
93
fill : array[1..MAX_DISP] of byte;
99
{ packed record, for testing misaligned access }
100
tlevel1rec_packed = packed record
104
tlevel2rec_packed = packed record
111
tlevel3rec_packed = packed record
116
tlevel4rec_packed = packed record
122
tlevel5rec_packed = packed record
129
fill : array[1..MAX_DISP] of byte;
142
{ test with global variables }
145
RESULT_U16BIT = $500F;
146
RESULT_S32BIT = $500F0000;
147
RESULT_S64BIT = $500F0000;
153
level1rec : tlevel1rec =
158
level2rec : tlevel2rec =
166
level3rec : tlevel3rec =
173
level4rec : tlevel4rec =
180
level5rec : tlevel5rec =
187
level1rec_packed : tlevel1rec_packed =
192
level2rec_packed : tlevel2rec_packed =
200
level3rec_packed : tlevel3rec_packed =
206
level4rec_packed : tlevel4rec_packed =
213
level5rec_packed : tlevel5rec_packed =
235
procedure clear_globals;
248
function getclass : tclass1;
253
function getclass2: tclass2;
259
procedure testlocal_big_1;
261
local1rec_big : tlevel1rec_big;
264
local1rec_big.c := RESULT_U8BIT;
266
if c <> RESULT_U8BIT then
271
procedure testlocal_big_2;
273
local2rec_big : tlevel2rec_big;
276
{ setup values - assign }
277
local2rec_big.c := RESULT_U8BIT;
278
local2rec_big.d := RESULT_U8BIT;
279
local2rec_big.s := RESULT_U16BIT;
280
local2rec_big.n := RESULT_S32BIT;
281
{ load values - load }
283
if c <> RESULT_U8BIT then
286
if d <> RESULT_U8BIT then
289
if s <> RESULT_U16BIT then
292
if n <> RESULT_S32BIT then
297
procedure testlocal_big_3;
299
local3rec_big : tlevel3rec_big;
302
{ setup values - assign }
303
local3rec_big.c := RESULT_U8BIT;
304
local3rec_big.s := RESULT_U16BIT;
306
if c <> RESULT_U8BIT then
309
if s <> RESULT_U16BIT then
313
procedure testlocal_big_4;
315
local4rec_big : tlevel4rec_big;
318
{ setup values - assign }
319
local4rec_big.c := RESULT_U8BIT;
320
local4rec_big.i := RESULT_S64BIT;
321
local4rec_big.s := RESULT_U16BIT;
324
if c <> RESULT_U8BIT then
327
if i <> RESULT_S64BIT then
330
if s <> RESULT_U16BIT then
335
procedure testlocal_big_5;
337
local5rec_big : tlevel5rec_big;
340
{ setup values - assign }
341
local5rec_big.c := RESULT_U8BIT;
342
local5rec_big.s := RESULT_U16BIT;
343
local5rec_big.j := RESULT_S32BIT;
345
if c <> RESULT_U8BIT then
348
if s <> RESULT_U16BIT then
351
if j <> RESULT_S32BIT then
356
procedure testlocals;
358
local1rec : tlevel1rec_packed;
359
local2rec : tlevel2rec_packed;
360
local3rec : tlevel3rec_packed;
361
local4rec : tlevel4rec_packed;
362
local5rec : tlevel5rec_packed;
364
{$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
365
{ normal record access }
366
Write('Non-Aligned simple local record access (secondvecn())...');
372
local1rec.c := RESULT_U8BIT;
374
if c <> RESULT_U8BIT then
378
{ setup values - assign }
379
local2rec.c := RESULT_U8BIT;
380
local2rec.d := RESULT_U8BIT;
381
local2rec.s := RESULT_U16BIT;
382
local2rec.n := RESULT_S32BIT;
383
{ load values - load }
385
if c <> RESULT_U8BIT then
388
if d <> RESULT_U8BIT then
391
if s <> RESULT_U16BIT then
394
if n <> RESULT_S32BIT then
399
{ setup values - assign }
400
local3rec.c := RESULT_U8BIT;
401
local3rec.s := RESULT_U16BIT;
403
if c <> RESULT_U8BIT then
406
if s <> RESULT_U16BIT then
410
{ setup values - assign }
411
local4rec.c := RESULT_U8BIT;
412
local4rec.i := RESULT_S64BIT;
413
local4rec.s := RESULT_U16BIT;
416
if c <> RESULT_U8BIT then
419
if i <> RESULT_S64BIT then
422
if s <> RESULT_U16BIT then
426
{ setup values - assign }
427
local5rec.c := RESULT_U8BIT;
428
local5rec.s := RESULT_U16BIT;
429
local5rec.j := RESULT_S32BIT;
432
if c <> RESULT_U8BIT then
435
if s <> RESULT_U16BIT then
438
if j <> RESULT_S32BIT then
445
{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
447
{---------------------------}
450
level1rec_big : tlevel1rec_big;
451
level2rec_big : tlevel2rec_big;
452
level3rec_big : tlevel3rec_big;
453
level4rec_big : tlevel4rec_big;
454
level5rec_big : tlevel5rec_big;
456
{ normal record access }
457
Write('Aligned simple global record access (secondvecn())...');
462
if c <> RESULT_U8BIT then
467
if c <> RESULT_U8BIT then
470
if d <> RESULT_U8BIT then
473
if s <> RESULT_U16BIT then
476
if n <> RESULT_S32BIT then
482
if c <> RESULT_U8BIT then
485
if s <> RESULT_U16BIT then
491
if c <> RESULT_U8BIT then
494
if i <> RESULT_S64BIT then
497
if s <> RESULT_U16BIT then
502
if c <> RESULT_U8BIT then
505
if s <> RESULT_U16BIT then
508
if j <> RESULT_S32BIT then
516
{$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
517
Write('Non-Aligned simple global record access (secondvecn())...');
520
c:= level1rec_packed.c;
521
if c <> RESULT_U8BIT then
525
c:= level2rec_packed.c;
526
if c <> RESULT_U8BIT then
528
d:= level2rec_packed.d;
529
if d <> RESULT_U8BIT then
531
s:= level2rec_packed.s;
532
if s <> RESULT_U16BIT then
534
n:= level2rec_packed.n;
535
if n <> RESULT_S32BIT then
540
c:= level3rec_packed.c;
541
if c <> RESULT_U8BIT then
543
s:= level3rec_packed.s;
544
if s <> RESULT_U16BIT then
549
c:= level4rec_packed.c;
550
if c <> RESULT_U8BIT then
552
i:= level4rec_packed.i;
553
if i <> RESULT_S64BIT then
555
s:= level4rec_packed.s;
556
if s <> RESULT_U16BIT then
560
c:= level5rec_packed.c;
561
if c <> RESULT_U8BIT then
563
s:= level5rec_packed.s;
564
if s <> RESULT_U16BIT then
566
j:= level5rec_packed.j;
567
if j <> RESULT_S32BIT then
575
Write('Non-Aligned big global record access (secondvecn())...');
578
level1rec_big.c := RESULT_U8BIT;
580
if c <> RESULT_U8BIT then
584
{ setup values - assign }
585
level2rec_big.c := RESULT_U8BIT;
586
level2rec_big.d := RESULT_U8BIT;
587
level2rec_big.s := RESULT_U16BIT;
588
level2rec_big.n := RESULT_S32BIT;
589
{ load values - load }
591
if c <> RESULT_U8BIT then
594
if d <> RESULT_U8BIT then
597
if s <> RESULT_U16BIT then
600
if n <> RESULT_S32BIT then
605
{ setup values - assign }
606
level3rec_big.c := RESULT_U8BIT;
607
level3rec_big.s := RESULT_U16BIT;
609
if c <> RESULT_U8BIT then
612
if s <> RESULT_U16BIT then
616
{ setup values - assign }
617
level4rec_big.c := RESULT_U8BIT;
618
level4rec_big.i := RESULT_S64BIT;
619
level4rec_big.s := RESULT_U16BIT;
622
if c <> RESULT_U8BIT then
625
if i <> RESULT_S64BIT then
628
if s <> RESULT_U16BIT then
632
{ setup values - assign }
633
level5rec_big.c := RESULT_U8BIT;
634
level5rec_big.s := RESULT_U16BIT;
635
level5rec_big.j := RESULT_S32BIT;
638
if c <> RESULT_U8BIT then
641
if s <> RESULT_U16BIT then
644
if j <> RESULT_S32BIT then
652
{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
656
{$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
658
Write('Non-Aligned big local record access (secondvecn())...');
671
{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
673
Write('Aligned class big field access (secondvecn())...');
679
class1:=tclass1.create;
680
class1.c:= RESULT_U8BIT;
681
class1.j:= RESULT_S32BIT;
682
class1.s:= RESULT_U16BIT;
684
if c <> RESULT_U8BIT then
687
if j <> RESULT_S32BIT then
690
if s <> RESULT_U16BIT then
697
class1:=tclass1.create;
698
class1.c:= RESULT_U8BIT;
699
class1.j:= RESULT_S32BIT;
700
class1.s:= RESULT_U16BIT;
702
if c <> RESULT_U8BIT then
705
if j <> RESULT_S32BIT then
708
if s <> RESULT_U16BIT then
718
{----------------------------------------------------------------------------}
719
Write('Aligned class simple field access (secondvecn())...');
725
class2:=tclass2.create;
726
class2.c:= RESULT_U8BIT;
727
class2.i:= RESULT_S64BIT;
728
class2.s:= RESULT_U16BIT;
730
if c <> RESULT_U8BIT then
733
if i <> RESULT_S64BIT then
736
if s <> RESULT_U16BIT then
743
class2:=tclass2.create;
744
class2.c:= RESULT_U8BIT;
745
class2.i:= RESULT_S64BIT;
746
class2.s:= RESULT_U16BIT;
748
if c <> RESULT_U8BIT then
751
if i <> RESULT_S64BIT then
754
if s <> RESULT_U16BIT then