Bug 1134638: 16. Use more macros; r=nbp

--HG--
extra : rebase_source : da4f2ea01a5a3cec8d22f82b4a6c905ba09ff0f8
This commit is contained in:
Benjamin Bouvier 2015-02-26 16:47:04 +01:00
parent 1b04f3a08d
commit d4fd88d65b
6 changed files with 60 additions and 62 deletions

View File

@ -5863,7 +5863,7 @@ CheckSimdOperationCall(FunctionCompiler &f, ParseNode *call, const ModuleCompile
case AsmJSSimdOperation_##OP: \
return CheckSimdBinary(f, call, opType, MSimdBinaryArith::Op_##OP, def, type);
ARITH_COMMONX4_SIMD_OP(OP_CHECK_CASE_LIST_)
ARITH_FLOAT32X4_SIMD_OP(OP_CHECK_CASE_LIST_)
BINARY_ARITH_FLOAT32X4_SIMD_OP(OP_CHECK_CASE_LIST_)
#undef OP_CHECK_CASE_LIST_
case AsmJSSimdOperation_lessThan:

View File

@ -187,24 +187,28 @@
INT32X4_QUARTERNARY_FUNCTION_LIST(V) \
INT32X4_SHUFFLE_FUNCTION_LIST(V)
#define CONVERSION_INT32X4_SIMD_OP(_) \
_(fromFloat32x4) \
_(fromFloat32x4Bits)
#define FOREACH_INT32X4_SIMD_OP(_) \
_(fromFloat32x4) \
_(fromFloat32x4Bits) \
CONVERSION_INT32X4_SIMD_OP(_) \
_(shiftLeftByScalar) \
_(shiftRightArithmeticByScalar) \
_(shiftRightLogicalByScalar)
#define ARITH_FLOAT32X4_SIMD_OP(_) \
#define UNARY_ARITH_FLOAT32X4_SIMD_OP(_) \
_(abs) \
_(sqrt) \
_(reciprocal) \
_(reciprocalSqrt)
#define BINARY_ARITH_FLOAT32X4_SIMD_OP(_) \
_(div) \
_(max) \
_(min) \
_(maxNum) \
_(minNum)
#define FOREACH_FLOAT32X4_SIMD_OP(_) \
ARITH_FLOAT32X4_SIMD_OP(_) \
_(abs) \
_(sqrt) \
_(reciprocal) \
_(reciprocalSqrt) \
UNARY_ARITH_FLOAT32X4_SIMD_OP(_) \
BINARY_ARITH_FLOAT32X4_SIMD_OP(_)\
_(fromInt32x4) \
_(fromInt32x4Bits)
#define ARITH_COMMONX4_SIMD_OP(_) \
@ -215,7 +219,7 @@
_(and) \
_(or) \
_(xor)
#define COMP_COMMONX4_SIMD_OP(_) \
#define COMP_COMMONX4_TO_INT32X4_SIMD_OP(_) \
_(lessThan) \
_(lessThanOrEqual) \
_(equal) \
@ -227,18 +231,21 @@
_(withY) \
_(withZ) \
_(withW)
#define FOREACH_COMMONX4_SIMD_OP(_) \
// TODO: remove when all SIMD calls are inlined (bug 1112155)
#define ION_COMMONX4_SIMD_OP(_) \
ARITH_COMMONX4_SIMD_OP(_) \
BITWISE_COMMONX4_SIMD_OP(_) \
COMP_COMMONX4_SIMD_OP(_) \
WITH_COMMONX4_SIMD_OP(_) \
_(bitselect) \
_(select) \
_(swizzle) \
_(shuffle) \
_(splat) \
_(not) \
_(neg) \
_(neg)
#define FOREACH_COMMONX4_SIMD_OP(_) \
ION_COMMONX4_SIMD_OP(_) \
COMP_COMMONX4_TO_INT32X4_SIMD_OP(_) \
_(swizzle) \
_(shuffle) \
_(load) \
_(loadX) \
_(loadXY) \

View File

@ -1,3 +1,6 @@
if (!this.hasOwnProperty("SIMD"))
quit();
function binaryX4(op, v, w) {
var arr = [];
var [varr, warr] = [simdToArray(v), simdToArray(w)];

View File

@ -9229,31 +9229,18 @@ GetTemplateObjectForNative(JSContext *cx, HandleScript script, jsbytecode *pc,
#define ADD_INT32X4_SIMD_OP_NAME_(OP) || native == js::simd_int32x4_##OP
#define ADD_FLOAT32X4_SIMD_OP_NAME_(OP) || native == js::simd_float32x4_##OP
if (false
ARITH_COMMONX4_SIMD_OP(ADD_INT32X4_SIMD_OP_NAME_)
BITWISE_COMMONX4_SIMD_OP(ADD_INT32X4_SIMD_OP_NAME_)
COMP_COMMONX4_SIMD_OP(ADD_INT32X4_SIMD_OP_NAME_)
COMP_COMMONX4_SIMD_OP(ADD_FLOAT32X4_SIMD_OP_NAME_)
WITH_COMMONX4_SIMD_OP(ADD_INT32X4_SIMD_OP_NAME_)
|| native == js::simd_int32x4_not || native == js::simd_int32x4_neg
|| native == js::simd_int32x4_fromFloat32x4 || native == js::simd_int32x4_fromFloat32x4Bits
|| native == js::simd_int32x4_select || native == js::simd_int32x4_bitselect
|| native == js::simd_int32x4_splat)
ION_COMMONX4_SIMD_OP(ADD_INT32X4_SIMD_OP_NAME_)
COMP_COMMONX4_TO_INT32X4_SIMD_OP(ADD_INT32X4_SIMD_OP_NAME_)
COMP_COMMONX4_TO_INT32X4_SIMD_OP(ADD_FLOAT32X4_SIMD_OP_NAME_)
CONVERSION_INT32X4_SIMD_OP(ADD_INT32X4_SIMD_OP_NAME_))
{
Rooted<SimdTypeDescr *> descr(cx, &cx->global()->int32x4TypeDescr().as<SimdTypeDescr>());
res.set(cx->compartment()->jitCompartment()->getSimdTemplateObjectFor(cx, descr));
return !!res;
}
if (false
ARITH_COMMONX4_SIMD_OP(ADD_FLOAT32X4_SIMD_OP_NAME_)
ARITH_FLOAT32X4_SIMD_OP(ADD_FLOAT32X4_SIMD_OP_NAME_)
BITWISE_COMMONX4_SIMD_OP(ADD_FLOAT32X4_SIMD_OP_NAME_)
WITH_COMMONX4_SIMD_OP(ADD_FLOAT32X4_SIMD_OP_NAME_)
|| native == js::simd_float32x4_abs || native == js::simd_float32x4_sqrt
|| native == js::simd_float32x4_reciprocal || native == js::simd_float32x4_reciprocalSqrt
|| native == js::simd_float32x4_not || native == js::simd_float32x4_neg
|| native == js::simd_float32x4_fromInt32x4 || native == js::simd_float32x4_fromInt32x4Bits
|| native == js::simd_float32x4_select || native == js::simd_float32x4_bitselect
|| native == js::simd_float32x4_splat)
FOREACH_FLOAT32X4_SIMD_OP(ADD_FLOAT32X4_SIMD_OP_NAME_)
ION_COMMONX4_SIMD_OP(ADD_FLOAT32X4_SIMD_OP_NAME_))
{
Rooted<SimdTypeDescr *> descr(cx, &cx->global()->float32x4TypeDescr().as<SimdTypeDescr>());
res.set(cx->compartment()->jitCompartment()->getSimdTemplateObjectFor(cx, descr));

View File

@ -257,19 +257,20 @@ IonBuilder::inlineNativeCall(CallInfo &callInfo, JSFunction *target)
return inlineBoundFunction(callInfo, target);
// Simd functions
#define INLINE_INT32X4_SIMD_ARITH_(OP) \
if (native == js::simd_int32x4_##OP) \
return inlineBinarySimd<MSimdBinaryArith>(callInfo, native, MSimdBinaryArith::Op_##OP, \
SimdTypeDescr::TYPE_INT32);
ARITH_COMMONX4_SIMD_OP(INLINE_INT32X4_SIMD_ARITH_)
#undef INLINE_INT32X4_SIMD_ARITH_
#define INLINE_FLOAT32X4_SIMD_ARITH_(OP) \
if (native == js::simd_float32x4_##OP) \
return inlineBinarySimd<MSimdBinaryArith>(callInfo, native, MSimdBinaryArith::Op_##OP, \
SimdTypeDescr::TYPE_FLOAT32);
#define INLINE_INT32X4_SIMD_ARITH_(OP) \
if (native == js::simd_int32x4_##OP) \
return inlineBinarySimd<MSimdBinaryArith>(callInfo, native, MSimdBinaryArith::Op_##OP, \
SimdTypeDescr::TYPE_INT32);
ARITH_COMMONX4_SIMD_OP(INLINE_INT32X4_SIMD_ARITH_)
ARITH_COMMONX4_SIMD_OP(INLINE_FLOAT32X4_SIMD_ARITH_)
ARITH_FLOAT32X4_SIMD_OP(INLINE_FLOAT32X4_SIMD_ARITH_)
BINARY_ARITH_FLOAT32X4_SIMD_OP(INLINE_FLOAT32X4_SIMD_ARITH_)
#undef INLINE_SIMD_ARITH_
#undef INLINE_FLOAT32X4_SIMD_ARITH_
#define INLINE_SIMD_BITWISE_(OP) \
@ -279,6 +280,7 @@ IonBuilder::inlineNativeCall(CallInfo &callInfo, JSFunction *target)
if (native == js::simd_float32x4_##OP) \
return inlineBinarySimd<MSimdBinaryBitwise>(callInfo, native, MSimdBinaryBitwise::OP##_, \
SimdTypeDescr::TYPE_FLOAT32);
BITWISE_COMMONX4_SIMD_OP(INLINE_SIMD_BITWISE_)
#undef INLINE_SIMD_BITWISE_
@ -287,7 +289,8 @@ IonBuilder::inlineNativeCall(CallInfo &callInfo, JSFunction *target)
return inlineCompSimd(callInfo, native, MSimdBinaryComp::OP, SimdTypeDescr::TYPE_INT32); \
if (native == js::simd_float32x4_##OP) \
return inlineCompSimd(callInfo, native, MSimdBinaryComp::OP, SimdTypeDescr::TYPE_FLOAT32);
COMP_COMMONX4_SIMD_OP(INLINE_SIMD_COMPARISON_)
COMP_COMMONX4_TO_INT32X4_SIMD_OP(INLINE_SIMD_COMPARISON_)
#undef INLINE_SIMD_COMPARISON_
#define INLINE_SIMD_SETTER_(LANE) \
@ -295,6 +298,7 @@ IonBuilder::inlineNativeCall(CallInfo &callInfo, JSFunction *target)
return inlineSimdWith(callInfo, native, SimdLane::Lane##LANE, SimdTypeDescr::TYPE_INT32); \
if (native == js::simd_float32x4_with##LANE) \
return inlineSimdWith(callInfo, native, SimdLane::Lane##LANE, SimdTypeDescr::TYPE_FLOAT32);
INLINE_SIMD_SETTER_(X)
INLINE_SIMD_SETTER_(Y)
INLINE_SIMD_SETTER_(Z)
@ -306,18 +310,16 @@ IonBuilder::inlineNativeCall(CallInfo &callInfo, JSFunction *target)
if (native == js::simd_int32x4_neg)
return inlineUnarySimd(callInfo, native, MSimdUnaryArith::neg, SimdTypeDescr::TYPE_INT32);
#define INLINE_SIMD_FLOAT32X4_UNARY_(OP) \
if (native == js::simd_float32x4_##OP) \
return inlineUnarySimd(callInfo, native, MSimdUnaryArith::OP, SimdTypeDescr::TYPE_FLOAT32);
UNARY_ARITH_FLOAT32X4_SIMD_OP(INLINE_SIMD_FLOAT32X4_UNARY_)
INLINE_SIMD_FLOAT32X4_UNARY_(neg)
#undef INLINE_SIMD_FLOAT32X4_UNARY_
if (native == js::simd_float32x4_not)
return inlineUnarySimd(callInfo, native, MSimdUnaryArith::not_, SimdTypeDescr::TYPE_FLOAT32);
if (native == js::simd_float32x4_neg)
return inlineUnarySimd(callInfo, native, MSimdUnaryArith::neg, SimdTypeDescr::TYPE_FLOAT32);
if (native == js::simd_float32x4_abs)
return inlineUnarySimd(callInfo, native, MSimdUnaryArith::abs, SimdTypeDescr::TYPE_FLOAT32);
if (native == js::simd_float32x4_sqrt)
return inlineUnarySimd(callInfo, native, MSimdUnaryArith::sqrt, SimdTypeDescr::TYPE_FLOAT32);
if (native == js::simd_float32x4_reciprocal)
return inlineUnarySimd(callInfo, native, MSimdUnaryArith::reciprocal, SimdTypeDescr::TYPE_FLOAT32);
if (native == js::simd_float32x4_reciprocalSqrt)
return inlineUnarySimd(callInfo, native, MSimdUnaryArith::reciprocalSqrt, SimdTypeDescr::TYPE_FLOAT32);
typedef bool IsCast;
if (native == js::simd_float32x4_fromInt32x4)

View File

@ -1898,12 +1898,11 @@ class MSimdUnaryArith
{
public:
enum Operation {
abs,
#define OP_LIST_(OP) OP,
UNARY_ARITH_FLOAT32X4_SIMD_OP(OP_LIST_)
neg,
not_,
reciprocal,
reciprocalSqrt,
sqrt
not_
#undef OP_LIST_
};
static const char* OperationName(Operation op) {
@ -1970,14 +1969,14 @@ class MSimdBinaryComp
public:
enum Operation {
#define NAME_(x) x,
COMP_COMMONX4_SIMD_OP(NAME_)
COMP_COMMONX4_TO_INT32X4_SIMD_OP(NAME_)
#undef NAME_
};
static const char* OperationName(Operation op) {
switch (op) {
#define NAME_(x) case x: return #x;
COMP_COMMONX4_SIMD_OP(NAME_)
COMP_COMMONX4_TO_INT32X4_SIMD_OP(NAME_)
#undef NAME_
}
MOZ_CRASH("unexpected operation");
@ -2055,7 +2054,7 @@ class MSimdBinaryArith
enum Operation {
#define OP_LIST_(OP) Op_##OP,
ARITH_COMMONX4_SIMD_OP(OP_LIST_)
ARITH_FLOAT32X4_SIMD_OP(OP_LIST_)
BINARY_ARITH_FLOAT32X4_SIMD_OP(OP_LIST_)
#undef OP_LIST_
};
@ -2063,7 +2062,7 @@ class MSimdBinaryArith
switch (op) {
#define OP_CASE_LIST_(OP) case Op_##OP: return #OP;
ARITH_COMMONX4_SIMD_OP(OP_CASE_LIST_)
ARITH_FLOAT32X4_SIMD_OP(OP_CASE_LIST_)
BINARY_ARITH_FLOAT32X4_SIMD_OP(OP_CASE_LIST_)
#undef OP_CASE_LIST_
}
MOZ_CRASH("unexpected operation");