[PATCH] D54911: [compiler-rt][builtins][PowerPC] Add ___fixunstfti builtin compiler-rt method support for PowerPC
Amy Kwan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 18 09:19:19 PST 2018
amyk updated this revision to Diff 178704.
amyk added a comment.
Updated revision to address:
- Grouping up common code (used in both the high and low cases) into a macro that will be used
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54911/new/
https://reviews.llvm.org/D54911
Files:
compiler-rt/lib/builtins/ppc/fixunstfti.c
Index: compiler-rt/lib/builtins/ppc/fixunstfti.c
===================================================================
--- compiler-rt/lib/builtins/ppc/fixunstfti.c
+++ compiler-rt/lib/builtins/ppc/fixunstfti.c
@@ -15,6 +15,19 @@
#include "../int_math.h"
#define BIAS 1023
+/* Macro to scale either the high or low doubles (CASE 2)
+ * when the high or low doubles do not fit within an int64. */
+#define SCALE_DOUBLE(exponent, result, doubleType) \
+ shift = exponent - 54; \
+ ldStructure.doubleBitPatterns[doubleType] &= 0x800FFFFFFFFFFFFFll; \
+ ldStructure.doubleBitPatterns[doubleType] |= 0x4350000000000000ll; \
+ if (doubleType == 0) { \
+ result = (unsigned long long)ldStructure.doublePairs[doubleType]; \
+ } else { \
+ result = (long long)ldStructure.doublePairs[doubleType]; \
+ } \
+ result = result << shift;
+
__uint128_t __fixunstfti(long double input) {
/* If we are trying to convert a NaN, return the NaN bit pattern. */
@@ -65,11 +78,7 @@
hiResult = (unsigned long long)ldStructure.doublePairs[0];
} else if (hiExponent < 128) {
/* CASE 2 - High double does not fit in int64, scale it. */
- shift = hiExponent - 54;
- ldStructure.doubleBitPatterns[0] &= 0x800FFFFFFFFFFFFFll;
- ldStructure.doubleBitPatterns[0] |= 0x4350000000000000ll;
- hiResult = (unsigned long long)ldStructure.doublePairs[0];
- hiResult = hiResult << shift;
+ SCALE_DOUBLE(hiExponent, hiResult, 0);
} else {
/* Detect cases for overflow. When the exponent of the high
* double is greater than 128 bits and when the long double
@@ -89,11 +98,7 @@
loResult = (long long)ldStructure.doublePairs[1];
} else {
/* CASE 2 - Low double does not fit in int64, scale it. */
- shift = loExponent - 54;
- ldStructure.doubleBitPatterns[1] &= 0x800FFFFFFFFFFFFFll;
- ldStructure.doubleBitPatterns[1] |= 0x4350000000000000ll;
- loResult = (long long)ldStructure.doublePairs[1];
- loResult = loResult << shift;
+ SCALE_DOUBLE(loExponent, loResult, 1);
}
/* Add the high and low doublewords together to form a 128 bit integer. */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54911.178704.patch
Type: text/x-patch
Size: 2436 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181218/daea7ff7/attachment.bin>
More information about the llvm-commits
mailing list