Commit 9b8dbba4 by Nicolas Capens

Implement remaining vector extract/insert operations.

Bug swiftshader:15 Change-Id: I9ed683b6d122183c4313d2bf609fd7c14bf5e387 Reviewed-on: https://swiftshader-review.googlesource.com/7958Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 8cda6909
...@@ -6470,14 +6470,9 @@ namespace sw ...@@ -6470,14 +6470,9 @@ namespace sw
return x86::sqrtps(x); return x86::sqrtps(x);
} }
RValue<Float4> Insert(const Float4 &val, RValue<Float> element, int i) RValue<Float4> Insert(RValue<Float4> val, RValue<Float> element, int i)
{ {
Value *value = val.loadValue(); return RValue<Float4>(Nucleus::createInsertElement(val.value, element.value, i));
Value *insert = Nucleus::createInsertElement(value, element.value, i);
val = RValue<Float4>(insert);
return val;
} }
RValue<Float> Extract(RValue<Float4> x, int i) RValue<Float> Extract(RValue<Float4> x, int i)
......
...@@ -1462,7 +1462,7 @@ namespace sw ...@@ -1462,7 +1462,7 @@ 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<Int> Extract(RValue<Int4> x, int i); RValue<Int> Extract(RValue<Int4> val, 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);
RValue<Int4> Swizzle(RValue<Int4> x, unsigned char select); RValue<Int4> Swizzle(RValue<Int4> x, unsigned char select);
...@@ -2135,7 +2135,7 @@ namespace sw ...@@ -2135,7 +2135,7 @@ namespace sw
RValue<Float4> Rcp_pp(RValue<Float4> val, bool exactAtPow2 = false); RValue<Float4> Rcp_pp(RValue<Float4> val, bool exactAtPow2 = false);
RValue<Float4> RcpSqrt_pp(RValue<Float4> val); RValue<Float4> RcpSqrt_pp(RValue<Float4> val);
RValue<Float4> Sqrt(RValue<Float4> x); RValue<Float4> Sqrt(RValue<Float4> x);
RValue<Float4> Insert(const Float4 &val, RValue<Float> element, int i); RValue<Float4> Insert(RValue<Float4> val, RValue<Float> element, int i);
RValue<Float> Extract(RValue<Float4> x, int i); RValue<Float> Extract(RValue<Float4> x, int i);
RValue<Float4> Swizzle(RValue<Float4> x, unsigned char select); RValue<Float4> Swizzle(RValue<Float4> x, unsigned char select);
RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, unsigned char imm); RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, unsigned char imm);
...@@ -2511,7 +2511,7 @@ namespace sw ...@@ -2511,7 +2511,7 @@ namespace sw
template<int T> template<int T>
RValue<Float4> SwizzleMask1Float4<T>::operator=(float x) const RValue<Float4> SwizzleMask1Float4<T>::operator=(float x) const
{ {
return Insert(*parent, Float(x), T & 0x3); return *parent = Insert(*parent, Float(x), T & 0x3);
} }
template<int T> template<int T>
...@@ -2523,7 +2523,7 @@ namespace sw ...@@ -2523,7 +2523,7 @@ namespace sw
template<int T> template<int T>
RValue<Float4> SwizzleMask1Float4<T>::operator=(RValue<Float> rhs) const // FIXME: Call a non-template function RValue<Float4> SwizzleMask1Float4<T>::operator=(RValue<Float> rhs) const // FIXME: Call a non-template function
{ {
return Insert(*parent, rhs, T & 0x3); return *parent = Insert(*parent, rhs, T & 0x3);
} }
template<int T> template<int T>
......
...@@ -260,6 +260,10 @@ ...@@ -260,6 +260,10 @@
<ClInclude Include="$(SolutionDir)third_party\pnacl-subzero\src\IceVariableSplitting.h" /> <ClInclude Include="$(SolutionDir)third_party\pnacl-subzero\src\IceVariableSplitting.h" />
<ClInclude Include="$(SolutionDir)third_party\pnacl-subzero\src\IceTargetLoweringX8664.h" /> <ClInclude Include="$(SolutionDir)third_party\pnacl-subzero\src\IceTargetLoweringX8664.h" />
<ClInclude Include="$(SolutionDir)third_party\pnacl-subzero\src\IceTargetLoweringX8664Traits.h" /> <ClInclude Include="$(SolutionDir)third_party\pnacl-subzero\src\IceTargetLoweringX8664Traits.h" />
<ClInclude Include="$(SolutionDir)third_party\pnacl-subzero\src\IceAssemblerX8664.h" />
<ClInclude Include="$(SolutionDir)third_party\pnacl-subzero\src\IceConditionCodesX8664.h" />
<ClInclude Include="$(SolutionDir)third_party\pnacl-subzero\src\IceInstX8664.h" />
<ClInclude Include="$(SolutionDir)third_party\pnacl-subzero\src\IceRegistersX8664.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="$(SolutionDir)third_party\pnacl-subzero\src\IceClFlags.def" /> <None Include="$(SolutionDir)third_party\pnacl-subzero\src\IceClFlags.def" />
......
...@@ -275,6 +275,18 @@ ...@@ -275,6 +275,18 @@
<ClInclude Include="$(SolutionDir)third_party\pnacl-subzero\src\IceTargetLoweringX8664.h"> <ClInclude Include="$(SolutionDir)third_party\pnacl-subzero\src\IceTargetLoweringX8664.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(SolutionDir)third_party\pnacl-subzero\src\IceAssemblerX8664.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)third_party\pnacl-subzero\src\IceConditionCodesX8664.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)third_party\pnacl-subzero\src\IceInstX8664.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)third_party\pnacl-subzero\src\IceRegistersX8664.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="$(SolutionDir)third_party\pnacl-subzero\src\IceClFlags.def"> <None Include="$(SolutionDir)third_party\pnacl-subzero\src\IceClFlags.def">
......
...@@ -3307,12 +3307,12 @@ namespace sw ...@@ -3307,12 +3307,12 @@ namespace sw
RValue<Short4> Insert(RValue<Short4> val, RValue<Short> element, int i) RValue<Short4> Insert(RValue<Short4> val, RValue<Short> element, int i)
{ {
assert(false && "UNIMPLEMENTED"); return RValue<Short4>(V(nullptr)); return RValue<Short4>(Nucleus::createInsertElement(val.value, element.value, i));
} }
RValue<Short> Extract(RValue<Short4> val, int i) RValue<Short> Extract(RValue<Short4> val, int i)
{ {
assert(false && "UNIMPLEMENTED"); return RValue<Short>(V(nullptr)); return RValue<Short>(Nucleus::createExtractElement(val.value, Int::getType(), i));
} }
RValue<Short4> CmpGT(RValue<Short4> x, RValue<Short4> y) RValue<Short4> CmpGT(RValue<Short4> x, RValue<Short4> y)
...@@ -4776,12 +4776,12 @@ namespace sw ...@@ -4776,12 +4776,12 @@ namespace sw
RValue<Int> Extract(RValue<Int2> val, int i) RValue<Int> Extract(RValue<Int2> val, int i)
{ {
assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr)); return RValue<Int>(Nucleus::createExtractElement(val.value, Int::getType(), i));
} }
RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i) RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i)
{ {
assert(false && "UNIMPLEMENTED"); return RValue<Int2>(V(nullptr)); return RValue<Int2>(Nucleus::createInsertElement(val.value, element.value, i));
} }
Type *Int2::getType() Type *Int2::getType()
...@@ -6187,14 +6187,9 @@ namespace sw ...@@ -6187,14 +6187,9 @@ namespace sw
return RValue<Float4>(V(result)); return RValue<Float4>(V(result));
} }
RValue<Float4> Insert(const Float4 &val, RValue<Float> element, int i) RValue<Float4> Insert(RValue<Float4> x, RValue<Float> element, int i)
{ {
Value *value = val.loadValue(); return RValue<Float4>(Nucleus::createInsertElement(x.value, element.value, i));
Value *insert = Nucleus::createInsertElement(value, element.value, i);
val = RValue<Float4>(insert);
return val;
} }
RValue<Float> Extract(RValue<Float4> x, int i) RValue<Float> Extract(RValue<Float4> x, int i)
......
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