[v3,1/3] LoongArch: Adjust D version strings.

Message ID 20231201100827.227376-2-yangyujie@loongson.cn
State New
Headers
Series LoongArch D support |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 fail Patch failed to apply

Commit Message

Yang Yujie Dec. 1, 2023, 10:08 a.m. UTC
  gcc/ChangeLog:

	* config/loongarch/loongarch-d.cc: Undefine LoongArch32.
	Define LoongArch_SF, LoongArch_F32, LoongArch_F64

gcc/d/ChangeLog:

	* dmd/cond.d: Same.
	* implement-d.texi: Same.
---
 gcc/config/loongarch/loongarch-d.cc | 27 ++++++++++++++-------------
 gcc/d/dmd/cond.d                    |  6 +++---
 gcc/d/implement-d.texi              |  6 ++++++
 3 files changed, 23 insertions(+), 16 deletions(-)
  

Comments

Iain Buclaw Dec. 7, 2023, 10:30 a.m. UTC | #1
Hi,

Thanks for this.

Excerpts from Yang Yujie's message of Dezember 1, 2023 11:08 am:
> diff --git a/gcc/d/dmd/cond.d b/gcc/d/dmd/cond.d
> index 568b639e0b6..02af0cc9e29 100644
> --- a/gcc/d/dmd/cond.d
> +++ b/gcc/d/dmd/cond.d
> @@ -693,10 +693,10 @@ extern (C++) final class VersionCondition : DVCondition
>              case "LDC":
>              case "linux":
>              case "LittleEndian":
> -            case "LoongArch32":
>              case "LoongArch64":
> -            case "LoongArch_HardFloat":
> -            case "LoongArch_SoftFloat":
> +            case "LoongArch_F64":
> +            case "LoongArch_F32":
> +            case "LoongArch_SF":
>              case "MinGW":
>              case "MIPS32":
>              case "MIPS64":

Changes to this module should be submitted to github.com/dlang/dmd,
otherwise it'll get overwritten on the next "merge" with upstream.

What's the rationale for F64 and SF abbreviations?

Otherwise, looks reasonable.

Iain.
  
Yang Yujie Dec. 8, 2023, 1:50 a.m. UTC | #2
On Thu, Dec 07, 2023 at 11:30:16AM +0100, Iain Buclaw wrote:
> Hi,
> 
> Thanks for this.
> 
> Excerpts from Yang Yujie's message of Dezember 1, 2023 11:08 am:
> > diff --git a/gcc/d/dmd/cond.d b/gcc/d/dmd/cond.d
> > index 568b639e0b6..02af0cc9e29 100644
> > --- a/gcc/d/dmd/cond.d
> > +++ b/gcc/d/dmd/cond.d
> > @@ -693,10 +693,10 @@ extern (C++) final class VersionCondition : DVCondition
> >              case "LDC":
> >              case "linux":
> >              case "LittleEndian":
> > -            case "LoongArch32":
> >              case "LoongArch64":
> > -            case "LoongArch_HardFloat":
> > -            case "LoongArch_SoftFloat":
> > +            case "LoongArch_F64":
> > +            case "LoongArch_F32":
> > +            case "LoongArch_SF":
> >              case "MinGW":
> >              case "MIPS32":
> >              case "MIPS64":
> 
> Changes to this module should be submitted to github.com/dlang/dmd,
> otherwise it'll get overwritten on the next "merge" with upstream.
> 
> What's the rationale for F64 and SF abbreviations?
> 
> Otherwise, looks reasonable.
> 
> Iain.

Hi Iain,

Thanks for the review!  I will push this to the dmd repo first shortly
and then send a v4 here.

By definition, LoongArch at the current stage can choose to implement either a
64-bit / 32-bit or no FPU at all, which are represented with target triplets
loongarch*-*{f64,f32.sf}.  The F64/F32/SF-suffixed version strings represents
this distinction, though the support of the "F32" ISA variant is not active
upstream.

From what I can see, the current usage of "F64/SF" is only needed for FP
context code.  I will also push the corresponding change to druntime later.

