Ejemplo n.º 1
0
int32_t
OMR::CodeGenerator::getEvaluationPriority(TR::Node *node)
   {
   // Evaluation priority is the depth of the sub-tree.
   //
   int32_t nodePriority = 0;

   for (int32_t childCount = node->getNumChildren() - 1; childCount >= 0; childCount--)
      {
      TR::Node *child = node->getChild(childCount);
      int32_t childPriority;
      if (child->getRegister() != NULL)
         childPriority = 0;
      else
         childPriority = child->getEvaluationPriority(self());
      if (childPriority >= nodePriority)
         nodePriority = childPriority + 1;
      }

   return nodePriority;
   }
Ejemplo n.º 2
0
int32_t
OMR::CodeGenerator::whichChildToEvaluate(TR::Node * node)
   {
   // Use tree depth as an indicator of priority.
   //
   int32_t nodePriority = 0;
   int32_t bestPriority = INT_MAX;
   int32_t bestChild = 0;

   for (int32_t childCount = 0; childCount < node->getNumChildren(); ++childCount)
      {
      TR::Node *child = node->getChild(childCount);
      int32_t childPriority = child->getEvaluationPriority(self());
      if (childPriority > bestPriority)
         {
         bestPriority = childPriority;
         nodePriority = childPriority + 1;
         bestChild = childCount;
         }
      }

   node->setEvaluationPriority(nodePriority);
   return bestChild;
   }