aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--i386-gen.c13
-rw-r--r--tcc.h5
-rw-r--r--tccgen.c4
-rw-r--r--x86_64-gen.c15
4 files changed, 34 insertions, 3 deletions
diff --git a/i386-gen.c b/i386-gen.c
index eace2df..79087d0 100644
--- a/i386-gen.c
+++ b/i386-gen.c
@@ -695,6 +695,19 @@ ST_FUNC void gjmp_addr(int a)
}
}
+ST_FUNC void gtst_addr(int inv, int a)
+{
+ inv ^= (vtop--)->c.i;
+ a -= ind + 2;
+ if (a == (char)a) {
+ g(inv - 32);
+ g(a);
+ } else {
+ g(0x0f);
+ oad(inv - 16, a - 4);
+ }
+}
+
/* generate a test. set 'inv' to invert test. Stack entry is popped */
ST_FUNC int gtst(int inv, int t)
{
diff --git a/tcc.h b/tcc.h
index 20846a3..9b292eb 100644
--- a/tcc.h
+++ b/tcc.h
@@ -1472,6 +1472,11 @@ ST_FUNC void gfunc_epilog(void);
ST_FUNC int gjmp(int t);
ST_FUNC void gjmp_addr(int a);
ST_FUNC int gtst(int inv, int t);
+#if defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64
+ST_FUNC void gtst_addr(int inv, int a);
+#else
+#define gtst_addr(inv, a) gsym_addr(gtst(inv, 0), a)
+#endif
ST_FUNC void gen_opi(int op);
ST_FUNC void gen_opf(int op);
ST_FUNC void gen_cvt_ftoi(int t);
diff --git a/tccgen.c b/tccgen.c
index 337941f..09ddb77 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -5179,7 +5179,7 @@ static void block(int *bsym, int *csym, int is_expr)
vpushi(v);
if (v == d) {
gen_op(TOK_EQ);
- gsym_addr(gtst(0, 0), sw.p[b]->sym);
+ gtst_addr(0, sw.p[b]->sym);
} else {
int e;
gen_op(TOK_GE);
@@ -5187,7 +5187,7 @@ static void block(int *bsym, int *csym, int is_expr)
vseti(c, 0);
vpushi(d);
gen_op(TOK_LE);
- gsym_addr(gtst(0, 0), sw.p[b]->sym);
+ gtst_addr(0, sw.p[b]->sym);
gsym(e);
}
}
diff --git a/x86_64-gen.c b/x86_64-gen.c
index 19418fd..921813b 100644
--- a/x86_64-gen.c
+++ b/x86_64-gen.c
@@ -1686,8 +1686,21 @@ void gjmp_addr(int a)
}
}
+ST_FUNC void gtst_addr(int inv, int a)
+{
+ inv ^= (vtop--)->c.i;
+ a -= ind + 2;
+ if (a == (char)a) {
+ g(inv - 32);
+ g(a);
+ } else {
+ g(0x0f);
+ oad(inv - 16, a - 4);
+ }
+}
+
/* generate a test. set 'inv' to invert test. Stack entry is popped */
-int gtst(int inv, int t)
+ST_FUNC int gtst(int inv, int t)
{
int v = vtop->r & VT_VALMASK;
if (v == VT_CMP) {