[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:
Bill Currie 2024-11-28 21:11:09 +09:00
parent 8323868b2c
commit d0db75779a
2 changed files with 22 additions and 1 deletions

View file

@ -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.

View file

@ -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;
}