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);
......
......@@ -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));
......
......@@ -53,10 +53,10 @@ 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));
......
......@@ -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