예제 #1
0
// Counts nodes that involved in PRE that are not stores or checks.
// These nodes require temps.
//
bool TR_LocalAnalysisInfo::countSupportedNodes(TR::Node *node, TR::Node *parent, bool &containsCallInStoreLhs)
   {
   if (_visitCount == node->getVisitCount())
      {
      return false;
      }

   node->setVisitCount(_visitCount);
   node->setContainsCall(false);

   if (isCallLike(node))
      {
      node->setContainsCall(true);
      // would return here
      }

   bool flag = false;
   TR::ILOpCode &opCode = node->getOpCode();
   int n = node->getNumChildren();

   int32_t i;
   for (i = 0; i < n; i++)
      {
      TR::Node *child = node->getChild(i);
      bool childHasCallsInStoreLhs = false;
      if (countSupportedNodes(child, node, childHasCallsInStoreLhs))
         flag = true;

      if (childHasCallsInStoreLhs)
         containsCallInStoreLhs = true;

      if (child->containsCall())
         {
         if (node->getOpCode().isStoreIndirect() && (i == 0))
            containsCallInStoreLhs = true;
         node->setContainsCall(true);
         }
      }

   if (TR_LocalAnalysis::isSupportedNode(node, _compilation, parent))
      {
      int oldExpressionOnRhs = hasOldExpressionOnRhs(node, false, containsCallInStoreLhs);

      if (oldExpressionOnRhs == -1)
         {
         if (trace())
            {
            traceMsg(comp(), "\nExpression #%d is : \n",_numNodes);
            _compilation->getDebug()->print(_compilation->getOutFile(), node, 6, true);
            }

         flag = true;
         node->setLocalIndex(_numNodes);
         _numNodes++;
         }
      else
        node->setLocalIndex(oldExpressionOnRhs);
      }
   else
      node->setLocalIndex(-1);

   return flag;
   }