| 15 | #include "GB_binop.h" |
| 16 | |
| 17 | void GB_binop_pattern |
| 18 | ( |
| 19 | // outputs: |
| 20 | bool *A_is_pattern, // true if A is pattern-only, because of the op |
| 21 | bool *B_is_pattern, // true if B is pattern-only, because of the op |
| 22 | // inputs: |
| 23 | const bool flipxy, // if true, z = op (b,a) will be computed |
| 24 | // if false, z = op (a,b) will be computed |
| 25 | const GB_Opcode opcode // opcode of binary op |
| 26 | ) |
| 27 | { |
| 28 | |
| 29 | //-------------------------------------------------------------------------- |
| 30 | // determine A_is_pattern and B_is_pattern |
| 31 | //-------------------------------------------------------------------------- |
| 32 | |
| 33 | bool op_is_positional = GB_OPCODE_IS_POSITIONAL (opcode) ; |
| 34 | bool op_is_first = (opcode == GB_FIRST_binop_code) ; |
| 35 | bool op_is_second = (opcode == GB_SECOND_binop_code) ; |
| 36 | bool op_is_pair = (opcode == GB_PAIR_binop_code) ; |
| 37 | |
| 38 | if (op_is_positional || op_is_pair) |
| 39 | { |
| 40 | // mult (x,y) does not depend on the values of x or y |
| 41 | (*A_is_pattern) = true ; |
| 42 | (*B_is_pattern) = true ; |
| 43 | } |
| 44 | else if (flipxy) |
| 45 | { |
| 46 | // z = mult (b,a) will be computed |
| 47 | (*A_is_pattern) = op_is_first ; |
| 48 | (*B_is_pattern) = op_is_second ; |
| 49 | } |
| 50 | else |
| 51 | { |
| 52 | // z = mult (a,b) will be computed |
| 53 | (*A_is_pattern) = op_is_second ; |
| 54 | (*B_is_pattern) = op_is_first ; |
| 55 | } |
| 56 | } |
| 57 |
no outgoing calls
no test coverage detected