[PATCH] D117181: [PowerPC] Use IEEE long double in proper toolchain
Qiu Chaofan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 12 20:01:38 PST 2022
qiucf created this revision.
Herald added subscribers: shchenz, kbarton, nemanjai.
qiucf requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
In toolchains with proper support for IEEE float128, we can switch default long double semantics to it, unless explicitly specified with options.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117181
Files:
clang/lib/Driver/ToolChains/PPCLinux.cpp
clang/lib/Driver/ToolChains/PPCLinux.h
clang/test/Driver/ppc-float-abi-warning.cpp
clang/test/Driver/ppc-float-abi.cpp
Index: clang/test/Driver/ppc-float-abi.cpp
===================================================================
--- clang/test/Driver/ppc-float-abi.cpp
+++ clang/test/Driver/ppc-float-abi.cpp
@@ -7,7 +7,13 @@
// RUN: %clang -### --driver-mode=g++ -target powerpc64le-linux-gnu %s\
// RUN: -mabi=ieeelongdouble -stdlib=libc++ -Wno-unsupported-abi 2>&1 | \
// RUN: FileCheck %s --check-prefix=NOWARN
+// RUN: %clang -### -target powerpc64le-linux-gnu %s -nostdlib 2>&1 | \
+// RUN: FileCheck %s --check-prefix=IEEE
+// RUN: %clang -### -target powerpc64le-linux-gnu %s -nostdlib \
+// RUN: -mabi=ibmlongdouble 2>&1 | FileCheck %s --check-prefix=NOIEEE
// CHECK: warning: float ABI 'ieeelongdouble' is not supported by current library
// NOWARN-NOT: warning: float ABI 'ieeelongdouble' is not supported by current library
+// IEEE: -mabi=ieeelongdouble
+// NOIEEE-NOT: -mabi=ieeelongdouble
long double foo(long double x) { return x; }
Index: clang/lib/Driver/ToolChains/PPCLinux.h
===================================================================
--- clang/lib/Driver/ToolChains/PPCLinux.h
+++ clang/lib/Driver/ToolChains/PPCLinux.h
@@ -24,6 +24,11 @@
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
+ void
+ addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args,
+ Action::OffloadKind DeviceOffloadKind) const override;
+
private:
bool SupportIEEEFloat128(const Driver &D, const llvm::Triple &Triple,
const llvm::opt::ArgList &Args) const;
Index: clang/lib/Driver/ToolChains/PPCLinux.cpp
===================================================================
--- clang/lib/Driver/ToolChains/PPCLinux.cpp
+++ clang/lib/Driver/ToolChains/PPCLinux.cpp
@@ -13,6 +13,7 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
+using namespace clang::driver;
using namespace clang::driver::toolchains;
using namespace llvm::opt;
using namespace llvm::sys;
@@ -68,6 +69,14 @@
Linux::AddClangSystemIncludeArgs(DriverArgs, CC1Args);
}
+void PPCLinuxToolChain::addClangTargetOptions(
+ const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
+ Action::OffloadKind DeviceOffloadKind) const {
+ if (SupportIEEEFloat128(getDriver(), getTriple(), DriverArgs) &&
+ !DriverArgs.hasArg(options::OPT_mabi_EQ))
+ CC1Args.push_back("-mabi=ieeelongdouble");
+}
+
bool PPCLinuxToolChain::SupportIEEEFloat128(
const Driver &D, const llvm::Triple &Triple,
const llvm::opt::ArgList &Args) const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117181.399537.patch
Type: text/x-patch
Size: 2674 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220113/32f85353/attachment.bin>
More information about the cfe-commits
mailing list