summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorAnton Vorontsov <avorontsov@ru.mvista.com>2009-11-28 01:33:49 +0300
committerFrank Ch. Eigler <fche@elastic.org>2009-12-01 11:57:33 -0500
commitb7c4fdcf0991791bf13b144c72767ff6b98cff53 (patch)
tree23feb8418017f9d95bac8ece16e7645cc3291e5c /runtime
parentfb4653ea565018aa26a730db6b59ff64f2c6afa8 (diff)
downloadsystemtap-steved-b7c4fdcf0991791bf13b144c72767ff6b98cff53.tar.gz
systemtap-steved-b7c4fdcf0991791bf13b144c72767ff6b98cff53.tar.xz
systemtap-steved-b7c4fdcf0991791bf13b144c72767ff6b98cff53.zip
Implement _div64 and _mod64 for ppc32
_div64 and _mod64 arch-specific details were taken from gcc/longlong.h, just as it was done for i386. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Diffstat (limited to 'runtime')
-rw-r--r--runtime/arith.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/runtime/arith.c b/runtime/arith.c
index 4c818a76..a032e9c1 100644
--- a/runtime/arith.c
+++ b/runtime/arith.c
@@ -20,7 +20,8 @@
/* 64-bit division for 64-bit cpus and i386 */
/* Other 32-bit cpus will need to modify this file. */
-#if defined (__i386__) || defined(__arm__)
+#if defined (__i386__) || defined(__arm__) || \
+ (defined(__powerpc__) && !defined(__powerpc64__))
static long long _div64 (long long u, long long v);
static long long _mod64 (long long u, long long v);
#endif
@@ -114,7 +115,8 @@ static int _stp_random_pm (unsigned n)
-#if defined (__i386__) || defined (__arm__)
+#if defined (__i386__) || defined (__arm__) || \
+ (defined(__powerpc__) && !defined(__powerpc64__))
/* 64-bit division functions extracted from libgcc */
typedef long long DWtype;
@@ -181,6 +183,40 @@ typedef union
(count) = __cbtmp ^ 31; \
} while (0)
+#elif defined (__powerpc__)
+/* these are the ppc versions of these macros from gcc/longlong.h */
+
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ do { \
+ if (__builtin_constant_p (ah) && (ah) == 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+ else if (__builtin_constant_p (ah) && (ah) == ~(USItype) 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+ else if (__builtin_constant_p (bh) && (bh) == 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+ else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0) \
+ __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2" \
+ : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+ else \
+ __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2" \
+ : "=r" (sh), "=&r" (sl) \
+ : "r" (ah), "r" (bh), "rI" (al), "r" (bl)); \
+ } while (0)
+
+#define count_leading_zeros(count, x) \
+ __asm__ ("{cntlz|cntlzw} %0,%1" : "=r" (count) : "r" (x))
+#define COUNT_LEADING_ZEROS_0 32
+
+#define umul_ppmm(ph, pl, m0, m1) \
+ do { \
+ USItype __m0 = (m0), __m1 = (m1); \
+ __asm__ ("mulhwu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \
+ (pl) = __m0 * __m1; \
+ } while (0)
+
#elif defined (__arm__)
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
@@ -548,6 +584,6 @@ static long long _mod64 (long long u, long long v)
return w;
}
-#endif /* __i386__ || __arm__ */
+#endif /* __i386__ || __arm__ || (__powerpc__ && !__powerpc64__) */
#endif /* _ARITH_C_ */