当前位置: 首页>>代码示例>>C++>>正文


C++ MInstruction::typePolicy方法代码示例

本文整理汇总了C++中MInstruction::typePolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ MInstruction::typePolicy方法的具体用法?C++ MInstruction::typePolicy怎么用?C++ MInstruction::typePolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MInstruction的用法示例。


在下文中一共展示了MInstruction::typePolicy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: adjustInputs

bool
BitwisePolicy::adjustInputs(TempAllocator &alloc, MInstruction *ins)
{
    MIRType specialization = ins->typePolicySpecialization();
    if (specialization == MIRType_None)
        return BoxInputsPolicy::adjustInputs(alloc, ins);

    MOZ_ASSERT(ins->type() == specialization);
    MOZ_ASSERT(specialization == MIRType_Int32 || specialization == MIRType_Double);

    // This policy works for both unary and binary bitwise operations.
    for (size_t i = 0, e = ins->numOperands(); i < e; i++) {
        MDefinition *in = ins->getOperand(i);
        if (in->type() == MIRType_Int32)
            continue;

        MInstruction *replace = MTruncateToInt32::New(alloc, in);
        ins->block()->insertBefore(ins, replace);
        ins->replaceOperand(i, replace);

        if (!replace->typePolicy()->adjustInputs(alloc, replace))
            return false;
    }

    return true;
}
开发者ID:msliu,项目名称:gecko-dev,代码行数:26,代码来源:TypePolicy.cpp

示例2:

bool
SimdShufflePolicy::adjustInputs(TempAllocator &alloc, MInstruction *ins)
{
    MIRType specialization = ins->typePolicySpecialization();

    MSimdGeneralShuffle *s = ins->toSimdGeneralShuffle();

    for (unsigned i = 0; i < s->numVectors(); i++) {
        if (!MaybeSimdUnbox(alloc, ins, specialization, i))
            return false;
    }

    // Next inputs are the lanes, which need to be int32
    for (unsigned i = 0; i < s->numLanes(); i++) {
        MDefinition *in = ins->getOperand(s->numVectors() + i);
        if (in->type() == MIRType_Int32)
            continue;

        MInstruction *replace = MToInt32::New(alloc, in, MacroAssembler::IntConversion_NumbersOnly);
        ins->block()->insertBefore(ins, replace);
        ins->replaceOperand(s->numVectors() + i, replace);
        if (!replace->typePolicy()->adjustInputs(alloc, replace))
            return false;
    }

    return true;
}
开发者ID:edunham,项目名称:mozjs,代码行数:27,代码来源:TypePolicy.cpp

示例3: SimdTypeToLaneType

bool
SimdScalarPolicy<Op>::staticAdjustInputs(TempAllocator& alloc, MInstruction* ins)
{
    MOZ_ASSERT(IsSimdType(ins->type()));
    MIRType laneType = SimdTypeToLaneType(ins->type());

    MDefinition* in = ins->getOperand(Op);

    // A vector with boolean lanes requires Int32 inputs that have already been
    // converted to 0/-1.
    // We can't insert a MIRType_Boolean lane directly - it requires conversion.
    if (laneType == MIRType_Boolean) {
        MOZ_ASSERT(in->type() == MIRType_Int32, "Boolean SIMD vector requires Int32 lanes.");
        return true;
    }

    if (in->type() == laneType)
        return true;

    MInstruction* replace;
    if (laneType == MIRType_Int32) {
        replace = MTruncateToInt32::New(alloc, in);
    } else {
        MOZ_ASSERT(laneType == MIRType_Float32);
        replace = MToFloat32::New(alloc, in);
    }

    ins->block()->insertBefore(ins, replace);
    ins->replaceOperand(Op, replace);

    return replace->typePolicy()->adjustInputs(alloc, replace);
}
开发者ID:shockkolate,项目名称:gecko-dev,代码行数:32,代码来源:TypePolicy.cpp

示例4: adjustInputs

