예제 #1
0
TR::Node *
OMR::TransformUtil::scalarizeAddressParameter(
      TR::Compilation *comp,
      TR::Node *address,
      size_t byteLengthOrPrecision, // precision for BCD types and byteLength for all other types
      TR::DataType dataType,
      TR::SymbolReference *ref,
      bool store)
   {
   TR_ASSERT(ref,"symRef should not be NULL in scalarizeAddressParameter for address node %p\n",address);

   TR::Node * loadOrStore = NULL;

#ifdef J9_PROJECT_SPECIFIC
   size_t byteLength = dataType.isBCD() ? TR::DataType::getSizeFromBCDPrecision(dataType, byteLengthOrPrecision) : byteLengthOrPrecision;
#else
   size_t byteLength = byteLengthOrPrecision;
#endif

   bool isLengthValidForDirect = false;
   if (address->getOpCodeValue() == TR::loadaddr &&
       address->getOpCode().hasSymbolReference() &&
       address->getSymbolReference() &&
       !address->getSymbol()->isStatic())
      {
      if (byteLength == address->getSymbol()->getSize())
         isLengthValidForDirect = true;
      }

   if (address->getOpCodeValue() == TR::loadaddr &&
            !address->getSymbol()->isStatic() &&
            isLengthValidForDirect &&
            address->getSymbolReference() == ref &&
            ref->getSymbol()->getDataType() == dataType)
      {
      if (comp->getOption(TR_TraceScalarizeSSOps))
         traceMsg(comp,"\n\tscalarizeAddressParameter auto direct case: address %p, dt %s\n",address,dataType.toString());

      TR::ILOpCodes opcode = store ? comp->il.opCodeForDirectStore(dataType)
                                  : comp->il.opCodeForDirectLoad(dataType);

      loadOrStore = TR::Node::create(address, opcode, store ? 1 : 0);
      loadOrStore->setSymbolReference(ref);
      }
   else
      {
      TR::ILOpCodes opcode = store ? comp->il.opCodeForIndirectArrayStore(dataType)
                                  : comp->il.opCodeForIndirectArrayLoad(dataType);

      loadOrStore = TR::Node::create(address, opcode, store ? 2 : 1);
      loadOrStore->setSymbolReference(ref);
      loadOrStore->setAndIncChild(0, address);
      }

   if (byteLength == 8)
      {
      comp->getJittedMethodSymbol()->setMayHaveLongOps(true);
      }
#ifdef J9_PROJECT_SPECIFIC
   if (loadOrStore->getType().isBCD())
      {
      loadOrStore->setDecimalPrecision(byteLengthOrPrecision);
      }
   else
#endif
      if (!store && loadOrStore->getType().isIntegral() && !loadOrStore->getType().isInt64())
      {
      loadOrStore->setUnsigned(true);
      }

   return loadOrStore;
   }