]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
s390: Simplify parsing of omitted index register operand
authorJens Remus <jremus@linux.ibm.com>
Fri, 29 Nov 2024 14:37:19 +0000 (15:37 +0100)
committerJens Remus <jremus@linux.ibm.com>
Fri, 29 Nov 2024 14:37:19 +0000 (15:37 +0100)
The index register operand X in D(X,B) can optionally be omitted by
coding D(,B) or D(B).  Simplify the parsing logic.

gas/
* config/tc-s390.c (md_gather_operands): Rename
omitted_base_or_index to omitted_index and simplify logic.

Signed-off-by: Jens Remus <jremus@linux.ibm.com>
gas/config/tc-s390.c

index 5d58991088150ae11123979333f11718e4708ec3..5d830c3e9adea5307c147aa59b51fe8b5b7c5df5 100644 (file)
@@ -1424,7 +1424,7 @@ md_gather_operands (char *str,
   expressionS ex;
   elf_suffix_type suffix;
   bfd_reloc_code_real_type reloc;
-  int omitted_base_or_index;
+  int omitted_index;
   int operand_number;
   char *f;
   int fc, i;
@@ -1433,7 +1433,7 @@ md_gather_operands (char *str,
     str++;
 
   /* Gather the operands.  */
-  omitted_base_or_index = 0;   /* Whether B in D(L,B) or X in D(X,B) were omitted.  */
+  omitted_index = 0;           /* Whether X in D(X,B) was omitted.  */
   operand_number = 1;          /* Current operand number in e.g. R1,I2,M3,D4(B4).  */
   fc = 0;
   for (opindex_ptr = opcode->operands; *opindex_ptr != 0; opindex_ptr++)
@@ -1450,13 +1450,13 @@ md_gather_operands (char *str,
          break;
        }
 
-      if (omitted_base_or_index && (operand->flags & S390_OPERAND_INDEX))
+      if (omitted_index && (operand->flags & S390_OPERAND_INDEX))
        {
          /* Skip omitted optional index register operand in D(X,B) due to
             D(,B) or D(B). Skip comma, if D(,B).  */
          if (*str == ',')
            str++;
-         omitted_base_or_index = 0;
+         omitted_index = 0;
          continue;
        }
 
@@ -1720,17 +1720,9 @@ md_gather_operands (char *str,
                  break;
              /* If there is no comma until the closing parenthesis ')' or
                 there is a comma right after the opening parenthesis '(',
-                we have to skip the omitted optional index or base register
-                operand:
-                - Index X in D(X,B), when D(,B) or D(B)
-                - Base B in D(L,B), when D(L)  */
-             if (*f == ',' && f == str)
-               {
-                 /* Comma directly after opening parenthesis '(' ? */
-                 omitted_base_or_index = 1;
-               }
-             else
-               omitted_base_or_index = (*f != ',');
+                we have to skip an omitted optional index register
+                operand X in D(X,B), when D(,B) or D(B).  */
+             omitted_index = ((*f == ',' && f == str) || (*f == ')'));
            }
        }
       else if (operand->flags & S390_OPERAND_BASE)
@@ -1741,7 +1733,7 @@ md_gather_operands (char *str,
                    operand_number);
          else
            str++;
-         omitted_base_or_index = 0;
+         omitted_index = 0;
 
          /* If there is no further input and the remaining operands are
             optional then have these optional operands processed.  */