** Patch destination register for a TESTSET instruction. ** If instruction in position 'node' is not a TESTSET, return 0 ("fails"). ** Otherwise, if 'reg' is not 'NO_REG', set it as the destination ** register. Otherwise, change instruction to a simple 'TEST' (produces ** no register value) */
| 193 | ** no register value) |
| 194 | */ |
| 195 | static int patchtestreg (FuncState *fs, int node, int reg) { |
| 196 | Instruction *i = getjumpcontrol(fs, node); |
| 197 | if (GET_OPCODE(*i) != OP_TESTSET) |
| 198 | return 0; /* cannot patch other instructions */ |
| 199 | if (reg != NO_REG && reg != GETARG_B(*i)) |
| 200 | SETARG_A(*i, reg); |
| 201 | else { |
| 202 | /* no register to put value or register already has the value; |
| 203 | change instruction to simple test */ |
| 204 | *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i)); |
| 205 | } |
| 206 | return 1; |
| 207 | } |
| 208 | |
| 209 | |
| 210 | /* |
no test coverage detected