aboutsummaryrefslogtreecommitdiff
path: root/libtcc1.c
diff options
context:
space:
mode:
authorbellard <bellard>2003-05-24 14:03:15 +0000
committerbellard <bellard>2003-05-24 14:03:15 +0000
commit813acdc691f5bc2361042f6f2c16e1f273651b5f (patch)
tree34116ce6bdf29d82fcd06fceec7ac83c4f9cffce /libtcc1.c
parent638e666c42bcc3f65499baa0660d558a2b40ad8f (diff)
downloadtinycc-813acdc691f5bc2361042f6f2c16e1f273651b5f.tar.gz
tinycc-813acdc691f5bc2361042f6f2c16e1f273651b5f.tar.bz2
added 32 bit shift support
Diffstat (limited to 'libtcc1.c')
-rw-r--r--libtcc1.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/libtcc1.c b/libtcc1.c
index f244206..a06016e 100644
--- a/libtcc1.c
+++ b/libtcc1.c
@@ -421,19 +421,58 @@ unsigned long long __umoddi3(unsigned long long u, unsigned long long v)
/* 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__)