[clang] [flang] [flang] Add nsw flag to do-variable increment with a new option (PR #91579)
https://github.com/vzakhari approved this pull request. It looks good to me except maybe for the naming of the lowering option. Thank you for doing this! https://github.com/llvm/llvm-project/pull/91579 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add nsw flag to do-variable increment with a new option (PR #91579)
https://github.com/vzakhari edited https://github.com/llvm/llvm-project/pull/91579 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add nsw flag to do-variable increment with a new option (PR #91579)
@@ -34,5 +34,9 @@ ENUM_LOWERINGOPT(NoPPCNativeVecElemOrder, unsigned, 1, 0) /// On by default. ENUM_LOWERINGOPT(Underscoring, unsigned, 1, 1) +/// If true, add nsw flags to arithmetic operations for integer. +/// Off by default. +ENUM_LOWERINGOPT(NoSignedWrap, unsigned, 1, 0) vzakhari wrote: `NoSignedWrap` sounds too generic for an option that only forces setting `NSW` for the loop variables' increments. Please consider renaming or at least make the scope of `NSW` assignment clear in the comment above. https://github.com/llvm/llvm-project/pull/91579 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] [cmake] Build executables with -no_exported_symbols when building Apple toolchain (PR #87684)
vzakhari wrote: FYI, it looks like this change broke `compiler-rt` build, e.g. in https://lab.llvm.org/buildbot/#/builders/270/builds/12485 https://github.com/llvm/llvm-project/pull/87684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][cuda] Add -fcuda option (PR #84944)
@@ -6488,6 +6488,9 @@ defm stack_arrays : BoolOptionWithoutMarshalling<"f", "stack-arrays", defm loop_versioning : BoolOptionWithoutMarshalling<"f", "version-loops-for-stride", PosFlag, NegFlag>; + +def fcuda : Flag<["-"], "fcuda">, Group, vzakhari wrote: I wonder if we also want to wire it to clang's `-x cuda` option. It might be good to use the same flags for clang/flang in makefiles/cmake. Though, I am not sure if the meaning of the two options is exactly the same. Maybe someone else knows. https://github.com/llvm/llvm-project/pull/84944 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][cuda] Add -fcuda option (PR #84944)
https://github.com/vzakhari edited https://github.com/llvm/llvm-project/pull/84944 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][cuda] Add -fcuda option (PR #84944)
https://github.com/vzakhari approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/84944 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. (PR #82832)
vzakhari wrote: I do not think the Windows CI failure has anything to do with my changes. I am going to merge this. https://github.com/llvm/llvm-project/pull/82832 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. (PR #82832)
https://github.com/vzakhari closed https://github.com/llvm/llvm-project/pull/82832 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. (PR #82832)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/82832 >From ef2b9e87295688743771f1a64b15aa6fee6499df Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Fri, 23 Feb 2024 13:08:49 -0800 Subject: [PATCH 1/2] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. Follow-up for #81971 to fix the disabled LIT test and add LIT tests for lowering of the added math intrinsics. --- clang/lib/Driver/ToolChains/CommonArgs.cpp| 15 flang/test/Driver/linker-flags.f90| 34 +-- flang/test/Lower/Intrinsics/cabs_real16.f90 | 10 ++ .../Lower/Intrinsics/missing-math-runtime.f90 | 12 +++ flang/test/Lower/Intrinsics/sin_real16.f90| 9 + flang/test/Lower/Intrinsics/sqrt_real16.f90 | 9 + flang/test/lit.cfg.py | 21 flang/test/lit.site.cfg.py.in | 1 + 8 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 flang/test/Lower/Intrinsics/cabs_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sin_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sqrt_real16.f90 diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 347b250260c4c4..faceee85a2f8dc 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1316,13 +1316,16 @@ void tools::addFortranRuntimeLibs(const ToolChain , const ArgList , // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { -StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); -f128LibName.consume_front_insensitive("lib"); -if (!f128LibName.empty()) { +StringRef F128LibName = TC.getDriver().getFlangF128MathLibrary(); +F128LibName.consume_front_insensitive("lib"); +if (!F128LibName.empty()) { + bool AsNeeded = !TC.getTriple().isOSAIX(); CmdArgs.push_back("-lFortranFloat128Math"); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); - CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + F128LibName)); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); } CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90 index 5e00520fcc098c..4d3d528b5e99e0 100644 --- a/flang/test/Driver/linker-flags.f90 +++ b/flang/test/Driver/linker-flags.f90 @@ -2,15 +2,15 @@ ! invocation. These libraries are added on top of other standard runtime ! libraries that the Clang driver will include. -! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN -! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-haiku %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,HAIKU -! RUN: %flang -### --target=x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MINGW +! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN,DARWIN-F128%f128-lib +! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,SOLARIS-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s
[clang] [flang] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. (PR #82832)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/82832 >From 4ad0b005081fe2286970b4c22721fe72ed26cf8b Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Fri, 23 Feb 2024 13:08:49 -0800 Subject: [PATCH 1/2] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. Follow-up for #81971 to fix the disabled LIT test and add LIT tests for lowering of the added math intrinsics. --- clang/lib/Driver/ToolChains/CommonArgs.cpp| 15 flang/test/Driver/linker-flags.f90| 34 +-- flang/test/Lower/Intrinsics/cabs_real16.f90 | 10 ++ .../Lower/Intrinsics/missing-math-runtime.f90 | 12 +++ flang/test/Lower/Intrinsics/sin_real16.f90| 9 + flang/test/Lower/Intrinsics/sqrt_real16.f90 | 9 + flang/test/lit.cfg.py | 21 flang/test/lit.site.cfg.py.in | 1 + 8 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 flang/test/Lower/Intrinsics/cabs_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sin_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sqrt_real16.f90 diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 347b250260c4c4..faceee85a2f8dc 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1316,13 +1316,16 @@ void tools::addFortranRuntimeLibs(const ToolChain , const ArgList , // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { -StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); -f128LibName.consume_front_insensitive("lib"); -if (!f128LibName.empty()) { +StringRef F128LibName = TC.getDriver().getFlangF128MathLibrary(); +F128LibName.consume_front_insensitive("lib"); +if (!F128LibName.empty()) { + bool AsNeeded = !TC.getTriple().isOSAIX(); CmdArgs.push_back("-lFortranFloat128Math"); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); - CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + F128LibName)); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); } CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90 index 5e00520fcc098c..4d3d528b5e99e0 100644 --- a/flang/test/Driver/linker-flags.f90 +++ b/flang/test/Driver/linker-flags.f90 @@ -2,15 +2,15 @@ ! invocation. These libraries are added on top of other standard runtime ! libraries that the Clang driver will include. -! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN -! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-haiku %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,HAIKU -! RUN: %flang -### --target=x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MINGW +! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN,DARWIN-F128%f128-lib +! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,SOLARIS-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s
[clang] [flang] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. (PR #82832)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/82832 >From fea6f95d3cfaa3ae75e0f8312198a20c36e79ad7 Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Fri, 23 Feb 2024 13:08:49 -0800 Subject: [PATCH 1/2] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. Follow-up for #81971 to fix the disabled LIT test and add LIT tests for lowering of the added math intrinsics. --- clang/lib/Driver/ToolChains/CommonArgs.cpp| 15 flang/test/Driver/linker-flags.f90| 34 +-- flang/test/Lower/Intrinsics/cabs_real16.f90 | 10 ++ .../Lower/Intrinsics/missing-math-runtime.f90 | 12 +++ flang/test/Lower/Intrinsics/sin_real16.f90| 9 + flang/test/Lower/Intrinsics/sqrt_real16.f90 | 9 + flang/test/lit.cfg.py | 21 flang/test/lit.site.cfg.py.in | 1 + 8 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 flang/test/Lower/Intrinsics/cabs_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sin_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sqrt_real16.f90 diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 347b250260c4c4..faceee85a2f8dc 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1316,13 +1316,16 @@ void tools::addFortranRuntimeLibs(const ToolChain , const ArgList , // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { -StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); -f128LibName.consume_front_insensitive("lib"); -if (!f128LibName.empty()) { +StringRef F128LibName = TC.getDriver().getFlangF128MathLibrary(); +F128LibName.consume_front_insensitive("lib"); +if (!F128LibName.empty()) { + bool AsNeeded = !TC.getTriple().isOSAIX(); CmdArgs.push_back("-lFortranFloat128Math"); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); - CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + F128LibName)); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); } CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90 index 5e00520fcc098c..4d3d528b5e99e0 100644 --- a/flang/test/Driver/linker-flags.f90 +++ b/flang/test/Driver/linker-flags.f90 @@ -2,15 +2,15 @@ ! invocation. These libraries are added on top of other standard runtime ! libraries that the Clang driver will include. -! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN -! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-haiku %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,HAIKU -! RUN: %flang -### --target=x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MINGW +! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN,DARWIN-F128%f128-lib +! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,SOLARIS-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s
[clang] [flang] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. (PR #82832)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/82832 >From 81ea8a2cf3a1cb4b9e99d590f7a80b156fe609b8 Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Fri, 23 Feb 2024 13:08:49 -0800 Subject: [PATCH 1/2] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. Follow-up for #81971 to fix the disabled LIT test and add LIT tests for lowering of the added math intrinsics. --- clang/lib/Driver/ToolChains/CommonArgs.cpp| 15 flang/test/Driver/linker-flags.f90| 34 +-- flang/test/Lower/Intrinsics/cabs_real16.f90 | 10 ++ .../Lower/Intrinsics/missing-math-runtime.f90 | 12 +++ flang/test/Lower/Intrinsics/sin_real16.f90| 9 + flang/test/Lower/Intrinsics/sqrt_real16.f90 | 9 + flang/test/lit.cfg.py | 21 flang/test/lit.site.cfg.py.in | 1 + 8 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 flang/test/Lower/Intrinsics/cabs_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sin_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sqrt_real16.f90 diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index e5196bd8b5ae9e..6c620a7f247a10 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1285,13 +1285,16 @@ void tools::addFortranRuntimeLibs(const ToolChain , const ArgList , // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { -StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); -f128LibName.consume_front_insensitive("lib"); -if (!f128LibName.empty()) { +StringRef F128LibName = TC.getDriver().getFlangF128MathLibrary(); +F128LibName.consume_front_insensitive("lib"); +if (!F128LibName.empty()) { + bool AsNeeded = !TC.getTriple().isOSAIX(); CmdArgs.push_back("-lFortranFloat128Math"); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); - CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + F128LibName)); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); } CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90 index 5e00520fcc098c..4d3d528b5e99e0 100644 --- a/flang/test/Driver/linker-flags.f90 +++ b/flang/test/Driver/linker-flags.f90 @@ -2,15 +2,15 @@ ! invocation. These libraries are added on top of other standard runtime ! libraries that the Clang driver will include. -! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN -! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-haiku %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,HAIKU -! RUN: %flang -### --target=x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MINGW +! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN,DARWIN-F128%f128-lib +! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,SOLARIS-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s
[clang] [flang] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. (PR #82832)
https://github.com/vzakhari created https://github.com/llvm/llvm-project/pull/82832 Follow-up for #81971 to fix the disabled LIT test and add LIT tests for lowering of the added math intrinsics. >From 81ea8a2cf3a1cb4b9e99d590f7a80b156fe609b8 Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Fri, 23 Feb 2024 13:08:49 -0800 Subject: [PATCH] [flang] Fixes for LIT testing of FLANG_RUNTIME_F128_MATH_LIB build. Follow-up for #81971 to fix the disabled LIT test and add LIT tests for lowering of the added math intrinsics. --- clang/lib/Driver/ToolChains/CommonArgs.cpp| 15 flang/test/Driver/linker-flags.f90| 34 +-- flang/test/Lower/Intrinsics/cabs_real16.f90 | 10 ++ .../Lower/Intrinsics/missing-math-runtime.f90 | 12 +++ flang/test/Lower/Intrinsics/sin_real16.f90| 9 + flang/test/Lower/Intrinsics/sqrt_real16.f90 | 9 + flang/test/lit.cfg.py | 21 flang/test/lit.site.cfg.py.in | 1 + 8 files changed, 87 insertions(+), 24 deletions(-) create mode 100644 flang/test/Lower/Intrinsics/cabs_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sin_real16.f90 create mode 100644 flang/test/Lower/Intrinsics/sqrt_real16.f90 diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index e5196bd8b5ae9e..6c620a7f247a10 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1285,13 +1285,16 @@ void tools::addFortranRuntimeLibs(const ToolChain , const ArgList , // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { -StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); -f128LibName.consume_front_insensitive("lib"); -if (!f128LibName.empty()) { +StringRef F128LibName = TC.getDriver().getFlangF128MathLibrary(); +F128LibName.consume_front_insensitive("lib"); +if (!F128LibName.empty()) { + bool AsNeeded = !TC.getTriple().isOSAIX(); CmdArgs.push_back("-lFortranFloat128Math"); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); - CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); - addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + F128LibName)); + if (AsNeeded) +addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); } CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); diff --git a/flang/test/Driver/linker-flags.f90 b/flang/test/Driver/linker-flags.f90 index 5e00520fcc098c..4d3d528b5e99e0 100644 --- a/flang/test/Driver/linker-flags.f90 +++ b/flang/test/Driver/linker-flags.f90 @@ -2,15 +2,15 @@ ! invocation. These libraries are added on top of other standard runtime ! libraries that the Clang driver will include. -! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN -! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-dragonfly %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX -! RUN: %flang -### --target=x86_64-unknown-haiku %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,HAIKU -! RUN: %flang -### --target=x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MINGW +! RUN: %flang -### --target=ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN,DARWIN-F128%f128-lib +! RUN: %flang -### --target=sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,SOLARIS-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-freebsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-netbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -### --target=x86_64-unknown-openbsd %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,UNIX,UNIX-F128%f128-lib +! RUN: %flang -###
[clang] [flang] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. (PR #81971)
vzakhari wrote: I have been doing some renaming and restructuring before uploading this for review, and I did not test the final version with `libquadmath`. The latest commit makes the `-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath` compiler fully functional (the end-to-end test is working). Thank you all for the reviews! I am going to merge this as soon as CI completes. I decided to keep the `compiler is built without support for` message as is, because emitting NYI might be confusing to the compiler developers. For users it will look like a compiler error, so I guess it does not matter for them if it has the NYI prefix or not. https://github.com/llvm/llvm-project/pull/81971 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. (PR #81971)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/81971 >From c798a2b74df57a1375882fb13a88ccf946f4bfbf Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Thu, 15 Feb 2024 20:01:35 -0800 Subject: [PATCH 1/3] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. Implemented few entry points for REAL(16) math in FortranF128Math static library. It is a thin wrapper around GNU libquadmath. Flang driver can always link it, and the dependencies will be brought in as needed. The final Fortran program/library that uses any of the entry points will depend on the underlying third-party library - this dependency has to be resolved somehow. I added FLANG_RUNTIME_F128_MATH_LIB CMake control so that the compiler driver and the runtime library can be built using the same third-party library: this way the linker knows which dependency to link in (under --as-needed). The compiler distribution should specify which third-party library is required for linking/running the apps that use REAL(16). The compiler package may provide a version of the third-party library or at least a stub library that can be used for linking, but the final program execution will still require the actual library. --- clang/include/clang/Driver/Driver.h | 10 ++ clang/lib/Driver/ToolChains/CommonArgs.cpp| 8 ++ flang/CMakeLists.txt | 17 +++ .../flang/Optimizer/Builder/IntrinsicCall.h | 19 ++-- flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 101 -- flang/runtime/CMakeLists.txt | 20 flang/runtime/Float128Math/CMakeLists.txt | 56 ++ flang/runtime/Float128Math/cabs.cpp | 24 + flang/runtime/Float128Math/math-entries.h | 77 + flang/runtime/Float128Math/sin.cpp| 22 flang/runtime/Float128Math/sqrt.cpp | 22 .../Lower/Intrinsics/missing-math-runtime.f90 | 6 +- flang/tools/flang-driver/driver.cpp | 3 + 13 files changed, 345 insertions(+), 40 deletions(-) create mode 100644 flang/runtime/Float128Math/CMakeLists.txt create mode 100644 flang/runtime/Float128Math/cabs.cpp create mode 100644 flang/runtime/Float128Math/math-entries.h create mode 100644 flang/runtime/Float128Math/sin.cpp create mode 100644 flang/runtime/Float128Math/sqrt.cpp diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 908bc87c14b1ca..a5ca637853a6ae 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -251,6 +251,11 @@ class Driver { /// from non-system headers are emitted. HeaderIncludeFilteringKind CCPrintHeadersFiltering = HIFIL_None; + /// Name of the library that provides implementations of + /// IEEE-754 128-bit float math functions used by Fortran F128 + /// runtime library. It should be linked as needed by the linker job. + std::string FlangF128MathLibrary; + /// Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics /// to CCLogDiagnosticsFilename or to stderr, in a stable machine readable /// format. @@ -440,6 +445,11 @@ class Driver { bool offloadHostOnly() const { return Offload == OffloadHost; } bool offloadDeviceOnly() const { return Offload == OffloadDevice; } + void setFlangF128MathLibrary(std::string name) { +FlangF128MathLibrary = std::move(name); + } + StringRef getFlangF128MathLibrary() const { return FlangF128MathLibrary; } + /// Compute the desired OpenMP runtime from the flags provided. OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList ) const; diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 0fd7b8424eb4ba..63d8e2f68f389f 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1285,6 +1285,14 @@ void tools::addFortranRuntimeLibs(const ToolChain , const ArgList , // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { +StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); +f128LibName.consume_front_insensitive("lib"); +if (!f128LibName.empty()) { + CmdArgs.push_back("-lFortranFloat128"); + addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); + addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); +} CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); } diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index f8ad39ba712f8c..21617aeea0215e 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -33,6 +33,17 @@ endif() option(FLANG_ENABLE_WERROR "Fail and stop building flang if a warning is triggered." OFF) +# The out of tree builds of the compiler and the Fortran runtime +# must use the same setting of
[clang] [flang] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. (PR #81971)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/81971 >From c798a2b74df57a1375882fb13a88ccf946f4bfbf Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Thu, 15 Feb 2024 20:01:35 -0800 Subject: [PATCH 1/2] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. Implemented few entry points for REAL(16) math in FortranF128Math static library. It is a thin wrapper around GNU libquadmath. Flang driver can always link it, and the dependencies will be brought in as needed. The final Fortran program/library that uses any of the entry points will depend on the underlying third-party library - this dependency has to be resolved somehow. I added FLANG_RUNTIME_F128_MATH_LIB CMake control so that the compiler driver and the runtime library can be built using the same third-party library: this way the linker knows which dependency to link in (under --as-needed). The compiler distribution should specify which third-party library is required for linking/running the apps that use REAL(16). The compiler package may provide a version of the third-party library or at least a stub library that can be used for linking, but the final program execution will still require the actual library. --- clang/include/clang/Driver/Driver.h | 10 ++ clang/lib/Driver/ToolChains/CommonArgs.cpp| 8 ++ flang/CMakeLists.txt | 17 +++ .../flang/Optimizer/Builder/IntrinsicCall.h | 19 ++-- flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 101 -- flang/runtime/CMakeLists.txt | 20 flang/runtime/Float128Math/CMakeLists.txt | 56 ++ flang/runtime/Float128Math/cabs.cpp | 24 + flang/runtime/Float128Math/math-entries.h | 77 + flang/runtime/Float128Math/sin.cpp| 22 flang/runtime/Float128Math/sqrt.cpp | 22 .../Lower/Intrinsics/missing-math-runtime.f90 | 6 +- flang/tools/flang-driver/driver.cpp | 3 + 13 files changed, 345 insertions(+), 40 deletions(-) create mode 100644 flang/runtime/Float128Math/CMakeLists.txt create mode 100644 flang/runtime/Float128Math/cabs.cpp create mode 100644 flang/runtime/Float128Math/math-entries.h create mode 100644 flang/runtime/Float128Math/sin.cpp create mode 100644 flang/runtime/Float128Math/sqrt.cpp diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 908bc87c14b1ca..a5ca637853a6ae 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -251,6 +251,11 @@ class Driver { /// from non-system headers are emitted. HeaderIncludeFilteringKind CCPrintHeadersFiltering = HIFIL_None; + /// Name of the library that provides implementations of + /// IEEE-754 128-bit float math functions used by Fortran F128 + /// runtime library. It should be linked as needed by the linker job. + std::string FlangF128MathLibrary; + /// Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics /// to CCLogDiagnosticsFilename or to stderr, in a stable machine readable /// format. @@ -440,6 +445,11 @@ class Driver { bool offloadHostOnly() const { return Offload == OffloadHost; } bool offloadDeviceOnly() const { return Offload == OffloadDevice; } + void setFlangF128MathLibrary(std::string name) { +FlangF128MathLibrary = std::move(name); + } + StringRef getFlangF128MathLibrary() const { return FlangF128MathLibrary; } + /// Compute the desired OpenMP runtime from the flags provided. OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList ) const; diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 0fd7b8424eb4ba..63d8e2f68f389f 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1285,6 +1285,14 @@ void tools::addFortranRuntimeLibs(const ToolChain , const ArgList , // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { +StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); +f128LibName.consume_front_insensitive("lib"); +if (!f128LibName.empty()) { + CmdArgs.push_back("-lFortranFloat128"); + addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); + addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); +} CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); } diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index f8ad39ba712f8c..21617aeea0215e 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -33,6 +33,17 @@ endif() option(FLANG_ENABLE_WERROR "Fail and stop building flang if a warning is triggered." OFF) +# The out of tree builds of the compiler and the Fortran runtime +# must use the same setting of
[clang] [flang] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. (PR #81971)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/81971 >From 32a034ada7ba4d5e4c195b5ef36cf671dcc2e06a Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Thu, 15 Feb 2024 20:01:35 -0800 Subject: [PATCH 1/2] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. Implemented few entry points for REAL(16) math in FortranF128Math static library. It is a thin wrapper around GNU libquadmath. Flang driver can always link it, and the dependencies will be brought in as needed. The final Fortran program/library that uses any of the entry points will depend on the underlying third-party library - this dependency has to be resolved somehow. I added FLANG_RUNTIME_F128_MATH_LIB CMake control so that the compiler driver and the runtime library can be built using the same third-party library: this way the linker knows which dependency to link in (under --as-needed). The compiler distribution should specify which third-party library is required for linking/running the apps that use REAL(16). The compiler package may provide a version of the third-party library or at least a stub library that can be used for linking, but the final program execution will still require the actual library. --- clang/include/clang/Driver/Driver.h | 10 ++ clang/lib/Driver/ToolChains/CommonArgs.cpp| 8 ++ flang/CMakeLists.txt | 17 +++ .../flang/Optimizer/Builder/IntrinsicCall.h | 19 ++-- flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 101 -- flang/runtime/CMakeLists.txt | 20 flang/runtime/Float128Math/CMakeLists.txt | 56 ++ flang/runtime/Float128Math/cabs.cpp | 24 + flang/runtime/Float128Math/math-entries.h | 77 + flang/runtime/Float128Math/sin.cpp| 22 flang/runtime/Float128Math/sqrt.cpp | 22 .../Lower/Intrinsics/missing-math-runtime.f90 | 6 +- flang/tools/flang-driver/driver.cpp | 3 + 13 files changed, 345 insertions(+), 40 deletions(-) create mode 100644 flang/runtime/Float128Math/CMakeLists.txt create mode 100644 flang/runtime/Float128Math/cabs.cpp create mode 100644 flang/runtime/Float128Math/math-entries.h create mode 100644 flang/runtime/Float128Math/sin.cpp create mode 100644 flang/runtime/Float128Math/sqrt.cpp diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 908bc87c14b1ca..a5ca637853a6ae 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -251,6 +251,11 @@ class Driver { /// from non-system headers are emitted. HeaderIncludeFilteringKind CCPrintHeadersFiltering = HIFIL_None; + /// Name of the library that provides implementations of + /// IEEE-754 128-bit float math functions used by Fortran F128 + /// runtime library. It should be linked as needed by the linker job. + std::string FlangF128MathLibrary; + /// Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics /// to CCLogDiagnosticsFilename or to stderr, in a stable machine readable /// format. @@ -440,6 +445,11 @@ class Driver { bool offloadHostOnly() const { return Offload == OffloadHost; } bool offloadDeviceOnly() const { return Offload == OffloadDevice; } + void setFlangF128MathLibrary(std::string name) { +FlangF128MathLibrary = std::move(name); + } + StringRef getFlangF128MathLibrary() const { return FlangF128MathLibrary; } + /// Compute the desired OpenMP runtime from the flags provided. OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList ) const; diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 0fd7b8424eb4ba..63d8e2f68f389f 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1285,6 +1285,14 @@ void tools::addFortranRuntimeLibs(const ToolChain , const ArgList , // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { +StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); +f128LibName.consume_front_insensitive("lib"); +if (!f128LibName.empty()) { + CmdArgs.push_back("-lFortranFloat128"); + addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); + addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); +} CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); } diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index f8ad39ba712f8c..21617aeea0215e 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -33,6 +33,17 @@ endif() option(FLANG_ENABLE_WERROR "Fail and stop building flang if a warning is triggered." OFF) +# The out of tree builds of the compiler and the Fortran runtime +# must use the same setting of
[clang] [flang] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. (PR #81971)
@@ -657,10 +657,61 @@ static llvm::cl::opt "instead of libm complex operations"), llvm::cl::init(false)); +/// Return a string containing the given Fortran intrinsic name +/// with the type of its arguments specified in funcType +/// surrounded by the given prefix/suffix. +static std::string +prettyPrintIntrinsicName(fir::FirOpBuilder , mlir::Location loc, + llvm::StringRef prefix, llvm::StringRef name, + llvm::StringRef suffix, mlir::FunctionType funcType) { + std::string output = prefix.str(); + llvm::raw_string_ostream sstream(output); + if (name == "pow") { +assert(funcType.getNumInputs() == 2 && "power operator has two arguments"); +std::string displayName{" ** "}; +sstream << numericMlirTypeToFortran(builder, funcType.getInput(0), loc, +displayName) +<< displayName +<< numericMlirTypeToFortran(builder, funcType.getInput(1), loc, +displayName); + } else { +sstream << name.upper() << "("; +if (funcType.getNumInputs() > 0) + sstream << numericMlirTypeToFortran(builder, funcType.getInput(0), loc, + name); +for (mlir::Type argType : funcType.getInputs().drop_front()) { + sstream << ", " << numericMlirTypeToFortran(builder, argType, loc, name); +} +sstream << ")"; + } + sstream << suffix; + return output; +} + +// Generate a call to the Fortran runtime library providing +// support for 128-bit float math via a third-party library. +// If the compiler is built without FLANG_RUNTIME_F128_MATH_LIB, +// this function will report an error. +static mlir::Value genLibF128Call(fir::FirOpBuilder , + mlir::Location loc, + const MathOperation , + mlir::FunctionType libFuncType, + llvm::ArrayRef args) { +#ifndef FLANG_RUNTIME_F128_MATH_LIB + std::string message = prettyPrintIntrinsicName( + builder, loc, "compiler is built without support for '", mathOp.key, "'", vzakhari wrote: I expect that we hit this code only when there is support for an intrinsic, but the compiler was built without `FLANG_RUNTIME_F128_MATH_LIB` set up. So `not yet implemented` would be confusing a bit. I can change this code to use the regular TODO macro, because it is probably irrelevant to the user whether it is intrinsic implementation gap or the configuration issue of the compiler build. https://github.com/llvm/llvm-project/pull/81971 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. (PR #81971)
https://github.com/vzakhari updated https://github.com/llvm/llvm-project/pull/81971 >From 32a034ada7ba4d5e4c195b5ef36cf671dcc2e06a Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Thu, 15 Feb 2024 20:01:35 -0800 Subject: [PATCH] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. Implemented few entry points for REAL(16) math in FortranF128Math static library. It is a thin wrapper around GNU libquadmath. Flang driver can always link it, and the dependencies will be brought in as needed. The final Fortran program/library that uses any of the entry points will depend on the underlying third-party library - this dependency has to be resolved somehow. I added FLANG_RUNTIME_F128_MATH_LIB CMake control so that the compiler driver and the runtime library can be built using the same third-party library: this way the linker knows which dependency to link in (under --as-needed). The compiler distribution should specify which third-party library is required for linking/running the apps that use REAL(16). The compiler package may provide a version of the third-party library or at least a stub library that can be used for linking, but the final program execution will still require the actual library. --- clang/include/clang/Driver/Driver.h | 10 ++ clang/lib/Driver/ToolChains/CommonArgs.cpp| 8 ++ flang/CMakeLists.txt | 17 +++ .../flang/Optimizer/Builder/IntrinsicCall.h | 19 ++-- flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 101 -- flang/runtime/CMakeLists.txt | 20 flang/runtime/Float128Math/CMakeLists.txt | 56 ++ flang/runtime/Float128Math/cabs.cpp | 24 + flang/runtime/Float128Math/math-entries.h | 77 + flang/runtime/Float128Math/sin.cpp| 22 flang/runtime/Float128Math/sqrt.cpp | 22 .../Lower/Intrinsics/missing-math-runtime.f90 | 6 +- flang/tools/flang-driver/driver.cpp | 3 + 13 files changed, 345 insertions(+), 40 deletions(-) create mode 100644 flang/runtime/Float128Math/CMakeLists.txt create mode 100644 flang/runtime/Float128Math/cabs.cpp create mode 100644 flang/runtime/Float128Math/math-entries.h create mode 100644 flang/runtime/Float128Math/sin.cpp create mode 100644 flang/runtime/Float128Math/sqrt.cpp diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 908bc87c14b1ca..a5ca637853a6ae 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -251,6 +251,11 @@ class Driver { /// from non-system headers are emitted. HeaderIncludeFilteringKind CCPrintHeadersFiltering = HIFIL_None; + /// Name of the library that provides implementations of + /// IEEE-754 128-bit float math functions used by Fortran F128 + /// runtime library. It should be linked as needed by the linker job. + std::string FlangF128MathLibrary; + /// Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics /// to CCLogDiagnosticsFilename or to stderr, in a stable machine readable /// format. @@ -440,6 +445,11 @@ class Driver { bool offloadHostOnly() const { return Offload == OffloadHost; } bool offloadDeviceOnly() const { return Offload == OffloadDevice; } + void setFlangF128MathLibrary(std::string name) { +FlangF128MathLibrary = std::move(name); + } + StringRef getFlangF128MathLibrary() const { return FlangF128MathLibrary; } + /// Compute the desired OpenMP runtime from the flags provided. OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList ) const; diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 0fd7b8424eb4ba..63d8e2f68f389f 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1285,6 +1285,14 @@ void tools::addFortranRuntimeLibs(const ToolChain , const ArgList , // add the correct libraries to link against as dependents in the object // file. if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) { +StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary(); +f128LibName.consume_front_insensitive("lib"); +if (!f128LibName.empty()) { + CmdArgs.push_back("-lFortranFloat128"); + addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true); + CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName)); + addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false); +} CmdArgs.push_back("-lFortranRuntime"); CmdArgs.push_back("-lFortranDecimal"); } diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index f8ad39ba712f8c..21617aeea0215e 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -33,6 +33,17 @@ endif() option(FLANG_ENABLE_WERROR "Fail and stop building flang if a warning is triggered." OFF) +# The out of tree builds of the compiler and the Fortran runtime +# must use the same setting of
[clang] [flang] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. (PR #81971)
https://github.com/vzakhari created https://github.com/llvm/llvm-project/pull/81971 Implemented few entry points for REAL(16) math in FortranF128Math static library. It is a thin wrapper around GNU libquadmath. Flang driver can always link it, and the dependencies will be brought in as needed. The final Fortran program/library that uses any of the entry points will depend on the underlying third-party library - this dependency has to be resolved somehow. I added FLANG_RUNTIME_F128_MATH_LIB CMake control so that the compiler driver and the runtime library can be built using the same third-party library: this way the linker knows which dependency to link in (under --as-needed). The compiler distribution should specify which third-party library is required for linking/running the apps that use REAL(16). The compiler package may provide a version of the third-party library or at least a stub library that can be used for linking, but the final program execution will still require the actual library. >From 3aee67fece1cbad69e912baa6cb191d2e5a0205a Mon Sep 17 00:00:00 2001 From: Slava Zakharin Date: Thu, 15 Feb 2024 20:01:35 -0800 Subject: [PATCH] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. Implemented few entry points for REAL(16) math in FortranF128Math static library. It is a thin wrapper around GNU libquadmath. Flang driver can always link it, and the dependencies will be brought in as needed. The final Fortran program/library that uses any of the entry points will depend on the underlying third-party library - this dependency has to be resolved somehow. I added FLANG_RUNTIME_F128_MATH_LIB CMake control so that the compiler driver and the runtime library can be built using the same third-party library: this way the linker knows which dependency to link in (under --as-needed). The compiler distribution should specify which third-party library is required for linking/running the apps that use REAL(16). The compiler package may provide a version of the third-party library or at least a stub library that can be used for linking, but the final program execution will still require the actual library. --- clang/include/clang/Driver/Driver.h | 10 ++ clang/lib/Driver/ToolChains/CommonArgs.cpp| 8 ++ flang/CMakeLists.txt | 17 +++ .../flang/Optimizer/Builder/IntrinsicCall.h | 19 ++-- flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 101 -- flang/runtime/CMakeLists.txt | 20 flang/runtime/Float128Math/CMakeLists.txt | 56 ++ flang/runtime/Float128Math/cabs.cpp | 24 + flang/runtime/Float128Math/math-entries.h | 77 + flang/runtime/Float128Math/sin.cpp| 22 flang/runtime/Float128Math/sqrt.cpp | 22 .../Lower/Intrinsics/missing-math-runtime.f90 | 6 +- flang/tools/flang-driver/driver.cpp | 3 + 13 files changed, 345 insertions(+), 40 deletions(-) create mode 100644 flang/runtime/Float128Math/CMakeLists.txt create mode 100644 flang/runtime/Float128Math/cabs.cpp create mode 100644 flang/runtime/Float128Math/math-entries.h create mode 100644 flang/runtime/Float128Math/sin.cpp create mode 100644 flang/runtime/Float128Math/sqrt.cpp diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 908bc87c14b1ca..a5ca637853a6ae 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -251,6 +251,11 @@ class Driver { /// from non-system headers are emitted. HeaderIncludeFilteringKind CCPrintHeadersFiltering = HIFIL_None; + /// Name of the library that provides implementations of + /// IEEE-754 128-bit float math functions used by Fortran F128 + /// runtime library. It should be linked as needed by the linker job. + std::string FlangF128MathLibrary; + /// Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics /// to CCLogDiagnosticsFilename or to stderr, in a stable machine readable /// format. @@ -440,6 +445,11 @@ class Driver { bool offloadHostOnly() const { return Offload == OffloadHost; } bool offloadDeviceOnly() const { return Offload == OffloadDevice; } + void setFlangF128MathLibrary(std::string name) { +FlangF128MathLibrary = std::move(name); + } + StringRef getFlangF128MathLibrary() const { return FlangF128MathLibrary; } + /// Compute the desired OpenMP runtime from the flags provided. OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList ) const; diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 0fd7b8424eb4ba..63d8e2f68f389f 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1285,6 +1285,14 @@ void tools::addFortranRuntimeLibs(const ToolChain , const ArgList , // add the correct libraries to link against as dependents in the object // file. if
[clang] [flang] [flang] (Re-)Enable alias tags pass by default (PR #74250)
https://github.com/vzakhari commented: Thank you, Tom! https://github.com/llvm/llvm-project/pull/74250 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Enable alias tags pass by default (PR #73111)
@@ -142,6 +142,26 @@ void Flang::addCodegenOptions(const ArgList , if (shouldLoopVersion(Args)) CmdArgs.push_back("-fversion-loops-for-stride"); + Arg *aliasAnalysis = Args.getLastArg(options::OPT_falias_analysis, + options::OPT_fno_alias_analysis); + Arg *optLevel = + Args.getLastArg(options::OPT_Ofast, options::OPT_O, options::OPT_O4); vzakhari wrote: It looks like `clang` generates `tbaa` metadata at all opt levels, except `-O0`. I think this makes sense: the optimization themselves need to decide how to use it, e.g. for improving performance/code-size/etc. https://github.com/llvm/llvm-project/pull/73111 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Enable alias tags pass by default (PR #73111)
https://github.com/vzakhari commented: Thank you for the changes, Tom! I have one minor comment, but I would like to ask to merge this after US holidays, if possible. Could you please postpone the merging until Monday GMT? https://github.com/llvm/llvm-project/pull/73111 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [clang] [flang] Enable alias tags pass by default (PR #73111)
https://github.com/vzakhari edited https://github.com/llvm/llvm-project/pull/73111 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][driver] add -flang-deprecated-no-hlfir hidden option (PR #71820)
https://github.com/vzakhari approved this pull request. Thank you, Jean! https://github.com/llvm/llvm-project/pull/71820 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [clang] WIP: [flang] Enable fir alias tags pass by default when optimizing for speed (PR #68597)
vzakhari wrote: Hi @tblah, is this ready for a merge? Let me know if you are just waiting for a review. https://github.com/llvm/llvm-project/pull/68597 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [APINotes] Upstream APINotesOptions (PR #70827)
vzakhari wrote: Hello @egorzhdan, this change breaks https://lab.llvm.org/buildbot/#/builders/270/builds/2125. Could you please fix or revert? https://github.com/llvm/llvm-project/pull/70827 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits