From: Iain Buclaw <ibuclaw@gdcproject.org>
To: gcc-patches@gcc.gnu.org, liushuyu <liushuyu011@gmail.com>
Subject: Re: [PATCH 1/1] gcc/d: add LoongArch64 support for D frontend
Date: Sun, 24 Sep 2023 11:02:59 +0200 [thread overview]
Message-ID: <1695544593.yjfl4jheix.astroid@pulse.none> (raw)
In-Reply-To: <24628144-581a-4fcb-9fcb-9a518c79778e@gmail.com>
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 <liushuyu011@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.
next prev parent reply other threads:[~2023-09-24 9:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-23 23:21 liushuyu
2023-09-24 9:02 ` Iain Buclaw [this message]
2023-09-23 23:30 [PATCH 0/1] Add " liushuyu
2023-09-23 23:30 ` [PATCH 1/1] gcc/d: add " liushuyu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1695544593.yjfl4jheix.astroid@pulse.none \
--to=ibuclaw@gdcproject.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=liushuyu011@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).