[PATCH 2/2] refactor emit_*_{after,before}{,_setloc} using common functions
Nathan Froyd
froydnj@codesourcery.com
Tue Mar 22 23:13:00 GMT 2011
On Tue, Mar 22, 2011 at 02:28:30PM -0700, Richard Henderson wrote:
> On 03/21/2011 08:18 PM, Nathan Froyd wrote:
> > +/* Insert PATTERN before BEFORE, setting its INSN_LOCATION to LOC.
> > + MAKE_RAW indicates how to turn PATTERN into a real insn. INSNP
> > + indicates if PATTERN is meant for an INSN as opposed to a JUMP_INSN,
> > + CALL_INSN, etc. */
> > +
> > +static rtx
> > +emit_pattern_before_setloc (rtx pattern, rtx before, int loc, bool insnp,
> > + rtx (*make_raw) (rtx))
> > {
> > rtx first = PREV_INSN (before);
> > - rtx last = emit_insn_before_noloc (pattern, before, NULL);
> > + rtx last = emit_pattern_before_noloc (pattern, before,
> > + insnp ? before : NULL_RTX,
> > + NULL, make_raw);
> >
> > - if (pattern == NULL_RTX || !loc)
> > + if (pattern == NULL_RTX || (!loc && insnp))
> > return last;
> >
> > - if (!first)
> > + if (!first && insnp)
> > first = get_insns ();
>
> Is this not merely indicative of a bug in one or more of the functions?
> Why would recording LOC be dependent on INSNP?
That's a good question; I don't know. I was trying to preserve the
existing behavior. Compare:
rtx
emit_insn_before_setloc (rtx pattern, rtx before, int loc)
{
...
if (pattern == NULL_RTX || !loc)
return last;
if (!first)
first = get_insns ();
else
first = NEXT_INSN (first);
...
to the similar:
rtx
emit_call_insn_before_setloc (rtx pattern, rtx before, int loc)
{
...
if (pattern == NULL_RTX)
return last;
first = NEXT_INSN (first);
The jump_insn and debug_insn variants have identical behavior to
call_insn.
-Nathan
More information about the Gcc-patches
mailing list