Commit 77dfab49 by Alexis Hetu Committed by Alexis Hétu

Added some truncation constructors in Nucleus

Added some extra constructors that simply truncate from a type which has a higher number of bits. The new constructors are: - Byte from UInt - Byte from UShort - SByte from Int - SByte from Short - UShort from UInt Also added an implementation of the RoundUInt function using the UInt from Float constructor, which had to be fixed since it was using createFPToSI instead of createFPToUI. Change-Id: Ie7ee21ef20fbb8133b9f7c74afa1fec9e6c51957 Reviewed-on: https://swiftshader-review.googlesource.com/4300Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 34cab51b
...@@ -933,6 +933,20 @@ namespace sw ...@@ -933,6 +933,20 @@ namespace sw
storeValue(integer); storeValue(integer);
} }
Byte::Byte(RValue<UInt> cast)
{
Value *integer = Nucleus::createTrunc(cast.value, Byte::getType());
storeValue(integer);
}
Byte::Byte(RValue<UShort> cast)
{
Value *integer = Nucleus::createTrunc(cast.value, Byte::getType());
storeValue(integer);
}
Byte::Byte() Byte::Byte()
{ {
} }
...@@ -1178,6 +1192,20 @@ namespace sw ...@@ -1178,6 +1192,20 @@ namespace sw
storeValue(argument); storeValue(argument);
} }
SByte::SByte(RValue<Int> cast)
{
Value *integer = Nucleus::createTrunc(cast.value, SByte::getType());
storeValue(integer);
}
SByte::SByte(RValue<Short> cast)
{
Value *integer = Nucleus::createTrunc(cast.value, SByte::getType());
storeValue(integer);
}
SByte::SByte() SByte::SByte()
{ {
} }
...@@ -1665,6 +1693,13 @@ namespace sw ...@@ -1665,6 +1693,13 @@ namespace sw
storeValue(argument); storeValue(argument);
} }
UShort::UShort(RValue<UInt> cast)
{
Value *integer = Nucleus::createTrunc(cast.value, UShort::getType());
storeValue(integer);
}
UShort::UShort() UShort::UShort()
{ {
} }
...@@ -4205,7 +4240,7 @@ namespace sw ...@@ -4205,7 +4240,7 @@ namespace sw
UInt::UInt(RValue<Float> cast) UInt::UInt(RValue<Float> cast)
{ {
Value *integer = Nucleus::createFPToSI(cast.value, UInt::getType()); Value *integer = Nucleus::createFPToUI(cast.value, UInt::getType());
storeValue(integer); storeValue(integer);
} }
......
...@@ -401,6 +401,8 @@ namespace sw ...@@ -401,6 +401,8 @@ namespace sw
explicit Byte(llvm::Argument *argument); explicit Byte(llvm::Argument *argument);
explicit Byte(RValue<Int> cast); explicit Byte(RValue<Int> cast);
explicit Byte(RValue<UInt> cast);
explicit Byte(RValue<UShort> cast);
Byte(); Byte();
Byte(int x); Byte(int x);
...@@ -456,6 +458,9 @@ namespace sw ...@@ -456,6 +458,9 @@ namespace sw
public: public:
explicit SByte(llvm::Argument *argument); explicit SByte(llvm::Argument *argument);
explicit SByte(RValue<Int> cast);
explicit SByte(RValue<Short> cast);
SByte(); SByte();
SByte(signed char x); SByte(signed char x);
SByte(RValue<SByte> rhs); SByte(RValue<SByte> rhs);
...@@ -564,6 +569,8 @@ namespace sw ...@@ -564,6 +569,8 @@ namespace sw
public: public:
explicit UShort(llvm::Argument *argument); explicit UShort(llvm::Argument *argument);
explicit UShort(RValue<UInt> cast);
UShort(); UShort();
UShort(unsigned short x); UShort(unsigned short x);
UShort(RValue<UShort> rhs); UShort(RValue<UShort> rhs);
......
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