[compiler-rt] 51835df - [MSVC] fix the build (#69634)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 20 14:43:22 PDT 2023
Author: nicole mazzuca
Date: 2023-10-20T14:43:18-07:00
New Revision: 51835dfadb36f8d904ee6ef3e88acb8bd1ac67cd
URL: https://github.com/llvm/llvm-project/commit/51835dfadb36f8d904ee6ef3e88acb8bd1ac67cd
DIFF: https://github.com/llvm/llvm-project/commit/51835dfadb36f8d904ee6ef3e88acb8bd1ac67cd.diff
LOG: [MSVC] fix the build (#69634)
MSVC in C mode apparently doesn't consider `const int` to be
sufficiently constant expression
This was broken in #66903.
Added:
Modified:
compiler-rt/lib/builtins/int_to_fp.h
compiler-rt/lib/builtins/int_to_fp_impl.inc
Removed:
################################################################################
diff --git a/compiler-rt/lib/builtins/int_to_fp.h b/compiler-rt/lib/builtins/int_to_fp.h
index 1adce097d7a8568..cbce49eed140c4c 100644
--- a/compiler-rt/lib/builtins/int_to_fp.h
+++ b/compiler-rt/lib/builtins/int_to_fp.h
@@ -44,7 +44,10 @@ static __inline int clzSrcT(usrc_t x) { return __clzti2(x); }
typedef float dst_t;
typedef uint32_t dst_rep_t;
#define DST_REP_C UINT32_C
-static const int dstSigBits = 23;
+
+enum {
+ dstSigBits = 23,
+};
#elif defined DST_DOUBLE
typedef double dst_t;
diff --git a/compiler-rt/lib/builtins/int_to_fp_impl.inc b/compiler-rt/lib/builtins/int_to_fp_impl.inc
index 263ae85d3283ca0..51f76fd76d80350 100644
--- a/compiler-rt/lib/builtins/int_to_fp_impl.inc
+++ b/compiler-rt/lib/builtins/int_to_fp_impl.inc
@@ -17,10 +17,15 @@
static __inline dst_t __floatXiYf__(src_t a) {
if (a == 0)
return 0.0;
- const int dstMantDig = dstSigBits + 1;
- const int srcBits = sizeof(src_t) * CHAR_BIT;
- const int srcIsSigned = ((src_t)-1) < 0;
+
+ enum {
+ dstMantDig = dstSigBits + 1,
+ srcBits = sizeof(src_t) * CHAR_BIT,
+ srcIsSigned = ((src_t)-1) < 0,
+ };
+
const src_t s = srcIsSigned ? a >> (srcBits - 1) : 0;
+
a = (usrc_t)(a ^ s) - s;
int sd = srcBits - clzSrcT(a); // number of significant digits
int e = sd - 1; // exponent
More information about the llvm-commits
mailing list