mirror of https://github.com/ZDoom/gzdoom-gles.git
- 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
|
@ -1161,9 +1161,8 @@ expr(X) ::= expr(A) LT expr(B). /* a < b */
|
|||
}
|
||||
expr(X) ::= expr(A) GT expr(B). /* a > b */
|
||||
{
|
||||
BINARY_EXPR(A,B,PEX_LTEQ);
|
||||
UNARY_EXPR(expr2,PEX_BoolNot);
|
||||
X = expr1;
|
||||
BINARY_EXPR(A,B,PEX_GT);
|
||||
X = expr2;
|
||||
}
|
||||
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 */
|
||||
{
|
||||
BINARY_EXPR(A,B,PEX_LT);
|
||||
UNARY_EXPR(expr1,PEX_BoolNot);
|
||||
X = expr1;
|
||||
BINARY_EXPR(A,B,PEX_GTEQ);
|
||||
X = expr2;
|
||||
}
|
||||
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 */
|
||||
{
|
||||
BINARY_EXPR(A,B,PEX_EQEQ);
|
||||
UNARY_EXPR(expr2,PEX_BoolNot);
|
||||
X = expr1;
|
||||
BINARY_EXPR(A,B,PEX_NEQ);
|
||||
X = expr2;
|
||||
}
|
||||
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 **)&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 **)&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; } },
|
||||
|
|
|
@ -36,10 +36,13 @@ xx(Concat, )
|
|||
|
||||
xx(LT, )
|
||||
xx(LTEQ, )
|
||||
xx(GT, )
|
||||
xx(GTEQ, )
|
||||
xx(LTGTEQ, )
|
||||
xx(Is, )
|
||||
|
||||
xx(EQEQ, )
|
||||
xx(NEQ, )
|
||||
xx(APREQ, )
|
||||
|
||||
xx(BitAnd, )
|
||||
|
|
Loading…
Reference in New Issue