This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] PowerPC instruction operand flag validation


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

commit 2eac3da184459607a476ebb5dcebd6e0acf9fefa
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Nov 6 13:23:20 2018 +1030

    PowerPC instruction operand flag validation
    
    This adds another check that might have saved me a little time
    recently if it had been present.
    
    	* config/tc-ppc.c (insn_validate): Check that optional operands
    	are not followed by non-optional operands.

Diff:
---
 gas/ChangeLog       | 5 +++++
 gas/config/tc-ppc.c | 9 +++++++++
 2 files changed, 14 insertions(+)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index ffff821..2773d92 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,8 @@
+2018-11-06  Alan Modra  <amodra@gmail.com>
+
+	* config/tc-ppc.c (insn_validate): Check that optional operands
+	are not followed by non-optional operands.
+
 2018-11-06  Jan Beulich  <jbeulich@suse.com>
 
 	* testsuite/gas/i386/evex-wig.s: Add vpbroadcastd cases.
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index d587a50..694c47a 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -1514,6 +1514,7 @@ insn_validate (const struct powerpc_opcode *op)
   /* The operands must not overlap the opcode or each other.  */
   for (o = op->operands; *o; ++o)
     {
+      bfd_boolean optional = FALSE;
       if (*o >= num_powerpc_operands)
         {
 	  as_bad (_("operand index error for %s"), op->name);
@@ -1538,6 +1539,14 @@ insn_validate (const struct powerpc_opcode *op)
 		}
 	      omask |= mask;
 	    }
+	  if ((operand->flags & PPC_OPERAND_OPTIONAL) != 0)
+	    optional = TRUE;
+	  else if (optional)
+	    {
+	      as_bad (_("non-optional operand %d follows optional operand in %s"),
+		      (int) (o - op->operands), op->name);
+	      return TRUE;
+	    }
         }
     }
   return FALSE;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]