* mips-tdep.c: General cleanup. Delete all #if 0 code. Convert
[deliverable/binutils-gdb.git] / gas / expr.c
index fcc633fbd1733a0378a263b5508dd23927220fba..fe2aa6204e1f8bedd6cea489b551068bbf37ea8b 100644 (file)
@@ -1,5 +1,5 @@
 /* expr.c -operands, expressions-
-   Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
+   Copyright (C) 1987, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
    Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
@@ -327,7 +327,7 @@ integer_constant (radix, expressionP)
 #define valuesize 32
 #endif
 
-  if (flag_m68k_mri && radix == 0)
+  if ((NUMBERS_WITH_SUFFIX || flag_m68k_mri) && radix == 0)
     {
       int flt = 0;
 
@@ -541,7 +541,9 @@ integer_constant (radix, expressionP)
        }
     }
 
-  if (flag_m68k_mri && suffix != NULL && input_line_pointer - 1 == suffix)
+  if ((NUMBERS_WITH_SUFFIX || flag_m68k_mri)
+      && suffix != NULL
+      && input_line_pointer - 1 == suffix)
     c = *input_line_pointer++;
 
   if (small)
@@ -797,6 +799,9 @@ operand (expressionP)
   SKIP_WHITESPACE ();          /* leading whitespace is part of operand. */
   c = *input_line_pointer++;   /* input_line_pointer->past char in c. */
 
