This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFA: autoincrement patches for gcc 4 - updated patch
- From: Ian Lance Taylor <iant at google dot com>
- To: Joern RENNECKE <joern dot rennecke at st dot com>
- Cc: Richard Henderson <rth at redhat dot com>, gcc-patches at gcc dot gnu dot org, Bernd Schmidt <bernd dot schmidt at analog dot com>
- Date: 14 Jul 2006 08:40:25 -0700
- Subject: Re: RFA: autoincrement patches for gcc 4 - updated patch
- References: <421F4698.1050809@st.com> <427136AB.50004@st.com> <20050517025434.GB31389@redhat.com> <428A22F3.4030602@st.com> <20050517171501.GA859@redhat.com> <428A41B3.6050104@st.com> <428B1267.9030004@st.com> <428B36B2.5050001@st.com> <428B4F84.7010302@st.com> <432EF25F.9040305@st.com> <44996F60.8000108@st.com>
Joern RENNECKE <joern.rennecke@st.com> writes:
> gen_add3_insn (rtx r0, rtx r1, rtx c)
> {
> int icode = (int) add_optab->handlers[(int) GET_MODE (r0)].insn_code;
> + int mcode;
> + rtx s;
>
> if (icode == CODE_FOR_nothing
> || !(insn_data[icode].operand[0].predicate
> - (r0, insn_data[icode].operand[0].mode))
> - || !(insn_data[icode].operand[1].predicate
> + (r0, insn_data[icode].operand[0].mode)))
> + return NULL_RTX;
> +
> + if ((insn_data[icode].operand[1].predicate
> (r1, insn_data[icode].operand[1].mode))
> - || !(insn_data[icode].operand[2].predicate
> + && (insn_data[icode].operand[2].predicate
> (c, insn_data[icode].operand[2].mode)))
> + return GEN_FCN (icode) (r0, r1, c);
> +
> + mcode = (int) mov_optab->handlers[(int) GET_MODE (r0)].insn_code;
> + if (REGNO (r0) == REGNO (r1)
> + || !(insn_data[icode].operand[1].predicate
> + (r0, insn_data[icode].operand[1].mode))
> + || !(insn_data[icode].operand[2].predicate
> + (r1, insn_data[icode].operand[2].mode))
> + || !(insn_data[mcode].operand[0].predicate
> + (r0, insn_data[mcode].operand[0].mode))
> + || !(insn_data[mcode].operand[1].predicate
> + (c, insn_data[mcode].operand[1].mode)))
> return NULL_RTX;
>
> - return GEN_FCN (icode) (r0, r1, c);
> + start_sequence ();
> + emit_insn (GEN_FCN (mcode) (r0, c));
> + emit_insn (GEN_FCN (icode) (r0, r0, r1));
> + s = get_insns ();
> + end_sequence ();
> + return s;
> }
I think we need a clearer description of what gen_add3_insn is for.
In general this function is hard to use safely and easily, as it
requires checking for a NULL return even though most of the callers do
not actually check. I note that the MIPS backend uses it, and the
changes above don't seem quite right for the MIPS backend.
Ian