On Thu, Nov 3, 2016 at 1:58 PM, Eric Botcazou <ebotca...@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.