+  if (is_end_of_line[(unsigned char) c])
+    goto eol;
+
   switch (c)
     {
     case '1':
@@ -810,13 +815,21 @@ operand (expressionP)
     case '9':
       input_line_pointer--;
 
-      integer_constant (flag_m68k_mri ? 0 : 10, expressionP);
+      integer_constant ((NUMBERS_WITH_SUFFIX || flag_m68k_mri)
+                        ? 0 : 10,
+                        expressionP);
+      break;
+
+#ifdef LITERAL_PREFIXDOLLAR_HEX
+    case '$':
+      integer_constant (16, expressionP);
       break;
+#endif
 
     case '0':
       /* non-decimal radix */
 
-      if (flag_m68k_mri)
+      if (NUMBERS_WITH_SUFFIX || flag_m68k_mri)
        {
          char *s;
 
@@ -829,8 +842,7 @@ operand (expressionP)
              integer_constant (0, expressionP);
              break;
            }
-       }
-
+        }
       c = *input_line_pointer;
       switch (c)
        {
@@ -840,7 +852,7 @@ operand (expressionP)
        case 'Q':
        case '8':
        case '9':
-         if (flag_m68k_mri)
+         if (NUMBERS_WITH_SUFFIX || flag_m68k_mri)
            {
              integer_constant (0, expressionP);
              break;
@@ -873,7 +885,7 @@ operand (expressionP)
          break;
 
        case 'b':
-         if (LOCAL_LABELS_FB && ! flag_m68k_mri)
+         if (LOCAL_LABELS_FB && ! (flag_m68k_mri || NUMBERS_WITH_SUFFIX))
            {
              /* This code used to check for '+' and '-' here, and, in
                 some conditions, fall through to call
@@ -895,7 +907,7 @@ operand (expressionP)
          /* Fall through.  */
        case 'B':
          input_line_pointer++;
-         if (flag_m68k_mri)
+         if (flag_m68k_mri || NUMBERS_WITH_SUFFIX)
            goto default_case;
          integer_constant (2, expressionP);
          break;
@@ -908,7 +920,9 @@ operand (expressionP)
        case '5':
        case '6':
        case '7':
-         integer_constant (flag_m68k_mri ? 0 : 8, expressionP);
+         integer_constant ((flag_m68k_mri || NUMBERS_WITH_SUFFIX)
+                            ? 0 : 8, 
+                            expressionP);
          break;
 
        case 'f':
@@ -918,7 +932,8 @@ operand (expressionP)
                 number, make it one.  Otherwise, make it a local label,
                 and try to deal with parsing the rest later.  */
              if (!input_line_pointer[1]
-                 || (is_end_of_line[0xff & input_line_pointer[1]]))
+                 || (is_end_of_line[0xff & input_line_pointer[1]])
+                 || strchr (FLT_CHARS, 'f') == NULL)
                goto is_0f_label;
              {
                char *cp = input_line_pointer + 1;
@@ -958,7 +973,7 @@ operand (expressionP)
 
        case 'd':
        case 'D':
-         if (flag_m68k_mri)
+         if (flag_m68k_mri || NUMBERS_WITH_SUFFIX)
            {
              integer_constant (0, expressionP);
              break;
@@ -995,16 +1010,21 @@ operand (expressionP)
       /* didn't begin with digit & not a name */
       segment = expression (expressionP);
       /* Expression() will pass trailing whitespace */
-      if ((c == '(' && *input_line_pointer++ != ')')
-         || (c == '[' && *input_line_pointer++ != ']'))
+      if ((c == '(' && *input_line_pointer != ')')
+         || (c == '[' && *input_line_pointer != ']'))
        {
-         as_bad (_("Missing ')' assumed"));
-         input_line_pointer--;
+#ifdef RELAX_PAREN_GROUPING
+         if (c != '(')
+#endif
+           as_bad (_("Missing '%c' assumed"), c == '(' ? ')' : ']');
        }
+      else
+        input_line_pointer++;
       SKIP_WHITESPACE ();
       /* here with input_line_pointer->char after "(...)" */
       return segment;
 
+#ifdef TC_M68K
     case 'E':
       if (! flag_m68k_mri || *input_line_pointer != '\'')
        goto de_fault;
@@ -1015,6 +1035,7 @@ operand (expressionP)
        goto de_fault;
       ++input_line_pointer;
       /* Fall through.  */
+#endif
     case '\'':
       if (! flag_m68k_mri)
        {
@@ -1034,11 +1055,13 @@ operand (expressionP)
       (void) operand (expressionP);
       break;
 
+#ifdef TC_M68K
     case '"':
       /* Double quote is the bitwise not operator in MRI mode.  */
       if (! flag_m68k_mri)
        goto de_fault;
       /* Fall through.  */
+#endif
     case '~':
       /* ~ is permitted to start a label on the Delta.  */
       if (is_name_beginner (c))
@@ -1080,6 +1103,7 @@ operand (expressionP)
       }
       break;
 
+#if defined (DOLLAR_DOT) || defined (TC_M68K)
     case '$':
       /* $ is the program counter when in MRI mode, or when DOLLAR_DOT
          is defined.  */
@@ -1100,6 +1124,7 @@ operand (expressionP)
 
       current_location (expressionP);
       break;
+#endif
 
     case '.':
       if (!is_part_of_name (*input_line_pointer))
@@ -1154,15 +1179,15 @@ operand (expressionP)
        {
          goto isname;
        }
+
     case ',':
-    case '\n':
-    case '\0':
     eol:
       /* can't imagine any other kind of operand */
       expressionP->X_op = O_absent;
       input_line_pointer--;
       break;
 
+#ifdef TC_M68K
     case '%':
       if (! flag_m68k_mri)
        goto de_fault;
@@ -1192,11 +1217,12 @@ operand (expressionP)
 
       current_location (expressionP);
       break;
+#endif
 
     default:
+#ifdef TC_M68K
     de_fault:
-      if (is_end_of_line[(unsigned char) c])
-       goto eol;
+#endif
       if (is_name_beginner (c))        /* here if did not begin with a digit */
        {
          /*
@@ -1484,6 +1510,22 @@ static operator_rankT op_rank[] =
   3,   /* O_logical_and */
   2,   /* O_logical_or */
   1,   /* O_index */
+  0,   /* O_md1 */
+  0,   /* O_md2 */
+  0,   /* O_md3 */
+  0,   /* O_md4 */
+  0,   /* O_md5 */
+  0,   /* O_md6 */
+  0,   /* O_md7 */
+  0,   /* O_md8 */
+  0,   /* O_md9 */
+  0,   /* O_md10 */
+  0,   /* O_md11 */
+  0,   /* O_md12 */
+  0,   /* O_md13 */
+  0,   /* O_md14 */
+  0,   /* O_md15 */
+  0,   /* O_md16 */
 };
 
 /* Unfortunately, in MRI mode for the m68k, multiplication and
@@ -1539,6 +1581,9 @@ operator ()
 
   c = *input_line_pointer & 0xff;
 
+  if (is_end_of_line[c])
+    return O_illegal;
+
   switch (c)
     {
     default:
@@ -1616,10 +1661,11 @@ operator ()
 /* Parse an expression.  */
 
 segT
-expr (rank, resultP)
-     operator_rankT rank;      /* Larger # is higher rank. */
+expr (rankarg, resultP)
+     int rankarg;      /* Larger # is higher rank. */
      expressionS *resultP;     /* Deliver result here. */
 {
+  operator_rankT rank = (operator_rankT) rankarg;
   segT retval;
   expressionS right;
   operatorT op_left;
@@ -1711,6 +1757,13 @@ expr (rank, resultP)
        }
 
       /* Optimize common cases.  */
+#ifdef md_optimize_expr
+      if (md_optimize_expr (resultP, op_left, &right))
+       {
+         /* skip */;
+       }
+      else
+#endif
       if (op_left == O_add && right.X_op == O_constant)
        {
          /* X + constant.  */
This page took 0.027189 seconds and 4 git commands to generate.