From 6fef85544442cc4dcb17ea04d1dc8441c1f07541 Mon Sep 17 00:00:00 2001 From: "Nicolas B. Pierron" Date: Mon, 26 Jan 2015 12:22:55 +0100 Subject: [PATCH] Bug 1112156 - Add SimdPolicy to extract SIMD operands based on the type of the instruction. r=bbouvier --- js/src/jit/TypePolicy.cpp | 23 +++++++++++++++++++++++ js/src/jit/TypePolicy.h | 13 +++++++++++++ 2 files changed, 36 insertions(+) diff --git a/js/src/jit/TypePolicy.cpp b/js/src/jit/TypePolicy.cpp index 4fc6efd2ff9a..b38e4a9ca381 100644 --- a/js/src/jit/TypePolicy.cpp +++ b/js/src/jit/TypePolicy.cpp @@ -717,6 +717,29 @@ template bool ObjectPolicy<1>::staticAdjustInputs(TempAllocator &alloc, MInstruc template bool ObjectPolicy<2>::staticAdjustInputs(TempAllocator &alloc, MInstruction *ins); template bool ObjectPolicy<3>::staticAdjustInputs(TempAllocator &alloc, MInstruction *ins); +template +bool +SimdSameAsReturnedTypePolicy::staticAdjustInputs(TempAllocator &alloc, MInstruction *ins) +{ + MIRType type = ins->type(); + MOZ_ASSERT(IsSimdType(type)); + + MDefinition *in = ins->getOperand(Op); + if (in->type() == type) + return true; + + MSimdUnbox *replace = MSimdUnbox::New(alloc, in, type); + ins->block()->insertBefore(ins, replace); + ins->replaceOperand(Op, replace); + + return replace->typePolicy()->adjustInputs(alloc, replace); +} + +template bool +SimdSameAsReturnedTypePolicy<0>::staticAdjustInputs(TempAllocator &alloc, MInstruction *ins); +template bool +SimdSameAsReturnedTypePolicy<1>::staticAdjustInputs(TempAllocator &alloc, MInstruction *ins); + bool CallPolicy::adjustInputs(TempAllocator &alloc, MInstruction *ins) { diff --git a/js/src/jit/TypePolicy.h b/js/src/jit/TypePolicy.h index 7a9b432e7f91..64a02a26f3c2 100644 --- a/js/src/jit/TypePolicy.h +++ b/js/src/jit/TypePolicy.h @@ -317,6 +317,19 @@ class SimdScalarPolicy MOZ_FINAL : public TypePolicy } }; +// SIMD value-type policy, use the returned type of the instruction to determine +// how to unbox its operand. +template +class SimdSameAsReturnedTypePolicy MOZ_FINAL : public TypePolicy +{ + public: + EMPTY_DATA_; + static bool staticAdjustInputs(TempAllocator &alloc, MInstruction *ins); + virtual bool adjustInputs(TempAllocator &alloc, MInstruction *ins) MOZ_OVERRIDE { + return staticAdjustInputs(alloc, ins); + } +}; + template class BoxPolicy MOZ_FINAL : public TypePolicy {