bool SameValuePolicy::adjustInputs(TempAllocator& alloc,
                                   MInstruction* def) const {
  MOZ_ASSERT(def->isSameValue());
  MSameValue* sameValue = def->toSameValue();
  MIRType lhsType = sameValue->lhs()->type();
  MIRType rhsType = sameValue->rhs()->type();

  // If both operands are numbers, convert them to doubles.
  if (IsNumberType(lhsType) && IsNumberType(rhsType)) {
    return AllDoublePolicy::staticAdjustInputs(alloc, def);
  }

  // SameValue(Anything, Double) is specialized, so convert the rhs if it's
  // not already a double.
  if (lhsType == MIRType::Value && IsNumberType(rhsType)) {
    if (rhsType != MIRType::Double) {
      MInstruction* replace = MToDouble::New(alloc, sameValue->rhs());
      def->block()->insertBefore(def, replace);
      def->replaceOperand(1, replace);

      if (!replace->typePolicy()->adjustInputs(alloc, replace)) {
        return false;
      }
    }

    return true;
  }

  // Otherwise box both operands.
  return BoxInputsPolicy::staticAdjustInputs(alloc, def);
}
开发者ID:servo,项目名称:mozjs,代码行数:31,代码来源:TypePolicy.cpp

示例5: boxAt

bool
FilterTypeSetPolicy::adjustInputs(TempAllocator &alloc, MInstruction *ins)
{
    MOZ_ASSERT(ins->numOperands() == 1);
    MIRType inputType = ins->getOperand(0)->type();
    MIRType outputType = ins->type();

    // Input and output type are already in accordance.
    if (inputType == outputType)
        return true;

    // Output is a value, box the input.
    if (outputType == MIRType_Value) {
        MOZ_ASSERT(inputType != MIRType_Value);
        ins->replaceOperand(0, boxAt(alloc, ins, ins->getOperand(0)));
        return true;
    }

    // The outputType should be a subset of the inputType else we are in code
    // that has never executed yet. Bail to see the new type (if that hasn't
    // happened yet).
    if (inputType != MIRType_Value) {
        MBail *bail = MBail::New(alloc);
        ins->block()->insertBefore(ins, bail);
        bail->setDependency(ins->dependency());
        ins->setDependency(bail);
        ins->replaceOperand(0, boxAt(alloc, ins, ins->getOperand(0)));
    }

    // We can't unbox a value to null/undefined/lazyargs. So keep output
    // also a value.
    // Note: Using setResultType shouldn't be done in TypePolicies,
    //       Here it is fine, since the type barrier has no uses.
    if (IsNullOrUndefined(outputType) || outputType == MIRType_MagicOptimizedArguments) {
        MOZ_ASSERT(!ins->hasDefUses());
        ins->setResultType(MIRType_Value);
        return true;
    }

    // Unbox / propagate the right type.
    MUnbox::Mode mode = MUnbox::Infallible;
    MInstruction *replace = MUnbox::New(alloc, ins->getOperand(0), ins->type(), mode);

    ins->block()->insertBefore(ins, replace);
    ins->replaceOperand(0, replace);
    if (!replace->typePolicy()->adjustInputs(alloc, replace))
        return false;

    // Carry over the dependency the MFilterTypeSet had.
    replace->setDependency(ins->dependency());

    return true;
}
开发者ID:msliu,项目名称:gecko-dev,代码行数:53,代码来源:TypePolicy.cpp

示例6:

bool
CallPolicy::adjustInputs(TempAllocator &alloc, MInstruction *ins)
{
    MCall *call = ins->toCall();

    MDefinition *func = call->getFunction();
    if (func->type() != MIRType_Object) {
        MInstruction *unbox = MUnbox::New(alloc, func, MIRType_Object, MUnbox::Fallible);
        call->block()->insertBefore(call, unbox);
        call->replaceFunction(unbox);

        if (!unbox->typePolicy()->adjustInputs(alloc, unbox))
            return false;
    }

    for (uint32_t i = 0; i < call->numStackArgs(); i++)
        EnsureOperandNotFloat32(alloc, call, MCall::IndexOfStackArg(i));

    return true;
}
开发者ID:msliu,项目名称:gecko-dev,代码行数:20,代码来源:TypePolicy.cpp

