This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH, i386]: Use ARRAY_SIZE some more
- From: Uros Bizjak <ubizjak at gmail dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 07 Jan 2009 19:26:21 +0100
- Subject: [PATCH, i386]: Use ARRAY_SIZE some more
Hello!
This patch was just too tempting to resist.
2009-01-07 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.c (ix86_target_string): Use ARRAY_SIZE.
(ix86_target_string): Ditto.
(ix86_valid_target_attribute_inner_p): Ditto.
Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu
{,-m32}, committed to mainline.
Uros.
Index: i386.c
===================================================================
--- i386.c (revision 143163)
+++ i386.c (working copy)
@@ -2306,9 +2306,7 @@ ix86_target_string (int isa, int flags,
{ "-mtls-direct-seg-refs", MASK_TLS_DIRECT_SEG_REFS },
};
- const char *opts[ (sizeof (isa_opts) / sizeof (isa_opts[0])
- + sizeof (flag_opts) / sizeof (flag_opts[0])
- + 6)][2];
+ const char *opts[ARRAY_SIZE (isa_opts) + ARRAY_SIZE (flag_opts) + 6][2];
char isa_other[40];
char target_other[40];
@@ -2337,7 +2335,7 @@ ix86_target_string (int isa, int flags,
}
/* Pick out the options in isa options. */
- for (i = 0; i < sizeof (isa_opts) / sizeof (isa_opts[0]); i++)
+ for (i = 0; i < ARRAY_SIZE (isa_opts); i++)
{
if ((isa & isa_opts[i].mask) != 0)
{
@@ -2353,7 +2351,7 @@ ix86_target_string (int isa, int flags,
}
/* Add flag options. */
- for (i = 0; i < sizeof (flag_opts) / sizeof (flag_opts[0]); i++)
+ for (i = 0; i < ARRAY_SIZE (flag_opts); i++)
{
if ((flags & flag_opts[i].mask) != 0)
{
@@ -2379,7 +2377,7 @@ ix86_target_string (int isa, int flags,
if (num == 0)
return NULL;
- gcc_assert (num < sizeof (opts) / sizeof (opts[0]));
+ gcc_assert (num < ARRAY_SIZE (opts));
/* Size the string. */
len = 0;
@@ -3526,7 +3524,7 @@ ix86_valid_target_attribute_inner_p (tre
/* Find the option. */
ch = *p;
opt = N_OPTS;
- for (i = 0; i < sizeof (attrs) / sizeof (attrs[0]); i++)
+ for (i = 0; i < ARRAY_SIZE (attrs); i++)
{
type = attrs[i].type;
opt_len = attrs[i].len;