Skip to content

Commit 2b481aa

Browse files
committed
port new comparison operations in QEMU.
1 parent ea62150 commit 2b481aa

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

accel/tcg/tcg-runtime-sym-common.c

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@
1313
#define SymExpr void*
1414
#include "RuntimeCommon.h"
1515

16+
static SymExpr _sym_build_tsteq(SymExpr a, SymExpr b) {
17+
size_t bits_a = _sym_bits_helper(a);
18+
size_t bits_b = _sym_bits_helper(a);
19+
20+
assert(bits_a == bits_b);
21+
22+
return _sym_build_equal(_sym_build_and(a, b), _sym_build_integer(0, bits_a));
23+
}
24+
25+
static SymExpr _sym_build_tstne(SymExpr a, SymExpr b) {
26+
size_t bits_a = _sym_bits_helper(a);
27+
size_t bits_b = _sym_bits_helper(a);
28+
29+
assert(bits_a == bits_b);
30+
31+
return _sym_build_not_equal(_sym_build_and(a, b), _sym_build_integer(0, bits_a));
32+
}
33+
1634
void *build_and_push_path_constraint(CPUArchState *env, void *arg1_expr, void *arg2_expr, uint32_t comparison_operator, uint8_t is_taken){
1735
void *(*handler)(void *, void*);
1836
switch (comparison_operator) {
@@ -22,31 +40,42 @@ void *build_and_push_path_constraint(CPUArchState *env, void *arg1_expr, void *a
2240
case TCG_COND_NE:
2341
handler = _sym_build_not_equal;
2442
break;
43+
44+
case TCG_COND_TSTEQ:
45+
handler = _sym_build_tsteq;
46+
break;
47+
case TCG_COND_TSTNE:
48+
handler = _sym_build_tstne;
49+
break;
50+
2551
case TCG_COND_LT:
2652
handler = _sym_build_signed_less_than;
2753
break;
2854
case TCG_COND_GE:
2955
handler = _sym_build_signed_greater_equal;
3056
break;
31-
case TCG_COND_LE:
32-
handler = _sym_build_signed_less_equal;
33-
break;
3457
case TCG_COND_GT:
3558
handler = _sym_build_signed_greater_than;
3659
break;
60+
case TCG_COND_LE:
61+
handler = _sym_build_signed_less_equal;
62+
break;
63+
3764
case TCG_COND_LTU:
3865
handler = _sym_build_unsigned_less_than;
3966
break;
4067
case TCG_COND_GEU:
4168
handler = _sym_build_unsigned_greater_equal;
4269
break;
43-
case TCG_COND_LEU:
44-
handler = _sym_build_unsigned_less_equal;
45-
break;
4670
case TCG_COND_GTU:
4771
handler = _sym_build_unsigned_greater_than;
4872
break;
73+
case TCG_COND_LEU:
74+
handler = _sym_build_unsigned_less_equal;
75+
break;
76+
4977
default:
78+
fprintf(stderr, "Unknown comparison operator 0x%x\n", comparison_operator);
5079
g_assert_not_reached();
5180
}
5281

0 commit comments

Comments
 (0)