Skip to content

[clang][Driver] Define soft float macros for PPC. #106012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 4, 2024

Conversation

alexrp
Copy link
Member

@alexrp alexrp commented Aug 25, 2024

Fixes #105972.

@llvmbot llvmbot added clang Clang issues not falling into any other category backend:PowerPC clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Aug 25, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 25, 2024

@llvm/pr-subscribers-backend-powerpc

@llvm/pr-subscribers-clang

Author: Alex Rønne Petersen (alexrp)

Changes

Fixes #105972.


Full diff: https://github.com/llvm/llvm-project/pull/106012.diff

1 Files Affected:

  • (modified) clang/lib/Basic/Targets/PPC.cpp (+5-3)
diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 04dc436eb1b9cd..91145b256804c7 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -402,9 +402,13 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
     Builder.defineMacro("__VEC__", "10206");
     Builder.defineMacro("__ALTIVEC__");
   }
-  if (HasSPE) {
+  if (HasSPE)
     Builder.defineMacro("__SPE__");
+  if (HasSPE || FloatABI == SoftFloat)
     Builder.defineMacro("__NO_FPRS__");
+  if (FloatABI == SoftFloat) {
+    Builder.defineMacro("_SOFT_FLOAT");
+    Builder.defineMacro("_SOFT_DOUBLE");
   }
   if (HasVSX)
     Builder.defineMacro("__VSX__");
@@ -439,14 +443,12 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
   // FIXME: The following are not yet generated here by Clang, but are
   //        generated by GCC:
   //
-  //   _SOFT_FLOAT_
   //   __RECIP_PRECISION__
   //   __APPLE_ALTIVEC__
   //   __RECIP__
   //   __RECIPF__
   //   __RSQRTE__
   //   __RSQRTEF__
-  //   _SOFT_DOUBLE_
   //   __NO_LWSYNC__
   //   __CMODEL_MEDIUM__
   //   __CMODEL_LARGE__

@alexrp
Copy link
Member Author

alexrp commented Aug 25, 2024

FWIW, if this patch is good, it would be nice if we could get it into 19.x since we're affected by it in Zig.

@ecnelises
Copy link
Member

Could you pick the test change from ecnelises@9dcb9c9 into this patch?

@alexrp alexrp force-pushed the clang-ppc-sf-macros branch from 5d52fe0 to 885a183 Compare August 26, 2024 11:29
@alexrp
Copy link
Member Author

alexrp commented Aug 26, 2024

@ecnelises done, thank you!

Copy link
Member

@ecnelises ecnelises left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@alexrp alexrp force-pushed the clang-ppc-sf-macros branch 2 times, most recently from b9e8103 to acd4bd9 Compare August 27, 2024 03:21
@alexrp alexrp force-pushed the clang-ppc-sf-macros branch from acd4bd9 to 4f766ab Compare August 27, 2024 13:36
Copy link
Collaborator

@chenzheng1030 chenzheng1030 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now. Thanks very much for the fix.

@alexrp
Copy link
Member Author

alexrp commented Sep 3, 2024

Forgot to note in the PR description that I don't have commit access.

@chenzheng1030 chenzheng1030 merged commit b55186e into llvm:main Sep 4, 2024
8 checks passed
@alexrp alexrp deleted the clang-ppc-sf-macros branch September 5, 2024 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:PowerPC clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Clang][PowerPC] Clang does not define soft float macros with -msoft-float
4 participants