From patchwork Wed Jun 28 13:13:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: WANG Xuerui X-Patchwork-Id: 113857 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8915782vqr; Wed, 28 Jun 2023 06:13:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7nP3iefSgLGDN6RHx07XvcIs/aqnq/A40Lre6VApH1dbSfEt3iDv0zzRk0bOt6kX/lQBXg X-Received: by 2002:a50:fc0c:0:b0:51d:9592:3117 with SMTP id i12-20020a50fc0c000000b0051d95923117mr6093113edr.29.1687958012327; Wed, 28 Jun 2023 06:13:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687958012; cv=none; d=google.com; s=arc-20160816; b=P2lyIyk8P4RHoFoatbSPzUo3iUleLGirKcO2PwWXtQSmL0gHGpujh0+jAMSZtqcBR2 1z/14T0+oukNqInB3ztzbaq9yTCgXs5uJGwzrwbLwkuxJwTFtHQRJRoyLqBHKea2Syh5 98QpS/febap7baAyOcL39ELz0w754A/B4ooNQuCo6Egc2Yb3YT3eZM9hZQfh3M3cGnJG BpdseoY6HO6ZZsq+TYBTcfxgeHpl5H8JIRKhrWu+XhMOo20pE+si42rOuUPT5DhrLgoT 8wjY8YPMdtuNLQDOrvDWKAlICw4nh/wpeJ4kXAcuqvy9ky/OJyZ0LNbIcWniELe0aNxq 5ofw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=pvzk6PFMcKvEiRsrmarzOrE/TcCjldbNtMTFrEBguGg=; fh=F52lMKP/ag7PTpjpGsg79bnedhkoffS1BBUct4g/1x0=; b=sbyHN3ZxqY9A0sdWXfd6fp/jGz84mMkgdi/dpOiAttUl8Y0qN9VzNdbEBnYUFnjKXY Ogx/ZsPFv/FJQwufWPYThFngci9ZTVA4nl4dJuia+vsUHbwArokHTZTZhtNq4Vn/Yqqu 9ohev3a2L6hOvWf1gIPbzm8gTjLJpQcpfW2Y6Ob5U6BXihmJ9TqxuNvu85twBu0cuyu8 yFm8hk/K5wGV74nW52Ed9Q5d8ho6zBUe+8z41kt0bhNVODzu+jQdi4gDI0Kyj0//OOxn IC4edzTQnsxphHhYRGeSE9zFdBah0tm7h+OKTiUpOL7YpFwJkCmQMLF6y5ToTv0G1Sym a4BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=x8kbrbrF; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f8-20020a056402068800b0051dd401bf24si233076edy.447.2023.06.28.06.13.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 06:13:32 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=x8kbrbrF; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 158FD3858C41 for ; Wed, 28 Jun 2023 13:13:31 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by sourceware.org (Postfix) with ESMTPS id AD3833858D35 for ; Wed, 28 Jun 2023 13:13:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AD3833858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=xen0n.name Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xen0n.name DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1687958000; bh=+lRJ4hZwFTSvK9pJkpPxlxRbOqwlR+U4mXRy3UIYoFg=; h=From:To:Cc:Subject:Date:From; b=x8kbrbrF1KawXRej0qbJiQASO4p19s9n6tVAyD0i8aywdYpq4p0+p0RcTy0jGcDm/ n7bQjOcsBbjaDa2ePKaL6pKJpqNpYHhbO1Uv06XKTVmaax5aODsILrxUnYXdrvNvdy 9UKZCN40hQ94VOzF5UdS7TARxoHHgx+FJUNTetMo= Received: from ld50.lan (unknown [101.88.25.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id CF305600A6; Wed, 28 Jun 2023 21:13:17 +0800 (CST) From: WANG Xuerui To: binutils@sourceware.org Cc: Chenghua Xu , Zhensong Liu , Qinggang Meng , Lulu Cheng , Fangrui Song , Xi Ruoyao , WANG Xuerui Subject: [PATCH v2] LoongArch: Deprecate $v[01], $fv[01] and $x names per spec Date: Wed, 28 Jun 2023 21:13:11 +0800 Message-Id: <20230628131311.3895731-1-i.swmail@xen0n.name> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769952260457341069?= X-GMAIL-MSGID: =?utf-8?q?1769952260457341069?= From: WANG Xuerui As outlined in the LoongArch ELF psABI spec [1], it is actually already 2 versions after the initial LoongArch support, and the $v[01] and $fv[01] names should really get sunset by now. In addition, the "$x" name for $r21 was never included in any released version of the ABI spec, and such usages are all fixed to say just $r21 for every project I could think of that accepted a LoongArch port. Plus, the upcoming LASX support makes use of registers named "$xrNN", so having "$x" alongside would potentially create confusion for developers. Issue warnings for such usages per the deprecation procedure detailed in the spec, so we can finally remove support in the next release cycle after this. [1]: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html --- v2: - Rebased (I can't even remember v1 was when) - Also deprecate $x (LASX will soon bring about $xrNN) - Improve diagnostics Hopefully this will make 2.41, to finally transition us away from old 2020 cruft... gas/config/tc-loongarch.c | 42 ++++++++++++++++--- .../gas/loongarch/deprecated_reg_aliases.d | 17 ++++++++ .../gas/loongarch/deprecated_reg_aliases.l | 7 ++++ .../gas/loongarch/deprecated_reg_aliases.s | 5 +++ include/opcode/loongarch.h | 4 +- opcodes/loongarch-opc.c | 8 ++-- 6 files changed, 72 insertions(+), 11 deletions(-) create mode 100644 gas/testsuite/gas/loongarch/deprecated_reg_aliases.d create mode 100644 gas/testsuite/gas/loongarch/deprecated_reg_aliases.l create mode 100644 gas/testsuite/gas/loongarch/deprecated_reg_aliases.s diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c index d1c5ce287e4..5d6d6679120 100644 --- a/gas/config/tc-loongarch.c +++ b/gas/config/tc-loongarch.c @@ -221,8 +221,12 @@ md_parse_option (int c, const char *arg) return ret; } +static const char *const *r_abi_names = NULL; +static const char *const *f_abi_names = NULL; static struct htab *r_htab = NULL; +static struct htab *r_deprecated_htab = NULL; static struct htab *f_htab = NULL; +static struct htab *f_deprecated_htab = NULL; static struct htab *c_htab = NULL; static struct htab *cr_htab = NULL; static struct htab *v_htab = NULL; @@ -266,7 +270,11 @@ loongarch_after_parse_args () /* Init ilp32/lp64 registers names. */ if (!r_htab) r_htab = str_htab_create (), str_hash_insert (r_htab, "", 0, 0); + if (!r_deprecated_htab) + r_deprecated_htab = str_htab_create (), + str_hash_insert (r_deprecated_htab, "", 0, 0); + r_abi_names = loongarch_r_normal_name; for (i = 0; i < ARRAY_SIZE (loongarch_r_normal_name); i++) str_hash_insert (r_htab, loongarch_r_normal_name[i], (void *) (i + 1), 0); @@ -281,7 +289,11 @@ loongarch_after_parse_args () { if (!f_htab) f_htab = str_htab_create (), str_hash_insert (f_htab, "", 0, 0); + if (!f_deprecated_htab) + f_deprecated_htab = str_htab_create (), + str_hash_insert (f_deprecated_htab, "", 0, 0); + f_abi_names = loongarch_f_normal_name; for (i = 0; i < ARRAY_SIZE (loongarch_f_normal_name); i++) str_hash_insert (f_htab, loongarch_f_normal_name[i], (void *) (i + 1), 0); @@ -318,22 +330,24 @@ loongarch_after_parse_args () /* Init lp64 registers alias. */ if (LARCH_opts.ase_lp64) { + r_abi_names = loongarch_r_lp64_name; for (i = 0; i < ARRAY_SIZE (loongarch_r_lp64_name); i++) str_hash_insert (r_htab, loongarch_r_lp64_name[i], (void *) (i + 1), 0); - for (i = 0; i < ARRAY_SIZE (loongarch_r_lp64_name1); i++) - str_hash_insert (r_htab, loongarch_r_lp64_name1[i], (void *) (i + 1), - 0); + for (i = 0; i < ARRAY_SIZE (loongarch_r_lp64_name_deprecated); i++) + str_hash_insert (r_deprecated_htab, loongarch_r_lp64_name_deprecated[i], + (void *) (i + 1), 0); } /* Init float-lp64 registers alias */ if ((LARCH_opts.ase_sf || LARCH_opts.ase_df) && LARCH_opts.ase_lp64) { + f_abi_names = loongarch_f_lp64_name; for (i = 0; i < ARRAY_SIZE (loongarch_f_lp64_name); i++) str_hash_insert (f_htab, loongarch_f_lp64_name[i], (void *) (i + 1), 0); - for (i = 0; i < ARRAY_SIZE (loongarch_f_lp64_name1); i++) - str_hash_insert (f_htab, loongarch_f_lp64_name1[i], + for (i = 0; i < ARRAY_SIZE (loongarch_f_lp64_name_deprecated); i++) + str_hash_insert (f_deprecated_htab, loongarch_f_lp64_name_deprecated[i], (void *) (i + 1), 0); } } @@ -664,11 +678,29 @@ loongarch_args_parser_can_match_arg_helper (char esc_ch1, char esc_ch2, imm = (intptr_t) str_hash_find (r_htab, arg); ip->match_now = 0 < imm; ret = imm - 1; + if (ip->match_now) + break; + /* Handle potential usage of deprecated register aliases. */ + imm = (intptr_t) str_hash_find (r_deprecated_htab, arg); + ip->match_now = 0 < imm; + ret = imm - 1; + if (ip->match_now && !ip->macro_id) + as_warn (_("register alias %s is deprecated, use %s instead"), + arg, r_abi_names[ret]); break; case 'f': imm = (intptr_t) str_hash_find (f_htab, arg); ip->match_now = 0 < imm; ret = imm - 1; + if (ip->match_now && !ip->macro_id) + break; + /* Handle potential usage of deprecated register aliases. */ + imm = (intptr_t) str_hash_find (f_deprecated_htab, arg); + ip->match_now = 0 < imm; + ret = imm - 1; + if (ip->match_now) + as_warn (_("register alias %s is deprecated, use %s instead"), + arg, f_abi_names[ret]); break; case 'c': switch (esc_ch2) diff --git a/gas/testsuite/gas/loongarch/deprecated_reg_aliases.d b/gas/testsuite/gas/loongarch/deprecated_reg_aliases.d new file mode 100644 index 00000000000..c2cb6f85ee5 --- /dev/null +++ b/gas/testsuite/gas/loongarch/deprecated_reg_aliases.d @@ -0,0 +1,17 @@ +#name: Deprecated register aliases +#as-new: +#objdump: -d +#warning_output: deprecated_reg_aliases.l + +.*:[ ]+file format .* + + +Disassembly of section .text: + +0000000000000000 : +[ ]+0:[ ]+14acf125[ ]+lu12i\.w[ ]+\$a1, 354185\(0x56789\) +[ ]+4:[ ]+038048a5[ ]+ori[ ]+\$a1, \$a1, 0x12 +[ ]+8:[ ]+16024685[ ]+lu32i\.d[ ]+\$a1, 4660\(0x1234\) +[ ]+c:[ ]+08200420[ ]+fmadd\.d[ ]+\$fa0, \$fa1, \$fa1, \$fa0 +[ ]+10:[ ]+380c16a4[ ]+ldx\.d[ ]+\$a0, \$r21, \$a1 +[ ]+14:[ ]+4c000020[ ]+jirl[ ]+\$zero, \$ra, 0 diff --git a/gas/testsuite/gas/loongarch/deprecated_reg_aliases.l b/gas/testsuite/gas/loongarch/deprecated_reg_aliases.l new file mode 100644 index 00000000000..b82c209e541 --- /dev/null +++ b/gas/testsuite/gas/loongarch/deprecated_reg_aliases.l @@ -0,0 +1,7 @@ +.*Assembler messages: +.*:2: Warning: register alias \$v1 is deprecated, use \$a1 instead +.*:3: Warning: register alias \$fv0 is deprecated, use \$fa0 instead +.*:3: Warning: register alias \$fv1 is deprecated, use \$fa1 instead +.*:3: Warning: register alias \$fv1 is deprecated, use \$fa1 instead +.*:4: Warning: register alias \$v0 is deprecated, use \$a0 instead +.*:4: Warning: register alias \$x is deprecated, use \$r21 instead diff --git a/gas/testsuite/gas/loongarch/deprecated_reg_aliases.s b/gas/testsuite/gas/loongarch/deprecated_reg_aliases.s new file mode 100644 index 00000000000..7848346e6ae --- /dev/null +++ b/gas/testsuite/gas/loongarch/deprecated_reg_aliases.s @@ -0,0 +1,5 @@ +foo: + li.d $v1, 0x123456789012 + fmadd.d $fv0, $fv1, $fv1, $fa0 + ldx.d $v0, $x, $a1 + ret diff --git a/include/opcode/loongarch.h b/include/opcode/loongarch.h index 004bb6561ef..de62b1693a0 100644 --- a/include/opcode/loongarch.h +++ b/include/opcode/loongarch.h @@ -181,10 +181,10 @@ dec2 : [1-9][0-9]? extern const char *const loongarch_r_normal_name[32]; extern const char *const loongarch_r_lp64_name[32]; - extern const char *const loongarch_r_lp64_name1[32]; + extern const char *const loongarch_r_lp64_name_deprecated[32]; extern const char *const loongarch_f_normal_name[32]; extern const char *const loongarch_f_lp64_name[32]; - extern const char *const loongarch_f_lp64_name1[32]; + extern const char *const loongarch_f_lp64_name_deprecated[32]; extern const char *const loongarch_c_normal_name[8]; extern const char *const loongarch_cr_normal_name[4]; extern const char *const loongarch_v_normal_name[32]; diff --git a/opcodes/loongarch-opc.c b/opcodes/loongarch-opc.c index 573b691c1fd..e3dbe1c1c10 100644 --- a/opcodes/loongarch-opc.c +++ b/opcodes/loongarch-opc.c @@ -45,14 +45,14 @@ const char *const loongarch_r_lp64_name[32] = { "$zero", "$ra", "$tp", "$sp", "$a0", "$a1", "$a2", "$a3", "$a4", "$a5", "$a6", "$a7", "$t0", "$t1", "$t2", "$t3", - "$t4", "$t5", "$t6", "$t7", "$t8", "$x", "$fp", "$s0", + "$t4", "$t5", "$t6", "$t7", "$t8", "$r21","$fp", "$s0", "$s1", "$s2", "$s3", "$s4", "$s5", "$s6", "$s7", "$s8", }; -const char *const loongarch_r_lp64_name1[32] = +const char *const loongarch_r_lp64_name_deprecated[32] = { "", "", "", "", "$v0", "$v1", "", "", "", "", "", "", "", "", "", "", - "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "$x", "", "", "", "", "", "", "", "", "", "", }; const char *const loongarch_f_normal_name[32] = @@ -71,7 +71,7 @@ const char *const loongarch_f_lp64_name[32] = "$fs0", "$fs1", "$fs2", "$fs3", "$fs4", "$fs5", "$fs6", "$fs7", }; -const char *const loongarch_f_lp64_name1[32] = +const char *const loongarch_f_lp64_name_deprecated[32] = { "$fv0", "$fv1", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",