[flang-commits] [flang] 57b89fd - [flang][runtime] Add FLANG_RUNTIME_NO_REAL_3 flag to build (#105856)
via flang-commits
flang-commits at lists.llvm.org
Fri Aug 23 11:27:28 PDT 2024
Author: Peter Klausler
Date: 2024-08-23T11:27:25-07:00
New Revision: 57b89fdd8af0a230ff270d6f018c0ca6b8562d71
URL: https://github.com/llvm/llvm-project/commit/57b89fdd8af0a230ff270d6f018c0ca6b8562d71
DIFF: https://github.com/llvm/llvm-project/commit/57b89fdd8af0a230ff270d6f018c0ca6b8562d71.diff
LOG: [flang][runtime] Add FLANG_RUNTIME_NO_REAL_3 flag to build (#105856)
Allow a runtime build to disable SELECTED_REAL_KIND from returning kind
3 (16-bit truncated form of 32-bit IEEE-754 floating point, a/k/a "brain
float" or bfloat16).
Added:
Modified:
flang/runtime/numeric.cpp
Removed:
################################################################################
diff --git a/flang/runtime/numeric.cpp b/flang/runtime/numeric.cpp
index 28687b1971b7ed..40bacf07157a27 100644
--- a/flang/runtime/numeric.cpp
+++ b/flang/runtime/numeric.cpp
@@ -142,6 +142,11 @@ inline RT_API_ATTRS CppTypeFor<TypeCategory::Integer, 4> SelectedRealKind(
#else
constexpr bool hasReal2{false};
#endif
+#ifndef FLANG_RUNTIME_NO_REAL_3
+ constexpr bool hasReal3{true};
+#else
+ constexpr bool hasReal3{false};
+#endif
#if defined LDBL_MANT_DIG == 64 && !defined FLANG_RUNTIME_NO_REAL_10
constexpr bool hasReal10{true};
#else
@@ -171,9 +176,9 @@ inline RT_API_ATTRS CppTypeFor<TypeCategory::Integer, 4> SelectedRealKind(
}
if (r <= 4) {
- kind = kind < 2 ? 2 : kind;
+ kind = kind < 2 ? (hasReal2 ? 2 : 4) : kind;
} else if (r <= 37) {
- kind = kind < 3 ? (p == 3 ? 4 : 3) : kind;
+ kind = kind < 3 ? (hasReal3 && p != 3 ? 3 : 4) : kind;
} else if (r <= 307) {
kind = kind < 8 ? 8 : kind;
} else if (hasReal10 && r <= 4931) {
More information about the flang-commits
mailing list