This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] gcc/*.c: Use REG_P and its friends everywhere.
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 26 Apr 2005 13:02:07 -0400 (EDT)
- Subject: [patch] gcc/*.c: Use REG_P and its friends everywhere.
Hi,
Attached is a patch to use REG_P and its friends everywhere.
Tested on i686-pc-linux-gnu. I don't see any project touching these
RTL-related files in "GCC 4.1 Projects" (well, tree-ssa-loop-ivopts.c
isn't quite an RTL optimizer), but I'll wait for 24 hours just in case
before I check in this patch as obvious.
Kazu Hirata
2005-04-26 Kazu Hirata <kazu@cs.umass.edu>
* bt-load.c, cfgexpand.c, dwarf2out.c, emit-rtl.c, expr.c,
function.c, global.c, lcm.c, loop-invariant.c, optabs.c,
reorg.c, resource.c, tree-ssa-loop-ivopts.c, value-prof.c: Use
JUMP_P, LABEL_P, REG_P, MEM_P, NONJUMP_INSN_P, and INSN_P
where appropriate.
Index: bt-load.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bt-load.c,v
retrieving revision 2.32
diff -u -d -p -r2.32 bt-load.c
--- bt-load.c 17 Feb 2005 22:41:31 -0000 2.32
+++ bt-load.c 24 Apr 2005 00:50:27 -0000
@@ -1008,7 +1008,7 @@ btr_def_live_range (btr_def def, HARD_RE
def->bb, user->bb,
(flag_btr_bb_exclusive
|| user->insn != BB_END (def->bb)
- || GET_CODE (user->insn) != JUMP_INSN));
+ || !JUMP_P (user->insn)));
}
else
{
@@ -1072,7 +1072,7 @@ combine_btr_defs (btr_def def, HARD_REG_
def->bb, user->bb,
(flag_btr_bb_exclusive
|| user->insn != BB_END (def->bb)
- || GET_CODE (user->insn) != JUMP_INSN));
+ || !JUMP_P (user->insn)));
btr = choose_btr (combined_btrs_live);
if (btr != -1)
Index: cfgexpand.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgexpand.c,v
retrieving revision 2.37
diff -u -d -p -r2.37 cfgexpand.c
--- cfgexpand.c 21 Apr 2005 15:47:22 -0000 2.37
+++ cfgexpand.c 24 Apr 2005 00:50:28 -0000
@@ -49,15 +49,15 @@ add_reg_br_prob_note (FILE *dump_file, r
if (profile_status == PROFILE_ABSENT)
return;
for (last = NEXT_INSN (last); last && NEXT_INSN (last); last = NEXT_INSN (last))
- if (GET_CODE (last) == JUMP_INSN)
+ if (JUMP_P (last))
{
/* It is common to emit condjump-around-jump sequence when we don't know
how to reverse the conditional. Special case this. */
if (!any_condjump_p (last)
- || GET_CODE (NEXT_INSN (last)) != JUMP_INSN
+ || !JUMP_P (NEXT_INSN (last))
|| !simplejump_p (NEXT_INSN (last))
- || GET_CODE (NEXT_INSN (NEXT_INSN (last))) != BARRIER
- || GET_CODE (NEXT_INSN (NEXT_INSN (NEXT_INSN (last)))) != CODE_LABEL
+ || !BARRIER_P (NEXT_INSN (NEXT_INSN (last)))
+ || !LABEL_P (NEXT_INSN (NEXT_INSN (NEXT_INSN (last))))
|| NEXT_INSN (NEXT_INSN (NEXT_INSN (NEXT_INSN (last)))))
goto failed;
gcc_assert (!find_reg_note (last, REG_BR_PROB, 0));
@@ -67,7 +67,7 @@ add_reg_br_prob_note (FILE *dump_file, r
REG_NOTES (last));
return;
}
- if (!last || GET_CODE (last) != JUMP_INSN || !any_condjump_p (last))
+ if (!last || !JUMP_P (last) || !any_condjump_p (last))
goto failed;
gcc_assert (!find_reg_note (last, REG_BR_PROB, 0));
REG_NOTES (last)
Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.587
diff -u -d -p -r1.587 dwarf2out.c
--- dwarf2out.c 22 Apr 2005 16:14:52 -0000 1.587
+++ dwarf2out.c 24 Apr 2005 00:50:31 -0000
@@ -1482,7 +1482,7 @@ dwarf2out_frame_debug_expr (rtx expr, co
src = SET_SRC (expr);
dest = SET_DEST (expr);
- if (GET_CODE (src) == REG)
+ if (REG_P (src))
{
rtx rsi = reg_saved_in (src);
if (rsi)
Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v
retrieving revision 1.438
diff -u -d -p -r1.438 emit-rtl.c
--- emit-rtl.c 23 Apr 2005 21:27:39 -0000 1.438
+++ emit-rtl.c 24 Apr 2005 00:50:32 -0000
@@ -2697,7 +2697,7 @@ get_first_nonnote_insn (void)
continue;
else
{
- if (GET_CODE (insn) == INSN
+ if (NONJUMP_INSN_P (insn)
&& GET_CODE (PATTERN (insn)) == SEQUENCE)
insn = XVECEXP (PATTERN (insn), 0, 0);
}
@@ -2723,7 +2723,7 @@ get_last_nonnote_insn (void)
continue;
else
{
- if (GET_CODE (insn) == INSN
+ if (NONJUMP_INSN_P (insn)
&& GET_CODE (PATTERN (insn)) == SEQUENCE)
insn = XVECEXP (PATTERN (insn), 0,
XVECLEN (PATTERN (insn), 0) - 1);
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.786
diff -u -d -p -r1.786 expr.c
--- expr.c 22 Apr 2005 16:14:53 -0000 1.786
+++ expr.c 24 Apr 2005 00:50:34 -0000
@@ -2650,7 +2650,7 @@ write_complex_part (rtx cplx, rtx val, b
the original object if it spans an even number of hard regs.
This special case is important for SCmode on 64-bit platforms
where the natural size of floating-point regs is 32-bit. */
- || (GET_CODE (cplx) == REG
+ || (REG_P (cplx)
&& REGNO (cplx) < FIRST_PSEUDO_REGISTER
&& hard_regno_nregs[REGNO (cplx)][cmode] % 2 == 0)
/* For MEMs we always try to make a "subreg", that is to adjust
@@ -2710,7 +2710,7 @@ read_complex_part (rtx cplx, bool imag_p
the original object if it spans an even number of hard regs.
This special case is important for SCmode on 64-bit platforms
where the natural size of floating-point regs is 32-bit. */
- || (GET_CODE (cplx) == REG
+ || (REG_P (cplx)
&& REGNO (cplx) < FIRST_PSEUDO_REGISTER
&& hard_regno_nregs[REGNO (cplx)][cmode] % 2 == 0)
/* For MEMs we always try to make a "subreg", that is to adjust
@@ -6213,7 +6213,7 @@ expand_expr_addr_expr_1 (tree exp, rtx t
/* If the DECL isn't in memory, then the DECL wasn't properly
marked TREE_ADDRESSABLE, which will be either a front-end
or a tree optimizer bug. */
- gcc_assert (GET_CODE (result) == MEM);
+ gcc_assert (MEM_P (result));
result = XEXP (result, 0);
/* ??? Is this needed anymore? */
Index: function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.613
diff -u -d -p -r1.613 function.c
--- function.c 23 Apr 2005 21:27:43 -0000 1.613
+++ function.c 24 Apr 2005 00:50:35 -0000
@@ -1244,15 +1244,14 @@ instantiate_virtual_regs (void)
/* Scan through all the insns, instantiating every virtual register still
present. */
for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
- if (GET_CODE (insn) == INSN || GET_CODE (insn) == JUMP_INSN
- || GET_CODE (insn) == CALL_INSN)
+ if (INSN_P (insn))
{
instantiate_virtual_regs_1 (&PATTERN (insn), insn, 1);
if (INSN_DELETED_P (insn))
continue;
instantiate_virtual_regs_1 (®_NOTES (insn), NULL_RTX, 0);
/* Instantiate any virtual registers in CALL_INSN_FUNCTION_USAGE. */
- if (GET_CODE (insn) == CALL_INSN)
+ if (CALL_P (insn))
instantiate_virtual_regs_1 (&CALL_INSN_FUNCTION_USAGE (insn),
NULL_RTX, 0);
Index: global.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/global.c,v
retrieving revision 1.123
diff -u -d -p -r1.123 global.c
--- global.c 17 Feb 2005 22:41:32 -0000 1.123
+++ global.c 24 Apr 2005 00:50:36 -0000
@@ -2192,7 +2192,7 @@ mark_reg_use_for_earlyclobber (rtx *x, v
basic_block bb = data;
struct bb_info *bb_info = BB_INFO (bb);
- if (GET_CODE (*x) == REG && REGNO (*x) >= FIRST_PSEUDO_REGISTER)
+ if (REG_P (*x) && REGNO (*x) >= FIRST_PSEUDO_REGISTER)
{
regno = REGNO (*x);
if (bitmap_bit_p (bb_info->killed, regno)
Index: lcm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/lcm.c,v
retrieving revision 1.73
diff -u -d -p -r1.73 lcm.c
--- lcm.c 21 Apr 2005 15:47:29 -0000 1.73
+++ lcm.c 24 Apr 2005 00:50:36 -0000
@@ -1000,7 +1000,7 @@ create_pre_exit (int n_entities, int *en
insert the final mode switch before the return value copy
to its hard register. */
if (EDGE_COUNT (EXIT_BLOCK_PTR->preds) == 1
- && GET_CODE ((last_insn = BB_END (src_bb))) == INSN
+ && NONJUMP_INSN_P ((last_insn = BB_END (src_bb)))
&& GET_CODE (PATTERN (last_insn)) == USE
&& GET_CODE ((ret_reg = XEXP (PATTERN (last_insn), 0))) == REG)
{
Index: loop-invariant.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-invariant.c,v
retrieving revision 2.12
diff -u -d -p -r2.12 loop-invariant.c
--- loop-invariant.c 1 Apr 2005 14:17:34 -0000 2.12
+++ loop-invariant.c 24 Apr 2005 00:50:36 -0000
@@ -427,7 +427,7 @@ find_invariant_insn (rtx insn, bool alwa
return;
dest = SET_DEST (set);
- if (GET_CODE (dest) != REG
+ if (!REG_P (dest)
|| HARD_REGISTER_P (dest))
simple = false;
Index: optabs.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/optabs.c,v
retrieving revision 1.276
diff -u -d -p -r1.276 optabs.c
--- optabs.c 21 Apr 2005 18:05:13 -0000 1.276
+++ optabs.c 24 Apr 2005 00:50:37 -0000
@@ -5554,7 +5554,7 @@ expand_bool_compare_and_swap (rtx mem, r
/* Ensure that if old_val == mem, that we're not comparing
against an old value. */
- if (GET_CODE (old_val) == MEM)
+ if (MEM_P (old_val))
old_val = force_reg (mode, old_val);
subtarget = expand_val_compare_and_swap_1 (mem, old_val, new_val,
Index: reorg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reorg.c,v
retrieving revision 1.106
diff -u -d -p -r1.106 reorg.c
--- reorg.c 23 Mar 2005 14:53:52 -0000 1.106
+++ reorg.c 24 Apr 2005 00:50:38 -0000
@@ -384,7 +384,7 @@ find_end_label (void)
/* If the basic block reorder pass moves the return insn to
some other place try to locate it again and put our
end_of_function_label there. */
- while (insn && ! (GET_CODE (insn) == JUMP_INSN
+ while (insn && ! (JUMP_P (insn)
&& (GET_CODE (PATTERN (insn)) == RETURN)))
insn = PREV_INSN (insn);
if (insn)
Index: resource.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/resource.c,v
retrieving revision 1.78
diff -u -d -p -r1.78 resource.c
--- resource.c 18 Jan 2005 11:36:18 -0000 1.78
+++ resource.c 24 Apr 2005 00:50:39 -0000
@@ -834,10 +834,10 @@ mark_set_resources (rtx x, struct resour
static bool
return_insn_p (rtx insn)
{
- if (GET_CODE (insn) == JUMP_INSN && GET_CODE (PATTERN (insn)) == RETURN)
+ if (JUMP_P (insn) && GET_CODE (PATTERN (insn)) == RETURN)
return true;
- if (GET_CODE (insn) == INSN && GET_CODE (PATTERN (insn)) == SEQUENCE)
+ if (NONJUMP_INSN_P (insn) && GET_CODE (PATTERN (insn)) == SEQUENCE)
return return_insn_p (XVECEXP (PATTERN (insn), 0, 0));
return false;
Index: tree-ssa-loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ivopts.c,v
retrieving revision 2.62
diff -u -d -p -r2.62 tree-ssa-loop-ivopts.c
--- tree-ssa-loop-ivopts.c 23 Apr 2005 21:31:16 -0000 2.62
+++ tree-ssa-loop-ivopts.c 24 Apr 2005 00:50:40 -0000
@@ -2464,7 +2464,7 @@ computation_cost (tree expr)
end_sequence ();
cost = seq_cost (seq);
- if (GET_CODE (rslt) == MEM)
+ if (MEM_P (rslt))
cost += address_cost (XEXP (rslt, 0), TYPE_MODE (type));
return cost;
Index: value-prof.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/value-prof.c,v
retrieving revision 1.27
diff -u -d -p -r1.27 value-prof.c
--- value-prof.c 22 Apr 2005 10:57:03 -0000 1.27
+++ value-prof.c 24 Apr 2005 00:50:40 -0000
@@ -232,7 +232,7 @@ find_mem_reference_1 (rtx *expr, void *r
{
rtx *mem = ret;
- if (GET_CODE (*expr) == MEM)
+ if (MEM_P (*expr))
{
*mem = *expr;
return 1;
@@ -283,7 +283,7 @@ insn_prefetch_values_to_profile (rtx ins
histogram_value hist;
/* It only makes sense to look for memory references in ordinary insns. */
- if (GET_CODE (insn) != INSN)
+ if (!NONJUMP_INSN_P (insn))
return false;
if (!find_mem_reference (insn, &mem, &write))