From: Hui Li <lihui@loongson.cn>
To: Luis Machado <luis.machado@arm.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: LoongArch: Add vector extensions support
Date: Fri, 8 Sep 2023 09:33:28 +0800 [thread overview]
Message-ID: <87228760-7105-966e-6f23-3079ddab5342@loongson.cn> (raw)
In-Reply-To: <3cf2dba4-ee15-a33c-b700-f6d3a9d3185b@arm.com>
Hi,
On 2023/8/29 下午11:04, Luis Machado wrote:
> Hi,
>
> On 8/29/23 13:10, Hui Li wrote:
>> Add LoongArch's vector extensions support, which including 128bit LSX
>> (i.e., Loongson SIMD eXtension) and 256bit LASX (i.e., Loongson Advanced
>> SIMD eXtension).
>>
>> Signed-off-by: Hui Li <lihui@loongson.cn>
>> Change-Id: I04e92203a86547654d9f6c8cd1a9c3a789cb73db
>> ---
>> gdb/arch/loongarch.c | 7 ++
>> gdb/arch/loongarch.h | 4 +
>> gdb/features/Makefile | 2 +
>> gdb/features/loongarch/lasx.c | 85 +++++++++++++++++++++
>> gdb/features/loongarch/lasx.xml | 61 ++++++++++++++++
>> gdb/features/loongarch/lsx.c | 82 +++++++++++++++++++++
>> gdb/features/loongarch/lsx.xml | 60 +++++++++++++++
>> gdb/loongarch-linux-nat.c | 123 +++++++++++++++++++++++++++++++
>> gdb/loongarch-linux-tdep.c | 126 ++++++++++++++++++++++++++++++++
>> gdb/loongarch-tdep.c | 32 ++++++++
>> gdb/loongarch-tdep.h | 2 +
>> 11 files changed, 584 insertions(+)
>> create mode 100644 gdb/features/loongarch/lasx.c
>> create mode 100644 gdb/features/loongarch/lasx.xml
>> create mode 100644 gdb/features/loongarch/lsx.c
>> create mode 100644 gdb/features/loongarch/lsx.xml
>>
>> diff --git a/gdb/arch/loongarch.c b/gdb/arch/loongarch.c
>> index 168fcbc15df..1fb3c24149e 100644
>> --- a/gdb/arch/loongarch.c
>> +++ b/gdb/arch/loongarch.c
>> @@ -25,6 +25,8 @@
>> #include "../features/loongarch/base32.c"
>> #include "../features/loongarch/base64.c"
>> #include "../features/loongarch/fpu.c"
>> +#include "../features/loongarch/lsx.c"
>> +#include "../features/loongarch/lasx.c"
>>
>> #ifndef GDBSERVER
>> #define STATIC_IN_GDB static
>> @@ -63,6 +65,11 @@ loongarch_create_target_description (const struct loongarch_gdbarch_features fea
>> /* For now we only support creating single float and double float. */
>> regnum = create_feature_loongarch_fpu (tdesc.get (), regnum);
>>
>> +
>> + /* For now we only support creating lsx and lasx. */
>> + regnum = create_feature_loongarch_lsx (tdesc.get (), regnum);
>> + regnum = create_feature_loongarch_lasx (tdesc.get (), regnum);
>> +
>> return tdesc;
>> }
>>
>> diff --git a/gdb/arch/loongarch.h b/gdb/arch/loongarch.h
>> index d0a63dc2ac5..48662af8c11 100644
>> --- a/gdb/arch/loongarch.h
>> +++ b/gdb/arch/loongarch.h
>> @@ -41,6 +41,10 @@ enum loongarch_regnum
>> LOONGARCH_FIRST_FCC_REGNUM = LOONGARCH_FIRST_FP_REGNUM + LOONGARCH_LINUX_NUM_FPREGSET,
>> LOONGARCH_LINUX_NUM_FCC = 8,
>> LOONGARCH_FCSR_REGNUM = LOONGARCH_FIRST_FCC_REGNUM + LOONGARCH_LINUX_NUM_FCC,
>> + LOONGARCH_FIRST_LSX_REGNUM = LOONGARCH_FCSR_REGNUM + 1,
>> + LOONGARCH_LINUX_NUM_LSXREGSET = 32,
>> + LOONGARCH_FIRST_LASX_REGNUM = LOONGARCH_FIRST_LSX_REGNUM + LOONGARCH_LINUX_NUM_LSXREGSET,
>> + LOONGARCH_LINUX_NUM_LASXREGSET = 32,
>> };
>>
>> enum loongarch_fputype
>> diff --git a/gdb/features/Makefile b/gdb/features/Makefile
>> index 32341f71815..965e32d3f04 100644
>> --- a/gdb/features/Makefile
>> +++ b/gdb/features/Makefile
>> @@ -237,6 +237,8 @@ FEATURE_XMLFILES = aarch64-core.xml \
>> loongarch/base32.xml \
>> loongarch/base64.xml \
>> loongarch/fpu.xml \
>> + loongarch/lsx.xml \
>> + loongarch/lasx.xml \
>> riscv/rv32e-xregs.xml \
>> riscv/32bit-cpu.xml \
>> riscv/32bit-fpu.xml \
>> diff --git a/gdb/features/loongarch/lasx.c b/gdb/features/loongarch/lasx.c
>> new file mode 100644
>> index 00000000000..52d486ecb09
>> --- /dev/null
>> +++ b/gdb/features/loongarch/lasx.c
>> @@ -0,0 +1,85 @@
>> +/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
>> + Original: lasx.xml */
>> +
>> +#include "gdbsupport/tdesc.h"
>> +
>> +static int
>> +create_feature_loongarch_lasx (struct target_desc *result, long regnum)
>> +{
>> + struct tdesc_feature *feature;
>> +
>> + feature = tdesc_create_feature (result, "org.gnu.gdb.loongarch.lasx");
>> + tdesc_type *element_type;
>> + element_type = tdesc_named_type (feature, "ieee_single");
>> + tdesc_create_vector (feature, "v8f32", element_type, 8);
>> +
>> + element_type = tdesc_named_type (feature, "ieee_double");
>> + tdesc_create_vector (feature, "v4f64", element_type, 4);
>> +
>> + element_type = tdesc_named_type (feature, "int8");
>> + tdesc_create_vector (feature, "v32i8", element_type, 32);
>> +
>> + element_type = tdesc_named_type (feature, "int16");
>> + tdesc_create_vector (feature, "v16i16", element_type, 16);
>> +
>> + element_type = tdesc_named_type (feature, "int32");
>> + tdesc_create_vector (feature, "v8i32", element_type, 8);
>> +
>> + element_type = tdesc_named_type (feature, "int64");
>> + tdesc_create_vector (feature, "v4i64", element_type, 4);
>> +
>> + element_type = tdesc_named_type (feature, "uint128");
>> + tdesc_create_vector (feature, "v2ui128", element_type, 2);
>> +
>> + tdesc_type_with_fields *type_with_fields;
>> + type_with_fields = tdesc_create_union (feature, "lasxv");
>> + tdesc_type *field_type;
>> + field_type = tdesc_named_type (feature, "v8f32");
>> + tdesc_add_field (type_with_fields, "v8_float", field_type);
>> + field_type = tdesc_named_type (feature, "v4f64");
>> + tdesc_add_field (type_with_fields, "v4_double", field_type);
>> + field_type = tdesc_named_type (feature, "v32i8");
>> + tdesc_add_field (type_with_fields, "v32_int8", field_type);
>> + field_type = tdesc_named_type (feature, "v16i16");
>> + tdesc_add_field (type_with_fields, "v16_int16", field_type);
>> + field_type = tdesc_named_type (feature, "v8i32");
>> + tdesc_add_field (type_with_fields, "v8_int32", field_type);
>> + field_type = tdesc_named_type (feature, "v4i64");
>> + tdesc_add_field (type_with_fields, "v4_int64", field_type);
>> + field_type = tdesc_named_type (feature, "v2ui128");
>> + tdesc_add_field (type_with_fields, "v2_uint128", field_type);
>> +
>> + tdesc_create_reg (feature, "xr0", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr1", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr2", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr3", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr4", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr5", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr6", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr7", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr8", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr9", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr10", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr11", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr12", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr13", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr14", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr15", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr16", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr17", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr18", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr19", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr20", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr21", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr22", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr23", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr24", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr25", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr26", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr27", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr28", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr29", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr30", regnum++, 1, "lasx", 256, "lasxv");
>> + tdesc_create_reg (feature, "xr31", regnum++, 1, "lasx", 256, "lasxv");
>> + return regnum;
>> +}
>> diff --git a/gdb/features/loongarch/lasx.xml b/gdb/features/loongarch/lasx.xml
>> new file mode 100644
>> index 00000000000..c6ce56660f2
>> --- /dev/null
>> +++ b/gdb/features/loongarch/lasx.xml
>> @@ -0,0 +1,61 @@
>> +<?xml version="1.0"?>
>> +<!-- Copyright (C) 2009-2018 Free Software Foundation, Inc.
>> + Contributed by ARM Ltd.
>> +
>> + Copying and distribution of this file, with or without modification,
>> + are permitted in any medium without royalty provided the copyright
>> + notice and this notice are preserved. -->
>
> You might want to adjust the headers of the xml files to drop the "Contributed by ARM Ltd.".
>
I will modify this in V2, thanks for your review.
Hui
prev parent reply other threads:[~2023-09-08 1:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-29 12:10 Hui Li
2023-08-29 15:04 ` Luis Machado
2023-09-08 1:33 ` Hui Li [this message]
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=87228760-7105-966e-6f23-3079ddab5342@loongson.cn \
--to=lihui@loongson.cn \
--cc=gdb-patches@sourceware.org \
--cc=luis.machado@arm.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).