home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adaptor.zip / adapt.zip / adaptor / src / adaptdol.c < prev    next >
Text File  |  1994-01-03  |  20KB  |  837 lines

  1. # include "DoLocal.h"
  2. # include "yyADoLoc.w"
  3. # include <stdio.h>
  4. # if defined __STDC__ | defined __cplusplus
  5. #  include <stdlib.h>
  6. # else
  7.    extern void exit ();
  8. # endif
  9. # include "Tree.h"
  10. # include "Definiti.h"
  11.  
  12. # ifndef NULL
  13. # define NULL 0L
  14. # endif
  15. # ifndef false
  16. # define false 0
  17. # endif
  18. # ifndef true
  19. # define true 1
  20. # endif
  21.  
  22. # ifdef yyInline
  23. # define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) \
  24.   if ((ptr = (tree) free) >= (tree) max) ptr = alloc (); \
  25.   free += nodesize [kind]; \
  26.   ptr->yyHead.yyMark = 0; \
  27.   ptr->Kind = kind;
  28. # else
  29. # define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) ptr = make (kind);
  30. # endif
  31.  
  32. # define yyWrite(s) (void) fputs (s, yyf)
  33. # define yyWriteNl (void) fputc ('\n', yyf)
  34.  
  35. # line 19 "AdaptDoLocal.puma"
  36.  
  37. # include <stdio.h>
  38. # include "Idents.h"
  39. # include "StringMe.h"
  40.  
  41. # include "protocol.h"
  42.  
  43. # include "Types.h"
  44. # include "Transfor.h"        /* CombineACF, ReplaceACF, ExpToVarParam */
  45. # include "Local.h"       /* MakeMask, LocalDOLOCAL */
  46. # include "Reductio.h"       /* GlobalReductionStmt, ResolveReduce  */
  47.  
  48. # include "Dalib.h"            /* MakeSizeExp */
  49. # include "NormalLo.h"       /* NormalLoop */
  50.  
  51. # define MAXForall 10
  52.  
  53. /*********************************************************************
  54. *                                                                    *
  55. *  Nest[0]          DOLOCAL I1 = ...                                  *
  56. *  Nest[1]          DOLOCAL I2 = ...                                  *
  57. *  ...                                                               *
  58. *  Nest[Nesting-1]  DOLOCAL Ik = ...                                  *
  59. *                                                                    *
  60. *    parvar    :         A(I1,I2,...,Ik)                             *
  61. *                                                                    *
  62. *********************************************************************/
  63.  
  64. static int   Nesting;          /* current nesting */
  65. static int   MaxNesting;       /* maximal nesting */
  66. static tTree Nest[MAXForall];  /* DOLOCAL loops for maximal nesting */
  67. static bool  found;            /* true if parallel variable found */
  68. static tTree parvar;           /* is parallel variable if found   */
  69.  
  70.  
  71.  
  72. static FILE * yyf = stdout;
  73.  
  74. static void yyAbort
  75. # ifdef __cplusplus
  76.  (char * yyFunction)
  77. # else
  78.  (yyFunction) char * yyFunction;
  79. # endif
  80. {
  81.  (void) fprintf (stderr, "Error: module AdaptDoLocal, routine %s failed\n", yyFunction);
  82.  exit (1);
  83. }
  84.  
  85. tTree TransformDoLocal ARGS((tTree t));
  86. static tTree DOLOCAL_do_it ARGS((tTree t, tTree parvar, int dist));
  87. static bool IsExpLoopId ARGS((tTree exp, tTree id));
  88. static bool LoopInvariant ARGS((tTree exp));
  89. static void FindParVariable ARGS((tTree body));
  90. static void FindReduceVariable ARGS((tTree body));
  91. static tTree CollectREDUCE ARGS((tTree t));
  92. static tTree GlobalLocExchange ARGS((tTree params));
  93. static tTree TransformSerialBody ARGS((tTree t));
  94.  
  95. tTree TransformDoLocal
  96. # if defined __STDC__ | defined __cplusplus
  97. (register tTree t)
  98. # else
  99. (t)
  100.  register tTree t;
  101. # endif
  102. {
  103. # line 63 "AdaptDoLocal.puma"
  104.  
  105. tTree newacf;
  106. char msg[100], n[100];
  107.  
  108.   if (t->Kind == kACF_DOLOCAL) {
  109. # line 68 "AdaptDoLocal.puma"
  110.   {
  111. # line 70 "AdaptDoLocal.puma"
  112.  
  113.  
  114.      Nesting    = 0;
  115.      MaxNesting = 0;
  116.      found      = false;
  117.      FindParVariable (t);
  118.  
  119.      if (!found)
  120.        { error_protocol ("No indexed Variable in DOLOCAL");
  121.          printf ("DOLOCAL (line=%d), no indexed variable\n", t->ACF_DOLOCAL.Line);
  122.          newacf = t;
  123.        }
  124.       else
  125.        { GetString (TreeVarName(t->ACF_DOLOCAL.DOLOCAL_ID), n);
  126.          sprintf (msg, "DOLOCAL %s (line=%d) is scheduled on ", n, t->ACF_DOLOCAL.Line);
  127.          tree_protocol (msg, parvar);
  128.          newacf = DOLOCAL_do_it (t, parvar, TreeDistribution (parvar));
  129.        }
  130.  
  131.   }
  132.    return newacf;
  133.  
  134.   }
  135.  yyAbort ("TransformDoLocal");
  136. }
  137.  
  138. static tTree DOLOCAL_do_it
  139. # if defined __STDC__ | defined __cplusplus
  140. (register tTree t, register tTree parvar, register int dist)
  141. # else
  142. (t, parvar, dist)
  143.  register tTree t;
  144.  register tTree parvar;
  145.  register int dist;
  146. # endif
  147. {
  148. # line 102 "AdaptDoLocal.puma"
  149.  
  150. int   i;
  151. tTree pl;
  152.  
  153.   if (t->Kind == kACF_DOLOCAL) {
  154.   if (equalint (dist, 0)) {
  155. # line 117 "AdaptDoLocal.puma"
  156.   {
  157. # line 121 "AdaptDoLocal.puma"
  158.  t->ACF_DOLOCAL.DOLOCAL_BODY = TransformSerialBody (t->ACF_DOLOCAL.DOLOCAL_BODY);
  159.      t->Kind = kACF_DOVEC;
  160.  
  161.   }
  162.    return t;
  163.  
  164.   }
  165.  {
  166.   tTree new;
  167.   if (equalint (dist, - 1)) {
  168. # line 138 "AdaptDoLocal.puma"
  169.   {
  170. # line 142 "AdaptDoLocal.puma"
  171.  
  172. # line 144 "AdaptDoLocal.puma"
  173.  for (i=0;i<MaxNesting;i++)
  174.         { pl = Nest[i];
  175.           pl->Kind = kACF_DOVEC;
  176.         }
  177.      new = mACF_ON (parvar, t);
  178.      new->ACF_NODE.Label = t->ACF_DOLOCAL.Label;
  179.      new->ACF_NODE.Line  = t->ACF_DOLOCAL.Line;
  180.  
  181.   }
  182.   {
  183.    return new;
  184.   }
  185.  
  186.   }
  187.  }
  188.   if (parvar->Kind == kINDEXED_VAR) {
  189.  {
  190.   tTree new;
  191.   if (equalint (dist, 1)) {
  192. # line 168 "AdaptDoLocal.puma"
  193.   {
  194. # line 172 "AdaptDoLocal.puma"
  195.    if (! (IsExpLoopId (LastIndex (parvar->INDEXED_VAR.IND_EXPS), t->ACF_DOLOCAL.DOLOCAL_ID))) goto yyL3;
  196.   {
  197. # line 176 "AdaptDoLocal.puma"
  198.  
  199. # line 178 "AdaptDoLocal.puma"
  200.  for (i=1;i<MaxNesting;i++)
  201.         { pl = Nest[i];
  202.           pl->Kind = kACF_DOVEC;
  203.         }
  204.      new = mACF_ON (parvar, t);
  205.      new->ACF_NODE.Label = t->ACF_DOLOCAL.Label;
  206.      new->ACF_NODE.Line  = t->ACF_DOLOCAL.Line;
  207.  
  208.   }
  209.   }
  210.   {
  211.    return new;
  212.   }
  213. yyL3:;
  214.  
  215.   }
  216.  }
  217.  {
  218.   bool found;
  219.   bool error;
  220.   int a;
  221.   int b;
  222.   tTree var;
  223.   tTree new;
  224.   if (equalint (dist, 1)) {
  225. # line 203 "AdaptDoLocal.puma"
  226.   {
  227. # line 205 "AdaptDoLocal.puma"
  228.    if (! (IsVarInExp (TreeVarName (t->ACF_DOLOCAL.DOLOCAL_ID), LastIndex (parvar->INDEXED_VAR.IND_EXPS)) == true)) goto yyL4;
  229.   {
  230. # line 207 "AdaptDoLocal.puma"
  231.  
  232. # line 208 "AdaptDoLocal.puma"
  233.  
  234. # line 209 "AdaptDoLocal.puma"
  235.  
  236. # line 210 "AdaptDoLocal.puma"
  237.  
  238. # line 211 "AdaptDoLocal.puma"
  239.  
  240. # line 212 "AdaptDoLocal.puma"
  241.  
  242. # line 214 "AdaptDoLocal.puma"
  243.  new = t;
  244.  
  245.      ResolveExpression (LastIndex(parvar->INDEXED_VAR.IND_EXPS), &found, &a, &b, &var);
  246.      error = (    (!found)
  247.                || (a != 1)
  248.                || (TreeVarName (var) != TreeVarName(t->ACF_DOLOCAL.DOLOCAL_ID))
  249.              );
  250.  
  251.      if (!error)
  252.        {
  253.  
  254.          stmt_protocol ("loop will be shifted");
  255.          tree_protocol ("variable for normalizatin : ", parvar);
  256.  
  257.          NormalLoop (new, b);
  258.  
  259.          stmt_protocol ("loop after shifting");
  260.  
  261.          for (i=1;i<MaxNesting;i++)
  262.           { pl = Nest[i];
  263.             pl->Kind = kACF_DOVEC;
  264.           }
  265.          new = mACF_ON (parvar, t);
  266.          new->ACF_NODE.Label = t->ACF_DOLOCAL.Label;
  267.          new->ACF_NODE.Line  = t->ACF_DOLOCAL.Line;
  268.  
  269.        }
  270.       else
  271.        { error_protocol ("parallel do loop has not normal index");
  272.          tree_protocol  ("lastindex = ", LastIndex (parvar->INDEXED_VAR.IND_EXPS));
  273.          tree_protocol  ("depends on this loop variable : ", t->ACF_DOLOCAL.DOLOCAL_ID);
  274.        }
  275.  
  276.   }
  277.   }
  278.   {
  279.    return new;
  280.   }
  281. yyL4:;
  282.  
  283.   }
  284.  }
  285.  {
  286.   tTree new;
  287.   if (equalint (dist, 1)) {
  288. # line 264 "AdaptDoLocal.puma"
  289.   {
  290. # line 266 "AdaptDoLocal.puma"
  291.    if (! (LoopInvariant (LastIndex (parvar->INDEXED_VAR.IND_EXPS)) == true)) goto yyL5;
  292.   {
  293. # line 268 "AdaptDoLocal.puma"
  294.  
  295. # line 270 "AdaptDoLocal.puma"
  296.  for (i=0;i<MaxNesting;i++)
  297.         { pl = Nest[i];
  298.           pl->Kind = kACF_DOVEC;
  299.         }
  300.      new = mACF_ON (parvar, t);
  301.      new->ACF_NODE.Label = t->ACF_DOLOCAL.Label;
  302.      new->ACF_NODE.Line  = t->ACF_DOLOCAL.Line;
  303.  
  304.   }
  305.   }
  306.   {
  307.    return new;
  308.   }
  309. yyL5:;
  310.  
  311.   }
  312.  }
  313.   if (equalint (dist, 1)) {
  314. # line 296 "AdaptDoLocal.puma"
  315.   {
  316. # line 298 "AdaptDoLocal.puma"
  317.  t->ACF_DOLOCAL.DOLOCAL_BODY = TransformSerialBody (t->ACF_DOLOCAL.DOLOCAL_BODY);
  318.      t->Kind = kACF_DOVEC;
  319.  
  320.   }
  321.    return t;
  322.  
  323.   }
  324.   }
  325.   }
  326.  yyAbort ("DOLOCAL_do_it");
  327. }
  328.  
  329. static bool IsExpLoopId
  330. # if defined __STDC__ | defined __cplusplus
  331. (register tTree exp, register tTree id)
  332. # else
  333. (exp, id)
  334.  register tTree exp;
  335.  register tTree id;
  336. # endif
  337. {
  338.   if (exp == NoTree) return false;
  339.   if (id == NoTree) return false;
  340.   if (exp->Kind == kVAR_EXP) {
  341. # line 307 "AdaptDoLocal.puma"
  342.   {
  343. # line 308 "AdaptDoLocal.puma"
  344.    if (! (TreeVarName (id) == TreeVarName (exp->VAR_EXP.V))) goto yyL1;
  345.   }
  346.    return true;
  347. yyL1:;
  348.  
  349.   }
  350.   return false;
  351. }
  352.  
  353. static bool LoopInvariant
  354. # if defined __STDC__ | defined __cplusplus
  355. (register tTree exp)
  356. # else
  357. (exp)
  358.  register tTree exp;
  359. # endif
  360. {
  361. # line 321 "AdaptDoLocal.puma"
  362.  {
  363.   tIdent name;
  364.   bool it_is;
  365.   tTree pl;
  366.   int i;
  367.   {
  368. # line 323 "AdaptDoLocal.puma"
  369.  
  370. # line 324 "AdaptDoLocal.puma"
  371.  
  372. # line 325 "AdaptDoLocal.puma"
  373.  
  374. # line 326 "AdaptDoLocal.puma"
  375.  
  376. # line 328 "AdaptDoLocal.puma"
  377.  it_is = true;
  378.  
  379.      for (i=0; i<MaxNesting; i++)
  380.        { name = TreeVarName ((Nest[i])->ACF_DOLOCAL.DOLOCAL_ID);
  381.          it_is = it_is && (!IsVarInExp (name, exp));
  382.        }
  383.  
  384.   }
  385.   {
  386.    return it_is;
  387.   }
  388.  }
  389.  
  390. }
  391.  
  392. static void FindParVariable
  393. # if defined __STDC__ | defined __cplusplus
  394. (register tTree body)
  395. # else
  396. (body)
  397.  register tTree body;
  398. # endif
  399. {
  400.   if (body == NoTree) return;
  401.  
  402.   switch (body->Kind) {
  403.   case kACF_LIST:
  404. # line 352 "AdaptDoLocal.puma"
  405.   {
  406. # line 353 "AdaptDoLocal.puma"
  407.    FindParVariable (body->ACF_LIST.Elem);
  408. # line 354 "AdaptDoLocal.puma"
  409.    FindParVariable (body->ACF_LIST.Next);
  410.   }
  411.    return;
  412.  
  413.   case kACF_EMPTY:
  414. # line 357 "AdaptDoLocal.puma"
  415.    return;
  416.  
  417.   case kACF_DOLOCAL:
  418. # line 360 "AdaptDoLocal.puma"
  419.   {
  420. # line 361 "AdaptDoLocal.puma"
  421.  if (Nesting < MaxNesting)
  422.        simple_error_protocol ("unstructured parfor nesting");
  423.      else
  424.        MaxNesting += 1;
  425.     Nest [Nesting] = body;
  426.     Nesting += 1;
  427.     FindParVariable (body->ACF_DOLOCAL.DOLOCAL_BODY);
  428.  
  429.   }
  430.    return;
  431.  
  432.   case kACF_IF:
  433. # line 371 "AdaptDoLocal.puma"
  434.   {
  435. # line 372 "AdaptDoLocal.puma"
  436.    FindParVariable (body->ACF_IF.THEN_PART);
  437. # line 373 "AdaptDoLocal.puma"
  438.    FindParVariable (body->ACF_IF.ELSE_PART);
  439.   }
  440.    return;
  441.  
  442.   case kACF_WHILE:
  443. # line 376 "AdaptDoLocal.puma"
  444.   {
  445. # line 377 "AdaptDoLocal.puma"
  446.    FindParVariable (body->ACF_WHILE.WHILE_BODY);
  447.   }
  448.    return;
  449.  
  450.   case kACF_DO:
  451. # line 380 "AdaptDoLocal.puma"
  452.   {
  453. # line 381 "AdaptDoLocal.puma"
  454.    FindParVariable (body->ACF_DO.DO_BODY);
  455.   }
  456.    return;
  457.  
  458.   case kACF_BASIC:
  459.   if (body->ACF_BASIC.BASIC_STMT->Kind == kREDUCE_STMT) {
  460.   if (body->ACF_BASIC.BASIC_STMT->REDUCE_STMT.RED_PARAMS->Kind == kBTP_LIST) {
  461.   if (body->ACF_BASIC.BASIC_STMT->REDUCE_STMT.RED_PARAMS->BTP_LIST.Next->Kind == kBTP_LIST) {
  462. # line 384 "AdaptDoLocal.puma"
  463.   {
  464. # line 386 "AdaptDoLocal.puma"
  465.    FindReduceVariable (body->ACF_BASIC.BASIC_STMT->REDUCE_STMT.RED_PARAMS->BTP_LIST.Next->BTP_LIST.Elem);
  466.   }
  467.    return;
  468.  
  469.   }
  470.   }
  471.   }
  472.   if (body->ACF_BASIC.BASIC_STMT->Kind == kASSIGN_STMT) {
  473. # line 389 "AdaptDoLocal.puma"
  474.   {
  475. # line 390 "AdaptDoLocal.puma"
  476.    FindParVariable (body->ACF_BASIC.BASIC_STMT->ASSIGN_STMT.ASSIGN_VAR);
  477.   }
  478.    return;
  479.  
  480.   }
  481. # line 393 "AdaptDoLocal.puma"
  482.    return;
  483.  
  484.   case kACF_DUMMY:
  485. # line 397 "AdaptDoLocal.puma"
  486.    return;
  487.  
  488.   case kACF_FORALL:
  489. # line 400 "AdaptDoLocal.puma"
  490.   {
  491. # line 401 "AdaptDoLocal.puma"
  492.    error_protocol ("FORALL in DO !parallel, should not happen");
  493.   }
  494.    return;
  495.  
  496.   case kUSED_VAR:
  497. # line 404 "AdaptDoLocal.puma"
  498.    return;
  499.  
  500.   case kINDEXED_VAR:
  501. # line 407 "AdaptDoLocal.puma"
  502.   {
  503. # line 408 "AdaptDoLocal.puma"
  504.  if (found)
  505.       {
  506.          if (    (TreeDistribution (parvar) != 0)
  507.               && (CountMovements (parvar, body) > 0)  )
  508.            { error_protocol ("moving conflict in parallel do loop");
  509.              tree_protocol ("parallel (on) variable is : ", parvar);
  510.              tree_protocol ("this variable is not conform : ", body);
  511.            }
  512.       }
  513.      else
  514.       { found = true;
  515.         parvar = body;
  516.       }
  517.  
  518.   }
  519.    return;
  520.  
  521.   }
  522.  
  523. # line 424 "AdaptDoLocal.puma"
  524.   {
  525. # line 425 "AdaptDoLocal.puma"
  526.    printf ("FindParVariable failed for \n");
  527. # line 426 "AdaptDoLocal.puma"
  528.    FileUnparse (stdout, body);
  529. # line 427 "AdaptDoLocal.puma"
  530.    WriteTree (stdout, body);
  531. # line 428 "AdaptDoLocal.puma"
  532.    exit (- 1);
  533.   }
  534.    return;
  535.  
  536. ;
  537. }
  538.  
  539. static void FindReduceVariable
  540. # if defined __STDC__ | defined __cplusplus
  541. (register tTree body)
  542. # else
  543. (body)
  544.  register tTree body;
  545. # endif
  546. {
  547. # line 435 "AdaptDoLocal.puma"
  548.  
  549. tTree reducevar;
  550.  
  551.   if (body == NoTree) return;
  552.   if (body->Kind == kVAR_PARAM) {
  553.   if (body->VAR_PARAM.V->Kind == kADDR) {
  554. # line 441 "AdaptDoLocal.puma"
  555.   {
  556. # line 442 "AdaptDoLocal.puma"
  557.    FindReduceVariable (body->VAR_PARAM.V->ADDR.E);
  558.   }
  559.    return;
  560.  
  561.   }
  562. # line 445 "AdaptDoLocal.puma"
  563.   {
  564. # line 446 "AdaptDoLocal.puma"
  565.    FindParVariable (body->VAR_PARAM.V);
  566.   }
  567.    return;
  568.  
  569.   }
  570.   if (body->Kind == kVAR_EXP) {
  571. # line 449 "AdaptDoLocal.puma"
  572.   {
  573. # line 450 "AdaptDoLocal.puma"
  574.    FindParVariable (body->VAR_EXP.V);
  575.   }
  576.    return;
  577.  
  578.   }
  579.   if (body->Kind == kOP_EXP) {
  580. # line 453 "AdaptDoLocal.puma"
  581.   {
  582. # line 454 "AdaptDoLocal.puma"
  583.    FindReduceVariable (body->OP_EXP.OPND1);
  584. # line 455 "AdaptDoLocal.puma"
  585.    FindReduceVariable (body->OP_EXP.OPND2);
  586.   }
  587.    return;
  588.  
  589.   }
  590.   if (body->Kind == kOP1_EXP) {
  591. # line 458 "AdaptDoLocal.puma"
  592.   {
  593. # line 459 "AdaptDoLocal.puma"
  594.    FindReduceVariable (body->OP1_EXP.OPND);
  595.   }
  596.    return;
  597.  
  598.   }
  599.   if (body->Kind == kCONST_EXP) {
  600. # line 462 "AdaptDoLocal.puma"
  601.    return;
  602.  
  603.   }
  604.   if (body->Kind == kFUNC_CALL_EXP) {
  605.   if (body->FUNC_CALL_EXP.FUNC_PARAMS->Kind == kBTP_LIST) {
  606.   if (body->FUNC_CALL_EXP.FUNC_PARAMS->BTP_LIST.Elem->Kind == kVAR_PARAM) {
  607. # line 465 "AdaptDoLocal.puma"
  608.   {
  609. # line 466 "AdaptDoLocal.puma"
  610.  
  611.      if (IsIntrFunc (body))
  612.       { if (IntrFuncKind1 (body->FUNC_CALL_EXP.FUNC_ID->PROC_OBJ.Ident))
  613.           {
  614.             FindReduceVariable (body->FUNC_CALL_EXP.FUNC_PARAMS->BTP_LIST.Elem);
  615.           }
  616.          else
  617.            error_protocol ("no reduce variable found in intr func call");
  618.       }
  619.      else
  620.        error_protocol ("no reduce variable found in func call");
  621.  
  622.   }
  623.    return;
  624.  
  625.   }
  626.   }
  627.   }
  628. # line 480 "AdaptDoLocal.puma"
  629.   {
  630. # line 481 "AdaptDoLocal.puma"
  631.    printf ("Find Reduce Variable failed for \n");
  632. # line 482 "AdaptDoLocal.puma"
  633.    FileUnparse (stdout, body);
  634. # line 483 "AdaptDoLocal.puma"
  635.    WriteTree (stdout, body);
  636.   }
  637.    return;
  638.  
  639. ;
  640. }
  641.  
  642. static tTree CollectREDUCE
  643. # if defined __STDC__ | defined __cplusplus
  644. (register tTree t)
  645. # else
  646. (t)
  647.  register tTree t;
  648. # endif
  649. {
  650. # line 501 "AdaptDoLocal.puma"
  651.  
  652. tTree newacf;
  653.  
  654.  
  655.   switch (t->Kind) {
  656.   case kACF_DOLOCAL:
  657. # line 505 "AdaptDoLocal.puma"
  658.    return CollectREDUCE (t->ACF_DOLOCAL.DOLOCAL_BODY);
  659.  
  660.   case kACF_LIST:
  661. # line 509 "AdaptDoLocal.puma"
  662.    return (CombineACF (CollectREDUCE (t->ACF_LIST.Elem), CollectREDUCE (t->ACF_LIST.Next)));
  663.  
  664.   case kACF_EMPTY:
  665. # line 513 "AdaptDoLocal.puma"
  666.    return NoTree;
  667.  
  668.   case kACF_IF:
  669. # line 517 "AdaptDoLocal.puma"
  670.    return (CombineACF (CollectREDUCE (t->ACF_IF.THEN_PART), CollectREDUCE (t->ACF_IF.ELSE_PART)));
  671.  
  672.   case kACF_WHILE:
  673. # line 521 "AdaptDoLocal.puma"
  674.    return CollectREDUCE (t->ACF_WHILE.WHILE_BODY);
  675.  
  676.   case kACF_DO:
  677. # line 525 "AdaptDoLocal.puma"
  678.    return CollectREDUCE (t->ACF_DO.DO_BODY);
  679.  
  680.   case kACF_BASIC:
  681.   if (t->ACF_BASIC.BASIC_STMT->Kind == kREDUCE_STMT) {
  682.   if (t->ACF_BASIC.BASIC_STMT->REDUCE_STMT.RED_PARAMS->Kind == kBTP_LIST) {
  683.   if (t->ACF_BASIC.BASIC_STMT->REDUCE_STMT.RED_PARAMS->BTP_LIST.Elem->Kind == kVAR_PARAM) {
  684.   if (t->ACF_BASIC.BASIC_STMT->REDUCE_STMT.RED_PARAMS->BTP_LIST.Next->Kind == kBTP_LIST) {
  685.   if (t->ACF_BASIC.BASIC_STMT->REDUCE_STMT.RED_PARAMS->BTP_LIST.Next->BTP_LIST.Next->Kind == kBTP_EMPTY) {
  686. # line 529 "AdaptDoLocal.puma"
  687.    return GlobalReductionStmt (t->ACF_BASIC.BASIC_STMT->REDUCE_STMT.RED_PARAMS->BTP_LIST.Elem->VAR_PARAM.V, TreeType (t->ACF_BASIC.BASIC_STMT->REDUCE_STMT.RED_PARAMS->BTP_LIST.Elem->VAR_PARAM.V), t->ACF_BASIC.BASIC_STMT->REDUCE_STMT.RED_FUNC);
  688.  
  689.   }
  690. # line 537 "AdaptDoLocal.puma"
  691.    return CombineACF (GlobalLocReductionStmt (t->ACF_BASIC.BASIC_STMT->REDUCE_STMT.RED_PARAMS->BTP_LIST.Elem->VAR_PARAM.V, TreeType (t->ACF_BASIC.BASIC_STMT->REDUCE_STMT.RED_PARAMS->BTP_LIST.Elem->VAR_PARAM.V), t->ACF_BASIC.BASIC_STMT->
  692. REDUCE_STMT.RED_FUNC), GlobalLocExchange (t->ACF_BASIC.BASIC_STMT->REDUCE_STMT.RED_PARAMS->BTP_LIST.Next->BTP_LIST.Next));
  693.  
  694.   }
  695.   }
  696.   }
  697.   }
  698. # line 546 "AdaptDoLocal.puma"
  699.    return NoTree;
  700.  
  701.   }
  702.  
  703.  yyAbort ("CollectREDUCE");
  704. }
  705.  
  706. static tTree GlobalLocExchange
  707. # if defined __STDC__ | defined __cplusplus
  708. (register tTree params)
  709. # else
  710. (params)
  711.  register tTree params;
  712. # endif
  713. {
  714. # line 554 "AdaptDoLocal.puma"
  715.  
  716. tTree newparams, stmt;
  717.  
  718.   if (params->Kind == kBTP_EMPTY) {
  719. # line 558 "AdaptDoLocal.puma"
  720.    return NoTree;
  721.  
  722.   }
  723.   if (params->Kind == kBTP_LIST) {
  724.   if (params->BTP_LIST.Elem->Kind == kVAR_PARAM) {
  725.   if (params->BTP_LIST.Next->Kind == kBTP_LIST) {
  726. # line 562 "AdaptDoLocal.puma"
  727.   {
  728. # line 564 "AdaptDoLocal.puma"
  729.  newparams = mBTP_EMPTY () ;
  730.       newparams = mBTP_LIST (ExpToVarParam (MakeSizeExp(params->BTP_LIST.Elem->VAR_PARAM.V)), newparams);
  731.       newparams = mBTP_LIST (mVAR_PARAM (params->BTP_LIST.Elem->VAR_PARAM.V), newparams);
  732.       stmt = mPROC_OBJ (MakeDalibId ("loc_exchange"));
  733.       stmt = mACF_BASIC (mCALL_STMT (stmt, newparams));
  734.  
  735.   }
  736.    return CombineACF (stmt, GlobalLocExchange (params->BTP_LIST.Next->BTP_LIST.Next));
  737.  
  738.   }
  739.   }
  740.   }
  741.  yyAbort ("GlobalLocExchange");
  742. }
  743.  
  744. static tTree TransformSerialBody
  745. # if defined __STDC__ | defined __cplusplus
  746. (register tTree t)
  747. # else
  748. (t)
  749.  register tTree t;
  750. # endif
  751. {
  752.  
  753.   switch (t->Kind) {
  754.   case kACF_LIST:
  755. # line 590 "AdaptDoLocal.puma"
  756.  {
  757.   tTree newacf;
  758.   {
  759. # line 592 "AdaptDoLocal.puma"
  760.  
  761. # line 594 "AdaptDoLocal.puma"
  762.  newacf = TransformSerialBody (t->ACF_LIST.Elem);
  763.        t->ACF_LIST.Next   = TransformSerialBody (t->ACF_LIST.Next);
  764.        newacf = ReplaceACF (t, newacf, t->ACF_LIST.Next);
  765.  
  766.   }
  767.   {
  768.    return newacf;
  769.   }
  770.  }
  771.  
  772.   case kACF_EMPTY:
  773. # line 601 "AdaptDoLocal.puma"
  774.    return t;
  775.  
  776.   case kACF_IF:
  777. # line 605 "AdaptDoLocal.puma"
  778.   {
  779. # line 606 "AdaptDoLocal.puma"
  780.  t->ACF_IF.THEN_PART = TransformSerialBody (t->ACF_IF.THEN_PART);
  781.        t->ACF_IF.ELSE_PART = TransformSerialBody (t->ACF_IF.ELSE_PART);
  782.  
  783.   }
  784.    return t;
  785.  
  786.   case kACF_WHILE:
  787. # line 612 "AdaptDoLocal.puma"
  788.   {
  789. # line 613 "AdaptDoLocal.puma"
  790.  t->ACF_WHILE.WHILE_BODY = TransformSerialBody (t->ACF_WHILE.WHILE_BODY);
  791.   }
  792.    return t;
  793.  
  794.   case kACF_DO:
  795. # line 617 "AdaptDoLocal.puma"
  796.   {
  797. # line 618 "AdaptDoLocal.puma"
  798.  t->ACF_DO.DO_BODY = TransformSerialBody (t->ACF_DO.DO_BODY);
  799.   }
  800.    return t;
  801.  
  802.   case kACF_DOLOCAL:
  803. # line 622 "AdaptDoLocal.puma"
  804.    return TransformDoLocal (t);
  805.  
  806.   case kACF_BASIC:
  807.   if (t->ACF_BASIC.BASIC_STMT->Kind == kREDUCE_STMT) {
  808. # line 626 "AdaptDoLocal.puma"
  809.    return ResolveReduce (t);
  810.  
  811.   }
  812. # line 630 "AdaptDoLocal.puma"
  813.    return t;
  814.  
  815.   case kACF_DUMMY:
  816. # line 634 "AdaptDoLocal.puma"
  817.    return t;
  818.  
  819.   }
  820.  
  821. # line 638 "AdaptDoLocal.puma"
  822.   {
  823. # line 639 "AdaptDoLocal.puma"
  824.    failure_protocol ("AdaptDoLocal", "TransformSerialBody", t);
  825.   }
  826.    return NoTree;
  827.  
  828. }
  829.  
  830. void BeginAdaptDoLocal ()
  831. {
  832. }
  833.  
  834. void CloseAdaptDoLocal ()
  835. {
  836. }
  837.