Bill Buzbee | 3b0b4b9 | 2016-02-02 13:45:36 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Generic one-operand compare-and-branch operation. Provide a "revcmp" |
| 3 | * fragment that specifies the *reverse* comparison to perform, e.g. |
| 4 | * for "if-le" you would use "gt". |
| 5 | * |
| 6 | * for: if-eqz, if-nez, if-ltz, if-gez, if-gtz, if-lez |
| 7 | */ |
| 8 | /* if-cmp vAA, +BBBB */ |
| 9 | #if MTERP_SUSPEND |
| 10 | mov w0, wINST, lsr #8 // w0<- AA |
| 11 | GET_VREG w2, w0 // w2<- vAA |
| 12 | FETCH_S w1, 1 // w1<- branch offset, in code units |
| 13 | cmp w2, #0 // compare (vA, 0) |
| 14 | mov${condition} w1, #2 // w1<- inst branch dist for not-taken |
| 15 | adds w1, w1, w1 // convert to bytes & set flags |
| 16 | FETCH_ADVANCE_INST_RB w1 // update rPC, load wINST |
| 17 | ldrmi rIBASE, [xSELF, #THREAD_CURRENT_IBASE_OFFSET] // refresh table base |
| 18 | GET_INST_OPCODE ip // extract opcode from wINST |
| 19 | GOTO_OPCODE ip // jump to next instruction |
| 20 | #else |
| 21 | lsr w0, wINST, #8 // w0<- AA |
| 22 | GET_VREG w2, w0 // w2<- vAA |
| 23 | FETCH_S w1, 1 // w1<- branch offset, in code units |
| 24 | ldr w7, [xSELF, #THREAD_FLAGS_OFFSET] |
| 25 | mov w0, #2 // Branch offset if not taken |
| 26 | cmp w2, #0 // compare (vA, 0) |
| 27 | csel w1, w1, w0, ${condition} // Branch if true |
| 28 | adds w2, w1, w1 // convert to bytes & set flags |
| 29 | FETCH_ADVANCE_INST_RB w2 // update rPC, load wINST |
| 30 | b.mi MterpCheckSuspendAndContinue |
| 31 | GET_INST_OPCODE ip // extract opcode from wINST |
| 32 | GOTO_OPCODE ip // jump to next instruction |
| 33 | #endif |