final.c (output_asm_insn): Use strtoul instead of atoi, save a loop.
authorGeoffrey Keating <geoffk@apple.com>
Fri, 10 Sep 2004 19:01:04 +0000 (19:01 +0000)
committerGeoffrey Keating <geoffk@gcc.gnu.org>
Fri, 10 Sep 2004 19:01:04 +0000 (19:01 +0000)
* final.c (output_asm_insn): Use strtoul instead of atoi, save a
loop.

From-SVN: r87316

gcc/ChangeLog
gcc/final.c

index a0178c3414fb8cab04bdd3f0745ac59fba0d560c..172adf37d86fc857831e4163f4a94abcaa7eac73 100644 (file)
@@ -1,5 +1,8 @@
 2004-09-10  Geoffrey Keating  <geoffk@apple.com>
 
+       * final.c (output_asm_insn): Use strtoul instead of atoi, save a
+       loop.
+
        * config/darwin.c: Include target.h.
        (struct machopic_indirection): Make ptr_name a string.
        (machopic_indirection_hash): Update for ptr_name a string.
index a0fd5b7f2fa3d3f53cf015f112faee311766863d..39214c3a427cc9c930513d6d7d4f118d7e033bea 100644 (file)
@@ -3084,61 +3084,66 @@ output_asm_insn (const char *template, rtx *operands)
        else if (ISALPHA (*p))
          {
            int letter = *p++;
-           c = atoi (p);
-
-           if (! ISDIGIT (*p))
-             output_operand_lossage ("operand number missing after %%-letter");
-           else if (this_is_asm_operands
-                    && (c < 0 || (unsigned int) c >= insn_noperands))
+           unsigned long opnum;
+           char *endptr;
+           
+           opnum = strtoul (p, &endptr, 10);
+
+           if (endptr == p)
+             output_operand_lossage ("operand number missing "
+                                     "after %%-letter");
+           else if (this_is_asm_operands && opnum >= insn_noperands)
              output_operand_lossage ("operand number out of range");
            else if (letter == 'l')
-             output_asm_label (operands[c]);
+             output_asm_label (operands[opnum]);
            else if (letter == 'a')
-             output_address (operands[c]);
+             output_address (operands[opnum]);
            else if (letter == 'c')
              {
-               if (CONSTANT_ADDRESS_P (operands[c]))
-                 output_addr_const (asm_out_file, operands[c]);
+               if (CONSTANT_ADDRESS_P (operands[opnum]))
+                 output_addr_const (asm_out_file, operands[opnum]);
                else
-                 output_operand (operands[c], 'c');
+                 output_operand (operands[opnum], 'c');
              }
            else if (letter == 'n')
              {
-               if (GET_CODE (operands[c]) == CONST_INT)
+               if (GET_CODE (operands[opnum]) == CONST_INT)
                  fprintf (asm_out_file, HOST_WIDE_INT_PRINT_DEC,
-                          - INTVAL (operands[c]));
+                          - INTVAL (operands[opnum]));
                else
                  {
                    putc ('-', asm_out_file);
-                   output_addr_const (asm_out_file, operands[c]);
+                   output_addr_const (asm_out_file, operands[opnum]);
                  }
              }
            else
-             output_operand (operands[c], letter);
+             output_operand (operands[opnum], letter);
 
-           if (!opoutput[c])
+           if (!opoutput[opnum])
              oporder[ops++] = c;
-           opoutput[c] = 1;
+           opoutput[opnum] = 1;
 
-           while (ISDIGIT (c = *p))
-             p++;
+           p = endptr;
+           c = *p;
          }
        /* % followed by a digit outputs an operand the default way.  */
        else if (ISDIGIT (*p))
          {
-           c = atoi (p);
-           if (this_is_asm_operands
-               && (c < 0 || (unsigned int) c >= insn_noperands))
+           unsigned long opnum;
+           char *endptr;
+           
+           opnum = strtoul (p, &endptr, 10);
+           if (this_is_asm_operands && opnum >= insn_noperands)
              output_operand_lossage ("operand number out of range");
            else
-             output_operand (operands[c], 0);
+             output_operand (operands[opnum], 0);
 
-           if (!opoutput[c])
+           if (!opoutput[opnum])
              oporder[ops++] = c;
-           opoutput[c] = 1;
+           opoutput[opnum] = 1;
 
-           while (ISDIGIT (c = *p))
-             p++;
+           p = endptr;
+           c = *p;
          }
        /* % followed by punctuation: output something for that
           punctuation character alone, with no operand.