mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
- added genuine PEX_GT, PEX_GTEQ and PEX_NEQ operations to the parser.
These were previously faked with the inverse plus a boolean not. Although this works, it either leads to sub-optimal code generation or some fudging to avoid the inefficient handling. Just adding proper handling to the parser seems the easiest and most straightforward way to get around this. The code generator already can deal with these operations properly so there's no good reason to do it differently.
This commit is contained in:
parent
552f094ec1
commit
d0a8960f61
3 changed files with 21 additions and 9 deletions
|
@ -1161,9 +1161,8 @@ expr(X) ::= expr(A) LT expr(B). /* a < b */
|
||||||
}
|
}
|
||||||
expr(X) ::= expr(A) GT expr(B). /* a > b */
|
expr(X) ::= expr(A) GT expr(B). /* a > b */
|
||||||
{
|
{
|
||||||
BINARY_EXPR(A,B,PEX_LTEQ);
|
BINARY_EXPR(A,B,PEX_GT);
|
||||||
UNARY_EXPR(expr2,PEX_BoolNot);
|
X = expr2;
|
||||||
X = expr1;
|
|
||||||
}
|
}
|
||||||
expr(X) ::= expr(A) LTEQ expr(B). /* a <= b */
|
expr(X) ::= expr(A) LTEQ expr(B). /* a <= b */
|
||||||
{
|
{
|
||||||
|
@ -1172,9 +1171,8 @@ expr(X) ::= expr(A) LTEQ expr(B). /* a <= b */
|
||||||
}
|
}
|
||||||
expr(X) ::= expr(A) GTEQ expr(B). /* a >= b */
|
expr(X) ::= expr(A) GTEQ expr(B). /* a >= b */
|
||||||
{
|
{
|
||||||
BINARY_EXPR(A,B,PEX_LT);
|
BINARY_EXPR(A,B,PEX_GTEQ);
|
||||||
UNARY_EXPR(expr1,PEX_BoolNot);
|
X = expr2;
|
||||||
X = expr1;
|
|
||||||
}
|
}
|
||||||
expr(X) ::= expr(A) LTGTEQ expr(B). /* a <>= b */
|
expr(X) ::= expr(A) LTGTEQ expr(B). /* a <>= b */
|
||||||
{
|
{
|
||||||
|
@ -1194,9 +1192,8 @@ expr(X) ::= expr(A) EQEQ expr(B). /* a == b */
|
||||||
}
|
}
|
||||||
expr(X) ::= expr(A) NEQ expr(B). /* a != b */
|
expr(X) ::= expr(A) NEQ expr(B). /* a != b */
|
||||||
{
|
{
|
||||||
BINARY_EXPR(A,B,PEX_EQEQ);
|
BINARY_EXPR(A,B,PEX_NEQ);
|
||||||
UNARY_EXPR(expr2,PEX_BoolNot);
|
X = expr2;
|
||||||
X = expr1;
|
|
||||||
}
|
}
|
||||||
expr(X) ::= expr(A) APPROXEQ expr(B). /* a ~== b */
|
expr(X) ::= expr(A) APPROXEQ expr(B). /* a ~== b */
|
||||||
{
|
{
|
||||||
|
|
|
@ -365,6 +365,18 @@ void ZCC_InitOperators()
|
||||||
{ PEX_LTEQ , (PType **)&TypeBool, (PType **)&TypeUInt32, (PType **)&TypeUInt32, [](auto *l, auto *r, auto &) { l->IntVal = l->UIntVal <= r->UIntVal; l->Type = TypeBool; return l; } },
|
{ PEX_LTEQ , (PType **)&TypeBool, (PType **)&TypeUInt32, (PType **)&TypeUInt32, [](auto *l, auto *r, auto &) { l->IntVal = l->UIntVal <= r->UIntVal; l->Type = TypeBool; return l; } },
|
||||||
{ PEX_LTEQ , (PType **)&TypeBool, (PType **)&TypeFloat64, (PType **)&TypeFloat64, [](auto *l, auto *r, auto &) { l->IntVal = l->DoubleVal <= r->DoubleVal; l->Type = TypeBool; return l; } },
|
{ PEX_LTEQ , (PType **)&TypeBool, (PType **)&TypeFloat64, (PType **)&TypeFloat64, [](auto *l, auto *r, auto &) { l->IntVal = l->DoubleVal <= r->DoubleVal; l->Type = TypeBool; return l; } },
|
||||||
|
|
||||||
|
{ PEX_GT , (PType **)&TypeBool, (PType **)&TypeSInt32, (PType **)&TypeSInt32, [](auto *l, auto *r, auto &) { l->IntVal = l->IntVal > r->IntVal; l->Type = TypeBool; return l; } },
|
||||||
|
{ PEX_GT , (PType **)&TypeBool, (PType **)&TypeUInt32, (PType **)&TypeUInt32, [](auto *l, auto *r, auto &) { l->IntVal = l->UIntVal > r->UIntVal; l->Type = TypeBool; return l; } },
|
||||||
|
{ PEX_GT , (PType **)&TypeBool, (PType **)&TypeFloat64, (PType **)&TypeFloat64, [](auto *l, auto *r, auto &) { l->IntVal = l->DoubleVal > r->DoubleVal; l->Type = TypeBool; return l; } },
|
||||||
|
|
||||||
|
{ PEX_GTEQ , (PType **)&TypeBool, (PType **)&TypeSInt32, (PType **)&TypeSInt32, [](auto *l, auto *r, auto &) { l->IntVal = l->IntVal >= r->IntVal; l->Type = TypeBool; return l; } },
|
||||||
|
{ PEX_GTEQ , (PType **)&TypeBool, (PType **)&TypeUInt32, (PType **)&TypeUInt32, [](auto *l, auto *r, auto &) { l->IntVal = l->UIntVal >= r->UIntVal; l->Type = TypeBool; return l; } },
|
||||||
|
{ PEX_GTEQ , (PType **)&TypeBool, (PType **)&TypeFloat64, (PType **)&TypeFloat64, [](auto *l, auto *r, auto &) { l->IntVal = l->DoubleVal >= r->DoubleVal; l->Type = TypeBool; return l; } },
|
||||||
|
|
||||||
|
{ PEX_NEQ , (PType **)&TypeBool, (PType **)&TypeSInt32, (PType **)&TypeSInt32, [](auto *l, auto *r, auto &) { l->IntVal = l->IntVal != r->IntVal; l->Type = TypeBool; return l; } },
|
||||||
|
{ PEX_NEQ , (PType **)&TypeBool, (PType **)&TypeUInt32, (PType **)&TypeUInt32, [](auto *l, auto *r, auto &) { l->IntVal = l->UIntVal != r->UIntVal; l->Type = TypeBool; return l; } },
|
||||||
|
{ PEX_NEQ , (PType **)&TypeBool, (PType **)&TypeFloat64, (PType **)&TypeFloat64, [](auto *l, auto *r, auto &) { l->IntVal = l->DoubleVal != r->DoubleVal; l->Type = TypeBool; return l; } },
|
||||||
|
|
||||||
{ PEX_EQEQ , (PType **)&TypeBool, (PType **)&TypeSInt32, (PType **)&TypeSInt32, [](auto *l, auto *r, auto &) { l->IntVal = l->IntVal == r->IntVal; l->Type = TypeBool; return l; } },
|
{ PEX_EQEQ , (PType **)&TypeBool, (PType **)&TypeSInt32, (PType **)&TypeSInt32, [](auto *l, auto *r, auto &) { l->IntVal = l->IntVal == r->IntVal; l->Type = TypeBool; return l; } },
|
||||||
{ PEX_EQEQ , (PType **)&TypeBool, (PType **)&TypeUInt32, (PType **)&TypeUInt32, [](auto *l, auto *r, auto &) { l->IntVal = l->UIntVal == r->UIntVal; l->Type = TypeBool; return l; } },
|
{ PEX_EQEQ , (PType **)&TypeBool, (PType **)&TypeUInt32, (PType **)&TypeUInt32, [](auto *l, auto *r, auto &) { l->IntVal = l->UIntVal == r->UIntVal; l->Type = TypeBool; return l; } },
|
||||||
{ PEX_EQEQ , (PType **)&TypeBool, (PType **)&TypeFloat64, (PType **)&TypeFloat64, [](auto *l, auto *r, auto &) { l->IntVal = l->DoubleVal == r->DoubleVal; l->Type = TypeBool; return l; } },
|
{ PEX_EQEQ , (PType **)&TypeBool, (PType **)&TypeFloat64, (PType **)&TypeFloat64, [](auto *l, auto *r, auto &) { l->IntVal = l->DoubleVal == r->DoubleVal; l->Type = TypeBool; return l; } },
|
||||||
|
|
|
@ -36,10 +36,13 @@ xx(Concat, )
|
||||||
|
|
||||||
xx(LT, )
|
xx(LT, )
|
||||||
xx(LTEQ, )
|
xx(LTEQ, )
|
||||||
|
xx(GT, )
|
||||||
|
xx(GTEQ, )
|
||||||
xx(LTGTEQ, )
|
xx(LTGTEQ, )
|
||||||
xx(Is, )
|
xx(Is, )
|
||||||
|
|
||||||
xx(EQEQ, )
|
xx(EQEQ, )
|
||||||
|
xx(NEQ, )
|
||||||
xx(APREQ, )
|
xx(APREQ, )
|
||||||
|
|
||||||
xx(BitAnd, )
|
xx(BitAnd, )
|
||||||
|
|
Loading…
Reference in a new issue