Commit 62abb558 by Nicolas Capens

Replace Concatenate with vector constructors.

Change-Id: Ic397b07800c423cfa2648b082ad8606c09223398 Reviewed-on: https://swiftshader-review.googlesource.com/4514Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 50c96364
...@@ -3540,6 +3540,19 @@ namespace sw ...@@ -3540,6 +3540,19 @@ namespace sw
storeValue(rhs.value); storeValue(rhs.value);
} }
Short8::Short8(RValue<Short4> lo, RValue<Short4> hi)
{
Value *loLong = Nucleus::createBitCast(lo.value, Long::getType());
Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType());
Value *long2 = UndefValue::get(Long2::getType());
long2 = Nucleus::createInsertElement(long2, loLong, 0);
long2 = Nucleus::createInsertElement(long2, hiLong, 1);
Value *short8 = Nucleus::createBitCast(long2, Short8::getType());
storeValue(short8);
}
RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs) RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs)
{ {
return RValue<Short8>(Nucleus::createAdd(lhs.value, rhs.value)); return RValue<Short8>(Nucleus::createAdd(lhs.value, rhs.value));
...@@ -3560,19 +3573,6 @@ namespace sw ...@@ -3560,19 +3573,6 @@ namespace sw
return x86::psraw(lhs, rhs); // FIXME: Fallback required return x86::psraw(lhs, rhs); // FIXME: Fallback required
} }
RValue<Short8> Concatenate(RValue<Short4> lo, RValue<Short4> hi)
{
Value *loLong = Nucleus::createBitCast(lo.value, Long::getType());
Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType());
Value *long2 = UndefValue::get(Long2::getType());
long2 = Nucleus::createInsertElement(long2, loLong, 0);
long2 = Nucleus::createInsertElement(long2, hiLong, 1);
Value *short8 = Nucleus::createBitCast(long2, Short8::getType());
return RValue<Short8>(short8);
}
RValue<Int4> MulAdd(RValue<Short8> x, RValue<Short8> y) RValue<Int4> MulAdd(RValue<Short8> x, RValue<Short8> y)
{ {
return x86::pmaddwd(x, y); // FIXME: Fallback required return x86::pmaddwd(x, y); // FIXME: Fallback required
...@@ -3612,6 +3612,19 @@ namespace sw ...@@ -3612,6 +3612,19 @@ namespace sw
storeValue(rhs.value); storeValue(rhs.value);
} }
UShort8::UShort8(RValue<UShort4> lo, RValue<UShort4> hi)
{
Value *loLong = Nucleus::createBitCast(lo.value, Long::getType());
Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType());
Value *long2 = UndefValue::get(Long2::getType());
long2 = Nucleus::createInsertElement(long2, loLong, 0);
long2 = Nucleus::createInsertElement(long2, hiLong, 1);
Value *short8 = Nucleus::createBitCast(long2, Short8::getType());
storeValue(short8);
}
RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs) const RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs) const
{ {
storeValue(rhs.value); storeValue(rhs.value);
...@@ -3697,19 +3710,6 @@ namespace sw ...@@ -3697,19 +3710,6 @@ namespace sw
return RValue<UShort8>(short8); return RValue<UShort8>(short8);
} }
RValue<UShort8> Concatenate(RValue<UShort4> lo, RValue<UShort4> hi)
{
Value *loLong = Nucleus::createBitCast(lo.value, Long::getType());
Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType());
Value *long2 = UndefValue::get(Long2::getType());
long2 = Nucleus::createInsertElement(long2, loLong, 0);
long2 = Nucleus::createInsertElement(long2, hiLong, 1);
Value *short8 = Nucleus::createBitCast(long2, Short8::getType());
return RValue<UShort8>(short8);
}
RValue<UShort8> MulHigh(RValue<UShort8> x, RValue<UShort8> y) RValue<UShort8> MulHigh(RValue<UShort8> x, RValue<UShort8> y)
{ {
return x86::pmulhuw(x, y); // FIXME: Fallback required return x86::pmulhuw(x, y); // FIXME: Fallback required
...@@ -4621,6 +4621,17 @@ namespace sw ...@@ -4621,6 +4621,17 @@ namespace sw
storeValue(value); storeValue(value);
} }
Int2::Int2(RValue<Int> lo, RValue<Int> hi)
{
Constant *shuffle[2];
shuffle[0] = Nucleus::createConstantInt(0);
shuffle[1] = Nucleus::createConstantInt(1);
Value *packed = Nucleus::createShuffleVector(Nucleus::createBitCast(lo.value, VectorType::get(Int::getType(), 1)), Nucleus::createBitCast(hi.value, VectorType::get(Int::getType(), 1)), Nucleus::createConstantVector(shuffle, 2));
storeValue(Nucleus::createBitCast(packed, Int2::getType()));
}
RValue<Int2> Int2::operator=(RValue<Int2> rhs) const RValue<Int2> Int2::operator=(RValue<Int2> rhs) const
{ {
storeValue(rhs.value); storeValue(rhs.value);
...@@ -4865,17 +4876,6 @@ namespace sw ...@@ -4865,17 +4876,6 @@ namespace sw
} }
} }
RValue<Int2> Concatenate(RValue<Int> lo, RValue<Int> hi)
{
Constant *shuffle[2];
shuffle[0] = Nucleus::createConstantInt(0);
shuffle[1] = Nucleus::createConstantInt(1);
Value *packed = Nucleus::createShuffleVector(Nucleus::createBitCast(lo.value, VectorType::get(Int::getType(), 1)), Nucleus::createBitCast(hi.value, VectorType::get(Int::getType(), 1)), Nucleus::createConstantVector(shuffle, 2));
return RValue<Int2>(Nucleus::createBitCast(packed, Int2::getType()));
}
RValue<Int> Extract(RValue<Int2> val, int i) RValue<Int> Extract(RValue<Int2> val, int i)
{ {
if(false) // FIXME: LLVM does not generate optimal code if(false) // FIXME: LLVM does not generate optimal code
...@@ -5335,6 +5335,19 @@ namespace sw ...@@ -5335,6 +5335,19 @@ namespace sw
storeValue(value); storeValue(value);
} }
Int4::Int4(RValue<Int2> lo, RValue<Int2> hi)
{
Value *loLong = Nucleus::createBitCast(lo.value, Long::getType());
Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType());
Value *long2 = UndefValue::get(Long2::getType());
long2 = Nucleus::createInsertElement(long2, loLong, 0);
long2 = Nucleus::createInsertElement(long2, hiLong, 1);
Value *int4 = Nucleus::createBitCast(long2, Int4::getType());
storeValue(int4);
}
RValue<Int4> Int4::operator=(RValue<Int4> rhs) const RValue<Int4> Int4::operator=(RValue<Int4> rhs) const
{ {
storeValue(rhs.value); storeValue(rhs.value);
...@@ -5549,19 +5562,6 @@ namespace sw ...@@ -5549,19 +5562,6 @@ namespace sw
return x86::packssdw(x, y); return x86::packssdw(x, y);
} }
RValue<Int4> Concatenate(RValue<Int2> lo, RValue<Int2> hi)
{
Value *loLong = Nucleus::createBitCast(lo.value, Long::getType());
Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType());
Value *long2 = UndefValue::get(Long2::getType());
long2 = Nucleus::createInsertElement(long2, loLong, 0);
long2 = Nucleus::createInsertElement(long2, hiLong, 1);
Value *int4 = Nucleus::createBitCast(long2, Int4::getType());
return RValue<Int4>(int4);
}
RValue<Int> Extract(RValue<Int4> x, int i) RValue<Int> Extract(RValue<Int4> x, int i)
{ {
return RValue<Int>(Nucleus::createExtractElement(x.value, i)); return RValue<Int>(Nucleus::createExtractElement(x.value, i));
...@@ -5680,6 +5680,19 @@ namespace sw ...@@ -5680,6 +5680,19 @@ namespace sw
storeValue(value); storeValue(value);
} }
UInt4::UInt4(RValue<UInt2> lo, RValue<UInt2> hi)
{
Value *loLong = Nucleus::createBitCast(lo.value, Long::getType());
Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType());
Value *long2 = UndefValue::get(Long2::getType());
long2 = Nucleus::createInsertElement(long2, loLong, 0);
long2 = Nucleus::createInsertElement(long2, hiLong, 1);
Value *uint4 = Nucleus::createBitCast(long2, Int4::getType());
storeValue(uint4);
}
RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs) const RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs) const
{ {
storeValue(rhs.value); storeValue(rhs.value);
...@@ -5889,19 +5902,6 @@ namespace sw ...@@ -5889,19 +5902,6 @@ namespace sw
return x86::packusdw(x, y); // FIXME: Fallback required return x86::packusdw(x, y); // FIXME: Fallback required
} }
RValue<UInt4> Concatenate(RValue<UInt2> lo, RValue<UInt2> hi)
{
Value *loLong = Nucleus::createBitCast(lo.value, Long::getType());
Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType());
Value *long2 = UndefValue::get(Long2::getType());
long2 = Nucleus::createInsertElement(long2, loLong, 0);
long2 = Nucleus::createInsertElement(long2, hiLong, 1);
Value *uint4 = Nucleus::createBitCast(long2, Int4::getType());
return RValue<UInt4>(uint4);
}
Type *UInt4::getType() Type *UInt4::getType()
{ {
return VectorType::get(UInt::getType(), 4); return VectorType::get(UInt::getType(), 4);
...@@ -6916,7 +6916,7 @@ namespace sw ...@@ -6916,7 +6916,7 @@ namespace sw
Int2 lo = x86::cvtps2pi(val); Int2 lo = x86::cvtps2pi(val);
Int2 hi = x86::cvtps2pi(Swizzle(val, 0xEE)); Int2 hi = x86::cvtps2pi(Swizzle(val, 0xEE));
return Concatenate(lo, hi); return Int4(lo, hi);
} }
} }
...@@ -7436,7 +7436,7 @@ namespace sw ...@@ -7436,7 +7436,7 @@ namespace sw
Short4 lo = x86::packssdw(loX, hiX); Short4 lo = x86::packssdw(loX, hiX);
Short4 hi = x86::packssdw(loY, hiY); Short4 hi = x86::packssdw(loY, hiY);
return Concatenate(lo, hi); return Short8(lo, hi);
} }
} }
...@@ -7545,7 +7545,7 @@ namespace sw ...@@ -7545,7 +7545,7 @@ namespace sw
lo = x86::pslld(lo, y); lo = x86::pslld(lo, y);
hi = x86::pslld(hi, y); hi = x86::pslld(hi, y);
return Concatenate(lo, hi); return Int4(lo, hi);
} }
} }
...@@ -7574,7 +7574,7 @@ namespace sw ...@@ -7574,7 +7574,7 @@ namespace sw
lo = x86::psrad(lo, y); lo = x86::psrad(lo, y);
hi = x86::psrad(hi, y); hi = x86::psrad(hi, y);
return Concatenate(lo, hi); return Int4(lo, hi);
} }
} }
...@@ -7603,7 +7603,7 @@ namespace sw ...@@ -7603,7 +7603,7 @@ namespace sw
lo = x86::psrld(lo, y); lo = x86::psrld(lo, y);
hi = x86::psrld(hi, y); hi = x86::psrld(hi, y);
return Concatenate(lo, hi); return UInt4(lo, hi);
} }
} }
......
...@@ -1058,6 +1058,7 @@ namespace sw ...@@ -1058,6 +1058,7 @@ namespace sw
Short8(RValue<Short8> rhs); Short8(RValue<Short8> rhs);
// Short8(const Short8 &rhs); // Short8(const Short8 &rhs);
// Short8(const Reference<Short8> &rhs); // Short8(const Reference<Short8> &rhs);
Short8(RValue<Short4> lo, RValue<Short4> hi);
// RValue<Short8> operator=(RValue<Short8> rhs) const; // RValue<Short8> operator=(RValue<Short8> rhs) const;
// RValue<Short8> operator=(const Short8 &rhs) const; // RValue<Short8> operator=(const Short8 &rhs) const;
...@@ -1102,7 +1103,6 @@ namespace sw ...@@ -1102,7 +1103,6 @@ namespace sw
// RValue<Bool> operator!=(RValue<Short8> lhs, RValue<Short8> rhs); // RValue<Bool> operator!=(RValue<Short8> lhs, RValue<Short8> rhs);
// RValue<Bool> operator==(RValue<Short8> lhs, RValue<Short8> rhs); // RValue<Bool> operator==(RValue<Short8> lhs, RValue<Short8> rhs);
RValue<Short8> Concatenate(RValue<Short4> lo, RValue<Short4> hi);
RValue<Short8> MulHigh(RValue<Short8> x, RValue<Short8> y); RValue<Short8> MulHigh(RValue<Short8> x, RValue<Short8> y);
RValue<Int4> MulAdd(RValue<Short8> x, RValue<Short8> y); RValue<Int4> MulAdd(RValue<Short8> x, RValue<Short8> y);
...@@ -1114,6 +1114,7 @@ namespace sw ...@@ -1114,6 +1114,7 @@ namespace sw
UShort8(RValue<UShort8> rhs); UShort8(RValue<UShort8> rhs);
// UShort8(const UShort8 &rhs); // UShort8(const UShort8 &rhs);
// UShort8(const Reference<UShort8> &rhs); // UShort8(const Reference<UShort8> &rhs);
UShort8(RValue<UShort4> lo, RValue<UShort4> hi);
RValue<UShort8> operator=(RValue<UShort8> rhs) const; RValue<UShort8> operator=(RValue<UShort8> rhs) const;
RValue<UShort8> operator=(const UShort8 &rhs) const; RValue<UShort8> operator=(const UShort8 &rhs) const;
...@@ -1159,7 +1160,6 @@ namespace sw ...@@ -1159,7 +1160,6 @@ namespace sw
// RValue<Bool> operator==(RValue<UShort8> lhs, RValue<UShort8> rhs); // RValue<Bool> operator==(RValue<UShort8> lhs, RValue<UShort8> rhs);
RValue<UShort8> Swizzle(RValue<UShort8> x, char select0, char select1, char select2, char select3, char select4, char select5, char select6, char select7); RValue<UShort8> Swizzle(RValue<UShort8> x, char select0, char select1, char select2, char select3, char select4, char select5, char select6, char select7);
RValue<UShort8> Concatenate(RValue<UShort4> lo, RValue<UShort4> hi);
RValue<UShort8> MulHigh(RValue<UShort8> x, RValue<UShort8> y); RValue<UShort8> MulHigh(RValue<UShort8> x, RValue<UShort8> y);
class Int : public Variable<Int> class Int : public Variable<Int>
...@@ -1512,6 +1512,7 @@ namespace sw ...@@ -1512,6 +1512,7 @@ namespace sw
Int2(RValue<Int2> rhs); Int2(RValue<Int2> rhs);
Int2(const Int2 &rhs); Int2(const Int2 &rhs);
Int2(const Reference<Int2> &rhs); Int2(const Reference<Int2> &rhs);
Int2(RValue<Int> lo, RValue<Int> hi);
RValue<Int2> operator=(RValue<Int2> rhs) const; RValue<Int2> operator=(RValue<Int2> rhs) const;
RValue<Int2> operator=(const Int2 &rhs) const; RValue<Int2> operator=(const Int2 &rhs) const;
...@@ -1561,7 +1562,6 @@ namespace sw ...@@ -1561,7 +1562,6 @@ namespace sw
// RValue<Int2> RoundInt(RValue<Float4> cast); // RValue<Int2> RoundInt(RValue<Float4> cast);
RValue<Long1> UnpackLow(RValue<Int2> x, RValue<Int2> y); RValue<Long1> UnpackLow(RValue<Int2> x, RValue<Int2> y);
RValue<Long1> UnpackHigh(RValue<Int2> x, RValue<Int2> y); RValue<Long1> UnpackHigh(RValue<Int2> x, RValue<Int2> y);
RValue<Int2> Concatenate(RValue<Int> lo, RValue<Int> hi);
RValue<Int> Extract(RValue<Int2> val, int i); RValue<Int> Extract(RValue<Int2> val, int i);
RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i); RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i);
...@@ -1639,6 +1639,7 @@ namespace sw ...@@ -1639,6 +1639,7 @@ namespace sw
Int4(RValue<UInt4> rhs); Int4(RValue<UInt4> rhs);
Int4(const UInt4 &rhs); Int4(const UInt4 &rhs);
Int4(const Reference<UInt4> &rhs); Int4(const Reference<UInt4> &rhs);
Int4(RValue<Int2> lo, RValue<Int2> hi);
RValue<Int4> operator=(RValue<Int4> rhs) const; RValue<Int4> operator=(RValue<Int4> rhs) const;
RValue<Int4> operator=(const Int4 &rhs) const; RValue<Int4> operator=(const Int4 &rhs) const;
...@@ -1696,7 +1697,6 @@ namespace sw ...@@ -1696,7 +1697,6 @@ namespace sw
RValue<Int4> Min(RValue<Int4> x, RValue<Int4> y); RValue<Int4> Min(RValue<Int4> x, RValue<Int4> y);
RValue<Int4> RoundInt(RValue<Float4> cast); RValue<Int4> RoundInt(RValue<Float4> cast);
RValue<Short8> Pack(RValue<Int4> x, RValue<Int4> y); RValue<Short8> Pack(RValue<Int4> x, RValue<Int4> y);
RValue<Int4> Concatenate(RValue<Int2> lo, RValue<Int2> hi);
RValue<Int> Extract(RValue<Int4> x, int i); RValue<Int> Extract(RValue<Int4> x, int i);
RValue<Int4> Insert(RValue<Int4> val, RValue<Int> element, int i); RValue<Int4> Insert(RValue<Int4> val, RValue<Int> element, int i);
RValue<Int> SignMask(RValue<Int4> x); RValue<Int> SignMask(RValue<Int4> x);
...@@ -1719,6 +1719,7 @@ namespace sw ...@@ -1719,6 +1719,7 @@ namespace sw
UInt4(RValue<Int4> rhs); UInt4(RValue<Int4> rhs);
UInt4(const Int4 &rhs); UInt4(const Int4 &rhs);
UInt4(const Reference<Int4> &rhs); UInt4(const Reference<Int4> &rhs);
UInt4(RValue<UInt2> lo, RValue<UInt2> hi);
RValue<UInt4> operator=(RValue<UInt4> rhs) const; RValue<UInt4> operator=(RValue<UInt4> rhs) const;
RValue<UInt4> operator=(const UInt4 &rhs) const; RValue<UInt4> operator=(const UInt4 &rhs) const;
...@@ -1776,7 +1777,6 @@ namespace sw ...@@ -1776,7 +1777,6 @@ namespace sw
RValue<UInt4> Min(RValue<UInt4> x, RValue<UInt4> y); RValue<UInt4> Min(RValue<UInt4> x, RValue<UInt4> y);
// RValue<UInt4> RoundInt(RValue<Float4> cast); // RValue<UInt4> RoundInt(RValue<Float4> cast);
RValue<UShort8> Pack(RValue<UInt4> x, RValue<UInt4> y); RValue<UShort8> Pack(RValue<UInt4> x, RValue<UInt4> y);
RValue<UInt4> Concatenate(RValue<UInt2> lo, RValue<UInt2> hi);
template<int T> template<int T>
class Swizzle2Float4 class Swizzle2Float4
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment