From: Richard Sandiford Date: Wed, 15 Jun 2022 10:12:51 +0000 (+0100) Subject: gen: Allow unspec numbers in .md attributes X-Git-Tag: basepoints/gcc-14~6105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=183a4f3829243b43a28fc70e59129521033b8f8a;p=thirdparty%2Fgcc.git gen: Allow unspec numbers in .md attributes Tamar pointed out that: (unspec:M ... ) didn't work when a value of attribute FOO was defined by define_constant, such as in: (define_int_attribute FOO [(UNSPEC_A "UNSPEC_B") ...]) This is because symbolic constants are substituted during lexing and only apply to bare symbol names, not strings. One option would have been to extend this lexing substitution to define_*_attribute values as well. However, that would replace symbolic names with integer constants in the generated .cc code, making it less readable. This patch goes for the more localised approach of only applying define_constants when we want their integer value. I don't think any changes to the docs are needed. This isn't adding a new feature, it's just making an existing one work in the expected way. gcc/ * read-rtl.cc (find_int): Substitute symbolic constants before converting the string to an integer. --- diff --git a/gcc/read-rtl.cc b/gcc/read-rtl.cc index 798d2485991..62c7895af60 100644 --- a/gcc/read-rtl.cc +++ b/gcc/read-rtl.cc @@ -284,6 +284,12 @@ find_int (const char *name) { HOST_WIDE_INT tmp; + struct md_constant tmp_def; + tmp_def.name = const_cast (name); + auto htab = rtx_reader_ptr->get_md_constants (); + if (auto def = (struct md_constant *) htab_find (htab, &tmp_def)) + name = def->value; + validate_const_int (name); #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT tmp = atoi (name);