aboutsummaryrefslogtreecommitdiff
path: root/i386-gen.c
diff options
context:
space:
mode:
authorgrischka <grischka>2014-01-06 19:07:08 +0100
committergrischka <grischka>2014-01-06 19:07:08 +0100
commit4ad186c5ef61477030ca37372f9d6c6d03681015 (patch)
tree027dc0291eeb4bf77d521ac7a69cf40e23f2ae4d /i386-gen.c
parent8efaa711904b897f9a4821656ac10f980c5ae9fe (diff)
downloadtinycc-4ad186c5ef61477030ca37372f9d6c6d03681015.tar.gz
tinycc-4ad186c5ef61477030ca37372f9d6c6d03681015.tar.bz2
i386: use __fixdfdi instead of __tcc_cvt_ftol
Variants __fixsfdi/__fixxfdi are not needed for now because the value is converted to double always. Also: - remove __tcc_fpinit for unix as it seems redundant by the __setfpucw call in the startup code - avoid reference to s->runtime_main in cross compilers - configure: fix --with-libgcc help - tcctok.h: cleanup
Diffstat (limited to 'i386-gen.c')
-rw-r--r--i386-gen.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/i386-gen.c b/i386-gen.c
index 2eb6922..4c4a54b 100644
--- a/i386-gen.c
+++ b/i386-gen.c
@@ -581,14 +581,6 @@ ST_FUNC void gfunc_prolog(CType *func_type)
func_bound_offset = lbounds_section->data_offset;
}
#endif
-
-#ifndef CONFIG_USE_LIBGCC
-#ifndef TCC_TARGET_PE
- if (0 == strcmp(funcname, "main"))
- gen_static_call(TOK___tcc_fpinit);
-#endif
-#endif
-
}
/* generate function epilog */
@@ -988,16 +980,20 @@ ST_FUNC void gen_cvt_itof(int t)
}
/* convert fp to int 't' type */
-/* XXX: handle long long case */
ST_FUNC void gen_cvt_ftoi(int t)
{
- gv(RC_FLOAT);
- save_reg(TREG_EAX);
- save_reg(TREG_EDX);
- gen_static_call(TOK___tcc_cvt_ftol);
- vtop->r = TREG_EAX; /* mark reg as used */
- if (t == VT_LLONG)
- vtop->r2 = TREG_EDX;
+ int bt = vtop->type.t & VT_BTYPE;
+ if (bt == VT_FLOAT)
+ vpush_global_sym(&func_old_type, TOK___fixsfdi);
+ else if (bt == VT_LDOUBLE)
+ vpush_global_sym(&func_old_type, TOK___fixxfdi);
+ else
+ vpush_global_sym(&func_old_type, TOK___fixdfdi);
+ vswap();
+ gfunc_call(1);
+ vpushi(0);
+ vtop->r = REG_IRET;
+ vtop->r2 = REG_LRET;
}
/* convert from one floating point type to another */