This patch uses the new gensupport feature (review pending) that allows to provide a block of C++ code in a symbol_ref sub-expression instead of just a C++ expression:
https://gcc.gnu.org/pipermail/gcc-patches/2024-September/664093.html Ok for trunk (provided the gensupport part is upstream) ? Johann -- AVR: Use (symbol_ref { code }) in attribute "length" computation. The symbol_ref sub-expression of an insn attribute may host the body of a C++ function provided (symbol_ref { code }) is used. gcc/ * config/avr/avr-protos.h (avr_len_op8_set_ZN): Remove. * config/avr/avr.cc (avr_len_op8_set_ZN): Remove. * config/avr/avr.md (*op8.for.cczn.<code>): Compute attribute "length" with the help of a symbol_ref that hosts the body of a C++ function.
diff --git a/gcc/config/avr/avr-protos.h b/gcc/config/avr/avr-protos.h index 96708eb4db5..71514a37812 100644 --- a/gcc/config/avr/avr-protos.h +++ b/gcc/config/avr/avr-protos.h @@ -64,7 +64,6 @@ extern const char *avr_out_extr_not (rtx_insn *, rtx*, int*); extern const char *avr_out_plus_set_ZN (rtx*, int*); extern const char *avr_out_plus_set_N (rtx*, int*); extern const char *avr_out_op8_set_ZN (rtx_code, rtx*, int*); -extern int avr_len_op8_set_ZN (rtx_code, rtx*); extern bool avr_op8_ZN_operator (rtx); extern const char *avr_out_cmp_ext (rtx*, rtx_code, int*); diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc index c0bf1320fdd..bbc9b278511 100644 --- a/gcc/config/avr/avr.cc +++ b/gcc/config/avr/avr.cc @@ -8958,18 +8958,6 @@ avr_out_op8_set_ZN (rtx_code code, rtx *xop, int *plen) } -/* Used in the "length" attribute of insn "*op8.for.cczn.<code>". */ - -int -avr_len_op8_set_ZN (rtx_code code, rtx *xop) -{ - int len; - (void) avr_out_op8_set_ZN (code, xop, &len); - - return len; -} - - /* Output bit operation (IOR, AND, XOR) with register XOP[0] and compile time constant XOP[2]: diff --git a/gcc/config/avr/avr.md b/gcc/config/avr/avr.md index aae8a696a63..84023866b30 100644 --- a/gcc/config/avr/avr.md +++ b/gcc/config/avr/avr.md @@ -7337,7 +7337,12 @@ (define_insn "*op8.for.cczn.<code>" return avr_out_op8_set_ZN (<CODE>, operands, nullptr); } [(set (attr "length") - (symbol_ref "avr_len_op8_set_ZN (<CODE>, operands)"))]) + (symbol_ref + { + int len; + avr_out_op8_set_ZN (<CODE>, operands, &len); + return len; + }))]) ;; Test a single bit in a QI/HI/SImode register.