public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] aarch64: Tweak handling of F_STRICT
@ 2022-10-17  9:30 Richard Sandiford
  0 siblings, 0 replies; only message in thread
From: Richard Sandiford @ 2022-10-17  9:30 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=13c0b769e826bc98492714193b5e7b222878bb82

commit 13c0b769e826bc98492714193b5e7b222878bb82
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Fri Sep 30 12:34:59 2022 +0100

    aarch64: Tweak handling of F_STRICT
    
    Current F_STRICT qualifier checking is enforced after the fact
    rather than as part of the match.  This makes it impossible to
    have, e.g.:
    
       QLF2(S_D, S_D)
       QLF2(S_D, NIL)
    
    in the same list.
    
    opcodes/
            * aarch64-opc.c (aarch64_find_best_match): Handle F_STRICT here
            rather than...
            (match_operands_qualifier): ...here.

Diff:
---
 opcodes/aarch64-opc.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/opcodes/aarch64-opc.c b/opcodes/aarch64-opc.c
index 1d4668a3fbd..a2882bdfaba 100644
--- a/opcodes/aarch64-opc.c
+++ b/opcodes/aarch64-opc.c
@@ -958,19 +958,19 @@ aarch64_find_best_match (const aarch64_inst *inst,
 	dump_match_qualifiers (inst->operands, qualifiers);
 #endif
 
-      /* Most opcodes has much fewer patterns in the list.
-	 First NIL qualifier indicates the end in the list.   */
-      if (empty_qualifier_sequence_p (qualifiers))
+      /* The first entry should be taken literally, even if it's an empty
+	 qualifier sequence.  (This matters for strict testing.)  In other
+	 positions an empty sequence acts as a terminator.  */
+      if (i > 0 && empty_qualifier_sequence_p (qualifiers))
 	{
-	  DEBUG_TRACE_IF (i == 0, "SUCCEED: empty qualifier list");
-	  if (i)
-	    found = 0;
+	  found = 0;
 	  break;
 	}
 
       for (j = 0; j < num_opnds && j <= stop_at; ++j, ++qualifiers)
 	{
-	  if (inst->operands[j].qualifier == AARCH64_OPND_QLF_NIL)
+	  if (inst->operands[j].qualifier == AARCH64_OPND_QLF_NIL
+	      && !(inst->opcode->flags & F_STRICT))
 	    {
 	      /* Either the operand does not have qualifier, or the qualifier
 		 for the operand needs to be deduced from the qualifier
@@ -1038,7 +1038,7 @@ aarch64_find_best_match (const aarch64_inst *inst,
 static int
 match_operands_qualifier (aarch64_inst *inst, bool update_p)
 {
-  int i, nops;
+  int i;
   aarch64_opnd_qualifier_seq_t qualifiers;
 
   if (!aarch64_find_best_match (inst, inst->opcode->qualifiers_list, -1,
@@ -1048,15 +1048,6 @@ match_operands_qualifier (aarch64_inst *inst, bool update_p)
       return 0;
     }
 
-  if (inst->opcode->flags & F_STRICT)
-    {
-      /* Require an exact qualifier match, even for NIL qualifiers.  */
-      nops = aarch64_num_of_operands (inst->opcode);
-      for (i = 0; i < nops; ++i)
-	if (inst->operands[i].qualifier != qualifiers[i])
-	  return false;
-    }
-
   /* Update the qualifiers.  */
   if (update_p)
     for (i = 0; i < AARCH64_MAX_OPND_NUM; ++i)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-17  9:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-17  9:30 [binutils-gdb] aarch64: Tweak handling of F_STRICT Richard Sandiford

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).