Commit 8dfd9a76 by Nicolas Capens

Implement support for vector constants.

Bug swiftshader:17 Change-Id: Ifde00443ab55a4cf68a038fac6356182518253fe Reviewed-on: https://swiftshader-review.googlesource.com/7715Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-on: https://swiftshader-review.googlesource.com/7671Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 66478362
......@@ -3458,23 +3458,17 @@ namespace sw
Short8::Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7)
{
// xyzw.parent = this;
int64_t constantVector[8] = {c0, c1, c2, c3, c4, c5, c6, c7};
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
Short8::Short8(RValue<Short8> rhs)
{
// xyzw.parent = this;
storeValue(rhs.value);
}
Short8::Short8(const Reference<Short8> &rhs)
{
// xyzw.parent = this;
Value *value = rhs.loadValue();
storeValue(value);
}
......@@ -3542,23 +3536,17 @@ namespace sw
UShort8::UShort8(unsigned short c0, unsigned short c1, unsigned short c2, unsigned short c3, unsigned short c4, unsigned short c5, unsigned short c6, unsigned short c7)
{
// xyzw.parent = this;
int64_t constantVector[8] = {c0, c1, c2, c3, c4, c5, c6, c7};
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
UShort8::UShort8(RValue<UShort8> rhs)
{
// xyzw.parent = this;
storeValue(rhs.value);
}
UShort8::UShort8(const Reference<UShort8> &rhs)
{
// xyzw.parent = this;
Value *value = rhs.loadValue();
storeValue(value);
}
......
......@@ -133,6 +133,55 @@ TEST(SubzeroReactorTest, SubVectorLoadStore)
delete routine;
}
TEST(SubzeroReactorTest, VectorConstant)
{
Routine *routine = nullptr;
{
Function<Int(Pointer<Byte>)> function;
{
Pointer<Byte> out = function.Arg<0>();
*Pointer<Int4>(out + 16 * 0) = Int4(0x04030201, 0x08070605, 0x0C0B0A09, 0x100F0E0D);
*Pointer<Short4>(out + 16 * 1) = Short4(0x1211, 0x1413, 0x1615, 0x1817);
*Pointer<Byte8>(out + 16 * 2) = Byte8(0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20);
*Pointer<Int2>(out + 16 * 3) = Int2(0x24232221, 0x28272625);
Return(0);
}
routine = function(L"one");
if(routine)
{
int8_t out[16 * 4] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
int8_t exp[16 * 4] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, -1, -1, -1, -1, -1, -1, -1, -1,
25, 26, 27, 28, 29, 30, 31, 32, -1, -1, -1, -1, -1, -1, -1, -1,
33, 34, 35, 36, 37, 38, 39, 40, -1, -1, -1, -1, -1, -1, -1, -1};
int(*callable)(void*) = (int(*)(void*))routine->getEntry();
callable(out);
for(int row = 0; row < 4; row++)
{
for(int col = 0; col < 16; col++)
{
int i = row * 16 + col;
EXPECT_EQ(out[i], exp[i]);
}
}
}
}
delete routine;
}
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
......
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