Bug 1042244: Remove return template parameter in SIMD operators; r=nmatsakis

This commit is contained in:
Benjamin Bouvier 2014-07-28 19:27:42 +02:00
Родитель 6d493a0fb0
Коммит c25aaa24ad
2 изменённых файлов: 87 добавлений и 87 удалений

Просмотреть файл

@ -436,53 +436,53 @@ template JSObject *js::Create<Float32x4>(JSContext *cx, Float32x4::Elem *data);
template JSObject *js::Create<Int32x4>(JSContext *cx, Int32x4::Elem *data);
namespace js {
template<typename T, typename V>
template<typename T>
struct Abs {
static inline T apply(T x, T zero) { return V::toType(x < 0 ? -1 * x : x); }
static inline T apply(T x, T zero) { return x < 0 ? -1 * x : x; }
};
template<typename T, typename V>
template<typename T>
struct Neg {
static inline T apply(T x, T zero) { return V::toType(-1 * x); }
static inline T apply(T x, T zero) { return -1 * x; }
};
template<typename T, typename V>
template<typename T>
struct Not {
static inline T apply(T x, T zero) { return V::toType(~x); }
static inline T apply(T x, T zero) { return ~x; }
};
template<typename T, typename V>
template<typename T>
struct Rec {
static inline T apply(T x, T zero) { return V::toType(1 / x); }
static inline T apply(T x, T zero) { return 1 / x; }
};
template<typename T, typename V>
template<typename T>
struct RecSqrt {
static inline T apply(T x, T zero) { return V::toType(1 / sqrt(x)); }
static inline T apply(T x, T zero) { return 1 / sqrt(x); }
};
template<typename T, typename V>
template<typename T>
struct Sqrt {
static inline T apply(T x, T zero) { return V::toType(sqrt(x)); }
static inline T apply(T x, T zero) { return sqrt(x); }
};
template<typename T, typename V>
template<typename T>
struct Add {
static inline T apply(T l, T r) { return V::toType(l + r); }
static inline T apply(T l, T r) { return l + r; }
};
template<typename T, typename V>
template<typename T>
struct Sub {
static inline T apply(T l, T r) { return V::toType(l - r); }
static inline T apply(T l, T r) { return l - r; }
};
template<typename T, typename V>
template<typename T>
struct Div {
static inline T apply(T l, T r) { return V::toType(l / r); }
static inline T apply(T l, T r) { return l / r; }
};
template<typename T, typename V>
template<typename T>
struct Mul {
static inline T apply(T l, T r) { return V::toType(l * r); }
static inline T apply(T l, T r) { return l * r; }
};
template<typename T, typename V>
template<typename T>
struct Minimum {
static inline T apply(T l, T r) { return V::toType(l < r ? l : r); }
static inline T apply(T l, T r) { return l < r ? l : r; }
};
template<typename T, typename V>
template<typename T>
struct Maximum {
static inline T apply(T l, T r) { return V::toType(l > r ? l : r); }
static inline T apply(T l, T r) { return l > r ? l : r; }
};
template<typename T>
struct LessThan {
@ -508,53 +508,53 @@ template<typename T>
struct NotEqual {
static inline int32_t apply(T l, T r) { return l != r ? 0xFFFFFFFF : 0x0; }
};
template<typename T, typename V>
template<typename T>
struct Xor {
static inline T apply(T l, T r) { return V::toType(l ^ r); }
static inline T apply(T l, T r) { return l ^ r; }
};
template<typename T, typename V>
template<typename T>
struct And {
static inline T apply(T l, T r) { return V::toType(l & r); }
static inline T apply(T l, T r) { return l & r; }
};
template<typename T, typename V>
template<typename T>
struct Or {
static inline T apply(T l, T r) { return V::toType(l | r); }
static inline T apply(T l, T r) { return l | r; }
};
template<typename T, typename V>
template<typename T>
struct Scale {
static inline T apply(int32_t lane, T scalar, T x) { return V::toType(scalar * x); }
static inline T apply(int32_t lane, T scalar, T x) { return scalar * x; }
};
template<typename T, typename V>
template<typename T>
struct WithX {
static inline T apply(int32_t lane, T scalar, T x) { return V::toType(lane == 0 ? scalar : x); }
static inline T apply(int32_t lane, T scalar, T x) { return lane == 0 ? scalar : x; }
};
template<typename T, typename V>
template<typename T>
struct WithY {
static inline T apply(int32_t lane, T scalar, T x) { return V::toType(lane == 1 ? scalar : x); }
static inline T apply(int32_t lane, T scalar, T x) { return lane == 1 ? scalar : x; }
};
template<typename T, typename V>
template<typename T>
struct WithZ {
static inline T apply(int32_t lane, T scalar, T x) { return V::toType(lane == 2 ? scalar : x); }
static inline T apply(int32_t lane, T scalar, T x) { return lane == 2 ? scalar : x; }
};
template<typename T, typename V>
template<typename T>
struct WithW {
static inline T apply(int32_t lane, T scalar, T x) { return V::toType(lane == 3 ? scalar : x); }
static inline T apply(int32_t lane, T scalar, T x) { return lane == 3 ? scalar : x; }
};
template<typename T, typename V>
template<typename T>
struct WithFlagX {
static inline T apply(T l, T f, T x) { return V::toType(l == 0 ? (f ? 0xFFFFFFFF : 0x0) : x); }
static inline T apply(T l, T f, T x) { return l == 0 ? (f ? 0xFFFFFFFF : 0x0) : x; }
};
template<typename T, typename V>
template<typename T>
struct WithFlagY {
static inline T apply(T l, T f, T x) { return V::toType(l == 1 ? (f ? 0xFFFFFFFF : 0x0) : x); }
static inline T apply(T l, T f, T x) { return l == 1 ? (f ? 0xFFFFFFFF : 0x0) : x; }
};
template<typename T, typename V>
template<typename T>
struct WithFlagZ {
static inline T apply(T l, T f, T x) { return V::toType(l == 2 ? (f ? 0xFFFFFFFF : 0x0) : x); }
static inline T apply(T l, T f, T x) { return l == 2 ? (f ? 0xFFFFFFFF : 0x0) : x; }
};
template<typename T, typename V>
template<typename T>
struct WithFlagW {
static inline T apply(T l, T f, T x) { return V::toType(l == 3 ? (f ? 0xFFFFFFFF : 0x0) : x); }
static inline T apply(T l, T f, T x) { return l == 3 ? (f ? 0xFFFFFFFF : 0x0) : x; }
};
template<typename T, typename V>
struct Shuffle {
@ -900,15 +900,15 @@ Int32x4Select(JSContext *cx, unsigned argc, Value *vp)
int32_t tr[Int32x4::lanes];
for (unsigned i = 0; i < Int32x4::lanes; i++)
tr[i] = And<int32_t, Int32x4>::apply(val[i], tv[i]);
tr[i] = And<int32_t>::apply(val[i], tv[i]);
int32_t fr[Int32x4::lanes];
for (unsigned i = 0; i < Int32x4::lanes; i++)
fr[i] = And<int32_t, Int32x4>::apply(Not<int32_t, Int32x4>::apply(val[i], 0), fv[i]);
fr[i] = And<int32_t>::apply(Not<int32_t>::apply(val[i], 0), fv[i]);
int32_t orInt[Int32x4::lanes];
for (unsigned i = 0; i < Int32x4::lanes; i++)
orInt[i] = Or<int32_t, Int32x4>::apply(tr[i], fr[i]);
orInt[i] = Or<int32_t>::apply(tr[i], fr[i]);
float *result = reinterpret_cast<float *>(orInt);
RootedObject obj(cx, Create<Float32x4>(cx, result));

Просмотреть файл

@ -22,38 +22,38 @@
V(zero, (FuncZero<Float32x4>), 0, 0, Zero)
#define FLOAT32X4_UNARY_FUNCTION_LIST(V) \
V(abs, (Func<Float32x4, Abs<float, Float32x4>, Float32x4>), 1, 0, Abs) \
V(abs, (Func<Float32x4, Abs<float>, Float32x4>), 1, 0, Abs) \
V(fromInt32x4Bits, (FuncConvertBits<Int32x4, Float32x4>), 1, 0, FromInt32x4Bits) \
V(neg, (Func<Float32x4, Neg<float, Float32x4>, Float32x4>), 1, 0, Neg) \
V(not, (CoercedFunc<Float32x4, Int32x4, Not<int32_t, Int32x4>, Float32x4>), 1, 0, Not) \
V(reciprocal, (Func<Float32x4, Rec<float, Float32x4>, Float32x4>), 1, 0, Reciprocal) \
V(reciprocalSqrt, (Func<Float32x4, RecSqrt<float, Float32x4>, Float32x4>), 1, 0, ReciprocalSqrt) \
V(neg, (Func<Float32x4, Neg<float>, Float32x4>), 1, 0, Neg) \
V(not, (CoercedFunc<Float32x4, Int32x4, Not<int32_t>, Float32x4>), 1, 0, Not) \
V(reciprocal, (Func<Float32x4, Rec<float>, Float32x4>), 1, 0, Reciprocal) \
V(reciprocalSqrt, (Func<Float32x4, RecSqrt<float>, Float32x4>), 1, 0, ReciprocalSqrt) \
V(splat, (FuncSplat<Float32x4>), 1, 0, Splat) \
V(sqrt, (Func<Float32x4, Sqrt<float, Float32x4>, Float32x4>), 1, 0, Sqrt) \
V(sqrt, (Func<Float32x4, Sqrt<float>, Float32x4>), 1, 0, Sqrt) \
V(fromInt32x4, (FuncConvert<Int32x4, Float32x4> ), 1, 0, FromInt32x4)
#define FLOAT32X4_BINARY_FUNCTION_LIST(V) \
V(add, (Func<Float32x4, Add<float, Float32x4>, Float32x4>), 2, 0, Add) \
V(and, (CoercedFunc<Float32x4, Int32x4, And<int32_t, Int32x4>, Float32x4>), 2, 0, And) \
V(div, (Func<Float32x4, Div<float, Float32x4>, Float32x4>), 2, 0, Div) \
V(add, (Func<Float32x4, Add<float>, Float32x4>), 2, 0, Add) \
V(and, (CoercedFunc<Float32x4, Int32x4, And<int32_t>, Float32x4>), 2, 0, And) \
V(div, (Func<Float32x4, Div<float>, Float32x4>), 2, 0, Div) \
V(equal, (Func<Float32x4, Equal<float>, Int32x4>), 2, 0, Equal) \
V(greaterThan, (Func<Float32x4, GreaterThan<float>, Int32x4>), 2, 0, GreaterThan) \
V(greaterThanOrEqual, (Func<Float32x4, GreaterThanOrEqual<float>, Int32x4>), 2, 0, GreaterThanOrEqual) \
V(lessThan, (Func<Float32x4, LessThan<float>, Int32x4>), 2, 0, LessThan) \
V(lessThanOrEqual, (Func<Float32x4, LessThanOrEqual<float>, Int32x4>), 2, 0, LessThanOrEqual) \
V(max, (Func<Float32x4, Maximum<float, Float32x4>, Float32x4>), 2, 0, Max) \
V(min, (Func<Float32x4, Minimum<float, Float32x4>, Float32x4>), 2, 0, Min) \
V(mul, (Func<Float32x4, Mul<float, Float32x4>, Float32x4>), 2, 0, Mul) \
V(max, (Func<Float32x4, Maximum<float>, Float32x4>), 2, 0, Max) \
V(min, (Func<Float32x4, Minimum<float>, Float32x4>), 2, 0, Min) \
V(mul, (Func<Float32x4, Mul<float>, Float32x4>), 2, 0, Mul) \
V(notEqual, (Func<Float32x4, NotEqual<float>, Int32x4>), 2, 0, NotEqual) \
V(or, (CoercedFunc<Float32x4, Int32x4, Or<int32_t, Int32x4>, Float32x4>), 2, 0, Or) \
V(shuffle, (FuncShuffle<Float32x4, Shuffle<float, Float32x4>, Float32x4>), 2, 0, Shuffle) \
V(scale, (FuncWith<Float32x4, Scale<float, Float32x4>, Float32x4>), 2, 0, Scale) \
V(sub, (Func<Float32x4, Sub<float, Float32x4>, Float32x4>), 2, 0, Sub) \
V(withX, (FuncWith<Float32x4, WithX<float, Float32x4>, Float32x4>), 2, 0, WithX) \
V(withY, (FuncWith<Float32x4, WithY<float, Float32x4>, Float32x4>), 2, 0, WithY) \
V(withZ, (FuncWith<Float32x4, WithZ<float, Float32x4>, Float32x4>), 2, 0, WithZ) \
V(withW, (FuncWith<Float32x4, WithW<float, Float32x4>, Float32x4>), 2, 0, WithW) \
V(xor, (CoercedFunc<Float32x4, Int32x4, Xor<int32_t, Int32x4>, Float32x4>), 2, 0, Xor)
V(or, (CoercedFunc<Float32x4, Int32x4, Or<int32_t>, Float32x4>), 2, 0, Or) \
V(scale, (FuncWith<Float32x4, Scale<float>, Float32x4>), 2, 0, Scale) \
V(sub, (Func<Float32x4, Sub<float>, Float32x4>), 2, 0, Sub) \
V(withX, (FuncWith<Float32x4, WithX<float>, Float32x4>), 2, 0, WithX) \
V(withY, (FuncWith<Float32x4, WithY<float>, Float32x4>), 2, 0, WithY) \
V(withZ, (FuncWith<Float32x4, WithZ<float>, Float32x4>), 2, 0, WithZ) \
V(withW, (FuncWith<Float32x4, WithW<float>, Float32x4>), 2, 0, WithW) \
V(xor, (CoercedFunc<Float32x4, Int32x4, Xor<int32_t>, Float32x4>), 2, 0, Xor)
#define FLOAT32X4_TERNARY_FUNCTION_LIST(V) \
V(clamp, Float32x4Clamp, 3, 0, Clamp) \
@ -70,33 +70,33 @@
#define INT32X4_UNARY_FUNCTION_LIST(V) \
V(fromFloat32x4Bits, (FuncConvertBits<Float32x4, Int32x4>), 1, 0, FromFloat32x4Bits) \
V(neg, (Func<Int32x4, Neg<int32_t, Int32x4>, Int32x4>), 1, 0, Neg) \
V(not, (Func<Int32x4, Not<int32_t, Int32x4>, Int32x4>), 1, 0, Not) \
V(neg, (Func<Int32x4, Neg<int32_t>, Int32x4>), 1, 0, Neg) \
V(not, (Func<Int32x4, Not<int32_t>, Int32x4>), 1, 0, Not) \
V(splat, (FuncSplat<Int32x4>), 0, 0, Splat) \
V(fromFloat32x4, (FuncConvert<Float32x4, Int32x4>), 1, 0, FromFloat32x4)
#define INT32X4_BINARY_FUNCTION_LIST(V) \
V(add, (Func<Int32x4, Add<int32_t, Int32x4>, Int32x4>), 2, 0, Add) \
V(and, (Func<Int32x4, And<int32_t, Int32x4>, Int32x4>), 2, 0, And) \
V(add, (Func<Int32x4, Add<int32_t>, Int32x4>), 2, 0, Add) \
V(and, (Func<Int32x4, And<int32_t>, Int32x4>), 2, 0, And) \
V(equal, (Func<Int32x4, Equal<int32_t>, Int32x4>), 2, 0, Equal) \
V(greaterThan, (Func<Int32x4, GreaterThan<int32_t>, Int32x4>), 2, 0, GreaterThan) \
V(lessThan, (Func<Int32x4, LessThan<int32_t>, Int32x4>), 2, 0, LessThan) \
V(mul, (Func<Int32x4, Mul<int32_t, Int32x4>, Int32x4>), 2, 0, Mul) \
V(or, (Func<Int32x4, Or<int32_t, Int32x4>, Int32x4>), 2, 0, Or) \
V(sub, (Func<Int32x4, Sub<int32_t, Int32x4>, Int32x4>), 2, 0, Sub) \
V(mul, (Func<Int32x4, Mul<int32_t>, Int32x4>), 2, 0, Mul) \
V(or, (Func<Int32x4, Or<int32_t>, Int32x4>), 2, 0, Or) \
V(sub, (Func<Int32x4, Sub<int32_t>, Int32x4>), 2, 0, Sub) \
V(shiftLeft, (Int32x4BinaryScalar<ShiftLeft>), 2, 0, ShiftLeft) \
V(shiftRight, (Int32x4BinaryScalar<ShiftRight>), 2, 0, ShiftRight) \
V(shiftRightLogical, (Int32x4BinaryScalar<ShiftRightLogical>), 2, 0, ShiftRightLogical) \
V(shuffle, (FuncShuffle<Int32x4, Shuffle<int32_t, Int32x4>, Int32x4>), 2, 0, Shuffle) \
V(withFlagX, (FuncWith<Int32x4, WithFlagX<int32_t, Int32x4>, Int32x4>), 2, 0, WithFlagX) \
V(withFlagY, (FuncWith<Int32x4, WithFlagY<int32_t, Int32x4>, Int32x4>), 2, 0, WithFlagY) \
V(withFlagZ, (FuncWith<Int32x4, WithFlagZ<int32_t, Int32x4>, Int32x4>), 2, 0, WithFlagZ) \
V(withFlagW, (FuncWith<Int32x4, WithFlagW<int32_t, Int32x4>, Int32x4>), 2, 0, WithFlagW) \
V(withX, (FuncWith<Int32x4, WithX<int32_t, Int32x4>, Int32x4>), 2, 0, WithX) \
V(withY, (FuncWith<Int32x4, WithY<int32_t, Int32x4>, Int32x4>), 2, 0, WithY) \
V(withZ, (FuncWith<Int32x4, WithZ<int32_t, Int32x4>, Int32x4>), 2, 0, WithZ) \
V(withW, (FuncWith<Int32x4, WithW<int32_t, Int32x4>, Int32x4>), 2, 0, WithW) \
V(xor, (Func<Int32x4, Xor<int32_t, Int32x4>, Int32x4>), 2, 0, Xor)
V(withFlagX, (FuncWith<Int32x4, WithFlagX<int32_t>, Int32x4>), 2, 0, WithFlagX) \
V(withFlagY, (FuncWith<Int32x4, WithFlagY<int32_t>, Int32x4>), 2, 0, WithFlagY) \
V(withFlagZ, (FuncWith<Int32x4, WithFlagZ<int32_t>, Int32x4>), 2, 0, WithFlagZ) \
V(withFlagW, (FuncWith<Int32x4, WithFlagW<int32_t>, Int32x4>), 2, 0, WithFlagW) \
V(withX, (FuncWith<Int32x4, WithX<int32_t>, Int32x4>), 2, 0, WithX) \
V(withY, (FuncWith<Int32x4, WithY<int32_t>, Int32x4>), 2, 0, WithY) \
V(withZ, (FuncWith<Int32x4, WithZ<int32_t>, Int32x4>), 2, 0, WithZ) \
V(withW, (FuncWith<Int32x4, WithW<int32_t>, Int32x4>), 2, 0, WithW) \
V(xor, (Func<Int32x4, Xor<int32_t>, Int32x4>), 2, 0, Xor)
#define INT32X4_TERNARY_FUNCTION_LIST(V) \
V(select, Int32x4Select, 3, 0, Select) \