1    /*
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    GET_OPA4(a0)                           #  a0 <- A+
10    GET_OPB(a1)                            #  a1 <- B
11    GET_VREG(a3, a1)                       #  a3 <- vB
12    GET_VREG(a2, a0)                       #  a2 <- vA
13    b${revcmp} a2, a3, 1f                  #  branch to 1 if comparison failed
14    FETCH_S(rINST, 1)                      #  rINST<- branch offset, in code units
15    b 2f
161:
17    li        rINST, 2                     #  rINST- BYTE branch dist for not-taken
182:
19#if MTERP_PROFILE_BRANCHES
20    EXPORT_PC()
21    move      a0, rSELF
22    addu      a1, rFP, OFF_FP_SHADOWFRAME
23    move      a2, rINST
24    JAL(MterpProfileBranch)                #  (self, shadow_frame, offset)
25    bnez      v0, MterpOnStackReplacement  #  Note: offset must be in rINST
26#endif
27    addu      a2, rINST, rINST             #  convert to bytes
28    FETCH_ADVANCE_INST_RB(a2)              #  update rPC, load rINST
29    bgez      a2, .L_${opcode}_finish
30    lw        ra, THREAD_FLAGS_OFFSET(rSELF)
31    b         MterpCheckSuspendAndContinue
32
33%break
34
35.L_${opcode}_finish:
36    GET_INST_OPCODE(t0)                    #  extract opcode from rINST
37    GOTO_OPCODE(t0)                        #  jump to next instruction
38