blob: 474bc3c2767a0c96d983a82b57b00ee3312f493e [file] [log] [blame]
buzbee1452bee2015-03-06 14:43:04 -08001 /*
2 * Generic two-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-eq, if-ne, if-lt, if-ge, if-gt, if-le
7 */
8 /* if-cmp vA, vB, +CCCC */
9#if MTERP_SUSPEND
10 mov r1, rINST, lsr #12 @ r1<- B
11 ubfx r0, rINST, #8, #4 @ r0<- A
12 GET_VREG r3, r1 @ r3<- vB
13 GET_VREG r2, r0 @ r2<- vA
14 FETCH_S r1, 1 @ r1<- branch offset, in code units
15 cmp r2, r3 @ compare (vA, vB)
16 mov${revcmp} r1, #2 @ r1<- BYTE branch dist for not-taken
17 adds r2, r1, r1 @ convert to bytes, check sign
18 FETCH_ADVANCE_INST_RB r2 @ update rPC, load rINST
19 ldrmi rIBASE, [rSELF, #THREAD_CURRENT_IBASE_OFFSET] @ refresh rIBASE
20 GET_INST_OPCODE ip @ extract opcode from rINST
21 GOTO_OPCODE ip @ jump to next instruction
22#else
23 mov r1, rINST, lsr #12 @ r1<- B
24 ubfx r0, rINST, #8, #4 @ r0<- A
25 GET_VREG r3, r1 @ r3<- vB
26 GET_VREG r2, r0 @ r2<- vA
27 ldr lr, [rSELF, #THREAD_FLAGS_OFFSET]
28 FETCH_S r1, 1 @ r1<- branch offset, in code units
29 cmp r2, r3 @ compare (vA, vB)
30 mov${revcmp} r1, #2 @ r1<- BYTE branch dist for not-taken
31 adds r2, r1, r1 @ convert to bytes, check sign
32 FETCH_ADVANCE_INST_RB r2 @ update rPC, load rINST
33 bmi MterpCheckSuspendAndContinue
34 GET_INST_OPCODE ip @ extract opcode from rINST
35 GOTO_OPCODE ip @ jump to next instruction
36#endif