gtst_addr(): short conditional jumps (i386, x86_64)

This commit is contained in:
Pavlas, Zdenek 2016-09-30 07:29:38 -07:00
parent fc0fc6aba3
commit e238e6521b
4 changed files with 34 additions and 3 deletions

View File

@ -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)
{

5
tcc.h
View File

@ -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);

View File

@ -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);
}
}

View File

@ -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) {