On 05/10/2011 03:47 PM, Bernd Schmidt wrote: > I've found it useful to use a construct such as the following: > > (define_attr "units64" > "unknown,d,d_addr,l,m,s,dl,ds,dls,ls" > (const_string "unknown")) > > (define_attr "units64p" > "unknown,d,d_addr,l,m,s,dl,ds,dls,ls" > (attr "units64")) > > to define one attribute in terms of another by default, allowing > individual insn patterns to override the definition of "units64p" where > necessary. This patch adds support for this in genattrtab.
Here's a new version, which emits casts to avoid C/C++ warnings when compiled with --enable-werror-always. Bootstrapped on i686-linux, and cross-compilers built for arm and c6x. An i686-linux testrun is in progress. Bernd
* genattrtab.c (evaluate_eq_attr): Allow an attribute to be defined in terms of another. (write_attr_value): Write a cast if necessary. Index: gcc/genattrtab.c =================================================================== --- gcc/genattrtab.c.orig +++ gcc/genattrtab.c @@ -1916,6 +1916,37 @@ evaluate_eq_attr (rtx exp, struct attr_d rtx newexp; int i; + while (GET_CODE (value) == ATTR) + { + struct attr_value *av = NULL; + + attr = find_attr (&XSTR (value, 0), 0); + + if (insn_code_values) + { + struct attr_value_list *iv; + for (iv = insn_code_values[insn_code]; iv; iv = iv->next) + if (iv->attr == attr) + { + av = iv->av; + break; + } + } + else + { + struct insn_ent *ie; + for (av = attr->first_value; av; av = av->next) + for (ie = av->first_insn; ie; ie = ie->next) + if (ie->def->insn_code == insn_code) + goto got_av; + } + if (av) + { + got_av: + value = av->value; + } + } + switch (GET_CODE (value)) { case CONST_STRING: @@ -4119,6 +4150,13 @@ write_attr_value (struct attr_desc *attr case ATTR: { struct attr_desc *attr2 = find_attr (&XSTR (value, 0), 0); + if (attr->enum_name) + printf ("(enum %s)", attr->enum_name); + else if (!attr->is_numeric) + printf ("(enum attr_%s)", attr->name); + else if (!attr2->is_numeric) + printf ("(int)"); + printf ("get_attr_%s (%s)", attr2->name, (attr2->is_const ? "" : "insn")); }