public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nelson Chu <nelson.chu@sifive.com>
To: binutils@sourceware.org, jim.wilson.gcc@gmail.com,
	andrew@sifive.com, craig.topper@sifive.com
Subject: [PATCH] RISC-V: Dump vset[i]vli immediate as numbers once vsew or vlmul is reserved.
Date: Mon, 29 Nov 2021 21:43:14 -0800	[thread overview]
Message-ID: <1638250994-21268-1-git-send-email-nelson.chu@sifive.com> (raw)

Consider the following case,

vsetvli  a0, a1,  0x4           # unrecognized vlmul
vsetvli  a0, a1,  0x20          # unrecognized vsew
vsetivli a0, 0xb, 0x4           # unrecognized vlmul
vsetivli a0, 0xb, 0x20          # unrecognized vsew

For the current dis-assembler, we get the result,

0000000000000000 <.text>:
   0:   0045f557                vsetvli a0,a1,e8,(null),tu,mu
   4:   0205f557                vsetvli a0,a1,e128,m1,tu,mu
   8:   c045f557                vsetivli        a0,11,e8,(null),tu,mu
   c:   c205f557                vsetivli        a0,11,e128,m1,tu,mu

The vsew e128 and vlmul (null) are preserved according to the spec,
so dump these fields looks wrong.  Consider that we are used to dump
the unrecognized csr as csr numbers directly, we should also dump
the whole vset[i]vli immediates as numbers, once the vsew or vlmul
is reserved.  Therefore, following is what I expected,

0000000000000000 <.text>:
   0:   0045f557                vsetvli a0,a1,4
   4:   0205f557                vsetvli a0,a1,32
   8:   c045f557                vsetivli        a0,11,4
   c:   c205f557                vsetivli        a0,11,32

gas/
	* testsuite/gas/riscv/vector-insns.d: Rewrite the vset[i]vli
	testcases since we should dump the immediate as numbers once
	the vsew or vlmul is reserved.
	* testsuite/gas/riscv/vector-insns.s: Likewise.
opcodes/
	* riscv-dis.c (print_insn_args): The reserved vsew and vlmul
	are NULL string in the riscv_vsew and riscv_vlmul, so dump the
	whole imm as numbers once one of them is NULL.
	* riscv-opc.c (riscv_vsew): Set the reserved vsew to NULL.
	(riscv_vlmul): Set the reserved vlmul to NULL.
---
 gas/testsuite/gas/riscv/vector-insns.d | 46 +++++++++----------------------
 gas/testsuite/gas/riscv/vector-insns.s | 50 ++++++++++------------------------
 opcodes/riscv-dis.c                    |  4 ++-
 opcodes/riscv-opc.c                    |  4 +--
 4 files changed, 33 insertions(+), 71 deletions(-)

diff --git a/gas/testsuite/gas/riscv/vector-insns.d b/gas/testsuite/gas/riscv/vector-insns.d
index 711f927..6325c74 100644
--- a/gas/testsuite/gas/riscv/vector-insns.d
+++ b/gas/testsuite/gas/riscv/vector-insns.d
@@ -10,40 +10,20 @@ Disassembly of section .text:
 [ 	]+[0-9a-f]+:[ 	]+80c5f557[ 	]+vsetvl[ 	]+a0,a1,a2
 [ 	]+[0-9a-f]+:[ 	]+0005f557[ 	]+vsetvli[ 	]+a0,a1,e8,m1,tu,mu
 [ 	]+[0-9a-f]+:[ 	]+7ff5f557[ 	]+vsetvli[ 	]+a0,a1,2047
