public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: gcc-patches@gcc.gnu.org
Cc: chenglulu <chenglulu@loongson.cn>,
	i@xen0n.name, xuchenghua@loongson.cn,
	Xi Ruoyao <xry111@xry111.site>
Subject: [PATCH 0/5] LoongArch: Initial LA664 support
Date: Thu, 16 Nov 2023 21:18:32 +0800	[thread overview]
Message-ID: <20231116131836.504699-2-xry111@xry111.site> (raw)

Loongson 3A6000 processor will be shipped to general users in this month
and it features 4 cores with the new LA664 micro architecture.  Here is
some changes from LA464:

1. The 32-bit division instruction now ignores the high 32 bits of the
   input registers.  This is enumerated via CPUCFG word 0x2, bit 26.
2. The micro architecture now guarantees two loads on the same memory
   address won't be reordered with each other.  dbar 0x700 is turned
   into nop.
3. The architecture now supports approximate square root instructions
   (FRECIPE and VRSQRTE) on 32-bit or 64-bit floating-point values and
   the vectors of these values.
4. The architecture now supports SC.Q instruction for 128-bit CAS.
5. The architecture now supports LL.ACQ and SC.REL instructions (well, I
   don't really know what they are for).
6. The architecture now supports CAS instructions for 64, 32, 16, or 8-bit
   values.
7. The architecture now supports atomic add and atomic swap instructions
   for 16 or 8-bit values.
8. Some non-zero hint values of DBAR instructions are added.

These features are documented in LoongArch v1.1.  Implementations can
implement any subset of them and enumerate the implemented features via
CPUCFG.  LA664 implements them all.

(8) is already implemented in previous patches because it's completely
backward-compatible.  This series implements (1) and (2) with switches
-mdiv32 and -mld-seq-sa (these names are derived from the names of the
corresponding CPUCFG bits documented in the LoongArch v1.1
specification).

The other features require Binutils support and we are close to the end
of GCC 14 stage 1, so I'm posting this series first now.

With -march=la664, these two options are implicitly enabled but they can
be turned off with -mno-div32 or -mno-ld-seq-sa.

With -march=native, the current CPU is probed via CPUCFG and these
options are implicitly enabled if the CPU supports the corresponding
feature.  They can be turned off with explicit -mno-div32 or
-mno-ld-seq-sa as well.

-mtune=la664 is implemented as a copy of -mtune=la464 and we can adjust
it with benchmark results later.

Bootstrapped and regtested on a LA664 with BOOT_CFLAGS="-march=la664
-O2", a LA464 with BOOT_CFLAGS="-march=native -O2".  And manually
verified -march=native probing on LA664 and LA464.

Xi Ruoyao (5):
  LoongArch: Switch loongarch-def to C++
  LoongArch: genopts: Add infrastructure to generate code for new
    features in ISA evolution
  LoongArch: Take the advantage of -mdiv32 if it's enabled
  LoongArch: Don't emit dbar 0x700 if -mld-seq-sa
  LoongArch: Add -march=la664 and -mtune=la664

 gcc/config/loongarch/genopts/genstr.sh        |  78 ++++++-
 gcc/config/loongarch/genopts/isa-evolution.in |   2 +
 .../loongarch/genopts/loongarch-strings       |   1 +
 gcc/config/loongarch/genopts/loongarch.opt.in |  10 +
 gcc/config/loongarch/loongarch-cpu.cc         |  37 ++--
 gcc/config/loongarch/loongarch-cpucfg-map.h   |  36 +++
 gcc/config/loongarch/loongarch-def-array.h    |  40 ++++
 gcc/config/loongarch/loongarch-def.c          | 205 ------------------
 gcc/config/loongarch/loongarch-def.cc         | 193 +++++++++++++++++
 gcc/config/loongarch/loongarch-def.h          |  67 ++++--
 gcc/config/loongarch/loongarch-opts.h         |   9 +-
 gcc/config/loongarch/loongarch-str.h          |   8 +-
 gcc/config/loongarch/loongarch-tune.h         | 123 ++++++++++-
 gcc/config/loongarch/loongarch.cc             |   6 +-
 gcc/config/loongarch/loongarch.md             |  31 ++-
 gcc/config/loongarch/loongarch.opt            |  23 +-
 gcc/config/loongarch/t-loongarch              |  25 ++-
 .../gcc.target/loongarch/div-div32.c          |  31 +++
 .../gcc.target/loongarch/div-no-div32.c       |  11 +
 19 files changed, 664 insertions(+), 272 deletions(-)
 create mode 100644 gcc/config/loongarch/genopts/isa-evolution.in
 create mode 100644 gcc/config/loongarch/loongarch-cpucfg-map.h
 create mode 100644 gcc/config/loongarch/loongarch-def-array.h
 delete mode 100644 gcc/config/loongarch/loongarch-def.c
 create mode 100644 gcc/config/loongarch/loongarch-def.cc
 create mode 100644 gcc/testsuite/gcc.target/loongarch/div-div32.c
 create mode 100644 gcc/testsuite/gcc.target/loongarch/div-no-div32.c

-- 
2.42.1


             reply	other threads:[~2023-11-16 13:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-16 13:18 Xi Ruoyao [this message]
2023-11-16 13:18 ` [PATCH 1/5] LoongArch: Switch loongarch-def to C++ Xi Ruoyao
2023-11-16 13:18 ` [PATCH 2/5] LoongArch: genopts: Add infrastructure to generate code for new features in ISA evolution Xi Ruoyao
2023-11-16 13:18 ` [PATCH 3/5] LoongArch: Take the advantage of -mdiv32 if it's enabled Xi Ruoyao
2023-11-16 13:18 ` [PATCH 4/5] LoongArch: Don't emit dbar 0x700 if -mld-seq-sa Xi Ruoyao
2023-11-16 13:18 ` [PATCH 5/5] LoongArch: Add -march=la664 and -mtune=la664 Xi Ruoyao
2023-11-17  2:41 ` [PATCH 0/5] LoongArch: Initial LA664 support chenglulu
2023-11-17  4:55   ` Xi Ruoyao
2023-11-17  6:07     ` chenglulu

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=20231116131836.504699-2-xry111@xry111.site \
    --to=xry111@xry111.site \
    --cc=chenglulu@loongson.cn \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=i@xen0n.name \
    --cc=xuchenghua@loongson.cn \
    /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).