[flang-commits] [flang] cde3838 - [flang][runtime] long double isn't always f80 (#106746)
via flang-commits
flang-commits at lists.llvm.org
Mon Sep 2 02:12:45 PDT 2024
Author: Tom Eccles
Date: 2024-09-02T10:12:43+01:00
New Revision: cde3838c430502620cb4c1663e843e465c6e67b5
URL: https://github.com/llvm/llvm-project/commit/cde3838c430502620cb4c1663e843e465c6e67b5
DIFF: https://github.com/llvm/llvm-project/commit/cde3838c430502620cb4c1663e843e465c6e67b5.diff
LOG: [flang][runtime] long double isn't always f80 (#106746)
f80 is only a thing on x86, and even then the size of long double can be
changed with compiler flags. Instead set the size according to the host
system (this is what is already done for integer types).
Added:
Modified:
flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
Removed:
################################################################################
diff --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
index 845ba385918d0d..a103861f1510b8 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
@@ -341,7 +341,18 @@ constexpr TypeBuilderFunc getModel<const double *>() {
template <>
constexpr TypeBuilderFunc getModel<long double>() {
return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::FloatType::getF80(context);
+ // See TODO at the top of the file. This is configuring for the host system
+ // - it might be incorrect when cross-compiling!
+ constexpr size_t size = sizeof(long double);
+ static_assert(size == 16 || size == 10 || size == 8,
+ "unsupported long double size");
+ if constexpr (size == 16)
+ return mlir::FloatType::getF128(context);
+ if constexpr (size == 10)
+ return mlir::FloatType::getF80(context);
+ if constexpr (size == 8)
+ return mlir::FloatType::getF64(context);
+ llvm_unreachable("failed static assert");
};
}
template <>
More information about the flang-commits
mailing list