-[ 	]+[0-9a-f]+:[ 	]+0095f557[ 	]+vsetvli[ 	]+a0,a1,e16,m2,tu,mu
-[ 	]+[0-9a-f]+:[ 	]+02b5f557[ 	]+vsetvli[ 	]+a0,a1,e256,m8,tu,mu
-[ 	]+[0-9a-f]+:[ 	]+0335f557[ 	]+vsetvli[ 	]+a0,a1,e512,m8,tu,mu
-[ 	]+[0-9a-f]+:[ 	]+03b5f557[ 	]+vsetvli[ 	]+a0,a1,e1024,m8,tu,mu
-[ 	]+[0-9a-f]+:[ 	]+0385f557[ 	]+vsetvli[ 	]+a0,a1,e1024,m1,tu,mu
-[ 	]+[0-9a-f]+:[ 	]+03f5f557[ 	]+vsetvli[ 	]+a0,a1,e1024,mf2,tu,mu
-[ 	]+[0-9a-f]+:[ 	]+0365f557[ 	]+vsetvli[ 	]+a0,a1,e512,mf4,tu,mu
-[ 	]+[0-9a-f]+:[ 	]+02d5f557[ 	]+vsetvli[ 	]+a0,a1,e256,mf8,tu,mu
-[ 	]+[0-9a-f]+:[ 	]+0695f557[ 	]+vsetvli[ 	]+a0,a1,e256,m2,ta,mu
-[ 	]+[0-9a-f]+:[ 	]+0a95f557[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a-f]+:[ 	]+c015f557[ 	]+vsetivli[ 	]+a0,11,e8,m2,tu,mu
+[ 	]+[0-9a-f]+:[ 	]+c4a5f557[ 	]+vsetivli[ 	]+a0,11,e16,m4,ta,mu
+[ 	]+[0-9a-f]+:[ 	]+c165f557[ 	]+vsetivli[ 	]+a0,11,e32,mf4,tu,mu
+[ 	]+[0-9a-f]+:[ 	]+c9d5f557[ 	]+vsetivli[ 	]+a0,11,e64,mf8,tu,ma
 [ 	]+[0-9a-f]+:[ 	]+02b50207[ 	]+vlm.v[ 	]+v4,\(a0\)
 [ 	]+[0-9a-f]+:[ 	]+02b50207[ 	]+vlm.v[ 	]+v4,\(a0\)
 [ 	]+[0-9a-f]+:[ 	]+02b50207[ 	]+vlm.v[ 	]+v4,\(a0\)
diff --git a/gas/testsuite/gas/riscv/vector-insns.s b/gas/testsuite/gas/riscv/vector-insns.s
index 37b6ba4..8370264 100644
--- a/gas/testsuite/gas/riscv/vector-insns.s
+++ b/gas/testsuite/gas/riscv/vector-insns.s
@@ -1,40 +1,20 @@
-	vsetvl a0, a1, a2
-	vsetvli a0, a1, 0
-	vsetvli a0, a1, 0x7ff
-	vsetvli a0, a1, e16, m2
-	vsetvli a0, a1, e256, m8
-	vsetvli a0, a1, e512, m8
-	vsetvli a0, a1, e1024, m8
-	vsetvli a0, a1, e1024, m1
-	vsetvli a0, a1, e1024, mf2
-	vsetvli a0, a1, e512, mf4
-	vsetvli a0, a1, e256, mf8
-	vsetvli a0, a1, e256, m2, ta
-	vsetvli a0, a1, e256, m2, ma
-	vsetvli a0, a1, e256, m2, tu
-	vsetvli a0, a1, e256, m2, mu
-	vsetvli a0, a1, e256, m2, ta, ma
-	vsetvli a0, a1, e256, m2, tu, ma
-	vsetvli a0, a1, e256, m2, ta, mu
-	vsetvli a0, a1, e256, m2, tu, mu
+	vsetvl   a0, a1,  a2
+	vsetvli  a0, a1,  0
+	vsetvli  a0, a1,  0x7ff
+	vsetvli  a0, a1,  0x4		# unrecognized vlmul
+	vsetvli  a0, a1,  0x20		# unrecognized vsew
+	vsetvli  a0, a1,  e8,  m2
+	vsetvli  a0, a1,  e16, m4, ta
+	vsetvli  a0, a1,  e32, mf4, mu
+	vsetvli  a0, a1,  e64, mf8, tu, ma
 	vsetivli a0, 0xb, 0
 	vsetivli a0, 0xb, 0x3ff
