Commit 5f02387d by Nathan Froyd Committed by Nathan Froyd

refactor emit_*_{after,before}_noloc using common functions

refactor emit_*_{after,before}_noloc using common functions
	* emit-rtl.c (emit_pattern_before_noloc): New function.
	(emit_insn_before_noloc, emit_jump_insn_before_noloc): Call it.
	(emit_call_insn_before_noloc, emit_debug_insn_before_noloc): Likewise.
	(emit_pattern_after_noloc): New function.
	(emit_insn_after_noloc, emit_jump_insn_after_noloc): Call it.
	(emit_call_insn_after_noloc, emit_debug_insn_after_noloc): Likewise.

From-SVN: r171339
parent fdf3e18a
2011-03-22 Nathan Froyd <froydnj@codesourcery.com> 2011-03-22 Nathan Froyd <froydnj@codesourcery.com>
* emit-rtl.c (emit_pattern_before_noloc): New function.
(emit_insn_before_noloc, emit_jump_insn_before_noloc): Call it.
(emit_call_insn_before_noloc, emit_debug_insn_before_noloc): Likewise.
(emit_pattern_after_noloc): New function.
(emit_insn_after_noloc, emit_jump_insn_after_noloc): Call it.
(emit_call_insn_after_noloc, emit_debug_insn_after_noloc): Likewise.
2011-03-22 Nathan Froyd <froydnj@codesourcery.com>
* libgcc2.c (__lshrdi3, __ashldi3, __ashrdi3): Use W_TYPE_SIZE. * libgcc2.c (__lshrdi3, __ashldi3, __ashrdi3): Use W_TYPE_SIZE.
(__ffsDI2): Likewise. (__ffsDI2): Likewise.
......
...@@ -4022,12 +4022,10 @@ reorder_insns (rtx from, rtx to, rtx after) ...@@ -4022,12 +4022,10 @@ reorder_insns (rtx from, rtx to, rtx after)
SEQUENCE rtl results in much fragmented RTL memory since the SEQUENCE SEQUENCE rtl results in much fragmented RTL memory since the SEQUENCE
generated would almost certainly die right after it was created. */ generated would almost certainly die right after it was created. */
/* Make X be output before the instruction BEFORE. */ static rtx
emit_pattern_before_noloc (rtx x, rtx before, rtx last, basic_block bb,
rtx rtx (*make_raw) (rtx))
emit_insn_before_noloc (rtx x, rtx before, basic_block bb)
{ {
rtx last = before;
rtx insn; rtx insn;
gcc_assert (before); gcc_assert (before);
...@@ -4061,7 +4059,7 @@ emit_insn_before_noloc (rtx x, rtx before, basic_block bb) ...@@ -4061,7 +4059,7 @@ emit_insn_before_noloc (rtx x, rtx before, basic_block bb)
#endif #endif
default: default:
last = make_insn_raw (x); last = (*make_raw) (x);
add_insn_before (last, before, bb); add_insn_before (last, before, bb);
break; break;
} }
...@@ -4069,48 +4067,22 @@ emit_insn_before_noloc (rtx x, rtx before, basic_block bb) ...@@ -4069,48 +4067,22 @@ emit_insn_before_noloc (rtx x, rtx before, basic_block bb)
return last; return last;
} }
/* Make X be output before the instruction BEFORE. */
rtx
emit_insn_before_noloc (rtx x, rtx before, basic_block bb)
{
return emit_pattern_before_noloc (x, before, before, bb, make_insn_raw);
}
/* Make an instruction with body X and code JUMP_INSN /* Make an instruction with body X and code JUMP_INSN
and output it before the instruction BEFORE. */ and output it before the instruction BEFORE. */
rtx rtx
emit_jump_insn_before_noloc (rtx x, rtx before) emit_jump_insn_before_noloc (rtx x, rtx before)
{ {
rtx insn, last = NULL_RTX; return emit_pattern_before_noloc (x, before, NULL_RTX, NULL,
make_jump_insn_raw);
gcc_assert (before);
switch (GET_CODE (x))
{
case DEBUG_INSN:
case INSN:
case JUMP_INSN:
case CALL_INSN:
case CODE_LABEL:
case BARRIER:
case NOTE:
insn = x;
while (insn)
{
rtx next = NEXT_INSN (insn);
add_insn_before (insn, before, NULL);
last = insn;
insn = next;
}
break;
#ifdef ENABLE_RTL_CHECKING
case SEQUENCE:
gcc_unreachable ();
break;
#endif
default:
last = make_jump_insn_raw (x);
add_insn_before (last, before, NULL);
break;
}
return last;
} }
/* Make an instruction with body X and code CALL_INSN /* Make an instruction with body X and code CALL_INSN
...@@ -4119,42 +4091,8 @@ emit_jump_insn_before_noloc (rtx x, rtx before) ...@@ -4119,42 +4091,8 @@ emit_jump_insn_before_noloc (rtx x, rtx before)
rtx rtx
emit_call_insn_before_noloc (rtx x, rtx before) emit_call_insn_before_noloc (rtx x, rtx before)
{ {
rtx last = NULL_RTX, insn; return emit_pattern_before_noloc (x, before, NULL_RTX, NULL,
make_call_insn_raw);
gcc_assert (before);
switch (GET_CODE (x))
{
case DEBUG_INSN:
case INSN:
case JUMP_INSN:
case CALL_INSN:
case CODE_LABEL:
case BARRIER:
case NOTE:
insn = x;
while (insn)
{
rtx next = NEXT_INSN (insn);
add_insn_before (insn, before, NULL);
last = insn;
insn = next;
}
break;
#ifdef ENABLE_RTL_CHECKING
case SEQUENCE:
gcc_unreachable ();
break;
#endif
default:
last = make_call_insn_raw (x);
add_insn_before (last, before, NULL);
break;
}
return last;
} }
/* Make an instruction with body X and code DEBUG_INSN /* Make an instruction with body X and code DEBUG_INSN
...@@ -4163,42 +4101,8 @@ emit_call_insn_before_noloc (rtx x, rtx before) ...@@ -4163,42 +4101,8 @@ emit_call_insn_before_noloc (rtx x, rtx before)
rtx rtx
emit_debug_insn_before_noloc (rtx x, rtx before) emit_debug_insn_before_noloc (rtx x, rtx before)
{ {
rtx last = NULL_RTX, insn; return emit_pattern_before_noloc (x, before, NULL_RTX, NULL,
make_debug_insn_raw);
gcc_assert (before);
switch (GET_CODE (x))
{
case DEBUG_INSN:
case INSN:
case JUMP_INSN:
case CALL_INSN:
case CODE_LABEL:
case BARRIER:
case NOTE:
insn = x;
while (insn)
{
rtx next = NEXT_INSN (insn);
add_insn_before (insn, before, NULL);
last = insn;
insn = next;
}
break;
#ifdef ENABLE_RTL_CHECKING
case SEQUENCE:
gcc_unreachable ();
break;
#endif
default:
last = make_debug_insn_raw (x);
add_insn_before (last, before, NULL);
break;
}
return last;
} }
/* Make an insn of code BARRIER /* Make an insn of code BARRIER
...@@ -4292,11 +4196,9 @@ emit_insn_after_1 (rtx first, rtx after, basic_block bb) ...@@ -4292,11 +4196,9 @@ emit_insn_after_1 (rtx first, rtx after, basic_block bb)
return last; return last;
} }
/* Make X be output after the insn AFTER and set the BB of insn. If static rtx
BB is NULL, an attempt is made to infer the BB from AFTER. */ emit_pattern_after_noloc (rtx x, rtx after, basic_block bb,
rtx (*make_raw)(rtx))
rtx
emit_insn_after_noloc (rtx x, rtx after, basic_block bb)
{ {
rtx last = after; rtx last = after;
...@@ -4324,7 +4226,7 @@ emit_insn_after_noloc (rtx x, rtx after, basic_block bb) ...@@ -4324,7 +4226,7 @@ emit_insn_after_noloc (rtx x, rtx after, basic_block bb)
#endif #endif
default: default:
last = make_insn_raw (x); last = (*make_raw) (x);
add_insn_after (last, after, bb); add_insn_after (last, after, bb);
break; break;
} }
...@@ -4332,6 +4234,15 @@ emit_insn_after_noloc (rtx x, rtx after, basic_block bb) ...@@ -4332,6 +4234,15 @@ emit_insn_after_noloc (rtx x, rtx after, basic_block bb)
return last; return last;
} }
/* Make X be output after the insn AFTER and set the BB of insn. If
BB is NULL, an attempt is made to infer the BB from AFTER. */
rtx
emit_insn_after_noloc (rtx x, rtx after, basic_block bb)
{
return emit_pattern_after_noloc (x, after, bb, make_insn_raw);
}
/* Make an insn of code JUMP_INSN with body X /* Make an insn of code JUMP_INSN with body X
and output it after the insn AFTER. */ and output it after the insn AFTER. */
...@@ -4339,35 +4250,7 @@ emit_insn_after_noloc (rtx x, rtx after, basic_block bb) ...@@ -4339,35 +4250,7 @@ emit_insn_after_noloc (rtx x, rtx after, basic_block bb)
rtx rtx
emit_jump_insn_after_noloc (rtx x, rtx after) emit_jump_insn_after_noloc (rtx x, rtx after)
{ {
rtx last; return emit_pattern_after_noloc (x, after, NULL, make_jump_insn_raw);
gcc_assert (after);
switch (GET_CODE (x))
{
case DEBUG_INSN:
case INSN:
case JUMP_INSN:
case CALL_INSN:
case CODE_LABEL:
case BARRIER:
case NOTE:
last = emit_insn_after_1 (x, after, NULL);
break;
#ifdef ENABLE_RTL_CHECKING
case SEQUENCE:
gcc_unreachable ();
break;
#endif
default:
last = make_jump_insn_raw (x);
add_insn_after (last, after, NULL);
break;
}
return last;
} }
/* Make an instruction with body X and code CALL_INSN /* Make an instruction with body X and code CALL_INSN
...@@ -4376,35 +4259,7 @@ emit_jump_insn_after_noloc (rtx x, rtx after) ...@@ -4376,35 +4259,7 @@ emit_jump_insn_after_noloc (rtx x, rtx after)
rtx rtx
emit_call_insn_after_noloc (rtx x, rtx after) emit_call_insn_after_noloc (rtx x, rtx after)
{ {
rtx last; return emit_pattern_after_noloc (x, after, NULL, make_call_insn_raw);
gcc_assert (after);
switch (GET_CODE (x))
{
case DEBUG_INSN:
case INSN:
case JUMP_INSN:
case CALL_INSN:
case CODE_LABEL:
case BARRIER:
case NOTE:
last = emit_insn_after_1 (x, after, NULL);
break;
#ifdef ENABLE_RTL_CHECKING
case SEQUENCE:
gcc_unreachable ();
break;
#endif
default:
last = make_call_insn_raw (x);
add_insn_after (last, after, NULL);
break;
}
return last;
} }
/* Make an instruction with body X and code CALL_INSN /* Make an instruction with body X and code CALL_INSN
...@@ -4413,35 +4268,7 @@ emit_call_insn_after_noloc (rtx x, rtx after) ...@@ -4413,35 +4268,7 @@ emit_call_insn_after_noloc (rtx x, rtx after)
rtx rtx
emit_debug_insn_after_noloc (rtx x, rtx after) emit_debug_insn_after_noloc (rtx x, rtx after)
{ {
rtx last; return emit_pattern_after_noloc (x, after, NULL, make_debug_insn_raw);
gcc_assert (after);
switch (GET_CODE (x))
{
case DEBUG_INSN:
case INSN:
case JUMP_INSN:
case CALL_INSN:
case CODE_LABEL:
case BARRIER:
case NOTE:
last = emit_insn_after_1 (x, after, NULL);
break;
#ifdef ENABLE_RTL_CHECKING
case SEQUENCE:
gcc_unreachable ();
break;
#endif
default:
last = make_debug_insn_raw (x);
add_insn_after (last, after, NULL);
break;
}
return last;
} }
/* Make an insn of code BARRIER /* Make an insn of code BARRIER
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment