aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoffrey Keating <geoffk@apple.com>2004-09-10 19:01:04 +0000
committerGeoffrey Keating <geoffk@gcc.gnu.org>2004-09-10 19:01:04 +0000
commitc383c15f2961771877e363073e38ef371405f0dc (patch)
treed2725cf5eb7f64356f71e827157bd7a30edac841
parent1adaa117728eb44d11776c676448d84b0a5c3111 (diff)
downloadgcc-c383c15f2961771877e363073e38ef371405f0dc.zip
gcc-c383c15f2961771877e363073e38ef371405f0dc.tar.gz
gcc-c383c15f2961771877e363073e38ef371405f0dc.tar.bz2
final.c (output_asm_insn): Use strtoul instead of atoi, save a loop.
* final.c (output_asm_insn): Use strtoul instead of atoi, save a loop. From-SVN: r87316
-rw-r--r--gcc/ChangeLog3
-rw-r--r--gcc/final.c59
2 files changed, 35 insertions, 27 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a0178c3..172adf3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/final.c b/gcc/final.c
index a0fd5b7..39214c3 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -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.