Home | History | Annotate | Download | only in x86
      1 %default {"suff":"d","nanval":"pos"}
      2 /*
      3  * Compare two floating-point values.  Puts 0, 1, or -1 into the
      4  * destination register based on the results of the comparison.
      5  *
      6  * int compare(x, y) {
      7  *     if (x == y) {
      8  *         return 0;
      9  *     } else if (x < y) {
     10  *         return -1;
     11  *     } else if (x > y) {
     12  *         return 1;
     13  *     } else {
     14  *         return nanval ? 1 : -1;
     15  *     }
     16  * }
     17  */
     18     /* op vAA, vBB, vCC */
     19     movzbl  3(rPC), %ecx                    # ecx<- CC
     20     movzbl  2(rPC), %eax                    # eax<- BB
     21     movs${suff} VREG_ADDRESS(%eax), %xmm0
     22     xor     %eax, %eax
     23     ucomis${suff} VREG_ADDRESS(%ecx), %xmm0
     24     jp      .L${opcode}_nan_is_${nanval}
     25     je      .L${opcode}_finish
     26     jb      .L${opcode}_less
     27 .L${opcode}_nan_is_pos:
     28     incl    %eax
     29     jmp     .L${opcode}_finish
     30 .L${opcode}_nan_is_neg:
     31 .L${opcode}_less:
     32     decl    %eax
     33 .L${opcode}_finish:
     34     SET_VREG %eax, rINST
     35     ADVANCE_PC_FETCH_AND_GOTO_NEXT 2
     36