Excerpts from liushuyu's message of September 24, 2023 1:21 am:
> 
> gcc/ChangeLog:
> 
>       * config.gcc: add loongarch-d.o to d_target_objs for LoongArch
>       architecture.
> 
> gcc/config/ChangeLog:
> 
>       * loongarch/loongarch-d.cc
>       (loongarch_d_target_versions): add interface function to define builtin
>       D versions for LoongArch architecture.
>       (loongarch_d_handle_target_float_abi): add interface function to define
>       builtin D traits for LoongArch architecture.
>       (loongarch_d_register_target_info): add interface function to register
>       loongarch_d_handle_target_float_abi function.
>       * loongarch/loongarch-d.h:
>       (loongarch_d_target_versions): add function prototype.
>       (loongarch_d_register_target_info): Likewise.
>       * loongarch/t-loongarch: add object target for loongarch-d.cc.
> 
> gcc/testsuite/ChangeLog:
> 
>       * gdc.test/fail_compilation/reserved_version.d: add reserved version
>       tests for LoongArch architecture and also updated expected output.
>       * gdc.test/fail_compilation/reserved_version_switch.d: Likewise.
> 
> libphobos/ChangeLog:
> 
>       * configure.tgt: enable libphobos for LoongArch architecture.
>       * configure: Regenerate.
>       * libdruntime/gcc/sections/elf.d: add TLS_DTV_OFFSET constant for
>       LoongArch64.
>       * libdruntime/gcc/unwind/generic.d: add __aligned__ constant for
>       LoongArch64.
>       * libdruntime/Makefile.in: Regenerate.
> 
> Signed-off-by: Zixing Liu <liushuyu...@gmail.com>

Thanks, some comments below.

> diff --git a/gcc/config/loongarch/loongarch-d.cc 
> b/gcc/config/loongarch/loongarch-d.cc
> new file mode 100644
> index 00000000000..d7875079212
> --- /dev/null
> +++ b/gcc/config/loongarch/loongarch-d.cc
> @@ -0,0 +1,82 @@
> +/* Subroutines for the D front end on the LoongArch architecture.
> +   Copyright (C) 2017-2023 Free Software Foundation, Inc.

Copyright years start from the year the source file was introduced.

> +
> +GCC is free software; you can redistribute it and/or modify
> +it under the terms of the GNU General Public License as published by
> +the Free Software Foundation; either version 3, or (at your option)
> +any later version.
> +
> +GCC is distributed in the hope that it will be useful,
> +but WITHOUT ANY WARRANTY; without even the implied warranty of
> +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +GNU General Public License for more details.
> +
> +You should have received a copy of the GNU General Public License
> +along with GCC; see the file COPYING3.  If not see
> +<http://www.gnu.org/licenses/>.  */
> +
> +#define IN_TARGET_CODE 1
> +
> +#include "config.h"
> +#include "system.h"
> +#include "coretypes.h"
> +#include "tm_d.h"
> +#include "d/d-target.h"
> +#include "d/d-target-def.h"
> +
> +/* Implement TARGET_D_CPU_VERSIONS for LoongArch targets.  */
> +
> +void
> +loongarch_d_target_versions (void)
> +{
> +  if (TARGET_64BIT)
> +    d_add_builtin_version ("LoongArch64");
> +  else
> +    d_add_builtin_version ("LoongArch32");
> +
> +  if (TARGET_ABI_LP64)
> +    d_add_builtin_version ("D_LP64");

D_LP64 is already predefined by d/d-builtins.cc if POINTER_SIZE == 64,
and it should not be confused with any LP64 ABI model.  I haven't
checked what happens if you predefine the same version twice.

> +  else
> +    d_add_builtin_version ("D_LP32");

D_LP32 is not a standardized predefined version condition as far as I'm
aware. Maybe these should be LoongArch_LP64 and LoongArch_LP32 instead.

> +
> +  if (TARGET_HARD_FLOAT_ABI)
> +    {
> +      d_add_builtin_version ("LoongArch_HardFloat");
> +      d_add_builtin_version ("D_HardFloat");
> +    }
> +  else if (TARGET_SOFT_FLOAT_ABI)
> +    {
> +      d_add_builtin_version ("LoongArch_SoftFloat");
> +      d_add_builtin_version ("D_SoftFloat");
> +    }
> +}
> +
> diff --git a/gcc/testsuite/gdc.test/fail_compilation/reserved_version.d 
> b/gcc/testsuite/gdc.test/fail_compilation/reserved_version.d
> index f7a554ce729..b00b3453d85 100644
> --- a/gcc/testsuite/gdc.test/fail_compilation/reserved_version.d
> +++ b/gcc/testsuite/gdc.test/fail_compilation/reserved_version.d

These tests would be added anyway as part of merging the upstream DMD
mainline, but otherwise I wouldn't object to update them here.

Regards,
Iain.

Reply via email to