Blame SOURCES/gdb-rhbz1420304-s390x-04of35.patch

e1d87d
commit a09f2586017aeed82fa07c8bfea6c75859295bd9
e1d87d
Author: Andreas Krebbel <krebbel@linux.vnet.ibm.com>
e1d87d
Date:   Mon May 29 12:34:56 2017 +0200
e1d87d
e1d87d
    S/390: Improve error checking for optional operands
e1d87d
    
e1d87d
    So far we only had an instruction flag which made an arbitrary number
e1d87d
    of operands optional.  This limits error checking capabilities for
e1d87d
    instructions marked that way.  With this patch the optparm flag only
e1d87d
    allows a single optional parameter and another one is added (optparm2)
e1d87d
    allowing 2 optional arguments.  Hopefully we won't need more than that
e1d87d
    in the future. So far there will be only a single use of optparm2.
e1d87d
    
e1d87d
    gas/ChangeLog:
e1d87d
    
e1d87d
    2017-05-30  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
e1d87d
    
e1d87d
            * config/tc-s390.c (md_gather_operands): Support new optparm2
e1d87d
            instruction flag.
e1d87d
    
e1d87d
    include/ChangeLog:
e1d87d
    
e1d87d
    2017-05-30  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
e1d87d
    
e1d87d
            * opcode/s390.h: Add new instruction flags optparm2.
e1d87d
    
e1d87d
    opcodes/ChangeLog:
e1d87d
    
e1d87d
    2017-05-30  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
e1d87d
    
e1d87d
            * s390-dis.c (s390_print_insn_with_opcode): Support new optparm2
e1d87d
            instruction flag.
e1d87d
            * s390-mkopc.c (main): Recognize the new instruction flag when
e1d87d
            parsing instruction list.
e1d87d
e1d87d
--- a/include/opcode/s390.h
e1d87d
+++ b/include/opcode/s390.h
e1d87d
@@ -48,10 +48,11 @@ enum s390_opcode_cpu_val
e1d87d
 
e1d87d
 /* Instruction specific flags.  */
e1d87d
 #define S390_INSTR_FLAG_OPTPARM 0x1
e1d87d
+#define S390_INSTR_FLAG_OPTPARM2 0x2
e1d87d
 
e1d87d
-#define S390_INSTR_FLAG_HTM 0x2
e1d87d
-#define S390_INSTR_FLAG_VX 0x4
e1d87d
-#define S390_INSTR_FLAG_FACILITY_MASK 0x6
e1d87d
+#define S390_INSTR_FLAG_HTM 0x4
e1d87d
+#define S390_INSTR_FLAG_VX 0x8
e1d87d
+#define S390_INSTR_FLAG_FACILITY_MASK 0xc
e1d87d
 
e1d87d
 /* The opcode table is an array of struct s390_opcode.  */
e1d87d
 
e1d87d
--- a/opcodes/s390-dis.c
e1d87d
+++ b/opcodes/s390-dis.c
e1d87d
@@ -206,11 +206,20 @@ s390_print_insn_with_opcode (bfd_vma memaddr,
e1d87d
 
e1d87d
       /* For instructions with a last optional operand don't print it
e1d87d
 	 if zero.  */
e1d87d
-      if ((opcode->flags & S390_INSTR_FLAG_OPTPARM)
e1d87d
+      if ((opcode->flags & (S390_INSTR_FLAG_OPTPARM | S390_INSTR_FLAG_OPTPARM2))
e1d87d
 	  && val.u == 0
e1d87d
 	  && opindex[1] == 0)
e1d87d
 	break;
e1d87d
 
e1d87d
+      if ((opcode->flags & S390_INSTR_FLAG_OPTPARM2)
e1d87d
+	  && val.u == 0 && opindex[1] != 0 && opindex[2] == 0)
e1d87d
+	{
e1d87d
+	  union operand_value next_op_val =
e1d87d
+	    s390_extract_operand (buffer, s390_operands + opindex[1]);
e1d87d
+	  if (next_op_val.u == 0)
e1d87d
+	    break;
e1d87d
+	}
e1d87d
+
e1d87d
       if (flags & S390_OPERAND_GPR)
e1d87d
 	info->fprintf_func (info->stream, "%c%%r%u", separator, val.u);
e1d87d
       else if (flags & S390_OPERAND_FPR)
e1d87d
--- a/opcodes/s390-mkopc.c
e1d87d
+++ b/opcodes/s390-mkopc.c
e1d87d
@@ -411,12 +411,16 @@ main (void)
e1d87d
 		&& (str[7] == 0 || str[7] == ',')) {
e1d87d
 	      flag_bits |= S390_INSTR_FLAG_OPTPARM;
e1d87d
 	      str += 7;
e1d87d
+	    } else if (strncmp (str, "optparm2", 8) == 0
e1d87d
+		       && (str[8] == 0 || str[8] == ',')) {
e1d87d
+	      flag_bits |= S390_INSTR_FLAG_OPTPARM2;
e1d87d
+	      str += 8;
e1d87d
 	    } else if (strncmp (str, "htm", 3) == 0
e1d87d
-		&& (str[3] == 0 || str[3] == ',')) {
e1d87d
+		       && (str[3] == 0 || str[3] == ',')) {
e1d87d
 	      flag_bits |= S390_INSTR_FLAG_HTM;
e1d87d
 	      str += 3;
e1d87d
 	    } else if (strncmp (str, "vx", 2) == 0
e1d87d
-		&& (str[2] == 0 || str[2] == ',')) {
e1d87d
+		       && (str[2] == 0 || str[2] == ',')) {
e1d87d
 	      flag_bits |= S390_INSTR_FLAG_VX;
e1d87d
 	      str += 2;
e1d87d
 	    } else {