示例7: SimdTypeToScalarType

bool
SimdScalarPolicy<Op>::staticAdjustInputs(TempAllocator &alloc, MInstruction *ins)
{
    MOZ_ASSERT(IsSimdType(ins->type()));
    MIRType scalarType = SimdTypeToScalarType(ins->type());

    MDefinition *in = ins->getOperand(Op);
    if (in->type() == scalarType)
        return true;

    MInstruction *replace;
    if (scalarType == MIRType_Int32) {
        replace = MTruncateToInt32::New(alloc, in);
    } else {
        MOZ_ASSERT(scalarType == MIRType_Float32);
        replace = MToFloat32::New(alloc, in);
    }

    ins->block()->insertBefore(ins, replace);
    ins->replaceOperand(Op, replace);

    return replace->typePolicy()->adjustInputs(alloc, replace);
}
开发者ID:edunham,项目名称:mozjs,代码行数:23,代码来源:TypePolicy.cpp

示例8: BoxAt

bool
FilterTypeSetPolicy::adjustInputs(TempAllocator& alloc, MInstruction* ins)
{
    MOZ_ASSERT(ins->numOperands() == 1);
    MIRType inputType = ins->getOperand(0)->type();
    MIRType outputType = ins->type();

    // Special case when output is a Float32, but input isn't.
    if (outputType == MIRType_Float32 && inputType != MIRType_Float32) {
        // Create a MToFloat32 to add between the MFilterTypeSet and
        // its uses.
        MInstruction* replace = MToFloat32::New(alloc, ins);
        ins->justReplaceAllUsesWithExcept(replace);
        ins->block()->insertAfter(ins, replace);

        // Reset the type to not MIRType_Float32
        // Note: setResultType shouldn't happen in TypePolicies,
        //       Here it is fine, since there is just one use we just
        //       added ourself. And the resulting type after MToFloat32
        //       equals the original type.
        ins->setResultType(ins->resultTypeSet()->getKnownMIRType());
        outputType = ins->type();

        // Do the type analysis
        if (!replace->typePolicy()->adjustInputs(alloc, replace))
            return false;

        // Fall through to let the MFilterTypeSet adjust its input based
        // on its new type.
    }

    // Input and output type are already in accordance.
    if (inputType == outputType)
        return true;

    // Output is a value, box the input.
    if (outputType == MIRType_Value) {
        MOZ_ASSERT(inputType != MIRType_Value);
        ins->replaceOperand(0, BoxAt(alloc, ins, ins->getOperand(0)));
        return true;
    }

    // The outputType should be a subset of the inputType else we are in code
    // that has never executed yet. Bail to see the new type (if that hasn't
    // happened yet).
    if (inputType != MIRType_Value) {
        MBail* bail = MBail::New(alloc);
        ins->block()->insertBefore(ins, bail);
        bail->setDependency(ins->dependency());
        ins->setDependency(bail);
        ins->replaceOperand(0, BoxAt(alloc, ins, ins->getOperand(0)));
    }

    // We can't unbox a value to null/undefined/lazyargs. So keep output
    // also a value.
    // Note: Using setResultType shouldn't be done in TypePolicies,
    //       Here it is fine, since the type barrier has no uses.
    if (IsNullOrUndefined(outputType) || outputType == MIRType_MagicOptimizedArguments) {
        MOZ_ASSERT(!ins->hasDefUses());
        ins->setResultType(MIRType_Value);
        return true;
    }

    // Unbox / propagate the right type.
    MUnbox::Mode mode = MUnbox::Infallible;
    MInstruction* replace = MUnbox::New(alloc, ins->getOperand(0), ins->type(), mode);

    ins->block()->insertBefore(ins, replace);
    ins->replaceOperand(0, replace);
    if (!replace->typePolicy()->adjustInputs(alloc, replace))
        return false;

    // Carry over the dependency the MFilterTypeSet had.
    replace->setDependency(ins->dependency());

    return true;
}
开发者ID:shockkolate,项目名称:gecko-dev,代码行数:77,代码来源:TypePolicy.cpp


注:本文中的MInstruction::typePolicy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。