home *** CD-ROM | disk | FTP | other *** search
- # include "Temporar.h"
- # include "yyATempo.w"
- # include <stdio.h>
- # if defined __STDC__ | defined __cplusplus
- # include <stdlib.h>
- # else
- extern void exit ();
- # endif
- # include "Tree.h"
- # include "Definiti.h"
-
- # ifndef NULL
- # define NULL 0L
- # endif
- # ifndef false
- # define false 0
- # endif
- # ifndef true
- # define true 1
- # endif
-
- # ifdef yyInline
- # define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) \
- if ((ptr = (tree) free) >= (tree) max) ptr = alloc (); \
- free += nodesize [kind]; \
- ptr->yyHead.yyMark = 0; \
- ptr->Kind = kind;
- # else
- # define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) ptr = make (kind);
- # endif
-
- # define yyWrite(s) (void) fputs (s, yyf)
- # define yyWriteNl (void) fputc ('\n', yyf)
-
- # line 43 "AdaptTemporary.puma"
-
- # include <stdio.h>
- # include "Idents.h"
- # include "StringMe.h"
-
- # include "protocol.h"
-
- # include "Types.h"
- # include "Transfor.h" /* ReplaceACF, ... */
- # include "Shapes.h"
- # include "Expressi.h" /* MakeNotExp */
- # include "ShowDefs.h" /* error messages */
- # include "TempScal.h" /* ExtractScalarMovements */
- # include "TempVars.h" /* MakeLocalExpression */
-
- static int forall_loops; /* global used for forall statements */
- static tTree forall_loopnest[10];
- static tTree forall_mask;
- static tTree forall_new_assigns;
-
-
-
- static FILE * yyf = stdout;
-
- static void yyAbort
- # ifdef __cplusplus
- (char * yyFunction)
- # else
- (yyFunction) char * yyFunction;
- # endif
- {
- (void) fprintf (stderr, "Error: module AdaptTemporary, routine %s failed\n", yyFunction);
- exit (1);
- }
-
- void AdaptTemporary ARGS((tTree t));
- static tTree ACFScalarTemps ARGS((tTree t));
- static tTree AppendBody ARGS((tTree list1, tTree list2));
- static tTree TempScalarIO ARGS((tTree stmt));
- static void SwitchAssignments ARGS((tTree t));
- static tTree AdaptTempACF ARGS((tTree t));
- static tTree AdaptTempAssign ARGS((tTree assign));
- static void AdaptTempForall ARGS((tTree t));
- static void ForallNewAssigns ARGS((tTree t, int line));
- static tTree MakeOuterLoop ARGS((tTree loop, tTree body));
- static tTree AdaptTempWhereList ARGS((tTree t));
- static tTree AdaptTempWhere ARGS((tTree t));
- static bool WhereMaskUpdate ARGS((tTree wherelist));
- static bool HasMaskUpdate ARGS((tTree mask, tTree stmtlist));
- static tTree GetSplittedWhereList ARGS((tTree t));
- static tTree SplitWhere ARGS((tTree wherestmt, tTree tp1, tTree fp1, tTree tp2, tTree fp2));
- static void NormalizeWhere ARGS((tTree wherestmt));
- static void ListSplitUp ARGS((tTree list, tTree mask, tTree * s1, tTree * s2));
- static bool HasWhereMovement ARGS((tTree stmt, tTree where_exp));
-
- void AdaptTemporary
- # if defined __STDC__ | defined __cplusplus
- (register tTree t)
- # else
- (t)
- register tTree t;
- # endif
- {
- if (t == NoTree) return;
-
- switch (t->Kind) {
- case kCOMP_UNIT:
- # line 77 "AdaptTemporary.puma"
- {
- # line 78 "AdaptTemporary.puma"
- open_protocol ("adaptor.tmp");
- # line 79 "AdaptTemporary.puma"
- AdaptTemporary (t->COMP_UNIT.COMP_ELEMENTS);
- # line 80 "AdaptTemporary.puma"
- close_protocol ();
- }
- return;
-
- case kDECL_LIST:
- # line 85 "AdaptTemporary.puma"
- {
- # line 86 "AdaptTemporary.puma"
- AdaptTemporary (t->DECL_LIST.Elem);
- # line 87 "AdaptTemporary.puma"
- AdaptTemporary (t->DECL_LIST.Next);
- }
- return;
-
- case kDECL_EMPTY:
- # line 90 "AdaptTemporary.puma"
- return;
-
- case kPROGRAM_DECL:
- # line 93 "AdaptTemporary.puma"
- {
- tDefinitions Obj;
- {
- # line 94 "AdaptTemporary.puma"
- set_protocol_unit (t);
- # line 95 "AdaptTemporary.puma"
- IsPure = false;
- # line 96 "AdaptTemporary.puma"
-
- # line 97 "AdaptTemporary.puma"
- Obj = GetDeclEntry (t->PROGRAM_DECL.Name, GetUnitEntries ());
- # line 98 "AdaptTemporary.puma"
- OpenScope (Obj->ProcObject.Declarations);
- # line 99 "AdaptTemporary.puma"
- AdaptTemporary (t->PROGRAM_DECL.PROGRAM_BODY);
- # line 100 "AdaptTemporary.puma"
- Obj->ProcObject.Declarations = GetCurrentScope ();
- # line 101 "AdaptTemporary.puma"
- CloseScope ();
- }
- return;
- }
-
- case kPROC_DECL:
- # line 104 "AdaptTemporary.puma"
- {
- tDefinitions Obj;
- {
- # line 105 "AdaptTemporary.puma"
- set_protocol_unit (t);
- # line 106 "AdaptTemporary.puma"
- IsPure = t->PROC_DECL.IsPure;
- # line 107 "AdaptTemporary.puma"
-
- # line 108 "AdaptTemporary.puma"
- Obj = GetDeclEntry (t->PROC_DECL.Name, GetUnitEntries ());
- # line 109 "AdaptTemporary.puma"
- OpenScope (Obj->ProcObject.Declarations);
- # line 110 "AdaptTemporary.puma"
- AdaptTemporary (t->PROC_DECL.PROC_BODY);
- # line 111 "AdaptTemporary.puma"
- if (! (Obj->ProcObject.Declarations = GetCurrentScope ())) goto yyL5;
- {
- # line 112 "AdaptTemporary.puma"
- CloseScope ();
- }
- }
- return;
- }
- yyL5:;
-
- break;
- case kFUNC_DECL:
- # line 115 "AdaptTemporary.puma"
- {
- tDefinitions Obj;
- {
- # line 116 "AdaptTemporary.puma"
- set_protocol_unit (t);
- # line 117 "AdaptTemporary.puma"
- IsPure = t->FUNC_DECL.IsPure;
- # line 118 "AdaptTemporary.puma"
-
- # line 119 "AdaptTemporary.puma"
- Obj = GetDeclEntry (t->FUNC_DECL.Name, GetUnitEntries ());
- # line 120 "AdaptTemporary.puma"
- OpenScope (Obj->FuncObject.Declarations);
- # line 121 "AdaptTemporary.puma"
- AdaptTemporary (t->FUNC_DECL.FUNC_BODY);
- # line 122 "AdaptTemporary.puma"
- if (! (Obj->FuncObject.Declarations = GetCurrentScope ())) goto yyL6;
- {
- # line 123 "AdaptTemporary.puma"
- CloseScope ();
- }
- }
- return;
- }
- yyL6:;
-
- break;
- case kBLOCK_DATA_DECL:
- # line 126 "AdaptTemporary.puma"
- {
- tDefinitions Obj;
- {
- # line 127 "AdaptTemporary.puma"
- set_protocol_unit (t);
- # line 128 "AdaptTemporary.puma"
- IsPure = false;
- # line 129 "AdaptTemporary.puma"
-
- # line 130 "AdaptTemporary.puma"
- Obj = GetDeclEntry (t->BLOCK_DATA_DECL.Name, GetUnitEntries ());
- # line 131 "AdaptTemporary.puma"
- OpenScope (Obj->BlockObject.Declarations);
- # line 132 "AdaptTemporary.puma"
- AdaptTemporary (t->BLOCK_DATA_DECL.DATA_BODY);
- # line 133 "AdaptTemporary.puma"
- if (! (Obj->BlockObject.Declarations = GetCurrentScope ())) goto yyL7;
- {
- # line 134 "AdaptTemporary.puma"
- CloseScope ();
- }
- }
- return;
- }
- yyL7:;
-
- break;
- case kBODY_NODE:
- # line 137 "AdaptTemporary.puma"
- {
- # line 138 "AdaptTemporary.puma"
- if (! ((IsPure == true))) goto yyL8;
- }
- return;
- yyL8:;
-
- # line 142 "AdaptTemporary.puma"
- {
- # line 143 "AdaptTemporary.puma"
- TempScalarsInitBody (t);
- # line 144 "AdaptTemporary.puma"
- t->BODY_NODE.STATS = ACFScalarTemps (t->BODY_NODE.STATS);
- # line 145 "AdaptTemporary.puma"
- TempScalarsDoneBody (t);
- # line 146 "AdaptTemporary.puma"
- TempVarsInitBody (t);
- # line 147 "AdaptTemporary.puma"
- t->BODY_NODE.STATS = AdaptTempACF (t->BODY_NODE.STATS);
- # line 148 "AdaptTemporary.puma"
- TempVarsDoneBody (t);
- }
- return;
-
- }
-
- ;
- }
-
- static tTree ACFScalarTemps
- # if defined __STDC__ | defined __cplusplus
- (register tTree t)
- # else
- (t)
- register tTree t;
- # endif
- {
- if (t->Kind == kACF_LIST) {
- # line 167 "AdaptTemporary.puma"
- {
- tTree newelem;
- {
- # line 169 "AdaptTemporary.puma"
-
- # line 171 "AdaptTemporary.puma"
- set_protocol_stmt (t->ACF_LIST.Elem);
- # line 172 "AdaptTemporary.puma"
- newelem = ACFScalarTemps (t->ACF_LIST.Elem);
- t->ACF_LIST.Next = ACFScalarTemps (t->ACF_LIST.Next);
- newelem = ReplaceACF (t, newelem, t->ACF_LIST.Next);
-
- }
- {
- return newelem;
- }
- }
-
- }
- if (t->Kind == kACF_EMPTY) {
- # line 179 "AdaptTemporary.puma"
- return t;
-
- }
- if (t->Kind == kACF_BASIC) {
-
- switch (t->ACF_BASIC.BASIC_STMT->Kind) {
- case kIO_STMT:
- # line 183 "AdaptTemporary.puma"
- return TempScalarIO (t);
-
- case kALLOCATE_STMT:
- # line 190 "AdaptTemporary.puma"
- {
- # line 191 "AdaptTemporary.puma"
- SetAllocateShapes (t->ACF_BASIC.BASIC_STMT->ALLOCATE_STMT.PARAMS);
- }
- return t;
-
- case kDEALLOCATE_STMT:
- # line 195 "AdaptTemporary.puma"
- {
- # line 196 "AdaptTemporary.puma"
- ResetDeallocateShapes (t->ACF_BASIC.BASIC_STMT->DEALLOCATE_STMT.PARAMS);
- }
- return t;
-
- case kCALL_STMT:
- # line 200 "AdaptTemporary.puma"
- return t;
-
- case kREDUCE_STMT:
- # line 204 "AdaptTemporary.puma"
- return t;
-
- case kSTOP_STMT:
- # line 208 "AdaptTemporary.puma"
- return t;
-
- case kGOTO_STMT:
- # line 212 "AdaptTemporary.puma"
- return t;
-
- case kCOMP_IF_STMT:
- # line 216 "AdaptTemporary.puma"
- return t;
-
- case kASSIGN_STMT:
- # line 226 "AdaptTemporary.puma"
- return t;
-
- }
-
- # line 230 "AdaptTemporary.puma"
- return t;
-
- }
-
- switch (t->Kind) {
- case kACF_DUMMY:
- # line 234 "AdaptTemporary.puma"
- return t;
-
- case kACF_WHILE:
- # line 238 "AdaptTemporary.puma"
- {
- tTree new;
- {
- # line 240 "AdaptTemporary.puma"
-
- # line 242 "AdaptTemporary.puma"
- t->ACF_WHILE.WHILE_BODY = ACFScalarTemps (t->ACF_WHILE.WHILE_BODY);
-
- t->ACF_WHILE.WHILE_EXP = ExtractScalarMovements (t->ACF_WHILE.WHILE_EXP, &new);
-
- if (new != NoTree)
- {
- t->ACF_WHILE.WHILE_BODY = AppendBody (t->ACF_WHILE.WHILE_BODY, CopyTree (new));
- new = CombineACF (new, mACF_LIST (t, NoTree));
- tree_protocol ("DO WHILE with new scalars in exp:\n", new);
- }
- else
- new = t;
-
- }
- {
- return new;
- }
- }
-
- case kACF_DO:
- # line 258 "AdaptTemporary.puma"
- {
- tTree new;
- {
- # line 260 "AdaptTemporary.puma"
-
- # line 262 "AdaptTemporary.puma"
- t->ACF_DO.DO_BODY = ACFScalarTemps (t->ACF_DO.DO_BODY);
-
- t->ACF_DO.DO_RANGE = ExtractScalarMovements (t->ACF_DO.DO_RANGE, &new);
-
- if (new != NoTree)
- {
- new = CombineACF (new, mACF_LIST (t, NoTree));
- tree_protocol ("DO with new scalars in range:\n", new);
- }
- else
- new = t;
-
- }
- {
- return new;
- }
- }
-
- case kACF_DOLOCAL:
- # line 277 "AdaptTemporary.puma"
- return t;
-
- case kACF_FORALL:
- # line 282 "AdaptTemporary.puma"
- return t;
-
- case kACF_IF:
- # line 286 "AdaptTemporary.puma"
- {
- tTree new;
- {
- # line 288 "AdaptTemporary.puma"
-
- # line 290 "AdaptTemporary.puma"
- t->ACF_IF.THEN_PART = ACFScalarTemps (t->ACF_IF.THEN_PART);
- t->ACF_IF.ELSE_PART = ACFScalarTemps (t->ACF_IF.ELSE_PART);
- t->ACF_IF.IF_EXP = ExtractScalarMovements (t->ACF_IF.IF_EXP, &new);
- if (new != NoTree)
- { new = CombineACF (new, mACF_LIST (t, NoTree));
- tree_protocol ("IF with new scalars : \n", new);
- }
- else
- new = t;
-
- }
- {
- return new;
- }
- }
-
- case kACF_WHERE:
- # line 303 "AdaptTemporary.puma"
- return t;
-
- case kACF_NODE:
- case kACF_BASIC:
- case kACF_SWITCH:
- case kACF_ALTER:
- case kACF_CASE:
- case kACF_REPEAT:
- case kACF_WITH:
- case kACF_LOOP:
- case kACF_DOVEC:
- case kACF_DOALL:
- case kACF_ON:
- case kACF_BODY:
- case kACF_FLOW_GRAPH:
- case kACF_ENTRY:
- # line 308 "AdaptTemporary.puma"
- {
- # line 309 "AdaptTemporary.puma"
- error_protocol ("This statement is not handled");
- }
- return t;
-
- }
-
- # line 313 "AdaptTemporary.puma"
- {
- # line 314 "AdaptTemporary.puma"
- tree_error_protocol ("ACFScalarTemps failed", t);
- # line 315 "AdaptTemporary.puma"
- printf ("ACFScalarTemps failed\n");
- # line 316 "AdaptTemporary.puma"
- WriteTree (stdout, t);
- # line 317 "AdaptTemporary.puma"
- kill_in_protocol ();
- }
- return t;
-
- }
-
- static tTree AppendBody
- # if defined __STDC__ | defined __cplusplus
- (register tTree list1, register tTree list2)
- # else
- (list1, list2)
- register tTree list1;
- register tTree list2;
- # endif
- {
- if (list1->Kind == kACF_EMPTY) {
- # line 332 "AdaptTemporary.puma"
- {
- # line 333 "AdaptTemporary.puma"
- if (! (list2 == NoTree)) goto yyL1;
- }
- return list1;
- yyL1:;
-
- if (list2->Kind == kACF_LIST) {
- # line 337 "AdaptTemporary.puma"
- {
- # line 338 "AdaptTemporary.puma"
- list2->ACF_LIST.Next = AppendBody (list1, list2->ACF_LIST.Next);
- }
- return list2;
-
- }
- }
- if (list1->Kind == kACF_LIST) {
- # line 342 "AdaptTemporary.puma"
- {
- # line 343 "AdaptTemporary.puma"
- list1->ACF_LIST.Next = AppendBody (list1->ACF_LIST.Next, list2);
- }
- return list1;
-
- }
- yyAbort ("AppendBody");
- }
-
- static tTree TempScalarIO
- # if defined __STDC__ | defined __cplusplus
- (register tTree stmt)
- # else
- (stmt)
- register tTree stmt;
- # endif
- {
- if (stmt->Kind == kACF_BASIC) {
- if (stmt->ACF_BASIC.BASIC_STMT->Kind == kIO_STMT) {
- {
- tTree new;
- if (equaltIdent (stmt->ACF_BASIC.BASIC_STMT->IO_STMT.ID->PROC_OBJ.Ident, MakeIdent ("PRINT", 5))) {
- # line 355 "AdaptTemporary.puma"
- {
- # line 357 "AdaptTemporary.puma"
-
- # line 359 "AdaptTemporary.puma"
- stmt->ACF_BASIC.BASIC_STMT->IO_STMT.IO_ITEMS = ExtractScalarMovements (stmt->ACF_BASIC.BASIC_STMT->IO_STMT.IO_ITEMS, &new);
-
- if (new != NoTree)
- { stmt_protocol ("IO PRINT statement has new scalar variables");
- tree_protocol ("new scalar assignments are : \n", new);
-
- new = CombineACF (new, mACF_LIST (stmt, NoTree));
- }
- else
- new = stmt;
-
- }
- {
- return new;
- }
-
- }
- }
- {
- tTree new;
- if (equaltIdent (stmt->ACF_BASIC.BASIC_STMT->IO_STMT.ID->PROC_OBJ.Ident, MakeIdent ("WRITE", 5))) {
- # line 373 "AdaptTemporary.puma"
- {
- # line 375 "AdaptTemporary.puma"
-
- # line 377 "AdaptTemporary.puma"
- stmt->ACF_BASIC.BASIC_STMT->IO_STMT.IO_ITEMS = ExtractScalarMovements (stmt->ACF_BASIC.BASIC_STMT->IO_STMT.IO_ITEMS, &new);
-
- if (new != NoTree)
- { stmt_protocol ("IO WRITE statement has new scalar variables");
- tree_protocol ("new scalar assignments are : \n", new);
-
- new = CombineACF (new, mACF_LIST (stmt, NoTree));
- }
- else
- new = stmt;
-
- }
- {
- return new;
- }
-
- }
- }
- {
- tTree new;
- if (equaltIdent (stmt->ACF_BASIC.BASIC_STMT->IO_STMT.ID->PROC_OBJ.Ident, MakeIdent ("READ", 4))) {
- # line 391 "AdaptTemporary.puma"
- {
- # line 393 "AdaptTemporary.puma"
-
- # line 395 "AdaptTemporary.puma"
- stmt->ACF_BASIC.BASIC_STMT->IO_STMT.IO_ITEMS = ExtractScalarMovements (stmt->ACF_BASIC.BASIC_STMT->IO_STMT.IO_ITEMS, &new);
-
- SwitchAssignments (new);
-
- if (new != NoTree)
- { stmt_protocol ("IO READ statement has new scalar variables");
- tree_protocol ("new scalar assignments are : \n", new);
- }
- new = CombineACF (stmt, new);
-
-
- }
- {
- return new;
- }
-
- }
- }
- # line 409 "AdaptTemporary.puma"
- return stmt;
-
- }
- }
- yyAbort ("TempScalarIO");
- }
-
- static void SwitchAssignments
- # if defined __STDC__ | defined __cplusplus
- (register tTree t)
- # else
- (t)
- register tTree t;
- # endif
- {
- if (t == NoTree) return;
- # line 418 "AdaptTemporary.puma"
- {
- # line 419 "AdaptTemporary.puma"
- if (! (t == NoTree)) goto yyL1;
- }
- return;
- yyL1:;
-
- if (t->Kind == kACF_EMPTY) {
- # line 422 "AdaptTemporary.puma"
- return;
-
- }
- if (t->Kind == kACF_LIST) {
- if (t->ACF_LIST.Elem->Kind == kACF_BASIC) {
- if (t->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->Kind == kASSIGN_STMT) {
- if (t->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP->Kind == kVAR_EXP) {
- # line 425 "AdaptTemporary.puma"
- {
- tTree hvar;
- {
- # line 427 "AdaptTemporary.puma"
-
- # line 428 "AdaptTemporary.puma"
- hvar = t->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR; t->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR = t->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP->VAR_EXP.V; t->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->
- ASSIGN_STMT.ASSIGN_EXP->VAR_EXP.V = hvar;
- # line 429 "AdaptTemporary.puma"
- SwitchAssignments (t->ACF_LIST.Next);
- }
- return;
- }
-
- }
- }
- }
- }
- # line 432 "AdaptTemporary.puma"
- {
- # line 433 "AdaptTemporary.puma"
- printf ("Something is wrong in SwitchAssignments for READ\n");
- # line 434 "AdaptTemporary.puma"
- WriteTree (stdout, t);
- # line 435 "AdaptTemporary.puma"
- FileUnparse (stdout, t);
- # line 436 "AdaptTemporary.puma"
- kill_in_protocol ();
- }
- return;
-
- ;
- }
-
- static tTree AdaptTempACF
- # if defined __STDC__ | defined __cplusplus
- (register tTree t)
- # else
- (t)
- register tTree t;
- # endif
- {
- # line 449 "AdaptTemporary.puma"
-
- tObject Obj, Obj1;
- tTree newacf, hacf;
- int count;
-
-
- switch (t->Kind) {
- case kACF_LIST:
- # line 455 "AdaptTemporary.puma"
- {
- # line 456 "AdaptTemporary.puma"
- set_protocol_stmt (t->ACF_LIST.Elem);
- # line 457 "AdaptTemporary.puma"
- newacf = AdaptTempACF (t->ACF_LIST.Elem);
- t->ACF_LIST.Next = AdaptTempACF (t->ACF_LIST.Next);
- newacf = ReplaceACF (t, newacf, t->ACF_LIST.Next);
-
- }
- return newacf;
-
- case kACF_EMPTY:
- # line 464 "AdaptTemporary.puma"
- return t;
-
- case kACF_BASIC:
-
- switch (t->ACF_BASIC.BASIC_STMT->Kind) {
- case kIO_STMT:
- # line 468 "AdaptTemporary.puma"
- return t;
-
- case kALLOCATE_STMT:
- # line 480 "AdaptTemporary.puma"
- {
- # line 481 "AdaptTemporary.puma"
- SetAllocateShapes (t->ACF_BASIC.BASIC_STMT->ALLOCATE_STMT.PARAMS);
- }
- return t;
-
- case kDEALLOCATE_STMT:
- # line 485 "AdaptTemporary.puma"
- {
- # line 486 "AdaptTemporary.puma"
- ResetDeallocateShapes (t->ACF_BASIC.BASIC_STMT->DEALLOCATE_STMT.PARAMS);
- }
- return t;
-
- case kCALL_STMT:
- # line 490 "AdaptTemporary.puma"
- return t;
-
- case kREDUCE_STMT:
- # line 494 "AdaptTemporary.puma"
- return t;
-
- case kSTOP_STMT:
- # line 498 "AdaptTemporary.puma"
- return t;
-
- case kGOTO_STMT:
- # line 502 "AdaptTemporary.puma"
- return t;
-
- case kCOMP_IF_STMT:
- # line 506 "AdaptTemporary.puma"
- return t;
-
- case kASSIGN_STMT:
- # line 516 "AdaptTemporary.puma"
- {
- # line 517 "AdaptTemporary.puma"
- if (! (CountMovements (t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP) == 0)) goto yyL11;
- }
- return t;
- yyL11:;
-
- # line 522 "AdaptTemporary.puma"
- {
- # line 523 "AdaptTemporary.puma"
- stmt_protocol ("Old Statement requires movements");
- # line 524 "AdaptTemporary.puma"
- newacf = AdaptTempAssign (t);
- # line 525 "AdaptTemporary.puma"
- tree_protocol ("New Statements:\n", newacf);
- }
- return newacf;
-
- }
-
- # line 529 "AdaptTemporary.puma"
- return t;
-
- case kACF_DUMMY:
- # line 533 "AdaptTemporary.puma"
- return t;
-
- case kACF_WHILE:
- # line 537 "AdaptTemporary.puma"
- {
- # line 538 "AdaptTemporary.puma"
- if (! (t->ACF_WHILE.WHILE_BODY = AdaptTempACF (t->ACF_WHILE.WHILE_BODY))) goto yyL15;
- }
- return t;
- yyL15:;
-
- break;
- case kACF_DO:
- # line 542 "AdaptTemporary.puma"
- {
- # line 543 "AdaptTemporary.puma"
- if (! (t->ACF_DO.DO_BODY = AdaptTempACF (t->ACF_DO.DO_BODY))) goto yyL16;
- }
- return t;
- yyL16:;
-
- break;
- case kACF_DOLOCAL:
- # line 547 "AdaptTemporary.puma"
- return t;
-
- case kACF_FORALL:
- # line 552 "AdaptTemporary.puma"
- {
- # line 554 "AdaptTemporary.puma"
-
- forall_loops = 0;
- forall_mask = NoTree;
-
- AdaptTempForall (t);
-
- if (forall_new_assigns != NoTree)
- newacf = CombineACF (forall_new_assigns, mACF_LIST (t, NoTree));
- else
- newacf = t;
-
- }
- return newacf;
-
- case kACF_IF:
- # line 569 "AdaptTemporary.puma"
- {
- # line 571 "AdaptTemporary.puma"
- if (! (t->ACF_IF.THEN_PART = AdaptTempACF (t->ACF_IF.THEN_PART))) goto yyL19;
- {
- # line 572 "AdaptTemporary.puma"
- if (! (t->ACF_IF.ELSE_PART = AdaptTempACF (t->ACF_IF.ELSE_PART))) goto yyL19;
- }
- }
- return t;
- yyL19:;
-
- break;
- }
-
- if (t->Kind == kACF_WHERE) {
- # line 576 "AdaptTemporary.puma"
- {
- tTree where_list;
- {
- # line 578 "AdaptTemporary.puma"
-
- # line 580 "AdaptTemporary.puma"
- where_list = GetSplittedWhereList (t);
-
- if (TreeListLength (where_list) > 1)
-
- { tree_protocol ("splitted where : \n", where_list);
- if (WhereMaskUpdate (where_list))
- error_protocol ("update of where expression, needs a mask");
- }
-
- where_list = AdaptTempWhereList (where_list);
-
- }
- {
- return where_list;
- }
- }
-
- }
- if (Tree_IsType (t, kACF_NODE)) {
- # line 595 "AdaptTemporary.puma"
- {
- # line 596 "AdaptTemporary.puma"
- error_protocol ("This statement is not handled");
- }
- return t;
-
- }
- # line 600 "AdaptTemporary.puma"
- {
- # line 601 "AdaptTemporary.puma"
- tree_error_protocol ("AdaptTempACF failed", t);
- # line 602 "AdaptTemporary.puma"
- printf ("AdaptTempACF failed\n");
- # line 603 "AdaptTemporary.puma"
- WriteTree (stdout, t);
- # line 604 "AdaptTemporary.puma"
- kill_in_protocol ();
- }
- return t;
-
- }
-
- static tTree AdaptTempAssign
- # if defined __STDC__ | defined __cplusplus
- (register tTree assign)
- # else
- (assign)
- register tTree assign;
- # endif
- {
- # line 616 "AdaptTemporary.puma"
-
- int needed;
- int no;
- bool simple;
- tTree new_assigns;
-
- if (assign->Kind == kACF_BASIC) {
- if (assign->ACF_BASIC.BASIC_STMT->Kind == kASSIGN_STMT) {
- # line 629 "AdaptTemporary.puma"
- {
- # line 631 "AdaptTemporary.puma"
- if (IsVarInExp (TreeVarName(assign->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR), assign->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP))
- no = 1;
- else
- no = 0;
- simple = false;
-
- assign->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP = MakeLocalExpression (assign->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP, assign->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, no, simple, &needed, &new_assigns);
-
- new_assigns = CombineACF (new_assigns, mACF_LIST (assign, NoTree));
-
- }
- return new_assigns;
-
- }
- }
- # line 645 "AdaptTemporary.puma"
- {
- # line 646 "AdaptTemporary.puma"
- printf ("AdaptTempAssign failed\n");
- # line 647 "AdaptTemporary.puma"
- WriteTree (stdout, assign);
- # line 648 "AdaptTemporary.puma"
- kill_in_protocol ();
- }
- return NoTree;
-
- }
-
- static void AdaptTempForall
- # if defined __STDC__ | defined __cplusplus
- (register tTree t)
- # else
- (t)
- register tTree t;
- # endif
- {
- # line 666 "AdaptTemporary.puma"
-
- int count1, count2, needed, no;
- bool simple;
-
- if (t == NoTree) return;
- if (t->Kind == kACF_FORALL) {
- # line 671 "AdaptTemporary.puma"
- {
- # line 672 "AdaptTemporary.puma"
- forall_loopnest[forall_loops] = t;
- forall_loops += 1;
-
- # line 675 "AdaptTemporary.puma"
- AdaptTempForall (t->ACF_FORALL.FORALL_BODY);
- }
- return;
-
- }
- if (t->Kind == kACF_IF) {
- if (t->ACF_IF.ELSE_PART->Kind == kACF_EMPTY) {
- # line 678 "AdaptTemporary.puma"
- {
- # line 679 "AdaptTemporary.puma"
- if (forall_mask != NoTree)
- error_protocol ("only one IF allowed in FORALL");
- forall_mask = t->ACF_IF.IF_EXP;
-
- # line 683 "AdaptTemporary.puma"
- AdaptTempForall (t->ACF_IF.THEN_PART);
- }
- return;
-
- }
- }
- if (t->Kind == kACF_BASIC) {
- if (t->ACF_BASIC.BASIC_STMT->Kind == kASSIGN_STMT) {
- # line 686 "AdaptTemporary.puma"
- {
- # line 688 "AdaptTemporary.puma"
- count1 = CountMovements (t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP);
-
- no = 1;
- simple = false;
-
- if (forall_mask != NoTree)
- { count2 = CountMovements (t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, forall_mask);
- simple = true;
- }
- else
- count2 = 0;
-
-
-
- forall_new_assigns = NoTree;
-
- if (count2 > 0)
-
-
-
- error_protocol ("Assignment in FORALL with MASK requires movements");
-
- else if (count1 > 0)
-
- {
-
- stmt_protocol ("Assignment in FORALL requires movements");
-
- t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP = MakeLocalExpression (t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP, t->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, 1, simple,
- &needed, &forall_new_assigns);
-
- if (forall_new_assigns != NoTree)
- {
- ForallNewAssigns (forall_new_assigns, t->ACF_BASIC.Line);
- tree_protocol ("new assigns = \n", forall_new_assigns);
- };
- tree_protocol ("old statement becomes : \n", t);
- }
-
- }
- return;
-
- }
- }
- if (t->Kind == kACF_LIST) {
- if (t->ACF_LIST.Next->Kind == kACF_EMPTY) {
- # line 730 "AdaptTemporary.puma"
- {
- # line 731 "AdaptTemporary.puma"
- set_protocol_stmt (t->ACF_LIST.Elem);
- # line 732 "AdaptTemporary.puma"
- AdaptTempForall (t->ACF_LIST.Elem);
- }
- return;
-
- }
- # line 735 "AdaptTemporary.puma"
- {
- # line 736 "AdaptTemporary.puma"
- error_protocol ("Too many Statement in FORALL");
- }
- return;
-
- }
- # line 739 "AdaptTemporary.puma"
- {
- # line 740 "AdaptTemporary.puma"
- error_protocol ("Illegal statements in FORALL for Temporaries");
- }
- return;
-
- ;
- }
-
- static void ForallNewAssigns
- # if defined __STDC__ | defined __cplusplus
- (register tTree t, register int line)
- # else
- (t, line)
- register tTree t;
- register int line;
- # endif
- {
- if (t == NoTree) return;
- if (t->Kind == kACF_LIST) {
- # line 753 "AdaptTemporary.puma"
- {
- int i;
- tTree s;
- {
- # line 755 "AdaptTemporary.puma"
-
- # line 756 "AdaptTemporary.puma"
-
- # line 758 "AdaptTemporary.puma"
- s = t->ACF_LIST.Elem;
- s->ACF_NODE.Line = line;
- for (i=forall_loops-1; i>=0; i--)
- s = MakeOuterLoop (forall_loopnest[i], s);
- t->ACF_LIST.Elem = s;
- if (t->ACF_LIST.Next != NoTree)
- ForallNewAssigns (t->ACF_LIST.Next, line);
-
- }
- return;
- }
-
- }
- if (t->Kind == kACF_EMPTY) {
- # line 768 "AdaptTemporary.puma"
- return;
-
- }
- # line 771 "AdaptTemporary.puma"
- {
- # line 772 "AdaptTemporary.puma"
- printf ("Internal Error in AdaptTemporary: ForallNewAssigns (line = %d\n", line);
- # line 774 "AdaptTemporary.puma"
- FileUnparse (stdout, t);
- # line 775 "AdaptTemporary.puma"
- kill_in_protocol ();
- }
- return;
-
- ;
- }
-
- static tTree MakeOuterLoop
- # if defined __STDC__ | defined __cplusplus
- (register tTree loop, register tTree body)
- # else
- (loop, body)
- register tTree loop;
- register tTree body;
- # endif
- {
- # line 786 "AdaptTemporary.puma"
-
- tTree new;
-
- if (loop->Kind == kACF_FORALL) {
- # line 790 "AdaptTemporary.puma"
- {
- # line 791 "AdaptTemporary.puma"
- new = mACF_LIST (body, mACF_EMPTY ());
- new = mACF_FORALL (CopyTree(loop->ACF_FORALL.FORALL_ID), CopyTree(loop->ACF_FORALL.FORALL_RANGE), new);
- new->ACF_NODE.Line = loop->ACF_FORALL.Line;
- new->ACF_NODE.Label = 0;
-
- }
- return new;
-
- }
- yyAbort ("MakeOuterLoop");
- }
-
- static tTree AdaptTempWhereList
- # if defined __STDC__ | defined __cplusplus
- (register tTree t)
- # else
- (t)
- register tTree t;
- # endif
- {
- # line 819 "AdaptTemporary.puma"
- {
- # line 820 "AdaptTemporary.puma"
- if (! (t == NoTree)) goto yyL1;
- }
- return t;
- yyL1:;
-
- if (t->Kind == kACF_LIST) {
- # line 824 "AdaptTemporary.puma"
- return CombineACF (AdaptTempWhere (t->ACF_LIST.Elem), AdaptTempWhereList (t->ACF_LIST.Next));
-
- }
- yyAbort ("AdaptTempWhereList");
- }
-
- static tTree AdaptTempWhere
- # if defined __STDC__ | defined __cplusplus
- (register tTree t)
- # else
- (t)
- register tTree t;
- # endif
- {
- # line 845 "AdaptTemporary.puma"
-
- int count1, count2, needed, no;
- bool simple;
- tTree result, new_assigns;
-
- if (t->Kind == kACF_WHERE) {
- if (t->ACF_WHERE.TRUE_PART->Kind == kACF_EMPTY) {
- if (t->ACF_WHERE.FALSE_PART->Kind == kACF_EMPTY) {
- # line 851 "AdaptTemporary.puma"
- return mACF_LIST (t, NoTree);
-
- }
- # line 855 "AdaptTemporary.puma"
- {
- # line 859 "AdaptTemporary.puma"
- tree_error_protocol ("This call of AdaptTempWhere should not happen\n", t);
- }
- return mACF_LIST (t, NoTree);
-
- }
- if (t->ACF_WHERE.TRUE_PART->Kind == kACF_LIST) {
- if (t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->Kind == kACF_BASIC) {
- if (t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->Kind == kASSIGN_STMT) {
- # line 863 "AdaptTemporary.puma"
- {
- # line 867 "AdaptTemporary.puma"
- set_protocol_stmt (t);
- # line 869 "AdaptTemporary.puma"
-
-
- no = 1;
- simple = true;
-
- count1 = CountMovements (t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, t->ACF_WHERE.WHERE_EXP);
- count2 = CountMovements (t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP);
-
- result = NoTree;
-
- if (count1 > 0)
- { stmt_protocol ("WHERE requires movement due to mask");
-
- t->ACF_WHERE.WHERE_EXP = MakeLocalExpression (t->ACF_WHERE.WHERE_EXP, t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, no, simple,
- &needed, &new_assigns);
- no = needed + 1;
- tree_protocol ("New Asssigns : \n", new_assigns);
- stmt_protocol ("New WHERE");
-
- result = CombineACF (new_assigns, result);
- }
-
- if (count2 > 0)
- { stmt_protocol ("WHERE requires movement due to rhs of assign");
-
- t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP = MakeLocalExpression (t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_EXP, t->ACF_WHERE.TRUE_PART->ACF_LIST.Elem->
- ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR, no, simple,
- &needed, &new_assigns);
- tree_protocol ("New Asssigns : \n", new_assigns);
- stmt_protocol ("New WHERE");
-
- result = CombineACF (new_assigns, result);
- }
-
- result = CombineACF (result, mACF_LIST (t, NoTree));
-
-
- }
- return result;
-
- }
- }
- }
- }
- yyAbort ("AdaptTempWhere");
- }
-
- static bool WhereMaskUpdate
- # if defined __STDC__ | defined __cplusplus
- (register tTree wherelist)
- # else
- (wherelist)
- register tTree wherelist;
- # endif
- {
- if (wherelist == NoTree) return false;
- # line 920 "AdaptTemporary.puma"
- {
- # line 921 "AdaptTemporary.puma"
- if (! (wherelist == NoTree)) goto yyL1;
- {
- # line 922 "AdaptTemporary.puma"
- return false;
- }
- }
- yyL1:;
-
- if (wherelist->Kind == kACF_LIST) {
- # line 925 "AdaptTemporary.puma"
- {
- # line 926 "AdaptTemporary.puma"
- if (! (wherelist->ACF_LIST.Next == NoTree)) goto yyL2;
- {
- # line 927 "AdaptTemporary.puma"
- return false;
- }
- }
- yyL2:;
-
- if (wherelist->ACF_LIST.Elem->Kind == kACF_WHERE) {
- # line 930 "AdaptTemporary.puma"
- {
- # line 931 "AdaptTemporary.puma"
- if (! (HasMaskUpdate (wherelist->ACF_LIST.Elem->ACF_WHERE.WHERE_EXP, wherelist->ACF_LIST.Elem->ACF_WHERE.TRUE_PART))) goto yyL3;
- }
- return true;
- yyL3:;
-
- # line 934 "AdaptTemporary.puma"
- {
- # line 935 "AdaptTemporary.puma"
- if (! (HasMaskUpdate (wherelist->ACF_LIST.Elem->ACF_WHERE.WHERE_EXP, wherelist->ACF_LIST.Elem->ACF_WHERE.FALSE_PART))) goto yyL4;
- }
- return true;
- yyL4:;
-
- # line 938 "AdaptTemporary.puma"
- {
- # line 939 "AdaptTemporary.puma"
- if (! (WhereMaskUpdate (wherelist->ACF_LIST.Next))) goto yyL5;
- }
- return true;
- yyL5:;
-
- }
- }
- return false;
- }
-
- static bool HasMaskUpdate
- # if defined __STDC__ | defined __cplusplus
- (register tTree mask, register tTree stmtlist)
- # else
- (mask, stmtlist)
- register tTree mask;
- register tTree stmtlist;
- # endif
- {
- if (mask == NoTree) return false;
- if (stmtlist == NoTree) return false;
- if (stmtlist->Kind == kACF_LIST) {
- # line 952 "AdaptTemporary.puma"
- {
- # line 953 "AdaptTemporary.puma"
- if (! (HasMaskUpdate (mask, stmtlist->ACF_LIST.Elem))) goto yyL1;
- }
- return true;
- yyL1:;
-
- # line 956 "AdaptTemporary.puma"
- {
- # line 957 "AdaptTemporary.puma"
- if (! (stmtlist->ACF_LIST.Next != NoTree)) goto yyL2;
- {
- # line 958 "AdaptTemporary.puma"
- if (! (HasMaskUpdate (mask, stmtlist->ACF_LIST.Next))) goto yyL2;
- }
- }
- return true;
- yyL2:;
-
- }
- if (stmtlist->Kind == kACF_BASIC) {
- if (stmtlist->ACF_BASIC.BASIC_STMT->Kind == kASSIGN_STMT) {
- # line 961 "AdaptTemporary.puma"
- {
- # line 962 "AdaptTemporary.puma"
- if (! (IsVarInExp (TreeVarName (stmtlist->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR), mask) == true)) goto yyL3;
- {
- # line 963 "AdaptTemporary.puma"
- tree_error_protocol ("assignment updates mask : ", stmtlist->ACF_BASIC.BASIC_STMT);
- # line 964 "AdaptTemporary.puma"
- tree_protocol ("mask is : ", mask);
- }
- }
- return true;
- yyL3:;
-
- }
- }
- return false;
- }
-
- static tTree GetSplittedWhereList
- # if defined __STDC__ | defined __cplusplus
- (register tTree t)
- # else
- (t)
- register tTree t;
- # endif
- {
- if (t->Kind == kACF_WHERE) {
- if (t->ACF_WHERE.TRUE_PART->Kind == kACF_LIST) {
- # line 979 "AdaptTemporary.puma"
- {
- tTree new_where;
- tTree help;
- {
- # line 981 "AdaptTemporary.puma"
- if (! (HasWhereMovement (t->ACF_WHERE.TRUE_PART, t->ACF_WHERE.WHERE_EXP))) goto yyL1;
- {
- # line 983 "AdaptTemporary.puma"
- if (! (((TreeListLength (t->ACF_WHERE.TRUE_PART->ACF_LIST.Next) > 0) || (TreeListLength (t->ACF_WHERE.FALSE_PART) > 0)))) goto yyL1;
- {
- # line 987 "AdaptTemporary.puma"
-
- # line 988 "AdaptTemporary.puma"
-
- # line 990 "AdaptTemporary.puma"
- help = t->ACF_WHERE.TRUE_PART->ACF_LIST.Next;
- t->ACF_WHERE.TRUE_PART->ACF_LIST.Next = mACF_EMPTY();
- new_where = SplitWhere (t, t->ACF_WHERE.TRUE_PART, mACF_EMPTY(), help, t->ACF_WHERE.FALSE_PART);
- new_where = GetSplittedWhereList (new_where);
-
- }
- }
- }
- {
- return CombineACF (t, new_where);
- }
- }
- yyL1:;
-
- # line 1001 "AdaptTemporary.puma"
- {
- tTree yyV1;
- tTree yyV2;
- tTree new_where;
- {
- # line 1003 "AdaptTemporary.puma"
- ListSplitUp (t->ACF_WHERE.TRUE_PART, t->ACF_WHERE.WHERE_EXP, & yyV1, & yyV2);
- # line 1005 "AdaptTemporary.puma"
- if (! (yyV2 != NoTree)) goto yyL2;
- {
- # line 1007 "AdaptTemporary.puma"
-
- # line 1009 "AdaptTemporary.puma"
- new_where = SplitWhere (t, yyV1, mACF_EMPTY(), yyV2, t->ACF_WHERE.FALSE_PART);
- new_where = GetSplittedWhereList (new_where);
-
- }
- }
- {
- return CombineACF (t, new_where);
- }
- }
- yyL2:;
-
- # line 1016 "AdaptTemporary.puma"
- {
- tTree new_where;
- {
- # line 1021 "AdaptTemporary.puma"
- if (! (HasWhereMovement (t->ACF_WHERE.FALSE_PART, t->ACF_WHERE.WHERE_EXP))) goto yyL3;
- {
- # line 1023 "AdaptTemporary.puma"
-
- # line 1024 "AdaptTemporary.puma"
- if (! (new_where = SplitWhere (t, t->ACF_WHERE.TRUE_PART, mACF_EMPTY (), mACF_EMPTY (), t->ACF_WHERE.FALSE_PART))) goto yyL3;
- {
- # line 1025 "AdaptTemporary.puma"
- if (! (new_where = GetSplittedWhereList (new_where))) goto yyL3;
- }
- }
- }
- {
- return CombineACF (t, new_where);
- }
- }
- yyL3:;
-
- }
- if (t->ACF_WHERE.TRUE_PART->Kind == kACF_EMPTY) {
- if (t->ACF_WHERE.FALSE_PART->Kind == kACF_LIST) {
- # line 1029 "AdaptTemporary.puma"
- {
- tTree h;
- {
- # line 1033 "AdaptTemporary.puma"
-
- # line 1035 "AdaptTemporary.puma"
- t->ACF_WHERE.WHERE_EXP = MakeNotExp (t->ACF_WHERE.WHERE_EXP);
- h = t->ACF_WHERE.FALSE_PART;
- t->ACF_WHERE.FALSE_PART = t->ACF_WHERE.TRUE_PART;
- t->ACF_WHERE.TRUE_PART = h;
-
- }
- {
- return GetSplittedWhereList (t);
- }
- }
-
- }
- }
- if (t->ACF_WHERE.FALSE_PART->Kind == kACF_LIST) {
- # line 1044 "AdaptTemporary.puma"
- {
- tTree yyV1;
- tTree yyV2;
- tTree new_where;
- {
- # line 1046 "AdaptTemporary.puma"
- ListSplitUp (t->ACF_WHERE.FALSE_PART, t->ACF_WHERE.WHERE_EXP, & yyV1, & yyV2);
- # line 1048 "AdaptTemporary.puma"
- if (! (yyV2 != NoTree)) goto yyL5;
- {
- # line 1050 "AdaptTemporary.puma"
-
- # line 1052 "AdaptTemporary.puma"
- if (! (new_where = SplitWhere (t, t->ACF_WHERE.TRUE_PART, yyV1, mACF_EMPTY (), yyV2))) goto yyL5;
- {
- # line 1053 "AdaptTemporary.puma"
- if (! (new_where = GetSplittedWhereList (new_where))) goto yyL5;
- }
- }
- }
- {
- return CombineACF (t, new_where);
- }
- }
- yyL5:;
-
- }
- # line 1057 "AdaptTemporary.puma"
- return mACF_LIST (t, NoTree);
-
- }
- yyAbort ("GetSplittedWhereList");
- }
-
- static tTree SplitWhere
- # if defined __STDC__ | defined __cplusplus
- (register tTree wherestmt, register tTree tp1, register tTree fp1, register tTree tp2, register tTree fp2)
- # else
- (wherestmt, tp1, fp1, tp2, fp2)
- register tTree wherestmt;
- register tTree tp1;
- register tTree fp1;
- register tTree tp2;
- register tTree fp2;
- # endif
- {
- if (wherestmt->Kind == kACF_WHERE) {
- # line 1082 "AdaptTemporary.puma"
- {
- tTree new_where;
- {
- # line 1084 "AdaptTemporary.puma"
-
- # line 1086 "AdaptTemporary.puma"
- new_where = mACF_WHERE (CopyTree(wherestmt->ACF_WHERE.WHERE_EXP), tp2, fp2);
- new_where->ACF_NODE.Label = wherestmt->ACF_WHERE.Label;
- new_where->ACF_NODE.Line = wherestmt->ACF_WHERE.Line;
- wherestmt->ACF_WHERE.TRUE_PART = tp1;
- wherestmt->ACF_WHERE.FALSE_PART = fp1;
- NormalizeWhere (wherestmt);
- NormalizeWhere (new_where);
-
- }
- {
- return new_where;
- }
- }
-
- }
- yyAbort ("SplitWhere");
- }
-
- static void NormalizeWhere
- # if defined __STDC__ | defined __cplusplus
- (register tTree wherestmt)
- # else
- (wherestmt)
- register tTree wherestmt;
- # endif
- {
- if (wherestmt == NoTree) return;
- if (wherestmt->Kind == kACF_WHERE) {
- if (wherestmt->ACF_WHERE.TRUE_PART->Kind == kACF_EMPTY) {
- if (wherestmt->ACF_WHERE.FALSE_PART->Kind == kACF_EMPTY) {
- # line 1109 "AdaptTemporary.puma"
- {
- # line 1111 "AdaptTemporary.puma"
- printf ("Empty WHERE statement will be normalized\n");
- # line 1112 "AdaptTemporary.puma"
- kill_in_protocol ();
- }
- return;
-
- }
- # line 1115 "AdaptTemporary.puma"
- {
- tTree h;
- {
- # line 1117 "AdaptTemporary.puma"
-
- # line 1119 "AdaptTemporary.puma"
- wherestmt->ACF_WHERE.WHERE_EXP = MakeNotExp (wherestmt->ACF_WHERE.WHERE_EXP);
- h = wherestmt->ACF_WHERE.FALSE_PART;
- wherestmt->ACF_WHERE.FALSE_PART = wherestmt->ACF_WHERE.TRUE_PART;
- wherestmt->ACF_WHERE.TRUE_PART = h;
-
- }
- return;
- }
-
- }
- }
- ;
- }
-
- static void ListSplitUp
- # if defined __STDC__ | defined __cplusplus
- (register tTree list, register tTree mask, register tTree * s1, register tTree * s2)
- # else
- (list, mask, s1, s2)
- register tTree list;
- register tTree mask;
- register tTree * s1;
- register tTree * s2;
- # endif
- {
- if (list == NoTree) return;
- if (mask == NoTree) return;
- if (list->Kind == kACF_LIST) {
- if (list->ACF_LIST.Next->Kind == kACF_EMPTY) {
- # line 1141 "AdaptTemporary.puma"
- * s1 = list;
- * s2 = NoTree;
- return;
-
- }
- # line 1144 "AdaptTemporary.puma"
- {
- tTree l1;
- tTree l2;
- {
- # line 1146 "AdaptTemporary.puma"
- if (! (HasWhereMovement (list->ACF_LIST.Next, mask))) goto yyL2;
- {
- # line 1148 "AdaptTemporary.puma"
-
- # line 1149 "AdaptTemporary.puma"
-
- # line 1151 "AdaptTemporary.puma"
- l2 = list->ACF_LIST.Next;
- list->ACF_LIST.Next = mACF_EMPTY ();
- l1 = list;
-
- }
- }
- * s1 = l1;
- * s2 = l2;
- return;
- }
- yyL2:;
-
- # line 1157 "AdaptTemporary.puma"
- {
- tTree back;
- tTree yyV1;
- tTree yyV2;
- {
- # line 1159 "AdaptTemporary.puma"
-
- # line 1161 "AdaptTemporary.puma"
- ListSplitUp (list->ACF_LIST.Next, mask, & yyV1, & yyV2);
- # line 1163 "AdaptTemporary.puma"
- list->ACF_LIST.Next = yyV1;
- back = list;
-
- }
- * s1 = back;
- * s2 = yyV2;
- return;
- }
-
- }
- ;
- }
-
- static bool HasWhereMovement
- # if defined __STDC__ | defined __cplusplus
- (register tTree stmt, register tTree where_exp)
- # else
- (stmt, where_exp)
- register tTree stmt;
- register tTree where_exp;
- # endif
- {
- if (stmt == NoTree) return false;
- if (where_exp == NoTree) return false;
- if (stmt->Kind == kACF_LIST) {
- # line 1176 "AdaptTemporary.puma"
- {
- # line 1177 "AdaptTemporary.puma"
- if (! (HasWhereMovement (stmt->ACF_LIST.Elem, where_exp))) goto yyL1;
- }
- return true;
- yyL1:;
-
- }
- if (stmt->Kind == kACF_BASIC) {
- # line 1180 "AdaptTemporary.puma"
- {
- # line 1181 "AdaptTemporary.puma"
- if (! (HasWhereMovement (stmt->ACF_BASIC.BASIC_STMT, where_exp))) goto yyL2;
- }
- return true;
- yyL2:;
-
- }
- if (stmt->Kind == kASSIGN_STMT) {
- # line 1184 "AdaptTemporary.puma"
- {
- # line 1185 "AdaptTemporary.puma"
- if (! (CountMovements (stmt->ASSIGN_STMT.ASSIGN_VAR, where_exp) > 0)) goto yyL3;
- }
- return true;
- yyL3:;
-
- # line 1188 "AdaptTemporary.puma"
- {
- # line 1189 "AdaptTemporary.puma"
- if (! (CountMovements (stmt->ASSIGN_STMT.ASSIGN_VAR, stmt->ASSIGN_STMT.ASSIGN_EXP) > 0)) goto yyL4;
- }
- return true;
- yyL4:;
-
- }
- return false;
- }
-
- void BeginAdaptTemporary ()
- {
- }
-
- void CloseAdaptTemporary ()
- {
- }