Also If you have the time, does the following patch look OK to you?
I couldn't get libphobos to build as a static library and this is the fix
I came up with.
https://gcc.gnu.org/pipermail/gcc-patches/2023-November/636767.html

Thanks,
Yujie
  

Patch

diff --git a/gcc/config/loongarch/loongarch-d.cc b/gcc/config/loongarch/loongarch-d.cc
index 9ac483c39a7..4692b78708a 100644
--- a/gcc/config/loongarch/loongarch-d.cc
+++ b/gcc/config/loongarch/loongarch-d.cc
@@ -29,24 +29,27 @@  along with GCC; see the file COPYING3.  If not see
 void
 loongarch_d_target_versions (void)
 {
-  if (TARGET_64BIT)
+  if (TARGET_ABI_LP64)
     d_add_builtin_version ("LoongArch64");
-  else
-    d_add_builtin_version ("LoongArch32");
 
-  if (TARGET_HARD_FLOAT_ABI)
+  if (TARGET_DOUBLE_FLOAT_ABI)
+    {
+      d_add_builtin_version ("LoongArch_F64");
+      d_add_builtin_version ("D_HardFloat");
+    }
+  else if (TARGET_SINGLE_FLOAT_ABI)
     {
-      d_add_builtin_version ("LoongArch_HardFloat");
+      d_add_builtin_version ("LoongArch_F32");
       d_add_builtin_version ("D_HardFloat");
     }
-  else if (TARGET_SOFT_FLOAT_ABI)
+  else
     {
-      d_add_builtin_version ("LoongArch_SoftFloat");
+      d_add_builtin_version ("LoongArch_SF");
       d_add_builtin_version ("D_SoftFloat");
     }
 }
 
-/* Handle a call to `__traits(getTargetInfo, "floatAbi")'.  */
+/* Handle trait getTargetInfo with key "floatAbi"  */
 
 static tree
 loongarch_d_handle_target_float_abi (void)
@@ -55,10 +58,8 @@  loongarch_d_handle_target_float_abi (void)
 
   if (TARGET_HARD_FLOAT_ABI)
     abi = "hard";
-  else if (TARGET_SOFT_FLOAT_ABI)
-    abi = "soft";
   else
-    abi = "";
+    abi = "soft";
 
   return build_string_literal (strlen (abi) + 1, abi);
 }
@@ -69,8 +70,8 @@  void
 loongarch_d_register_target_info (void)
 {
   const struct d_target_info_spec handlers[] = {
-    {"floatAbi", loongarch_d_handle_target_float_abi},
-    {NULL, NULL},
+    { "floatAbi", loongarch_d_handle_target_float_abi },
+    { NULL, NULL },
   };
 
   d_add_target_info_handlers (handlers);
diff --git a/gcc/d/dmd/cond.d b/gcc/d/dmd/cond.d
index 568b639e0b6..02af0cc9e29 100644
--- a/gcc/d/dmd/cond.d
+++ b/gcc/d/dmd/cond.d
@@ -693,10 +693,10 @@  extern (C++) final class VersionCondition : DVCondition
             case "LDC":
             case "linux":
             case "LittleEndian":
-            case "LoongArch32":
             case "LoongArch64":
-            case "LoongArch_HardFloat":
-            case "LoongArch_SoftFloat":
+            case "LoongArch_F64":
+            case "LoongArch_F32":
+            case "LoongArch_SF":
             case "MinGW":
             case "MIPS32":
             case "MIPS64":
diff --git a/gcc/d/implement-d.texi b/gcc/d/implement-d.texi
index 6f33bc192fe..cc0d1ecf593 100644
--- a/gcc/d/implement-d.texi
+++ b/gcc/d/implement-d.texi
@@ -1966,6 +1966,12 @@  Version relating to GNU Hurd systems.
 @item linux
 Version relating to Linux systems.
 
+@item LoongArch64
+@item LoongArch_SF
+@item LoongArch_F32
+@item LoongArch_F64
+Versions relating to the LoongArch family of processors.
+
 @item MinGW
 Version relating to the MinGW environment.