mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-04-07 01:42:04 +00:00
[qfcc] Add a check for shifts and expand math ops
I found a need to check for shifts separately (not sure it's the right approach for that problem, though), and there are a few more math ops than just +-*/.
This commit is contained in:
parent
8323868b2c
commit
d0db75779a
2 changed files with 22 additions and 1 deletions
|
@ -893,6 +893,13 @@ const expr_t *constant_expr (const expr_t *e);
|
|||
*/
|
||||
bool is_compare (int op) __attribute__((const));
|
||||
|
||||
/** Check if the op-code is a bit-shift.
|
||||
|
||||
\param op The op-code to check.
|
||||
\return True if the op-code is a bit-shift operator.
|
||||
*/
|
||||
bool is_shift (int op) __attribute__((const));
|
||||
|
||||
/** Check if the op-code is a math operator.
|
||||
|
||||
\param op The op-code to check.
|
||||
|
|
|
@ -1900,11 +1900,25 @@ is_compare (int op)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
is_shift (int op)
|
||||
{
|
||||
if (op == QC_SHL || op == QC_SHR) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
is_math_op (int op)
|
||||
{
|
||||
if (op == '*' || op == '/' || op == '+' || op == '-')
|
||||
if (op == '*' || op == '/' || op == '+' || op == '-' || op == '%'
|
||||
|| op == QC_MOD || op == QC_SCALE || op == QC_GEOMETRIC
|
||||
|| op == QC_QMUL || op == QC_QVMUL || op == QC_VQMUL
|
||||
|| op == QC_HADAMARD || op == QC_CROSS || op == QC_DOT
|
||||
|| op == QC_OUTER || op == QC_WEDGE || op == QC_REGRESSIVE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue