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

Download this file

if2alloc.c    867 lines (622 with data), 31.2 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
/**************************************************************************/
/* FILE ************** if2alloc.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:05 miller
* Initial revision
*
* Revision 12.7 1992/10/21 18:09:21 miller
* Initial RCS Version by Cann
*/
/**************************************************************************/
#include "world.h"
extern int agg;
/**************************************************************************/
/* STATIC ************** AttachSizeExpression ************************/
/**************************************************************************/
/* PURPOSE: ATTACH p'S SIZE EXPRESION exp TO p AT IMPORT PORT iport. */
/**************************************************************************/
static void AttachSizeExpression( p, expr, iport )
PNODE p;
PEDGE expr;
int iport;
{
register PEDGE e;
if ( IsConstSize( expr ) ) {
e = EdgeAlloc( NULL_NODE, CONST_PORT, p, iport );
e->info = integer;
e->CoNsT = IntToAscii( expr->csize );
LinkImport( p, e );
}
else
ThreadToUse( expr->esize, 1, p, iport, integer );
}
/**************************************************************************/
/* LOCAL ************** MakeMultipleOrBufferInfo ************************/
/**************************************************************************/
/* PURPOSE: APPEND A MULTIPLE OR BUFFER TYPE TO THE SYMBOL TABLE AND */
/* RETURN IT. */
/**************************************************************************/
static PINFO MakeMultipleOrBufferInfo( type, aelem )
int type;
PINFO aelem;
{
register PINFO i;
i = FindInfo( ++maxint, type );
i->funct = FALSE; /* REFER TO if1build.c: MakeInfo(...) */
i->file = FALSE;
i->A_ELEM = aelem;
return( i );
}
/**************************************************************************/
/* LOCAL ************** ABuildReconstruction ************************/
/**************************************************************************/
/* PURPOSE: REPRODUCE ABuild NODE e->src LINKING IT DIRECTLY TO THE LEFT */
/* OF e->dst IN ITS NODE LIST. A REFERENCE TO THE COPY IS */
/* RETURNED. */
/**************************************************************************/
static PEDGE ABuildReconstruction( e )
PEDGE e;
{
register PNODE pr;
register PEDGE ee;
register PEDGE i;
register PNODE bld;
pr = e->dst->npred;
ee = FindSource( e );
bld = NodeAlloc( ++maxint, IFABuildAT );
bld->lstack = pr->lstack;
bld->level = pr->level;
CopyPragmas( ee->src, bld );
LinkNode( pr, bld );
for ( i = ee->src->imp; i != NULL; i = i->isucc ) {
if ( IsConst( i ) ) {
CopyEdgeAndThreadToUse( i, bld, i->iport );
continue;
}
ThreadToUse( i->src, i->eport, bld, i->iport, i->info );
if ( !IsArray( i->info ) )
continue;
/* MAKE SURE THE NEW REFERENCE HAS THE PROPER SIZE INFORMATION */
for ( ee = i->src->exp; ee != NULL; ee = ee->esucc )
if ( ee->eport == i->eport ) {
ee->lsize = i->lsize;
ee->esize = i->esize;
ee->csize = i->csize;
}
}
/* LINK AND RETURN A REFERENCE TO THE COPY */
ee = EdgeAlloc( bld, 1, NULL_NODE, -1 );
ee->info = e->info;
ee->lsize = e->lsize;
ee->csize = e->csize;
ee->esize = e->esize;
LinkExport( bld, ee );
return( ee );
}
/**************************************************************************/
/* LOCAL ************** AllocNewBuffer ************************/
/**************************************************************************/
/* PURPOSE: CONSTRUCT AND RETURN A REFERENCE TO A BUFFER DEFINITION AND */
/* STORAGE ALLOCATION SUBGRAPH FOR THE SIZE EXPRESSION DEFINED */
/* BY EDGE e USING NODE rpoint AS THE REFERENCE POINT. */
/**************************************************************************/
static PEDGE AllocNewBuffer( rpoint, e )
PNODE rpoint;
PEDGE e;
{
register PEDGE ee;
register PNODE pr;
register PNODE n;
/* WHERE SHOULD THE SUBGRAPH BE PLACED WITHIN rpoint's NODE LIST? */
if ( IsConstSize( e ) )
pr = rpoint->lstack[rpoint->level];
else if ( e->esize->level < rpoint->level )
pr = rpoint->lstack[rpoint->level];
else
pr = e->esize;
/* ALLOCATE IFDefArrayBuf( SIZE, BUFFER LITERAL ) */
n = NodeAlloc( ++maxint, IFDefArrayBuf );
n->lstack = pr->lstack;
n->level = pr->level;
LinkNode( pr, n );
pr = n;
/* ATTACH SIZE EXPRESSION */
AttachSizeExpression( n, e, 1 );
/* ATTACH BUFFER LITERAL */
ee = EdgeAlloc( NULL_NODE, CONST_PORT, n, 2 );
ee->info = e->info->A_ELEM;
ee->CoNsT = "Buffer";
LinkImport( n, ee );
/* ALLOCATE IFMemAlloc( IFDefArrayBuf(...,...) ) */
n = NodeAlloc( ++maxint, IFMemAlloc );
n->lstack = pr->lstack;
n->level = pr->level;
LinkNode( pr, n );
/* ATTACH IFDefArrayBuf NODE */
ThreadToUse( pr, 1, n, 1, MakeMultipleOrBufferInfo( IF_BUFFER, e->info ) );
ee = EdgeAlloc( n, 1, NULL_NODE, -1 );
ee->info = n->imp->info;
LinkExport( n, ee );
return( ee );
}
/**************************************************************************/
/* LOCAL ************** GetBuffer ************************/
/**************************************************************************/
/* PURPOSE: LOCATE AN AT-NODE CONSUMER OF NODE p'S EXPORT AND GENERATE A */
/* SUBGRAPH (IF NECESSARY) CALCULATING p'S BUFFER (A FUNCTION OF */
/* THE CHILD'S BUFFER). DATA FLOW ORDERING CHECKS ARE MADE TO */
/* GUARANTEE ITS PRESERVATION. A REFERENCE TO THE CALCULATED */
/* BUFFER IS RETURNED. IF minopt IS TRUE, A NEW BUFFER IS */
/* ALLOCATED FOR p AND A CHILD AT-NODE SEARCH IS NOT PERFORMED. */
/**************************************************************************/
static PEDGE GetBuffer( p )
PNODE p;
{
register PEDGE e;
register PNODE n;
register PEDGE i1;
register PNODE pr;
register PEDGE ee;
register PEDGE b;
register PEDGE rat;
register PNODE scat;
register int eport;
/* ATTEMPT TO LOCATE AN AT-NODE CHILD OF p GIVING PRIORITY TO */
/* IFReduceAT NODES (A SPECIAL CASE!). */
switch ( p->type ) {
case IFAGather:
if ( p->exp->esucc != NULL )
Error1( "GetMemoryBuffer: RETURN NODE WITH FANOUT > ONE" );
if ( p->imp->isucc->isucc != NULL ) /* FILTER? */
return( AllocNewBuffer( p->exp->dst->G_DAD, p->exp ) );
eport = p->exp->iport;
p = p->exp->dst->G_DAD;
break;
case IFFinalValue:
case IFReduce:
case IFRedLeft:
case IFRedRight:
case IFRedTree:
if ( p->exp->esucc != NULL )
Error1( "GetMemoryBuffer: RETURN NODE WITH FANOUT > ONE" );
eport = p->exp->iport;
p = p->exp->dst->G_DAD;
break;
default:
eport = 1;
break;
}
/* UNLESS minopt IS TRUE, CHECK IF p HAS A IFReduceAT CHILD */
if ( !minopt )
for ( e = p->exp; e != NULL; e = e->esucc ) {
if ( e->eport != eport )
continue;
if ( !IsSGraph( e->dst ) ) /* IS IMMEDIATE CHILD A SUBGRAPH? */
continue;
n = e->dst->G_DAD;
if ( !IsForall( n ) ) /* IS IT PART OF A FORALL? */
continue;
if ( n->F_BODY != e->dst ) /* IS IT THE FORALL BODY? */
continue;
if ( (rat = FindExport( n->F_RET, e->iport )) == NULL )
continue;
if ( !IsReduceAT( rat->dst ) )
continue;
/* BUILD IFScatterBufPartitions IN THE GENERATE SUBGRAPH AND */
/* RETURN A REFERENCE TO THE SCATTERED PARTITIONS WITHIN THE */
/* BODY SUBGRAPH. */
pr = FindLastNode( n->F_GEN ); /* PLACE AT END OF NODE LIST */
scat = NodeAlloc( ++maxint, IFScatterBufPartitions );
scat->lstack = pr->lstack;
scat->level = pr->level;
LinkNode( pr, scat );
b = FindImport( rat->dst, 5 ); /* FIND BUFFER REFERENCE */
/* ATTACH BUFFER TO IFScatterBufPartitions */
ThreadToUse( n->F_GEN, b->eport, scat, 1, b->info );
/* ATTACH STEP SIZE TO IFScatterBufPartitions */
AttachSizeExpression( scat, e, 2 );
/* ATTACH IFScatterBufPartitions EXPORT AND BODY REFERENCE */
eport = ++maxint;
ThreadToUse( scat, 1, n->F_GEN, eport,
MakeMultipleOrBufferInfo( IF_MULTIPLE, b->info ) );
ee = EdgeAlloc( n->F_BODY, eport, NULL_NODE, -1 );
ee->info = b->info;
LinkExport( n->F_BODY, ee );
/* ASSIGN %mk=P TO THE MULTIPLE IMPORT OF THE REDUCE AT-NODE */
MarkAsBuiltInplace( rat->dst->imp->isucc->isucc );
MarkAsBuiltInplace( e );
return( ee );
}
/* AN IFReduceAT CHILD WAS NOT FOUND; HENCE, ATTEMPT TO LOCATE A */
/* NON-IFReduceAT AT-NODE CHILD (THE FIRST ENCOUNTER WINS!) */
for ( e = p->exp; e != NULL; e = e->esucc )
if ( e->eport == eport ) {
ee = e; /* TO REMEMBER THE SIZE EXPRESSION */
/* IF AN AT-NODE CHILD NOT FOUND */
if ( IsAtNode( e->dst ) ) {
if ( IsABuildAT( e->dst ) || IsAFillAT( e->dst ) )
continue;
break;
}
}
if ( minopt || (e == NULL) ) /* CREATE A NEW BUFFER? */
return( AllocNewBuffer( p, ee ) );
/* THE CHILD AT-NODE MUST BE EITHER AN IFAAddHAT, IFAAddLAT, OR */
/* IFACatenateAT WITH THE THIRD IMPORT DEFINING ITS BUFFER */
b = e->dst->imp->isucc->isucc;
switch ( e->dst->type ) {
case IFAAddHAT:
if ( (MaxNodeInDFO( p, b->src, p ) != p) || (e->iport == 2) )
return( AllocNewBuffer( p, e ) );
MarkAsBuiltInplace( e );
/* RETURN A NEW REFERENCE TO THE BUFFER */
ee = EdgeAlloc( b->src, b->eport, NULL_NODE, -1 );
ee->info = b->info;
LinkExport( b->src, ee );
return( ee );
case IFAAddLAT:
if ( (MaxNodeInDFO( p, b->src, p ) != p ) || (e->iport == 2) )
return( AllocNewBuffer( p, e ) );
/* ALLOCATE IFShiftBuffer( b, 1 ) */
n = NodeAlloc( ++maxint, IFShiftBuffer );
n->lstack = p->lstack;
n->level = p->level;
LinkNode( b->src, n );
/* ATTACH 1 TO THE SECOND IMPORT OF THE SHIFT NODE */
ee = EdgeAlloc( NULL_NODE, CONST_PORT, n, 2 );
ee->info = integer;
ee->CoNsT = "1";
LinkImport( n, ee );
/* ATTACH A b REFERENCE TO THE FIRST IMPORT OF THE SHIFT NODE */
CopyEdgeAndThreadToUse( b, n, 1 );
/* RETURN A REFERENCE TO THE SHIFT NODE */
ee = EdgeAlloc( n, 1, NULL_NODE, -1 );
ee->info = b->info;
LinkExport( n, ee );
/* ASSIGN %mk=P TO e AS e->src WILL BUILD e INPLACE AND e->dst */
/* NEED DO NOTHING WITH e. */
MarkAsBuiltInplace( e );
return( ee );
case IFACatenateAT:
if ( e->iport == 1 ) {
if ( MaxNodeInDFO( p, b->src, p ) != p )
return( AllocNewBuffer( p, e ) );
/* ASSIGN %mk=P TO e AS e->src WILL BUILD e INPLACE AND */
/* e->dst NEED DO NOTHING WITH e. */
MarkAsBuiltInplace( e );
ee = EdgeAlloc( b->src, b->eport, NULL_NODE, -1 );
ee->info = b->info;
LinkExport( b->src, ee );
return( ee );
}
i1 = e->dst->imp;
if ( MaxNodeInDFO( p, b->src, p ) != p )
return( AllocNewBuffer( p, e ) );
if ( !IsConstSize( i1 ) )
if ( MaxNodeInDFO( p, i1->esize, p ) != p )
return( AllocNewBuffer( p, e ) );
/* ALLOCATE IFShiftBuffer( b, SIZE OF FIRST IMPORT ) */
n = NodeAlloc( ++maxint, IFShiftBuffer );
n->lstack = p->lstack;
n->level = p->level;
if ( IsConstSize( i1 ) )
pr = b->src;
else if ( i1->esize->level < p->level )
pr = b->src;
else
pr = MaxNodeInDFO( p, b->src, i1->esize );
LinkNode( pr, n );
/* LINK b REFERENCE TO THE SHIFT NODE */
CopyEdgeAndThreadToUse( b, n, 1 );
/* LINK THE SIZE OF THE FIRST IMPORT TO THE SHIFT NODE */
AttachSizeExpression( n, i1, 2 );
/* RETURN A REFERENCE TO THE SHIFT NODE */
ee = EdgeAlloc( n, 1, NULL_NODE, -1 );
ee->info = b->info;
LinkExport( n, ee );
/* ASSIGN %mk=P TO e AS e->src WILL BUILD e INPLACE AND e->dst */
/* NEED DO NOTHING WITH e. */
MarkAsBuiltInplace( e );
return( ee );
default:
Error1( "GetBuffer: ILLEGAL CHILD AT-NODE ENCOUNTERED" );
}
return NULL;
}
/**************************************************************************/
/* GLOBAL ************** AllocIf2Nodes ************************/
/**************************************************************************/
/* PURPOSE: USE THE SIZE INFORMATION TO CONSTRUCT BUFFERS AND LINK THEM */
/* TO THEIR USES WITHIN FUNCTION GRAPH f. */
/**************************************************************************/
void AllocIf2Nodes( f )
PNODE f;
{
register PNODE p, n, nn, m;
register PEDGE b, init;
register PNODE l, g, bld;
register PEDGE e, lval, lbody;
register int old;
while ( (p = PopAtNode()) != NULL ) {
if ( IsAtNode( p ) )
continue;
if ( p->exp == NULL ) /* DEAD? */
continue;
/* GET NODE p'S BUFFER, A FUNCTION OF ITS AT-NODE CHILD */
b = GetBuffer( p );
++agg;
/* LINK p'S BUFFER TO p. IF p MAIPULATES A MULTIPLE VALUE THEN */
/* THE BUFFER IS APPROPRIATELY LINKED TO OTHER POTENTIAL AT-NODES */
/* WITHIN THE OWNING LOOP. */
switch ( p->type ) {
case IFAFill:
p->type = IFAFillAT;
b->iport = 4;
LinkImport( p, b );
/* ATTACH SIZE EXPRESSION: NOTE THIS VIOLATES IF2 */
AttachSizeExpression( p, p->exp, 5 );
break;
case IFABuild:
p->type = IFABuildAT;
b->iport = p->exp->csize + 2;
LinkImport( p, b );
break;
case IFAAddH:
p->type = IFAAddHAT;
b->iport = 3;
LinkImport( p, b );
/* ATTACH SIZE EXPRESSION: NOTE THIS VIOLATES IF2 */
AttachSizeExpression( p, p->exp, 4 );
break;
case IFAAddL:
p->type = IFAAddLAT;
b->iport = 3;
LinkImport( p, b );
/* ATTACH SIZE EXPRESSION: NOTE THIS VIOLATES IF2 */
AttachSizeExpression( p, p->exp, 4 );
break;
case IFACatenate:
p->type = IFACatenateAT;
b->iport = 3;
LinkImport( p, b );
/* ATTACH SIZE EXPRESSION: NOTE THIS VIOLATES IF2 */
AttachSizeExpression( p, p->exp, 4 );
break;
case IFAGather:
p->type = IFAGatherAT;
b->iport = ++maxint;
g = p->exp->dst; /* SUBGRAPH WHOSE NODE LIST CONTAINS p */
/* LINK BUFFER b TO THE LOOPS IMPORT LIST */
LinkImport( g->G_DAD, b );
/* LINK A REFERENCE TO THE IMPORTED BUFFER TO p */
ThreadToUse( g, maxint, p, 4, b->info );
/* IF p'S BUFFER IS A FUNCTION OF ANOTHER AT-NODE THEN */
/* MARK ITS EXPORT. */
if ( (!IsMemAlloc( b->src )) || (b->src->exp->esucc != NULL) )
MarkAsBuiltInplace( p->exp );
/* ATTACH SIZE EXPRESSION: NOTE THIS VIOLATES IF2 */
AttachSizeExpression( p, p->exp, 5 );
break;
case IFReduce:
p->type = IFReduceAT; goto ReduceStart;
case IFRedLeft:
p->type = IFRedLeftAT; goto ReduceStart;
case IFRedRight:
p->type = IFRedRightAT; goto ReduceStart;
case IFRedTree:
p->type = IFRedTreeAT;
ReduceStart:
/* IF p'S BUFFER IS A FUNCTION OF ANOTHER AT-NODE THEN */
/* MARK ITS EXPORT. */
if ( (!IsMemAlloc( b->src )) || (b->src->exp->esucc != NULL) )
MarkAsBuiltInplace( p->exp );
g = p->exp->dst; /* SUBGRAPH WHOSE NODE LIST CONTAINS p */
/* LINK BUFFER b TO THE FORALL NODE AND TO p ITSELF. */
b->iport = ++maxint;
LinkImport( g->G_DAD, b );
ThreadToUse( g, maxint, p, 5, b->info );
/* ATTACH SIZE EXPRESSION: NOTE THIS VIOLATES IF2 */
AttachSizeExpression( p, p->exp, 6 );
break;
case IFFinalValue:
p->type = IFFinalValueAT;
/* IF p'S BUFFER IS A FUNCTION OF ANOTHER AT-NODE THEN */
/* MARK ITS EXPORT. */
if ( (!IsMemAlloc( b->src )) || (b->src->exp->esucc != NULL) )
MarkAsBuiltInplace( p->exp );
g = p->exp->dst; /* SUBGRAPH WHOSE NODE LIST CONTAINS p */
l = g->G_DAD; /* SEQUENTIAL LOOP OWNING g */
/* LINK THE BUFFER b TO l AND TO p ITSELF. MARK p'S */
/* MULTIPLE IMPORT AS BUILT INPLACE (DONE IN THE BODY) */
b->iport = ++maxint;
LinkImport( l, b );
ThreadToUse( g, maxint, p, 3, b->info );
MarkAsBuiltInplace( p->imp );
/* FIND THE ABuild NODE SERVING AS p'S INITIAL VALUE */
lval = FindImport( l->L_INIT, p->imp->eport );
init = FindImport( l, lval->eport );
MarkAsBuiltInplace( lval );
/* RECONSTRUCT THE INITIAL ABuild SO TO GUARANTEE */
/* PRESERVATION OF DATA FLOW ORDERING. Init IS MARKED AS */
/* BUILT INPLACE. */
init = ABuildReconstruction( init );
bld = init->src;
init->iport = ++maxint;
lval->eport = maxint;
LinkImport( l, init );
MarkAsBuiltInplace( init );
/* LOCATE MONOTONIC CONSTRUCTION NODE IN THE LOOP BODY */
/* AND MARK IT AS BUILT INPLACE */
lbody = FindImport( l->L_BODY, lval->iport );
MarkAsBuiltInplace( lbody );
/* COMPLETE MONOTONIC CONSTURCTION OF EACH INDIVIDUAL CASE */
m = lbody->src;
switch ( m->type ) {
case IFAAddH:
m->type = IFAAddHAT;
/* LINK l's IMPORT BUFFER b TO m IN THE BODY AND */
/* MARK THE FIRST IMPORT TO m AS BUILT INPLACE */
ThreadToUse( l->L_BODY, b->iport, m, 3, b->info );
MarkAsBuiltInplace( m->imp );
/* LINK A b REFERENCE TO THE RECONSTRUCTED ABuilt */
/* NODE. */
CopyEdgeAndThreadToUse( b, bld, init->csize + 2 );
/* ATTACH SIZE EXPRESSION: NOTE THIS VIOLATES IF2 */
/* AttachSizeExpression( m, p->exp, 4 ); */
AttachSizeExpression( m, m->exp, 4 );
break;
case IFAAddL:
m->type = IFAAddLAT;
/* CONSTRUCT IFShiftBuffer( old b, -1 ) */
n = NodeAlloc( ++maxint, IFShiftBuffer );
n->lstack = m->lstack;
n->level = m->level;
LinkNode( m->npred, n );
/* ATTACH THE -1 IMPORT TO THE SHIFT NODE */
e = EdgeAlloc( NULL_NODE, CONST_PORT, n, 2 );
e->info = integer;
e->CoNsT = "-1";
LinkImport( n, e );
/* ATTACH old b TO THE SHIFT NODE */
ThreadToUse( l->L_BODY, ++maxint, n, 1, b->info );
/* LINK A REFERENCE FROM n TO m AND n TO THE BODY */
/* AND MARK m's FIRST IMPORT AS BUILT INPLACE */
ThreadToUse( n, 1, m, 3, b->info );
ThreadToUse( n, 1, l->L_BODY, maxint, b->info );
MarkAsBuiltInplace( m->imp );
/* INITIALIZE THE INITIAL SUBGRAPH SO THAT THE */
/* BUFFER CAN BE CARRIED ACROSS LOOP ITERATIONS. */
old = maxint;
ThreadToUse( l->L_INIT, ++maxint,
l->L_INIT, old, b->info );
old = maxint;
/* ADJUST b LINKING IT TO THE RECONSTRUCTED ABuild */
/* NODE AND l: IFShiftBuffer( b, SIZE OF RESULT - */
/* SIZE OF THE ABUILD ) */
n = NodeAlloc( ++maxint, IFShiftBuffer );
n->lstack = bld->lstack;
n->level = bld->level;
LinkNode( bld->npred, n );
/* ATTACH b REFERENCE TO THE SHIFT NODE */
CopyEdgeAndThreadToUse( b, n, 1 );
/* ATTACH SHIFT AMOUNT TO THE SHIFT NODE */
nn = NodeAlloc( ++maxint, IFMinus );
nn->lstack = n->lstack;
nn->level = n->level;
LinkNode( n->npred, nn );
/* LINK RESULT SIZE TO FIRST IMPORT OF MINUS NODE */
ThreadToUse( p->exp->esize, 1, nn, 1, integer );
/* LINK ABuild SIZE TO SECOND IMPORT OF MINUS NODE */
e = EdgeAlloc( NULL_NODE, CONST_PORT, nn, 2 );
e->info = integer;
e->CoNsT = IntToAscii( init->csize );
LinkImport( nn, e );
/* ATTACH THE MINUS NODE TO THE SHIFT NODE */
ThreadToUse( nn, 1, n, 2, integer );
/* ATTACH REFERENCE FROM SHIFT NODE TO THE ABuild */
/* NODE AND TO l. */
ThreadToUse( n, 1, bld, init->csize + 2, b->info );
ThreadToUse( n, 1, l, old, b->info );
/* ATTACH SIZE EXPRESSION: NOTE THIS VIOLATES IF2 */
/* AttachSizeExpression( m, p->exp, 4 ); */
AttachSizeExpression( m, m->exp, 4 );
break;
case IFACatenate:
m->type = IFACatenateAT;
/* ATTACH SIZE EXPRESSION: NOTE THIS VIOLATES IF2 */
/* AttachSizeExpression( m, p->exp, 4 ); */
AttachSizeExpression( m, m->exp, 4 );
if ( m->imp->eport == lbody->iport ) {
/* LINK l's IMPORT BUFFER b TO m IN THE BODY */
/* AND MARK THE FIRST IMPORT TO m AS BUILT */
/* INPLACE */
ThreadToUse( l->L_BODY, b->iport, m, 3, b->info );
MarkAsBuiltInplace( m->imp );
/* LINK A b REFERENCE TO THE RECONSTRUCTED */
/* ABuild NODE. */
CopyEdgeAndThreadToUse( b, bld, init->csize + 2 );
break;
}
/* CONSTRUCT IFShiftBuffer( old b, SIZE OF FIRST */
/* IMPORT TO m) */
n = NodeAlloc( ++maxint, IFShiftBuffer );
n->lstack = m->lstack;
n->level = m->level;
/* LINK AT HEAD OF NODE LIST. THE EXPANSION SIZE */
/* EXPRESSION IS EITHER CONSTANT OR AT A LEVEL */
/* BELOW THE LOOP (IsMonotonicConstruction) */
LinkNode( m->lstack[m->level], n );
/* ATTACH THE NEGATION OF OF m'S FIRST IMPORT SIZE */
/* TO THE SHIFT NODE */
if ( IsConstSize( m->imp ) ) {
e = EdgeAlloc( NULL_NODE, CONST_PORT, n, 2 );
e->info = integer;
e->CoNsT = IntToAscii( -(m->imp->csize) );
LinkImport( n, e );
} else {
nn = NodeAlloc( ++maxint, IFNeg );
nn->lstack = n->lstack;
nn->level = n->level;
LinkNode( n->npred, nn );
ThreadToUse( m->imp->esize, 1, nn, 1, integer );
ThreadToUse( nn, 1, n, 2, integer );
}
/* ATTACH old b TO THE SHIFT NODE */
ThreadToUse( l->L_BODY, ++maxint, n, 1, b->info );
/* LINK A REFERENCE FROM n TO m AND n TO THE BODY */
/* AND MARK m's SECOND IMPORT AS BUILT INPLACE */
ThreadToUse( n, 1, m, 3, b->info );
ThreadToUse( n, 1, l->L_BODY, maxint, b->info );
MarkAsBuiltInplace( m->imp->isucc );
/* INITIALIZE THE INITIAL SUBGRAPH SO THAT THE */
/* BUFFER CAN BE CARRIED ACROSS LOOP ITERATIONS. */
old = maxint;
ThreadToUse( l->L_INIT, ++maxint,
l->L_INIT, old, b->info );
old = maxint;
/* ADJUST b LINKING IT TO THE RECONSTRUCTED ABuild */
/* NODE AND l: IFShiftBuffer( b, SIZE OF RESULT - */
/* SIZE OF THE ABUILD ) */
n = NodeAlloc( ++maxint, IFShiftBuffer );
n->lstack = bld->lstack;
n->level = bld->level;
LinkNode( bld->npred, n );
/* ATTACH b REFERENCE TO THE SHIFT NODE */
CopyEdgeAndThreadToUse( b, n, 1 );
/* ATTACH SHIFT AMOUNT TO THE SHIFT NODE */
nn = NodeAlloc( ++maxint, IFMinus );
nn->lstack = n->lstack;
nn->level = n->level;
LinkNode( n->npred, nn );
/* LINK RESULT SIZE TO FIRST IMPORT OF MINUS NODE */
ThreadToUse( p->exp->esize, 1, nn, 1, integer );
/* LINK ABuild SIZE TO SECOND IMPORT OF MINUS NODE */
e = EdgeAlloc( NULL_NODE, CONST_PORT, nn, 2 );
e->info = integer;
e->CoNsT = IntToAscii( init->csize );
LinkImport( nn, e );
/* ATTACH THE MINUS NODE TO THE SHIFT NODE */
ThreadToUse( nn, 1, n, 2, integer );
/* ATTACH REFERENCE FROM SHIFT NODE TO THE ABuild */
/* NODE AND TO l. */
ThreadToUse( n, 1, bld, init->csize + 2, b->info );
ThreadToUse( n, 1, l, old, b->info );
break;
default:
Error1( "AllocIf2Nodes: ILLEGAL MONOTONIC BODY NODE" );
break;
}
break;
default:
Error1( "AllocIf2Nodes: ILLEGAL POTENTIAL AT-NODE" );
break;
}
}
}