Skip to content

Commit

Permalink
[flang][runtime] long double isn't always f80 (llvm#106746)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
tblah authored Sep 2, 2024
1 parent a0a2531 commit cde3838
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <>
Expand Down

0 comments on commit cde3838

Please sign in to comment.