blob: 0e0477fadf8cb0bef1be618edfca8a23bb52e758 [file] [log] [blame]
Alexey Frunze00b53b72016-02-02 20:25:45 -08001 /*
2 * Generic one-operand compare-and-branch operation. Provide a "condition"
3 * fragment that specifies the comparison to perform, e.g. for
4 * "if-lez" you would use "le".
5 *
6 * For: if-eqz, if-nez, if-ltz, if-gez, if-gtz, if-lez
7 */
8 /* if-cmp vAA, +BBBB */
Alexey Frunzedb045be2016-03-03 17:50:48 -08009 .extern MterpProfileBranch
Alexey Frunze00b53b72016-02-02 20:25:45 -080010 srl a2, rINST, 8 # a2 <- AA
Alexey Frunzedb045be2016-03-03 17:50:48 -080011 lh rINST, 2(rPC) # rINST <- offset (sign-extended BBBB)
Alexey Frunze00b53b72016-02-02 20:25:45 -080012 GET_VREG a0, a2 # a0 <- vAA
Alexey Frunze00b53b72016-02-02 20:25:45 -080013 b${condition}zc a0, 1f
Alexey Frunzedb045be2016-03-03 17:50:48 -080014 li rINST, 2 # offset if branch not taken
Alexey Frunze00b53b72016-02-02 20:25:45 -0800151:
Alexey Frunzedb045be2016-03-03 17:50:48 -080016#if MTERP_PROFILE_BRANCHES
17 EXPORT_PC
18 move a0, rSELF
19 daddu a1, rFP, OFF_FP_SHADOWFRAME
20 move a2, rINST
21 jal MterpProfileBranch # (self, shadow_frame, offset)
22 bnezc v0, MterpOnStackReplacement # Note: offset must be in rINST
Alexey Frunze00b53b72016-02-02 20:25:45 -080023#endif
Alexey Frunzedb045be2016-03-03 17:50:48 -080024 dlsa rPC, rINST, rPC, 1 # rPC <- rPC + offset * 2
25 lw ra, THREAD_FLAGS_OFFSET(rSELF) # Preload flags for MterpCheckSuspendAndContinue
26 move a0, rINST # a0 <- offset
27 FETCH_INST # load rINST
28 bltz a0, MterpCheckSuspendAndContinue # suspend check if backwards branch
Alexey Frunze00b53b72016-02-02 20:25:45 -080029 GET_INST_OPCODE v0 # extract opcode from rINST
30 GOTO_OPCODE v0 # jump to next instruction