Bit Flag Conditional
This MR introduces a bit flag conditional that acts like a ternary operator for a single bit flag. It takes at least three arguments:
-
flag_bit
specifies which bit of the mask is examined -
mask_expression
is an integer-typed expression which acts as a bit mask -
then_expression
is a SymPy expression of arbitrary type, and - optionally
else_expression
is a SymPy expression of arbitrary type
flag_cond
examines the given bit of the given mask and takes the value of then_expression
if the bit is set to 1. If not, it becomes either 0
or else_expression
:
Three argument version:
flag_cond(flag_bit, mask, expr) = expr if (flag_bit is set in mask) else 0
Four argument version:
flag_cond(flag_bit, mask, expr_then, expr_else) = expr_then if (flag_bit is set in mask) else expr_else