Commit 81f1830d by Nicolas Capens

Make Function arguments type-safe.

Change-Id: I3d4262ea4be0c7b1128b2ca410e985cc6f58c9c9 Reviewed-on: https://swiftshader-review.googlesource.com/1970Tested-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 2ab859f2
......@@ -236,8 +236,8 @@ namespace sw
Function<Void(Pointer<Byte>, Pointer<Byte>)> function;
{
Pointer<Byte> dst(function.arg(0));
Pointer<Byte> src(function.arg(1));
Pointer<Byte> dst(function.Arg<0>());
Pointer<Byte> src(function.Arg<1>());
For(Int y = 0, y < height, y++)
{
......
......@@ -294,7 +294,7 @@ namespace sw
return function;
}
llvm::Argument *Nucleus::getArgument(llvm::Function *function, unsigned int index)
llvm::Value *Nucleus::getArgument(llvm::Function *function, unsigned int index)
{
llvm::Function::arg_iterator args = function->arg_begin();
......@@ -847,9 +847,9 @@ namespace sw
return Type::getX86_MMXTy(*Nucleus::getContext());
}
Bool::Bool(Argument *argument)
Bool::Bool(Argument<Bool> argument)
{
storeValue(argument);
storeValue(argument.value);
}
Bool::Bool()
......@@ -921,9 +921,9 @@ namespace sw
return Type::getInt1Ty(*Nucleus::getContext());
}
Byte::Byte(Argument *argument)
Byte::Byte(Argument<Byte> argument)
{
storeValue(argument);
storeValue(argument.value);
}
Byte::Byte(RValue<Int> cast)
......@@ -1187,9 +1187,9 @@ namespace sw
return Type::getInt8Ty(*Nucleus::getContext());
}
SByte::SByte(Argument *argument)
SByte::SByte(Argument<SByte> argument)
{
storeValue(argument);
storeValue(argument.value);
}
SByte::SByte(RValue<Int> cast)
......@@ -1441,9 +1441,9 @@ namespace sw
return Type::getInt8Ty(*Nucleus::getContext());
}
Short::Short(Argument *argument)
Short::Short(Argument<Short> argument)
{
storeValue(argument);
storeValue(argument.value);
}
Short::Short(RValue<Int> cast)
......@@ -1688,9 +1688,9 @@ namespace sw
return Type::getInt16Ty(*Nucleus::getContext());
}
UShort::UShort(Argument *argument)
UShort::UShort(Argument<UShort> argument)
{
storeValue(argument);
storeValue(argument.value);
}
UShort::UShort(RValue<UInt> cast)
......@@ -3747,9 +3747,9 @@ namespace sw
return VectorType::get(UShort::getType(), 8);
}
Int::Int(Argument *argument)
Int::Int(Argument<Int> argument)
{
storeValue(argument);
storeValue(argument.value);
}
Int::Int(RValue<Byte> cast)
......@@ -4225,9 +4225,9 @@ namespace sw
return VectorType::get(Long::getType(), 2);
}
UInt::UInt(Argument *argument)
UInt::UInt(Argument<UInt> argument)
{
storeValue(argument);
storeValue(argument.value);
}
UInt::UInt(RValue<UShort> cast)
......@@ -6765,62 +6765,62 @@ namespace sw
return VectorType::get(Float::getType(), 4);
}
RValue<Pointer<Byte> > operator+(RValue<Pointer<Byte> > lhs, int offset)
RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset)
{
return RValue<Pointer<Byte> >(Nucleus::createGEP(lhs.value, Nucleus::createConstantInt(offset)));
return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Nucleus::createConstantInt(offset)));
}
RValue<Pointer<Byte> > operator+(RValue<Pointer<Byte> > lhs, RValue<Int> offset)
RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset)
{
return RValue<Pointer<Byte> >(Nucleus::createGEP(lhs.value, offset.value));
return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, offset.value));
}
RValue<Pointer<Byte> > operator+(RValue<Pointer<Byte> > lhs, RValue<UInt> offset)
RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset)
{
return RValue<Pointer<Byte> >(Nucleus::createGEP(lhs.value, offset.value));
return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, offset.value));
}
RValue<Pointer<Byte> > operator+=(const Pointer<Byte> &lhs, int offset)
RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, int offset)
{
return lhs = lhs + offset;
}
RValue<Pointer<Byte> > operator+=(const Pointer<Byte> &lhs, RValue<Int> offset)
RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<Int> offset)
{
return lhs = lhs + offset;
}
RValue<Pointer<Byte> > operator+=(const Pointer<Byte> &lhs, RValue<UInt> offset)
RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<UInt> offset)
{
return lhs = lhs + offset;
}
RValue<Pointer<Byte> > operator-(RValue<Pointer<Byte> > lhs, int offset)
RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, int offset)
{
return lhs + -offset;
}
RValue<Pointer<Byte> > operator-(RValue<Pointer<Byte> > lhs, RValue<Int> offset)
RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<Int> offset)
{
return lhs + -offset;
}
RValue<Pointer<Byte> > operator-(RValue<Pointer<Byte> > lhs, RValue<UInt> offset)
RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<UInt> offset)
{
return lhs + -offset;
}
RValue<Pointer<Byte> > operator-=(const Pointer<Byte> &lhs, int offset)
RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, int offset)
{
return lhs = lhs - offset;
}
RValue<Pointer<Byte> > operator-=(const Pointer<Byte> &lhs, RValue<Int> offset)
RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<Int> offset)
{
return lhs = lhs - offset;
}
RValue<Pointer<Byte> > operator-=(const Pointer<Byte> &lhs, RValue<UInt> offset)
RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<UInt> offset)
{
return lhs = lhs - offset;
}
......@@ -7761,7 +7761,7 @@ namespace sw
return RValue<Int>(Nucleus::createCall(pmovmskb, As<MMX>(x).value));
}
//RValue<Int2> movd(RValue<Pointer<Int> > x)
//RValue<Int2> movd(RValue<Pointer<Int>> x)
//{
// Value *element = Nucleus::createLoad(x.value);
......
......@@ -589,7 +589,7 @@ namespace sw
{
unsigned short mask = (writeB ? 0x001F : 0x0000) | (writeG ? 0x07E0 : 0x0000) | (writeR ? 0xF800 : 0x0000);
unsigned short unmask = ~mask;
*Pointer<UShort>(element) = (*Pointer<UShort>(element) & UShort(unmask)) |
*Pointer<UShort>(element) = (*Pointer<UShort>(element) & UShort(unmask)) |
(UShort(RoundInt(Float(c.z)) |
(RoundInt(Float(c.y)) << Int(5)) |
(RoundInt(Float(c.x)) << Int(11))) & UShort(mask));
......@@ -966,10 +966,10 @@ namespace sw
{
Function<Void(Pointer<Byte>)> function;
{
Pointer<Byte> blit(function.arg(0));
Pointer<Byte> blit(function.Arg<0>());
Pointer<Byte> source = *Pointer<Pointer<Byte> >(blit + OFFSET(BlitData,source));
Pointer<Byte> dest = *Pointer<Pointer<Byte> >(blit + OFFSET(BlitData,dest));
Pointer<Byte> source = *Pointer<Pointer<Byte>>(blit + OFFSET(BlitData,source));
Pointer<Byte> dest = *Pointer<Pointer<Byte>>(blit + OFFSET(BlitData,dest));
Int sPitchB = *Pointer<Int>(blit + OFFSET(BlitData,sPitchB));
Int dPitchB = *Pointer<Int>(blit + OFFSET(BlitData,dPitchB));
......@@ -1147,7 +1147,7 @@ namespace sw
criticalSection.lock();
Routine *blitRoutine = blitCache->query(state);
if(!blitRoutine)
{
blitRoutine = generate(state);
......@@ -1179,7 +1179,7 @@ namespace sw
data.h = 1.0f / (dRect.y1 - dRect.y0) * (sRect.y1 - sRect.y0);
data.x0 = (float)sRect.x0 + 0.5f * data.w;
data.y0 = (float)sRect.y0 + 0.5f * data.h;
data.x0d = dRect.x0;
data.x1d = dRect.x1;
data.y0d = dRect.y0;
......
......@@ -53,16 +53,16 @@ namespace sw
Long pixelTime = Ticks();
#endif
Pointer<Byte> primitive(function.arg(0));
Int count(function.arg(1));
Int cluster(function.arg(2));
Pointer<Byte> data(function.arg(3));
Pointer<Byte> primitive(function.Arg<0>());
Int count(function.Arg<1>());
Int cluster(function.Arg<2>());
Pointer<Byte> data(function.Arg<3>());
Registers& r = *createRegisters(shader);
r.constants = *Pointer<Pointer<Byte> >(data + OFFSET(DrawData,constants));
r.cluster = cluster;
r.data = data;
Do
{
r.primitive = primitive;
......@@ -134,20 +134,20 @@ namespace sw
}
Int y = yMin;
Do
{
Int x0a = Int(*Pointer<Short>(r.primitive + OFFSET(Primitive,outline->left) + (y + 0) * sizeof(Primitive::Span)));
Int x0b = Int(*Pointer<Short>(r.primitive + OFFSET(Primitive,outline->left) + (y + 1) * sizeof(Primitive::Span)));
Int x0 = Min(x0a, x0b);
for(unsigned int q = 1; q < state.multiSample; q++)
{
x0a = Int(*Pointer<Short>(r.primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->left) + (y + 0) * sizeof(Primitive::Span)));
x0b = Int(*Pointer<Short>(r.primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->left) + (y + 1) * sizeof(Primitive::Span)));
x0 = Min(x0, Min(x0a, x0b));
}
x0 &= 0xFFFFFFFE;
Int x1a = Int(*Pointer<Short>(r.primitive + OFFSET(Primitive,outline->right) + (y + 0) * sizeof(Primitive::Span)));
......@@ -193,7 +193,7 @@ namespace sw
pitch = *Pointer<Int>(r.data + OFFSET(DrawData,depthPitchB));
}
else
{
{
buffer = zBuffer + 8 * x0;
}
......@@ -202,7 +202,7 @@ namespace sw
Float4 z = interpolate(xxxx, r.Dz[0], z, r.primitive + OFFSET(Primitive,z), false, false);
Float4 zValue;
if(!state.quadLayoutDepthBuffer)
{
// FIXME: Properly optimizes?
......
......@@ -36,10 +36,10 @@ namespace sw
{
Function<Bool(Pointer<Byte>, Pointer<Byte>, Pointer<Byte>, Pointer<Byte>)> function;
{
Pointer<Byte> primitive(function.arg(0));
Pointer<Byte> tri(function.arg(1));
Pointer<Byte> polygon(function.arg(2));
Pointer<Byte> data(function.arg(3));
Pointer<Byte> primitive(function.Arg<0>());
Pointer<Byte> tri(function.Arg<1>());
Pointer<Byte> polygon(function.Arg<2>());
Pointer<Byte> data(function.Arg<3>());
Pointer<Byte> constants = *Pointer<Pointer<Byte> >(data + OFFSET(DrawData,constants));
......
......@@ -36,10 +36,10 @@ namespace sw
{
Function<Void(Pointer<Byte>, Pointer<Byte>, Pointer<Byte>, Pointer<Byte>)> function;
{
Pointer<Byte> vertex(function.arg(0));
Pointer<Byte> batch(function.arg(1));
Pointer<Byte> task(function.arg(2));
Pointer<Byte> data(function.arg(3));
Pointer<Byte> vertex(function.Arg<0>());
Pointer<Byte> batch(function.Arg<1>());
Pointer<Byte> task(function.Arg<2>());
Pointer<Byte> data(function.Arg<3>());
const bool texldl = state.shaderContainsTexldl;
......
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