/* both operands are live */
if (op1_idx == 0) {
+ /* res = tos X op */
dst = op_ia32_fcomJmp;
} else if (op2_idx == 0) {
+ /* res = op X tos */
dst = op_ia32_fcomrJmp;
} else {
/* bring the first one to tos */
if (op2_idx == 0)
op2_idx = op1_idx;
op1_idx = 0;
+ /* res = tos X op */
dst = op_ia32_fcomJmp;
}
} else {
op2_idx = op1_idx;
op1_idx = 0;
}
+ /* res = tos X op, pop */
dst = op_ia32_fcompJmp;
pop_cnt = 1;
}
op1_idx = op2_idx;
op2_idx = 0;
}
+ /* res = op X tos, pop */
dst = op_ia32_fcomrpJmp;
pop_cnt = 1;
} else {
op1_idx = 0;
op2_idx = 0;
}
+ /* res = tos X op, pop */
dst = op_ia32_fcompJmp;
pop_cnt = 1;
}
if (op1_idx != 0) {
/* bring the first on top */
x87_create_fxch(state, n, op1_idx, BINOP_IDX_1);
+ assert(op2_idx != 0);
op1_idx = 0;
}
+ /* res = tos X op, pop, pop */
dst = op_ia32_fcomppJmp;
pop_cnt = 2;
} else if (op1_idx == 1) {
if (op2_idx != 0) {
/* bring the first on top */
x87_create_fxch(state, n, op2_idx, BINOP_IDX_2);
+ assert(op1_idx != 0);
op2_idx = 0;
}
dst = op_ia32_fcomrppJmp;
if (op1_idx == 0) {
/* first one is TOS, move to st(1) */
x87_create_fxch(state, n, 1, BINOP_IDX_1);
+ assert(op2_idx != 1);
op1_idx = 1;
x87_create_fxch(state, n, op2_idx, BINOP_IDX_2);
op2_idx = 0;
+ /* res = op X tos, pop, pop */
dst = op_ia32_fcomrppJmp;
pop_cnt = 2;
} else if (op2_idx == 0) {
/* second one is TOS, move to st(1) */
x87_create_fxch(state, n, 1, BINOP_IDX_2);
+ assert(op1_idx != 1);
op2_idx = 1;
x87_create_fxch(state, n, op1_idx, BINOP_IDX_1);
op1_idx = 0;
- dst = op_ia32_fcomrppJmp;
+ /* res = tos X op, pop, pop */
+ dst = op_ia32_fcomppJmp;
pop_cnt = 2;
} else {
/* none of them is either TOS or st(1), 3 fxch needed */
x87_create_fxch(state, n, op2_idx, BINOP_IDX_2);
+ assert(op1_idx != 0);
x87_create_fxch(state, n, 1, BINOP_IDX_2);
op2_idx = 1;
x87_create_fxch(state, n, op1_idx, BINOP_IDX_1);
op1_idx = 0;
+ /* res = tos X op, pop, pop */
dst = op_ia32_fcomppJmp;
pop_cnt = 2;
}