Commit 7d0cde2c by Nicolas Capens

Implement increment/decrement operators.

Bug swiftshader:6 Change-Id: Ie59ca6e16eb82b84b01d9f47e5168fce7614084e Reviewed-on: https://swiftshader-review.googlesource.com/7953Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 568c3c25
...@@ -1529,32 +1529,26 @@ namespace sw ...@@ -1529,32 +1529,26 @@ namespace sw
RValue<Byte> operator++(const Byte &val, int) // Post-increment RValue<Byte> operator++(const Byte &val, int) // Post-increment
{ {
RValue<Byte> res = val; RValue<Byte> res = val;
val += Byte(1);
assert(false && "UNIMPLEMENTED");
return res; return res;
} }
const Byte &operator++(const Byte &val) // Pre-increment const Byte &operator++(const Byte &val) // Pre-increment
{ {
assert(false && "UNIMPLEMENTED"); val += Byte(1);
return val; return val;
} }
RValue<Byte> operator--(const Byte &val, int) // Post-decrement RValue<Byte> operator--(const Byte &val, int) // Post-decrement
{ {
RValue<Byte> res = val; RValue<Byte> res = val;
val -= Byte(1);
assert(false && "UNIMPLEMENTED");
return res; return res;
} }
const Byte &operator--(const Byte &val) // Pre-decrement const Byte &operator--(const Byte &val) // Pre-decrement
{ {
assert(false && "UNIMPLEMENTED"); val -= Byte(1);
return val; return val;
} }
...@@ -1779,35 +1773,26 @@ namespace sw ...@@ -1779,35 +1773,26 @@ namespace sw
RValue<SByte> operator++(const SByte &val, int) // Post-increment RValue<SByte> operator++(const SByte &val, int) // Post-increment
{ {
RValue<SByte> res = val; RValue<SByte> res = val;
val += SByte(1);
assert(false && "UNIMPLEMENTED");
return res; return res;
} }
const SByte &operator++(const SByte &val) // Pre-increment const SByte &operator++(const SByte &val) // Pre-increment
{ {
assert(false && "UNIMPLEMENTED"); val += SByte(1);
assert(false && "UNIMPLEMENTED");
return val; return val;
} }
RValue<SByte> operator--(const SByte &val, int) // Post-decrement RValue<SByte> operator--(const SByte &val, int) // Post-decrement
{ {
RValue<SByte> res = val; RValue<SByte> res = val;
val -= SByte(1);
assert(false && "UNIMPLEMENTED");
assert(false && "UNIMPLEMENTED");
return res; return res;
} }
const SByte &operator--(const SByte &val) // Pre-decrement const SByte &operator--(const SByte &val) // Pre-decrement
{ {
assert(false && "UNIMPLEMENTED"); val -= SByte(1);
assert(false && "UNIMPLEMENTED");
return val; return val;
} }
...@@ -2025,36 +2010,26 @@ namespace sw ...@@ -2025,36 +2010,26 @@ namespace sw
RValue<Short> operator++(const Short &val, int) // Post-increment RValue<Short> operator++(const Short &val, int) // Post-increment
{ {
RValue<Short> res = val; RValue<Short> res = val;
val += Short(1);
assert(false && "UNIMPLEMENTED");
assert(false && "UNIMPLEMENTED");
return res; return res;
} }
const Short &operator++(const Short &val) // Pre-increment const Short &operator++(const Short &val) // Pre-increment
{ {
assert(false && "UNIMPLEMENTED"); val += Short(1);
assert(false && "UNIMPLEMENTED");
return val; return val;
} }
RValue<Short> operator--(const Short &val, int) // Post-decrement RValue<Short> operator--(const Short &val, int) // Post-decrement
{ {
RValue<Short> res = val; RValue<Short> res = val;
val -= Short(1);
assert(false && "UNIMPLEMENTED");
assert(false && "UNIMPLEMENTED");
return res; return res;
} }
const Short &operator--(const Short &val) // Pre-decrement const Short &operator--(const Short &val) // Pre-decrement
{ {
assert(false && "UNIMPLEMENTED"); val -= Short(1);
assert(false && "UNIMPLEMENTED");
return val; return val;
} }
...@@ -2279,36 +2254,26 @@ namespace sw ...@@ -2279,36 +2254,26 @@ namespace sw
RValue<UShort> operator++(const UShort &val, int) // Post-increment RValue<UShort> operator++(const UShort &val, int) // Post-increment
{ {
RValue<UShort> res = val; RValue<UShort> res = val;
val += UShort(1);
assert(false && "UNIMPLEMENTED");
assert(false && "UNIMPLEMENTED");
return res; return res;
} }
const UShort &operator++(const UShort &val) // Pre-increment const UShort &operator++(const UShort &val) // Pre-increment
{ {
assert(false && "UNIMPLEMENTED"); val += UShort(1);
assert(false && "UNIMPLEMENTED");
return val; return val;
} }
RValue<UShort> operator--(const UShort &val, int) // Post-decrement RValue<UShort> operator--(const UShort &val, int) // Post-decrement
{ {
RValue<UShort> res = val; RValue<UShort> res = val;
val -= UShort(1);
assert(false && "UNIMPLEMENTED");
assert(false && "UNIMPLEMENTED");
return res; return res;
} }
const UShort &operator--(const UShort &val) // Pre-decrement const UShort &operator--(const UShort &val) // Pre-decrement
{ {
assert(false && "UNIMPLEMENTED"); val -= UShort(1);
assert(false && "UNIMPLEMENTED");
return val; return val;
} }
...@@ -2358,7 +2323,8 @@ namespace sw ...@@ -2358,7 +2323,8 @@ namespace sw
{ {
// xyzw.parent = this; // xyzw.parent = this;
assert(false && "UNIMPLEMENTED"); Value *value = rhs.loadValue();
storeValue(value);
} }
Type *Byte4::getType() Type *Byte4::getType()
...@@ -3973,28 +3939,28 @@ namespace sw ...@@ -3973,28 +3939,28 @@ namespace sw
RValue<Int> operator++(const Int &val, int) // Post-increment RValue<Int> operator++(const Int &val, int) // Post-increment
{ {
auto oldValue = val.loadValue(); RValue<UInt> res = val;
auto newValue = ::function->makeVariable(Ice::IceType_i32); val += 1;
auto inc = Ice::InstArithmetic::create(::function, Ice::InstArithmetic::Add, newValue, oldValue, ::context->getConstantInt32(1)); return res;
::basicBlock->appendInst(inc);
val.storeValue(V(newValue));
return RValue<Int>(oldValue);
} }
const Int &operator++(const Int &val) // Pre-increment const Int &operator++(const Int &val) // Pre-increment
{ {
assert(false && "UNIMPLEMENTED"); return val; val += 1;
return val;
} }
RValue<Int> operator--(const Int &val, int) // Post-decrement RValue<Int> operator--(const Int &val, int) // Post-decrement
{ {
assert(false && "UNIMPLEMENTED"); return RValue<Int>(V(nullptr)); RValue<Int> res = val;
val -= 1;
return res;
} }
const Int &operator--(const Int &val) // Pre-decrement const Int &operator--(const Int &val) // Pre-decrement
{ {
assert(false && "UNIMPLEMENTED"); return val; val -= 1;
return val;
} }
RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs) RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs)
...@@ -4388,22 +4354,28 @@ namespace sw ...@@ -4388,22 +4354,28 @@ namespace sw
RValue<UInt> operator++(const UInt &val, int) // Post-increment RValue<UInt> operator++(const UInt &val, int) // Post-increment
{ {
assert(false && "UNIMPLEMENTED"); return RValue<UInt>(V(nullptr)); RValue<UInt> res = val;
val += 1;
return res;
} }
const UInt &operator++(const UInt &val) // Pre-increment const UInt &operator++(const UInt &val) // Pre-increment
{ {
assert(false && "UNIMPLEMENTED"); return val; val += 1;
return val;
} }
RValue<UInt> operator--(const UInt &val, int) // Post-decrement RValue<UInt> operator--(const UInt &val, int) // Post-decrement
{ {
assert(false && "UNIMPLEMENTED"); return RValue<UInt>(V(nullptr)); RValue<UInt> res = val;
val -= 1;
return res;
} }
const UInt &operator--(const UInt &val) // Pre-decrement const UInt &operator--(const UInt &val) // Pre-decrement
{ {
assert(false && "UNIMPLEMENTED"); return val; val -= 1;
return val;
} }
RValue<UInt> Max(RValue<UInt> x, RValue<UInt> y) RValue<UInt> Max(RValue<UInt> x, RValue<UInt> y)
......
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