This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 2/2, i386]: Implement TARGET_EXPAND_DIVMOD_LIBFUNC
- From: Uros Bizjak <ubizjak at gmail dot com>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Prathamesh Kulkarni <prathamesh dot kulkarni at linaro dot org>, Kugan <kugan dot vivekanandarajah at linaro dot org>, jim dot wilson at linaro dot org
- Date: Thu, 3 Nov 2016 14:06:48 +0100
- Subject: Re: [PATCH 2/2, i386]: Implement TARGET_EXPAND_DIVMOD_LIBFUNC
- Authentication-results: sourceware.org; auth=none
- References: <CAFULd4ZSMEBPKSTCPS8R=AMAo+nuEq34h3nW6JU27pKYj8T4dQ@mail.gmail.com> <2310401.5T5cJgJx99@polaris> <CAFULd4bFNUX70ijQtjAL9TrwW94HR7qpy_otSwXAhSc=bYivPw@mail.gmail.com> <8347631.dS1miiSmds@polaris>
On Thu, Nov 3, 2016 at 1:58 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> libfunc, as in "__{,u}divmod{di,ti}4 library function" is already
>> implemented in libgcc. But the enablement of this function inside the
>> compiler has to be performed by each target.
>
> So can we do it generically instead of duplicating it ~50 times?
I guess it can be done. Currently the expander goes:
--cut here--
/* Check if optab_handler exists for divmod_optab for given mode. */
if (optab_handler (tab, mode) != CODE_FOR_nothing)
{
quotient = gen_reg_rtx (mode);
remainder = gen_reg_rtx (mode);
expand_twoval_binop (tab, op0, op1, quotient, remainder, unsignedp);
}
/* Generate call to divmod libfunc if it exists. */
else if ((libfunc = optab_libfunc (tab, mode)) != NULL_RTX)
targetm.expand_divmod_libfunc (libfunc, mode, op0, op1,
"ient, &remainder);
else
gcc_unreachable ();
--cut here--
so, by declaring divmod libfunc, the target also has to provide target hook.
Let's ask authors of the original divmod patch for the details.
Uros.