-	vsetivli a0, 0xb, e16, m2
-	vsetivli a0, 0xb, e256, m8
-	vsetivli a0, 0xb, e512, m8
-	vsetivli a0, 0xb, e1024, m8
-	vsetivli a0, 0xb, e1024, m1
-	vsetivli a0, 0xb, e1024, mf2
-	vsetivli a0, 0xb, e512, mf4
-	vsetivli a0, 0xb, e256, mf8
-	vsetivli a0, 0xb, e256, m2, ta
-	vsetivli a0, 0xb, e256, m2, ma
-	vsetivli a0, 0xb, e256, m2, tu
-	vsetivli a0, 0xb, e256, m2, mu
-	vsetivli a0, 0xb, e256, m2, ta, ma
-	vsetivli a0, 0xb, e256, m2, tu, ma
-	vsetivli a0, 0xb, e256, m2, ta, mu
-	vsetivli a0, 0xb, e256, m2, tu, mu
+	vsetivli a0, 0xb, 0x4		# unrecognized vlmul
+	vsetivli a0, 0xb, 0x20		# unrecognized vsew
+	vsetivli a0, 0xb, e8,  m2
+	vsetivli a0, 0xb, e16, m4, ta
+	vsetivli a0, 0xb, e32, mf4, mu
+	vsetivli a0, 0xb, e64, mf8, tu, ma
 
 	vlm.v v4, (a0)
 	vlm.v v4, 0(a0)
diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index 18e498a..a3c8506 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -334,7 +334,9 @@ print_insn_args (const char *oparg, insn_t l, bfd_vma pc, disassemble_info *info
 		    && imm_vlmul < ARRAY_SIZE (riscv_vlmul)
 		    && imm_vta < ARRAY_SIZE (riscv_vta)
 		    && imm_vma < ARRAY_SIZE (riscv_vma)
-		    && !imm_vtype_res)
+		    && !imm_vtype_res
+		    && riscv_vsew[imm_vsew] != NULL
+		    && riscv_vlmul[imm_vlmul] != NULL)
 		  print (info->stream, "%s,%s,%s,%s", riscv_vsew[imm_vsew],
 			 riscv_vlmul[imm_vlmul], riscv_vta[imm_vta],
 			 riscv_vma[imm_vma]);
diff --git a/opcodes/riscv-opc.c b/opcodes/riscv-opc.c
index bad77fb..40037db 100644
--- a/opcodes/riscv-opc.c
+++ b/opcodes/riscv-opc.c
@@ -76,13 +76,13 @@ const char * const riscv_vecm_names_numeric[NVECM] =
 /* The vsetvli vsew constants.  */
 const char * const riscv_vsew[8] =
 {
-  "e8", "e16", "e32", "e64", "e128", "e256", "e512", "e1024"
+  "e8", "e16", "e32", "e64", NULL, NULL, NULL, NULL
 };
 
 /* The vsetvli vlmul constants.  */
 const char * const riscv_vlmul[8] =
 {
-  "m1", "m2", "m4", "m8", 0, "mf8", "mf4", "mf2"
+  "m1", "m2", "m4", "m8", NULL, "mf8", "mf4", "mf2"
 };
 
 /* The vsetvli vta constants.  */
-- 
2.7.4


             reply	other threads:[~2021-11-30  5:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30  5:43 Nelson Chu [this message]
2021-11-30  7:12 ` Andrew Waterman
2021-11-30  7:15   ` Nelson Chu

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=1638250994-21268-1-git-send-email-nelson.chu@sifive.com \
    --to=nelson.chu@sifive.com \
    --cc=andrew@sifive.com \
    --cc=binutils@sourceware.org \
    --cc=craig.topper@sifive.com \
    --cc=jim.wilson.gcc@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).