This probably counts as obvious; still I will leave it for a couple of days and commit both patches unless someone objects.
On Tue, Sep 08, 2026 at 09:29:33AM +0200, Stefan Schulze Frielinghaus wrote: > From: Stefan Schulze Frielinghaus <[email protected]> > > For the subsequent patch I need the number of mnemonics. Instead of > introducing a new named constant which may potentially clash with a > mnemonic, I went for a new preprocessor definition > ATTR_ENUM_MNEMONIC_COUNT. Though, if there are reasons to choose a > named constant instaed, I'm fine with this, too. > > gcc/ChangeLog: > > * genattr-common.cc (gen_attr): New preprocessor definition > ATTR_ENUM_MNEMONIC_COUNT. > --- > Bootstrapped and regtested on x86_64-linux and s390x-linux. Ok for > mainline? > > gcc/genattr-common.cc | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/gcc/genattr-common.cc b/gcc/genattr-common.cc > index 4d000c81fa9..20138333c0a 100644 > --- a/gcc/genattr-common.cc > +++ b/gcc/genattr-common.cc > @@ -40,6 +40,7 @@ static void > gen_attr (md_rtx_info *info) > { > const char *p, *tag; > + size_t count = 0; > > rtx attr = info->def; > p = XSTR (attr, 1); > @@ -55,8 +56,11 @@ gen_attr (md_rtx_info *info) > putchar (TOUPPER (*tag++)); > if (*p == ',') > fputs (", ", stdout); > + ++count; > } > fputs ("};\n", stdout); > + if (strcmp (XSTR (attr, 0), "mnemonic") == 0) > + printf ("#define ATTR_ENUM_MNEMONIC_COUNT %zu\n", count); > } > } > > -- > 2.55.0 >
