blob: 800804d95eddfb8d56c6d5d0485cf669f0587fb4 [file] [log] [blame]
buzbee1452bee2015-03-06 14:43:04 -08001 /*
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 */
Bill Buzbeefd522f92016-02-11 22:37:42 +00009#if MTERP_PROFILE_BRANCHES
buzbee1452bee2015-03-06 14:43:04 -080010 mov r0, rINST, lsr #8 @ r0<- AA
11 GET_VREG r2, r0 @ r2<- vAA
Bill Buzbeefd522f92016-02-11 22:37:42 +000012 FETCH_S rINST, 1 @ rINST<- branch offset, in code units
13 ldr lr, [rSELF, #THREAD_FLAGS_OFFSET]
buzbee1452bee2015-03-06 14:43:04 -080014 cmp r2, #0 @ compare (vA, 0)
Bill Buzbeefd522f92016-02-11 22:37:42 +000015 b${revcmp} .L_${opcode}_not_taken
16 EXPORT_PC
17 mov r0, rSELF
18 add r1, rFP, #OFF_FP_SHADOWFRAME
19 mov r2, rINST
20 bl MterpProfileBranch @ (self, shadow_frame, offset)
21 cmp r0, #0
22 bne MterpOnStackReplacement @ Note: offset must be in rINST
23 adds r1, rINST, rINST @ convert to bytes & set flags
buzbee1452bee2015-03-06 14:43:04 -080024 FETCH_ADVANCE_INST_RB r1 @ update rPC, load rINST
Bill Buzbeefd522f92016-02-11 22:37:42 +000025 bmi MterpCheckSuspendAndContinue
26 GET_INST_OPCODE ip @ extract opcode from rINST
27 GOTO_OPCODE ip @ jump to next instruction
28.L_${opcode}_not_taken:
29 FETCH_ADVANCE_INST 2 @ update rPC, load rINST
buzbee1452bee2015-03-06 14:43:04 -080030 GET_INST_OPCODE ip @ extract opcode from rINST
31 GOTO_OPCODE ip @ jump to next instruction
32#else
33 mov r0, rINST, lsr #8 @ r0<- AA
34 GET_VREG r2, r0 @ r2<- vAA
Bill Buzbeefd522f92016-02-11 22:37:42 +000035 FETCH_S rINST, 1 @ rINST<- branch offset, in code units
buzbee1452bee2015-03-06 14:43:04 -080036 ldr lr, [rSELF, #THREAD_FLAGS_OFFSET]
37 cmp r2, #0 @ compare (vA, 0)
Bill Buzbeefd522f92016-02-11 22:37:42 +000038 mov${revcmp} rINST, #2 @ rINST<- inst branch dist for not-taken
39 adds r1, rINST, rINST @ convert to bytes & set flags
buzbee1452bee2015-03-06 14:43:04 -080040 FETCH_ADVANCE_INST_RB r1 @ update rPC, load rINST
41 bmi MterpCheckSuspendAndContinue
42 GET_INST_OPCODE ip @ extract opcode from rINST
43 GOTO_OPCODE ip @ jump to next instruction
44#endif