[28e18d]: Backend / If2mem / if2size.c Maximize Restore History

Download this file

if2size.c    1452 lines (1099 with data), 45.8 kB

   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
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
/**************************************************************************/
/* FILE ************** if2size.c ************************/
/**************************************************************************/
/* Author: Dave Cann */
/* Update: Patrick Miller -- Ansi support (Dec 2000) */
/* Copyright (C) University of California Regents */
/**************************************************************************/
/*
* $Log:
*
* Revision 12.7 1992/11/04 22:05:06 miller
* Initial revision
*
* Revision 12.7 1992/10/21 18:09:22 miller
* Initial RCS Version by Cann
*/
/**************************************************************************/
#include "world.h"
static PEDGE linit; /* FinalValue MONOTONIC EXPANSION INITAL VALUE */
static PEDGE lxpnd; /* FinalValue MONOTONIC EXPANSION CONSTANT */
int paddh = 0; /* COUNT OF AAddH PREFERENCES */
/**************************************************************************/
/* LOCAL ************** PreferAAddH ************************/
/**************************************************************************/
/* PURPOSE: RETURN TRUE IF IFAAddH IS PREFERRED OVER IFAAddHAT. */
/**************************************************************************/
static int PreferAAddH( n )
PNODE n;
{
register PEDGE e;
if ( IsConst( n->imp ) )
return( FALSE );
/* IMPORTANT TO CHECK n->imp FIRST SO NOT TO PREMATURELY ANSWER TRUE */
switch ( n->imp->src->type ) {
case IFABuild:
case IFAAddH:
case IFAAddL:
case IFACatenate:
case IFForall:
case IFLoopA:
case IFLoopB:
return( FALSE );
default:
break;
}
for ( e = n->exp; e != NULL; e = e->esucc )
switch ( e->dst->type ) {
case IFAAddH:
case IFAAddL:
if ( e->iport != 1 ) /* NOT FIRST IMPORT? */
return( TRUE );
return( FALSE );
case IFACatenate:
return( FALSE );
default:
break;
}
return( TRUE );
}
/**************************************************************************/
/* LOCAL ************** BindExportSizes ************************/
/**************************************************************************/
/* PURPOSE: ASSIGN SIZE INFORMATION (lsize, csize, AND esize) TO ALL */
/* EXPORTS OF NODE n. */
/**************************************************************************/
static void BindExportSizes( n, lsize, csize, esize )
PNODE n;
int lsize;
int csize;
PNODE esize;
{
register PEDGE e;
for ( e = n->exp; e != NULL; e = e->esucc ) {
e->lsize = lsize;
e->csize = csize;
e->esize = esize;
}
}
/**************************************************************************/
/* LOCAL ************** PropagateImportSizes ************************/
/**************************************************************************/
/* PURPOSE: PROPAGATE THE SIZE INFORMATION OF NODE n1's IMPORTS to TO THE */
/* CORRESPONDING EXPORTS OF NODE n2. IF AN IMPORT IS EXPORTED */
/* FROM AN AGather NODE WITH A FILTER, THEN ITS SIZE INFORMATION */
/* IS NOT PROPAGATED. NOTE: ASize SIZE EXPRESSIONS ARE ONLY */
/* PROPAGATED TO LOOPS. */
/**************************************************************************/
static void PropagateImportSizes( n1, n2 )
PNODE n1, n2 ;
{
register PEDGE i;
register PEDGE e;
for ( i = n1->imp ; i != NULL ; i = i->isucc ) {
if ( !IsConst( i ) )
if ( IsAGather( i->src ) )
if ( i->src->imp->isucc->isucc != NULL ) /* FILTER? */
continue;
if ( IsSizeUnknown( i ) )
continue;
/* ONLY PROPAGATE ASize SIZE EXPRESSIONS TO LOOP SUBGRAPHS */
if ( !IsConstSize( i ) )
if ( IsASize( i->esize ) )
if ( IsSGraph( n2 ) )
if ( !(IsLoop( n2->G_DAD ) || IsForall( n2->G_DAD )) )
continue;
for ( e = n2->exp ; e != NULL ; e = e->esucc )
if ( i->iport == e ->eport ) {
e->lsize = i->lsize ;
e->csize = i->csize ;
e->esize = i->esize ;
}
}
}
/* NEW CANN 2/92 */
static int FirstIterationSkipped( l, n, mult )
PNODE l;
PNODE n;
PEDGE mult;
{
register PEDGE i;
register PEDGE ii;
if ( IsConst( mult->isucc ) )
return( FALSE );
if ( !IsSGraph( mult->isucc->src ) )
return( FALSE );
/* THE BODY FILTER MUST BE A "TRUE" CONSTANT */
if ( (i = FindImport( l->L_BODY, mult->isucc->eport )) == NULL )
return( FALSE );
if ( !IsConst( i ) || i->CoNsT == NULL )
return( FALSE );
switch ( i->CoNsT[0] ) {
case 't':
case 'T':
break;
default:
return( FALSE );
}
/* THE INITIAL FILTER MUST BE A "FALSE" CONSTANT */
if ( (ii = FindImport( l->L_INIT, mult->isucc->eport )) == NULL )
return( FALSE );
if ( !IsConst( ii ) || ii->CoNsT == NULL )
return( FALSE );
switch ( ii->CoNsT[0] ) {
case 'f':
case 'F':
break;
default:
return( FALSE );
}
/* OK, THE IMPLICIT FIRST ITERATION IS SKIPPED!!! */
n->umark = TRUE;
/* GET RID OF THE FILTER!!! */
UnlinkExport( mult->isucc );
UnlinkImport( mult->isucc );
/* FREE THE BODY CONSTANT? */
if ( UsageCount( l->L_RET, i->iport ) == 0 ) {
UnlinkImport( i );
if ( !(IsExport( l->L_TEST, ii->iport ) ||
IsExport( l->L_BODY, ii->iport )) )
UnlinkImport( ii );
}
return( TRUE );
}
/**************************************************************************/
/* LOCAL ************** IsGatherFinalOrReduceOk ************************/
/**************************************************************************/
/* PURPOSE: RETURN TRUE IF AGather, FinalValue, OR Reduce NODE n MEETS */
/* THE FOLLOWING CONDITIONS: */
/* */
/* 1. THE NUMBER OF LOOP ITERATIONS EXPRESSION IS KNOWN */
/* 2. NODE n EXPORTS AN ARRAY */
/* 3. NODE n IS NOT PART OF AN returns old STATEMENT */
/* 4. THE MULTIPLE INPUTS TO NODE n ARE NOT FILTERED OR NODE */
/* n IS AN AGather AND fover IS ENABLED. */
/* */
/* ELSE FALSE IS RETURNED. */
/**************************************************************************/
static int IsGatherFinalOrReduceOk( l, n, mult )
PNODE l;
PNODE n;
PEDGE mult;
{
if ( IsSizeUnknown( l ) )
return( FALSE );
if ( !IsArray( n->exp->info ) )
return( FALSE );
if ( !IsConst( mult ) )
if ( !IsSGraph( mult->src ) )
return( FALSE );
if ( mult->isucc != NULL ) {
/* NEW CANN 2/92 */
if ( IsAGather( n ) && IsLoopB( l ) )
if ( FirstIterationSkipped( l, n, mult ) )
return( TRUE );
/* END NEW CANN 2/92 */
if ( !( IsAGather( n ) && fover ) )
return( FALSE );
}
return( TRUE );
}
/**************************************************************************/
/* LOCAL ************** HighMinusLowPlusOne ************************/
/**************************************************************************/
/* PURPOSE: GENERATE THE IF1 SUBEXPRESSION max( hi - lo + 1, 0 ) GIVEN */
/* EDGE lo and EDGE hi. THE SUBEXPRESSION IS PLACED IN THE */
/* NODE LIST CONTAINING NODE rpoint SO NOT TO VIOLATE DATA FLOW */
/* ORDERINGS. THE max NODE IS RETURNED. */
/**************************************************************************/
static PNODE HighMinusLowPlusOne( rpoint, lo, hi )
PNODE rpoint;
PEDGE lo;
PEDGE hi;
{
register PNODE pr;
register PNODE n;
register PEDGE e;
lo = FindSource( lo );
hi = FindSource( hi );
pr = MaxSourceInDFO( rpoint, lo, hi );
/* HIGH MINUS LOW */
n = NodeAlloc( ++maxint, IFMinus );
n->level = pr->level;
n->lstack = pr->lstack;
CopyEdgeAndThreadToUse( hi, n, 1 );
CopyEdgeAndThreadToUse( lo, n, 2 );
LinkNode( pr, n );
pr = n;
/* (HIGH MINUS LOW) + 1 */
n = NodeAlloc( ++maxint, IFPlus );
n->level = pr->level;
n->lstack = pr->lstack;
e = EdgeAlloc( NULL_NODE, CONST_PORT, n, 2 );
e->info = integer;
e->CoNsT = "1";
LinkImport( n, e );
ThreadToUse( pr, 1, n, 1, integer );
LinkNode( pr, n );
pr = n;
/* MAX ( (HIGH MINUS LOW) + 1, 0 ) */
n = NodeAlloc( ++maxint, IFMax );
n->level = pr->level;
n->lstack = pr->lstack;
e = EdgeAlloc( NULL_NODE, CONST_PORT, n, 2 );
e->info = integer;
e->CoNsT = "0";
LinkImport( n, e );
ThreadToUse( pr, 1, n, 1, integer );
LinkNode( pr, n );
return( n );
}
#define LessEqual 0
#define Less 1
#define GreatEqual 2
#define Great 3
/**************************************************************************/
/* LOCAL ************** BuildLoopIterExpr ***********************/
/**************************************************************************/
/* PURPOSE: BUILD THE ITERATION EXPRESSION FOR LoopA OR LoopB NODE n. */
/* ONLY THE FOLLOWING LOOP FORMS, RESULT IN EXPRESSION */
/* CONSTRUCTION: */
/* */
/* -> for initial */
/* x := ive, WHERE ive is a CoNsTant OR K-PORT VALUE */
/* */
/* -> while ( x binop fve ) repeat ... */
/* repeat ... until ( x binop fve ) */
/* WHERE fve is a CoNsTant OR K-PORT VALUE AND binop IS */
/* EITHER <, <=, >, >= */
/* */
/* -> ... <- x := old x op ide, WHERE op IS EITHER + or - AND */
/* ide IS A POSITIVE CONSTANT */
/* */
/* FURTHER, THE LOOP MUST BE WELL BEHAVED: */
/* */
/* -> IF op IS + THEN binop MUST BE EITHER < OR <= FOR LoopB */
/* LOOPS and > OR >= FOR LoopA LOOPS */
/* */
/* -> IF op IS - THEN binop MUST BE EITHER >= OR > FOR LoopB */
/* LOOPS and < OR <= FOR LoopA LOOPS */
/* */
/* THE RESULTING EXPRESSION TAKES THE FOLLOWING FORM; NOTE THAT */
/* REGAURDLESS OF THE LOOP TYPE, TEST SUBGRAPHS APPEAR AS WHILE */
/* NOT DONE TESTS (ITS ONLY ITS FINAL POSITION WITHIN THE LOOP */
/* THAT VARIES): */
/* */
/* -> FOR THE < CASE: ((((fve - 1) - ive) + ide) / ide) */
/* -> FOR THE > CASE: ((((fve + 1) - ive) + ide) / ide) */
/* -> ELSE: ((((fve) - ive) + ide) / ide) */
/* */
/* THEN THE SIZE EXPRESSION IS IMPORTED TO A MAX NODE: */
/* */
/* -> FOR LoopA: max( expr, 1 ) */
/* -> FOR LoopB: max( expr, 0 ) */
/* */
/* NOTE: x > fve appears as NOT( x <= fve ) IN IF1 AND x >= fve */
/* APPEATS AS NOT( x < fve ) IN IF1. */
/**************************************************************************/
static void BuildLoopIterExpr( l )
PNODE l;
{
register PNODE n;
register PNODE adj;
register PNODE pr;
register PEDGE lvalue;
register PNODE upd;
register PEDGE fve;
register PEDGE ive;
register PEDGE c;
register int bop;
register int cnt;
register char *ide;
char buf[100];
/* CHECK LOOP TEST STRUCTURE, INITIALIZING fve and bop */
for ( n = l->L_TEST->G_NODES, cnt = 0; n != NULL; n = n->nsucc )
cnt++;
switch ( cnt ) {
case 1:
n = l->L_TEST->G_NODES;
switch ( n->type ) {
case IFLessEqual: bop = LessEqual; break;
case IFLess: bop = Less; break;
default:
return;
}
break;
case 2:
n = l->L_TEST->G_NODES;
if ( !IsNot( n->nsucc ) )
return;
switch ( n->type ) {
case IFLess: bop = GreatEqual; break;
case IFLessEqual: bop = Great; break;
default:
return;
}
break;
default:
return;
}
if ( IsConst( n->imp ) )
return;
if ( !IsSGraph( n->imp->src ) )
return;
lvalue = n->imp;
fve = lvalue->isucc;
if ( !IsConst( fve ) )
if ( (fve = FindImport( l, fve->eport )) == NULL )
return;
/* INITIALIZE ive, CHECKING ITS STRUCTURE */
if ( (ive = FindImport( l->L_INIT, lvalue->eport )) == NULL )
return;
if ( !IsConst( ive ) ) {
if ( !IsSGraph( ive->src ) )
return;
ive = FindImport( l, ive->eport );
}
/* INITIALIZE upd (THE ive UPDATE), CHECKING ITS STRUCTURE */
if ( (lvalue = FindImport( l->L_BODY, lvalue->eport )) == NULL )
return;
if ( IsConst( lvalue ) )
return;
upd = lvalue->src;
switch ( upd->type ) {
case IFPlus:
case IFMinus:
break;
default:
return;
}
if ( IsConst( upd->imp ) )
return;
if ( !IsSGraph( upd->imp->src ) )
return;
if ( upd->imp->eport != lvalue->iport )
return;
if ( !IsConst( upd->imp->isucc ) )
return;
/* CANN: May 5th */
if ( upd->imp->isucc->CoNsT == NULL )
return;
/* INITIALIZE ide, CHECKING IF THE LOOP IS WELL BEHAVED */
/* BE CAREFUL NOT TO DIVIDE BY ZERO IN BuildLoopIterExpr */
if ( atoi( upd->imp->isucc->CoNsT ) == 0 )
return;
if ( upd->imp->isucc->CoNsT[0] == '-' )
return;
if ( IsPlus( upd ) ) {
if ( (bop != Less) && (bop != LessEqual) )
return;
ide = upd->imp->isucc->CoNsT;
} else {
if ( (bop != Great) && (bop != GreatEqual) )
return;
SPRINTF( buf, "-%s", upd->imp->isucc->CoNsT );
ide = CopyString( buf );
}
/* CONSTRUCT THE NUMBER OF ITERATIONS EXPRESSION */
fve = FindSource( fve );
ive = FindSource( ive );
pr = MaxSourceInDFO( l, ive, fve );
/* ((fve MINUS 1) MINUS ive), ((fve PLUS 1) MINUS ive), OR */
/* (fve MINUS ive) */
n = NodeAlloc( ++maxint, IFMinus );
n->level = pr->level;
n->lstack = pr->lstack;
CopyEdgeAndThreadToUse( ive, n, 2 );
switch ( bop ) {
case Great:
case Less:
if ( bop == Great )
adj = NodeAlloc( ++maxint, IFPlus );
else
adj = NodeAlloc( ++maxint, IFMinus );
adj->level = pr->level;
adj->lstack = pr->lstack;
c = EdgeAlloc( NULL_NODE, CONST_PORT, adj, 2 );
c->info = integer;
c->CoNsT = "1";
LinkImport( adj, c );
CopyEdgeAndThreadToUse( fve, adj, 1 );
ThreadToUse( adj, 1, n, 1, integer );
LinkNode( pr, adj );
pr = adj;
break;
default:
CopyEdgeAndThreadToUse( fve, n, 1 );
break;
}
LinkNode( pr, n );
pr = n;
/* (PREVIOUS) PLUS ide */
n = NodeAlloc( ++maxint, IFPlus );
n->level = pr->level;
n->lstack = pr->lstack;
ThreadToUse( pr, 1, n, 1, integer );
c = EdgeAlloc( NULL_NODE, CONST_PORT, n, 2 );
c->info = integer;
c->CoNsT = ide;
LinkImport( n, c );
LinkNode( pr, n );
pr = n;
/* (PREVIOUS) DIV ide */
n = NodeAlloc( ++maxint, IFDiv );
n->level = pr->level;
n->lstack = pr->lstack;
ThreadToUse( pr, 1, n, 1, integer );
c = EdgeAlloc( NULL_NODE, CONST_PORT, n, 2 );
c->info = integer;
c->CoNsT = ide;
LinkImport( n, c );
LinkNode( pr, n );
pr = n;
/* MAX( (PREVIOUS), 1 ) OR MAX( (PREVIOUS), 0 ) */
n = NodeAlloc( ++maxint, IFMax );
n->level = pr->level;
n->lstack = pr->lstack;
ThreadToUse( pr, 1, n, 1, integer );
c = EdgeAlloc( NULL_NODE, CONST_PORT, n, 2 );
c->info = integer;
if ( IsLoopA ( l ) )
c->CoNsT = "1";
else
c->CoNsT = "0";
LinkImport( n, c );
LinkNode( pr, n );
l->lsize = n->level;
l->esize = n;
}
/**************************************************************************/
/* LOCAL ************** BuildForallIterExpr ***********************/
/**************************************************************************/
/* PURPOSE: BUILD THE ITERATION EXPRESSION FOR FORALL NODE n. IF n IS */
/* CONTROLLED BY A STREAM SCATTER NODE THEN THE EXPRESSION ISN'T */
/* BUILT. FURTHER AN EXPRESSION IS NOT BUILT IF AN ARRAY SCATTER */
/* IMPORT SIZE IS NOT KNOWN. NOTE THE RESULTING EXPRESSION */
/* MIGHT BE A CONSTANT: for i in array [1: 1 2 3]. */
/**************************************************************************/
static void BuildForallIterExpr( n )
PNODE n;
{
register PNODE c ;
register PEDGE lo, hi ;
/* FIND THE FORALL GENERATE NODE CONTROLLING THE LOOP */
c = n->F_GEN->imp->src;
if ( IsAScatter( c ) ) {
if ((!IsArray(c->imp->info)) || (IsSizeUnknown(c->imp)))
return;
n->lsize = c->imp->lsize;
n->csize = c->imp->csize;
n->esize = c->imp->esize;
return;
}
/* c MUST BE A IFRangeGenerate NODE */
/* EACH IMPORT TO c MUST BE A CONSTANT OR A K-PORT VALUE */
lo = c->imp;
hi = lo->isucc;
if ( !IsConst( lo ) ) {
if( !IsSGraph( lo->src ) )
return;
else
lo = FindImport( n, lo->eport );
}
if ( !IsConst( hi ) ) {
if( !IsSGraph( hi->src ) )
return;
else
hi = FindImport( n, hi->eport );
}
n->esize = HighMinusLowPlusOne( n, lo, hi ) ;
n->lsize = n->esize->level ;
}
/**************************************************************************/
/* LOCAL ************** IsMonotonicConstruction ***********************/
/**************************************************************************/
/* PURPOSE: CHECK AND RETURN TRUE OR FALSE BASED ON WHETHER FinalValue */
/* NODE (n) IS A CANDIDATE FOR PREALLOCATION OR NOT. IF TRUE, */
/* GLOBAL VARIABLES lxpnd, AND linit ARE INITIALIZED. Loop IS */
/* THE LOOP NODE OWNING n (A LoopA OR LoopB NODE). THE FOLLOWING */
/* CONDITIONS MUST HOLD FOR n TO BE A CANDIDATE: */
/* */
/* 1. n IS NOT PART OF A returns value of "string" STATEMENT */
/* 2. THE INITIAL ARRAY SEGMENT IS GENERATED BY AN ABuild NODE */
/* 3. THE MONOTONIC CONSTRUCTION MATCHES ONE OF THE FOLLOWING: */
/* */
/* a. x := array_addh( old x, ... ); */
/* b. x := array_addl( old x, ... ); */
/* c. x := old x || (yyy); */
/* d. x := (yyy) || old x; */
/* */
/* WHERE yyy HAS A LOOP INVARIANT SIZE EXPRESSION. */
/* */
/* THIS ROUTINE ASSUMES THAT n PASSED ANALYSIS DONE IN FUNCTION */
/* IsGatherFinalOrReduceOk. NOTE: THE BODY NODE CAN ONLY */
/* REDEFINE ONE L VALUE (x) AND x'S ONLY REFERENCE IN THE RETURN */
/* SUBGRAPH MUST BE BY FinalValue NODE n. */
/**************************************************************************/
static int IsMonotonicConstruction( l, n )
PNODE l;
PNODE n;
{
register PEDGE lb;
register PEDGE i1;
register PEDGE i2;
register PEDGE lsrc;
register int cnt;
if ( IsConst( n->imp ) )
return( FALSE );
/* NODE n'S IMPORT CANNOT BE REFERENCED BY ANY OTHER MULTIPLE NODES */
if ( UsageCount( n->imp->src, n->imp->eport ) != 1 )
return( FALSE );
if ( (linit = FindImport( l->L_INIT, n->imp->eport )) == NULL )
return( FALSE );
if ( IsSizeUnknown( linit ) ) /* A PROPAGATED SIZE */
return( FALSE );
/* HENCE, linit CAN'T BE A STRING AND MUST BE A K-PORT VALUE, ALSO */
/* NOT A STRING, THAT IS A ABuild EXPORT. */
linit = FindImport( l, linit->eport );
lsrc = FindSource( linit );
if ( !IsABuild( lsrc->src ) )
return( FALSE );
if ( (lb = FindImport( l->L_BODY, n->imp->eport )) == NULL )
return( FALSE );
if ( IsConst( lb ) )
return( FALSE );
/* THE BODY NODE CAN ONLY REDEFINE ONE L VALUE. */
for ( cnt = 0, i1 = l->L_BODY->imp; i1 != NULL; i1 = i1->isucc ) {
if ( IsConst( i1 ) )
continue;
if ( i1->src == lb->src )
cnt++;
}
if ( cnt != 1 )
return( FALSE );
switch ( lb->src->type ) {
case IFAAddH:
case IFAAddL:
i1 = lb->src->imp;
if ( IsConst( i1 ) )
return( FALSE );
if ( !IsSGraph( i1->src ) )
return( FALSE );
if ( i1->eport != lb->iport )
return( FALSE );
lxpnd = NULL;
break;
case IFACatenate:
i1 = lb->src->imp;
i2 = i1->isucc;
/* WE DON't HANDLE CATENATE NODES WITH >= 3 IMPORTS */
if ( i2->isucc != NULL )
return( FALSE );
if ( IsSizeUnknown( i1 ) || IsSizeUnknown( i2 ) )
return( FALSE );
/* ONE OF THE IMPORTS MUST BE A REFERENCE TO old x */
if ( IsSGraph( i1->src ) ) {
if ( i1->eport == lb->iport )
lxpnd = i2;
else if ( IsSGraph( i2->src ) && (i2->eport == lb->iport) )
lxpnd = i1;
else
return( FALSE );
}
else if ( IsSGraph( i2->src ) && ( i2->eport == lb->iport ) )
lxpnd = i1;
else
return( FALSE );
/* IS THE EXPANSION ARRAY SIZE INVARIANT? */
if ( !IsConstSize( lxpnd ) )
if ( lxpnd->esize->level >= n->level )
return( FALSE );
break;
default:
return( FALSE );
}
return(TRUE);
}
/**************************************************************************/
/* LOCAL ************** BuildAddLHSize ************************/
/**************************************************************************/
/* PURPOSE: CALCULATE THE SIZE EXPRESSION FOR AAdd[H/L] NODE n AND ASSIGN */
/* THE EXPRESSION TO ALL EXPORTS OF n. THE SIZE EXPRESSION IS */
/* ONE LARGER THAN THE SIZE OF THE FIRST IMPORT. THIS ROUTINE */
/* ASSUMES THAT THE FIRST IMPORT SIZE IS KNOWN AND n EXPORTS AN */
/* ARRAY. */
/**************************************************************************/
static void BuildAddLHSize( n )
PNODE n;
{
register PNODE plus;
register PEDGE one;
register PNODE pr;
if ( IsConstSize( n->imp ) ) {
BindExportSizes( n, n->imp->lsize, n->imp->csize + 1, NULL_NODE );
return;
}
pr = n->imp->esize;
if ( pr->level < n->level )
pr = ReferencePoint( n, pr->level );
plus = NodeAlloc( ++maxint, IFPlus );
plus->level = pr->level;
plus->lstack = pr->lstack;
one = EdgeAlloc( NULL_NODE, CONST_PORT, plus, 2 );
one->CoNsT = "1";
one->info = integer;
LinkImport( plus, one );
ThreadToUse( n->imp->esize, 1, plus, 1, integer );
LinkNode( pr, plus );
BindExportSizes( n, plus->level, UNKNOWN_CSIZE, plus );
}
/**************************************************************************/
/* LOCAL ************** BuildACatSize ************************/
/**************************************************************************/
/* PURPOSE: CALCULATE THE SIZE EXPRESSION FOR ACatenate NODE n AND ASSIGN */
/* THE EXPRESSION TO ALL EXPORTS OF n. THIS ROUTINE ASSUMES n */
/* HAS ONLY 2 IMPORTS, EXPORTS AN ARRAY, AND BOTH IMPORT SIZES */
/* ARE KNOWN. */
/**************************************************************************/
static void BuildACatSize( n )
PNODE n ;
{
register PEDGE i1;
register PEDGE i2;
register PNODE plus;
register PEDGE CoNsT;
register PNODE pr;
register char *cptr;
register PNODE non_CoNsT;
i1 = n->imp ;
i2 = n->imp->isucc ;
if ( IsConstSize( i1 ) && IsConstSize( i2 ) ) {
BindExportSizes( n, Max( i1->lsize, i2->lsize ),
i1->csize + i2->csize, NULL_NODE );
return;
}
if ( (!IsConstSize( i1 )) && (!IsConstSize( i2 )) ) {
plus = NodeAlloc( ++maxint, IFPlus ) ;
pr = MaxNodeInDFO( n, i1->esize, i2->esize ) ;
plus->level = pr->level ;
plus->lstack = pr->lstack ;
ThreadToUse( i1->esize, 1, plus, 1, integer ) ;
ThreadToUse( i2->esize, 1, plus, 2, integer ) ;
LinkNode( pr, plus ) ;
BindExportSizes( n, plus->level, UNKNOWN_CSIZE, plus ) ;
return;
}
/* EXACTLY ONE ARRAY IMPORT MUST HAVE CONSTANT SIZE */
if (IsConstSize(i1)) {
cptr = IntToAscii( i1->csize );
non_CoNsT = i2->esize;
} else {
cptr = IntToAscii( i2->csize );
non_CoNsT = i1->esize;
}
pr = non_CoNsT;
if ( pr->level < n->level )
pr = ReferencePoint( n, pr->level );
plus = NodeAlloc( ++maxint, IFPlus );
plus->level = pr->level;
plus->lstack = pr->lstack;
CoNsT = EdgeAlloc( NULL_NODE, CONST_PORT, plus, 2 );
CoNsT->info = integer;
CoNsT->CoNsT = cptr;
LinkImport( plus, CoNsT );
ThreadToUse( non_CoNsT, 1, plus, 1, integer );
LinkNode( pr, plus );
BindExportSizes( n, plus->level, UNKNOWN_CSIZE, plus ) ;
return;
}
/**************************************************************************/
/* LOCAL ************** BuildABuildSize ************************/
/**************************************************************************/
/* PURPOSE: CALCULATE THE SIZE EXPRESSION FOR ABuild NODE n AND ASSIGN */
/* THE EXPRESSION TO ALL EXPORTS OF n. THIS ROUTINE ASSUMES THAT */
/* THE EXPORT IS AN ARRAY. */
/**************************************************************************/
static void BuildABuildSize( n )
PNODE n;
{
register PEDGE i;
register int numb;
/* COUNT NUMBER OF INPUTS TO n IGNORING THE THE LOWER BOUND. */
for ( numb = -1, i = n->imp; i != NULL; i = i->isucc )
numb++;
BindExportSizes( n, n->level, numb, NULL_NODE );
}
/**************************************************************************/
/* LOCAL ************** BuildAGatherSize ************************/
/**************************************************************************/
/* PURPOSE: CALCULATE THE SIZE EXPRESSION FOR AGather NODE n AND ASSIGN */
/* THE EXPRESSION TO ALL EXPORTS OF n. THIS ROUTINE ASSUMES THAT */
/* n PASSED ANALYSIS DONE IN FUNCTION IsGatherFinalOrReduceOk. */
/* THE SIZE OF THE GATERED ARRAY IS EQUAL TO THE NUMBER OF LOOP */
/* ITERATIONS. NOTE l CAN BE A LoopA, LoopB, OR FORALL NODE. */
/**************************************************************************/
static void BuildAGatherSize( l, n )
PNODE l ;
PNODE n ;
{
register PNODE plus;
register PEDGE one;
register PNODE pr;
if ( IsForall( l ) ) {
BindExportSizes( n, l->lsize, l->csize, l->esize );
return;
}
/* NODE l IS A LoopA OR LoopB NODE, WHOSE ITERATION EXPRESSION IS NOT */
/* A CONSTANT. */
pr = l->esize;
if ( pr->level < l->level )
pr = ReferencePoint( l, pr->level );
plus = NodeAlloc( ++maxint, IFPlus );
plus->level = pr->level;
plus->lstack = pr->lstack;
one = EdgeAlloc( NULL_NODE, CONST_PORT, plus, 2 ) ;
/* NEW CANN 2/92 */
if ( n->umark )
one->CoNsT = "0" ; /* NO IMPLICIT FIRST ITERATION */
else
one->CoNsT = "1" ;
/* END NEW CANN 2/92 */
one->info = integer ;
LinkImport( plus, one ) ;
ThreadToUse( l->esize, 1, plus, 1, integer ) ;
LinkNode( pr, plus ) ;
BindExportSizes( n, plus->level, UNKNOWN_CSIZE, plus ) ;
}
/**************************************************************************/
/* LOCAL ************** BuildAFinalValueSize ************************/
/**************************************************************************/
/* PURPOSE: CALCULATE THE SIZE EXPRESSION FOR FinalValue NODE n AND */
/* THE EXPRESSION TO ALL EXPORTS OF n. THIS ROUTINE ASSUMES */
/* THAT n PASSED ANALYSIS DONE IN IsGatherFinalOrReduceOk AND */
/* IsMonotonicConstruction, AND l, THE LOOP OWNING n, IS NOT A */
/* FORALL NODE. Linit and lxpnd WERE INITIALIZED IN FUNCTION */
/* IsMonotonicConstruction. NOTE, IT IS ASSUMED THAT linit IS */
/* A CONSTANT SIZE (EXPORT OF AN ABuild NODE). THE CALCULATED */
/* EXPRESSION IS: */
/* */
/* ((# iterations) * expansion size) + initial size, */
/* */
/* WHERE lxpnd DEFINES THE EXPANSION SIZE AND linit->csize */
/* DEFINES THE CONSTANT INITIAL SIZE. IF lxpnd IS NULL, THE */
/* EXPANSION SIZE IS 1. IT IS ASSUMED THAT THE NUMBER OF */
/* ITERATIONS IS DEFINED BY AN IF1 SUBGRAPH, WHOSE ROOT NODE IS */
/* IN THE NODE LIST CONTAINING LOOP l. */
/**************************************************************************/
static void BuildFinalValueSize( l, n )
PNODE l, n ;
{
register PNODE pr;
register PNODE times, plus ;
register PEDGE ce ;
if ( lxpnd == NULL ) {
pr = l->esize;
if ( pr->level < l->level )
pr = ReferencePoint( l, pr->level );
}
else if ( IsConstSize( lxpnd ) ) {
pr = l->esize;
if ( pr->level < l->level )
pr = ReferencePoint( l, pr->level );
}
else
pr = MaxNodeInDFO( l, lxpnd->esize, l->esize );
times = NodeAlloc( ++maxint, IFTimes ) ;
times->level = pr->level ;
times->lstack = pr->lstack ;
ThreadToUse( l->esize, 1, times, 1, integer ) ;
if ( lxpnd == NULL ) {
ce = EdgeAlloc( NULL_NODE, CONST_PORT, times, 2 ) ;
ce->info = integer ;
ce->CoNsT = "1";
LinkImport( times, ce );
}
else if ( IsConstSize( lxpnd ) ) {
ce = EdgeAlloc( NULL_NODE, CONST_PORT, times, 2 ) ;
ce->info = integer ;
ce->CoNsT = IntToAscii( lxpnd->csize );
LinkImport( times, ce );
}
else
ThreadToUse( lxpnd->esize, 1, times, 2, integer );
LinkNode( pr, times );
plus = NodeAlloc( ++maxint, IFPlus ) ;
plus->level = times->level ;
plus->lstack = times->lstack ;
ce = EdgeAlloc( NULL_NODE, CONST_PORT, plus, 2 ) ;
ce->info = integer ;
ce->CoNsT = IntToAscii( linit->csize ) ;
LinkImport( plus, ce ) ;
ThreadToUse( times, 1, plus, 1, integer ) ;
LinkNode( times, plus );
BindExportSizes( n, plus->level, UNKNOWN_CSIZE, plus );
}
/**************************************************************************/
/* LOCAL ************** ExprTimesConst ************************/
/**************************************************************************/
/* PURPOSE: GENERATE THE IF1 SUBEXPRESSION expr * CoNsT, WHERE expr IS AN */
/* IF1 SUBEXPRESSION and CoNsT IS AN INTEGER CONSTANT. THE times */
/* NODE IS RETURNED. */
/**************************************************************************/
static PNODE ExprTimesConst( rpoint, expr, CoNsT )
PNODE rpoint;
PNODE expr;
int CoNsT;
{
register PNODE times;
register PEDGE ce;
register PNODE pr;
pr = expr;
if ( pr->level < rpoint->level )
pr = ReferencePoint( rpoint, pr->level );
times = NodeAlloc( ++maxint, IFTimes );
times->level = pr->level;
times->lstack = pr->lstack;
ThreadToUse( expr, 1, times, 1, integer );
ce = EdgeAlloc( NULL_NODE, CONST_PORT, times, 2 );
ce->info = integer;
ce->CoNsT = IntToAscii( CoNsT );
LinkImport( times, ce );
LinkNode( pr, times );
return(times);
}
/**************************************************************************/
/* LOCAL ************** BuildRedCatSize ************************/
/**************************************************************************/
/* PURPOSE: CALCULATE THE SIZE EXPRESSION FOR Reduce-Catenate NODE n AND */
/* ASSIGN THE EXPRESSION TO THE EXPORTS OF n. LOOP l OWNS n AND */
/* mult IS THE MULTIPLE VALUE INPUT TO n. THIS ROUTINE ASSUMES */
/* THAT n PASSED ANALYSIS DONE IN IsGatherFinalOrReduceOk, mult, */
/* WHOSE SIZE IS KNOWN OUTSIDE l, IS NOT A STRING, AND l IS A */
/* FORALL NODE. */
/**************************************************************************/
static void BuildRedCatSize( l, mult, n )
PNODE l;
PEDGE mult;
PNODE n;
{
register PNODE times;
register PNODE pr;
if ( IsConstSize( mult ) ) {
if ( IsConstSize( l ) ) {
BindExportSizes( n, Max( l->lsize, mult->lsize ),
l->csize * mult->csize, NULL_NODE );
return;
}
times = ExprTimesConst( l, l->esize, mult->csize );
} else {
if ( IsConstSize( l ) )
times = ExprTimesConst( l, mult->esize, l->csize );
else {
pr = MaxNodeInDFO( l, mult->esize, l->esize ) ;
times = NodeAlloc( ++maxint, IFTimes ) ;
times->level = pr->level ;
times->lstack = pr->lstack ;
ThreadToUse( l->esize, 1, times, 1, integer ) ;
ThreadToUse( mult->esize, 1, times, 2, integer ) ;
LinkNode( pr, times ) ;
}
}
BindExportSizes( n, times->level, UNKNOWN_CSIZE, times ) ;
}
/**************************************************************************/
/* LOCAL ************** AssignExportSizes ************************/
/**************************************************************************/
/* PURPOSE: ASSIGN A SIZE EXPRESSION FOR EACH ARRAY EXPORT OF NODE n */
/* WHOSE SIZE IS UNKNOWN (LINKING IN AN ASize NODE). NODE n WILL */
/* EITHER BE A COMPOUND NODE, SUBGRAPH, FUNCTION GRAPH, OR CALL */
/* NODE. */
/**************************************************************************/
static void AssignExportSizes( n )
PNODE n ;
{
register PEDGE e;
register PEDGE ee;
register PNODE asize;
for ( e = n->exp ; e != NULL ; e = e->esucc )
if ( IsSizeUnknown(e) && IsArray(e->info) ) {
asize = NodeAlloc( ++maxint, IFASize );
asize->level = n->level;
asize->lstack = n->lstack;
CopyEdgeAndThreadToUse( e, asize, 1 );
LinkNode( n, asize );
/* NOTE THE COPIED EDGE IS NOT ASSIGNED THE SIZE INFORMATION */
for ( ee = e; ee != NULL; ee = ee->esucc )
if ( ee->eport == e->eport) {
/* NOTE csize NEEDN'T BE ASSIGNED */
ee->esize = asize;
ee->lsize = asize->level;
}
}
}
/**************************************************************************/
/* GLOBAL ************** AssignSizes ************************/
/**************************************************************************/
/* PURPOSE: ASSIGN SIZE EXPRESSIONS TO ALL THE POTENTIAL At-Nodes IN THE */
/* NODE LIST OF GRAPH g AND PUSH THEM ON THE At-Node STACK. IF */
/* ONLY MINIMAL OPTIMIZATIONS ARE DESIRED, A BUFFER IS LINKED TO */
/* ONLY ONE NODE, ALL ABuild, AFill, ACatenate, AddH, AND AddL */
/* NODES ARE CONVERTED TO AT-NODES, AND ONLY Forall MULTIPLE */
/* NODES ARE CONSIDERED CANDIDATES FOR CONVERSION. */
/**************************************************************************/
void AssignSizes( g )
PNODE g;
{
register PNODE nd;
register PNODE sg;
register PEDGE mult;
PNODE expr;
PNODE l;
AssignExportSizes( g );
for ( nd = g->G_NODES; nd != NULL; nd = nd->nsucc )
switch ( nd->type) {
case IFAAddH:
if ( !IsArray( nd->imp->info ) )
break;
if ( IsConst( nd->imp ) )
break;
/* FOR ERROR VALUES */
if ( IsSizeUnknown( nd->imp ) )
nd->imp->csize = 1;
BuildAddLHSize( nd );
/* SHOULD WE DELAY EVERYTHING UNTIL RUN TIME? */
if ( (!minopt) && PreferAAddH( nd ) ) {
paddh++;
break;
}
PushAtNode( nd );
break;
case IFAAddL:
if ( !IsArray( nd->imp->info ) )
break;
/* FOR ERROR VALUES! */
if ( IsSizeUnknown( nd->imp ) )
nd->imp->csize = 1;
BuildAddLHSize( nd );
PushAtNode( nd );
break;
case IFACatenate:
if ( !IsArray( nd->exp->info ) ) /* EXPORTS AN ARRAY? */
break;
if ( nd->imp->isucc->isucc != NULL )
Error1( "AssignSizes: ACatenate WITH > 2 IMPORTS" );
/* FOR ERROR VALUES! */
if ( IsSizeUnknown ( nd->imp ) )
nd->imp->csize = 1;
if ( IsSizeUnknown( nd->imp->isucc ) )
nd->imp->isucc->csize = 1;
BuildACatSize ( nd ) ;
PushAtNode( nd );
break;
case IFABuild:
if ( !IsArray( nd->exp->info ) ) /* EXPORTS AN ARRAY? */
break;
BuildABuildSize( nd );
if ( minopt )
break;
PushAtNode( nd );
break;
case IFAFill:
if ( !IsArray( nd->exp->info ) ) /* EXPORTS AN ARRAY? */
break ;
expr = HighMinusLowPlusOne( nd, nd->imp, nd->imp->isucc);
BindExportSizes ( nd, expr->level, UNKNOWN_CSIZE, expr );
PushAtNode ( nd ) ;
break;
case IFAGather:
l = nd->exp->dst->G_DAD; /* LOOP OWNING NODE nd */
if ( minopt ) /* PERFORM MINIMAL OPTIMIZATION */
break;
if ( !IsGatherFinalOrReduceOk( l, nd, nd->imp->isucc ) )
break;
BuildAGatherSize( l, nd );
PushAtNode( nd );
break;
case IFFinalValue:
if ( minopt ) /* ONLY PERFORM MINIMAL OPTIMIZATION */
break;
l = nd->exp->dst->G_DAD; /* LOOP OWNING NODE nd */
if ( IsForall( l ) ) /* ONLY FOR LoopA OR LoopB NODES */
break;
if ( !IsGatherFinalOrReduceOk( l, nd, nd->imp ) )
break;
if ( !IsMonotonicConstruction( l, nd ) )
break;
BuildFinalValueSize( l, nd ) ;
PushAtNode( nd ) ;
break;
case IFReduce:
case IFRedLeft:
case IFRedRight:
case IFRedTree:
if ( minopt ) /* ONLY PERFORM MINIMAL OPTIMIZATION */
break;
if ( nd->imp->CoNsT[0] != REDUCE_CATENATE ) /* CATENATE? */
break;
l = nd->exp->dst->G_DAD; /* LOOP OWNING NODE nd */
mult = nd->imp->isucc->isucc;
if ( !IsForall(l) ) /* ONLY FOR FORALLS */
break;
if ( !IsGatherFinalOrReduceOk( l, nd, mult ) )
break;
if ( IsConst( mult ) ) /* NOT IF CATENATING STRINGS */
break;
/* IF mult IS NOT A K-PORT VALUE IT MUST BE A T-PORT VALUE */
/* WHOSE SIZE IS EITHER CONSTANT OR KNOWN OUTSIDE THE LOOP */
if ( !IsImport( l, mult->eport ) )
mult = FindImport( l->F_BODY, mult->eport );
if ( mult == NULL )
break;
if ( IsSizeUnknown( mult ) )
break;
if ( !IsConstSize( mult ) )
if ( mult->esize->level >= nd->level )
break;
BuildRedCatSize( l, mult, nd );
PushAtNode( nd ) ;
break ;
case IFForall:
PropagateImportSizes( nd, nd->F_GEN ) ;
PropagateImportSizes( nd, nd->F_BODY ) ;
PropagateImportSizes( nd, nd->F_RET ) ;
AssignSizes( nd->F_BODY ) ;
BuildForallIterExpr( nd ) ;
AssignSizes( nd->F_RET ) ;
PropagateImportSizes( nd->F_RET, nd ) ;
/* ASSIGN SIZES TO THE EDGES NOT HANDLED BY PREVIOUS STEP */
AssignExportSizes( nd ) ;
break;
case IFLoopA:
case IFLoopB:
PropagateImportSizes( nd, nd->L_INIT );
PropagateImportSizes( nd, nd->L_BODY );
AssignSizes( nd->L_BODY );
BuildLoopIterExpr( nd );
AssignSizes( nd->L_RET );
PropagateImportSizes( nd->L_RET, nd );
/* ASSIGN SIZES TO THE EDGES NOT HANDLED BY PREVIOUS STEP */
AssignExportSizes( nd );
break;
case IFSelect:
PropagateImportSizes( nd, nd->S_CONS );
PropagateImportSizes( nd, nd->S_ALT );
AssignSizes( nd->S_CONS );
AssignSizes( nd->S_ALT );
AssignExportSizes( nd );
break;
case IFTagCase:
for ( sg = nd->C_SUBS; sg != NULL; sg = sg->gsucc )
PropagateImportSizes( nd, sg );
for (sg = nd->C_SUBS; sg != NULL; sg = sg->gsucc )
AssignSizes( sg );
AssignExportSizes( nd );
break;
default:
AssignExportSizes( nd );
break;
}
}