Mercurial > hg > tinycc
changeset 267:8bb4ed29d7ed
[project @ 2003-05-24 14:03:15 by bellard]
added 32 bit shift support
author | bellard |
---|---|
date | Sat, 24 May 2003 14:03:15 +0000 |
parents | ad6556433072 |
children | 2e1231fbfb0e |
files | libtcc1.c |
diffstat | 1 files changed, 39 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libtcc1.c Sun May 18 18:48:33 2003 +0000 +++ b/libtcc1.c Sat May 24 14:03:15 2003 +0000 @@ -421,19 +421,58 @@ /* XXX: fix tcc's code generator to do this instead */ long long __sardi3(long long a, int b) { +#ifdef __TINYC__ + DWunion u; + u.ll = a; + if (b >= 32) { + u.s.low = u.s.high >> (b - 32); + u.s.high = u.s.high >> 31; + } else if (b != 0) { + u.s.low = ((unsigned)u.s.low >> b) | (u.s.high << (32 - b)); + u.s.high = u.s.high >> b; + } + return u.ll; +#else return a >> b; +#endif } /* XXX: fix tcc's code generator to do this instead */ unsigned long long __shrdi3(unsigned long long a, int b) { +#ifdef __TINYC__ + DWunion u; + u.ll = a; + if (b >= 32) { + u.s.low = (unsigned)u.s.high >> (b - 32); + u.s.high = 0; + } else if (b != 0) { + u.s.low = ((unsigned)u.s.low >> b) | (u.s.high << (32 - b)); + u.s.high = (unsigned)u.s.high >> b; + } + return u.ll; +#else return a >> b; +#endif } /* XXX: fix tcc's code generator to do this instead */ long long __shldi3(long long a, int b) { +#ifdef __TINYC__ + DWunion u; + u.ll = a; + if (b >= 32) { + u.s.high = (unsigned)u.s.low << (b - 32); + u.s.low = 0; + } else if (b != 0) { + u.s.high = ((unsigned)u.s.high << b) | (u.s.low >> (32 - b)); + u.s.low = (unsigned)u.s.low << b; + } + return u.ll; +#else return a << b; +#endif } #if defined(__i386__)