summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-12-02 23:30:24 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-12-02 23:30:24 +0000
commit5f9afc59f8be2f246281a3ca380ee5f5dbc8fde3 (patch)
tree3f86e8958394b86be6341b6a734286a4108ec7a7 /clang/lib
parent22f58dffeb6eb57b18e78d73cce3b2b98af329f5 (diff)
downloadbcm5719-llvm-5f9afc59f8be2f246281a3ca380ee5f5dbc8fde3.tar.gz
bcm5719-llvm-5f9afc59f8be2f246281a3ca380ee5f5dbc8fde3.zip
Intrin: Add _umul128
Implement _umul128; it provides the high and low halves of a 128-bit multiply. We can simply use our __int128 arithmetic to implement this, we generate great code for it: movq %rdx, %rax mulq %rcx movq %rdx, (%r8) retq Differential Revision: http://reviews.llvm.org/D6486 llvm-svn: 223175
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Headers/Intrin.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/Headers/Intrin.h b/clang/lib/Headers/Intrin.h
index 016c480adf2..89e0d0c82d8 100644
--- a/clang/lib/Headers/Intrin.h
+++ b/clang/lib/Headers/Intrin.h
@@ -417,9 +417,18 @@ int __cdecl _setjmpex(jmp_buf);
#endif
unsigned __int64 _shlx_u64(unsigned __int64, unsigned int);
unsigned __int64 shrx_u64(unsigned __int64, unsigned int);
-unsigned __int64 _umul128(unsigned __int64 _Multiplier,
- unsigned __int64 _Multiplicand,
- unsigned __int64 *_HighProduct);
+/*
+ * Multiply two 64-bit integers and obtain a 64-bit result.
+ * The low-half is returned directly and the high half is in an out parameter.
+ */
+static __inline__ unsigned __int64 __attribute__((__always_inline__, __nodebug__))
+_umul128(unsigned __int64 _Multiplier, unsigned __int64 _Multiplicand,
+ unsigned __int64 *_HighProduct) {
+ unsigned __int128 _FullProduct =
+ (unsigned __int128)_Multiplier * (unsigned __int128)_Multiplicand;
+ *_HighProduct = FullProduct >> 64;
+ return FullProduct;
+}
void __cdecl _xrstor64(void const *, unsigned __int64);
void __cdecl _xsave64(void *, unsigned __int64);
void __cdecl _xsaveopt64(void *, unsigned __int64);
OpenPOWER on IntegriCloud