The following patch adds a macro: /* Get the label that a LABEL_REF references. */ #define LABEL_REF_LABEL(LABREF) XCEXP (LABREF, 0, LABEL_REF)
and uses it in place of XEXP (foo, 0) for "foo" known to be a LABEL_REF, throughout the "gcc" directory, in the hope of (A) improving the clarity of the code (B) perhaps making it easier to make things typesafe in future patches. It's rather verbose compared to XEXP (x, 0), but I think it's clearer, and easier to grep for. Maybe "LABEL_REF_LAB"? I haven't gone through the config subfirectories yet. Bootstrapped on x86_64-unknown-linux-gnu (Fedora 20), and has been rebuilt as part of a config-list.mk build for all working configurations. OK for trunk? gcc/ChangeLog: * rtl.h (LABEL_REF_LABEL): New macro. * alias.c (rtx_equal_for_memref_p): Use LABEL_REF_LABEL in place of XEXP (, 0), where we know that we have a LABEL_REF. * cfgbuild.c (make_edges): Likewise. (purge_dead_tablejump_edges): Likewise. * cfgexpand.c (convert_debug_memory_address): Likewise. * cfgrtl.c (patch_jump_insn): Likewise. * combine.c (distribute_notes): Likewise. * cse.c (hash_rtx_cb): Likewise. (exp_equiv_p): Likewise. (fold_rtx): Likewise. (check_for_label_ref): Likewise. * cselib.c (rtx_equal_for_cselib_1): Likewise. (cselib_hash_rtx): Likewise. * emit-rtl.c (mark_label_nuses): Likewise. * explow.c (convert_memory_address_addr_space): Likewise. * final.c (output_asm_label): Likewise. (output_addr_const): Likewise. * gcse.c (add_label_notes): Likewise. * genconfig.c (walk_insn_part): Likewise. * genrecog.c (validate_pattern): Likewise. * ifcvt.c (cond_exec_get_condition): Likewise. (noce_emit_store_flag): Likewise. (noce_get_alt_condition): Likewise. (noce_get_condition): Likewise. * jump.c (maybe_propagate_label_ref): Likewise. (mark_jump_label_1): Likewise. (redirect_exp_1): Likewise. (rtx_renumbered_equal_p): Likewise. * lra-constraints.c (operands_match_p): Likewise. * reload.c (operands_match_p): Likewise. (find_reloads): Likewise. * reload1.c (set_label_offsets): Likewise. * reorg.c (get_branch_condition): Likewise. * rtl.c (rtx_equal_p_cb): Likewise. (rtx_equal_p): Likewise. * rtlanal.c (reg_mentioned_p): Likewise. (rtx_referenced_p): Likewise. (get_condition): Likewise. * sched-vis.c (print_value): Likewise. * varasm.c (const_hash_1): Likewise. (compare_constant): Likewise. (const_rtx_hash_1): Likewise. (output_constant_pool_1): Likewise. --- gcc/alias.c | 2 +- gcc/cfgbuild.c | 4 ++-- gcc/cfgexpand.c | 2 +- gcc/cfgrtl.c | 2 +- gcc/combine.c | 4 ++-- gcc/cse.c | 20 ++++++++++---------- gcc/cselib.c | 4 ++-- gcc/emit-rtl.c | 4 ++-- gcc/explow.c | 2 +- gcc/final.c | 4 ++-- gcc/gcse.c | 6 +++--- gcc/genconfig.c | 4 ++-- gcc/genrecog.c | 4 ++-- gcc/ifcvt.c | 8 ++++---- gcc/jump.c | 16 ++++++++-------- gcc/lra-constraints.c | 2 +- gcc/reload.c | 13 +++++++------ gcc/reload1.c | 6 +++--- gcc/reorg.c | 6 +++--- gcc/rtl.c | 4 ++-- gcc/rtl.h | 4 ++++ gcc/rtlanal.c | 8 +++++--- gcc/sched-vis.c | 2 +- gcc/varasm.c | 11 ++++++----- 24 files changed, 75 insertions(+), 67 deletions(-) diff --git a/gcc/alias.c b/gcc/alias.c index 602e9e0..a098cb7 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -1521,7 +1521,7 @@ rtx_equal_for_memref_p (const_rtx x, const_rtx y) return REGNO (x) == REGNO (y); case LABEL_REF: - return XEXP (x, 0) == XEXP (y, 0); + return LABEL_REF_LABEL (x) == LABEL_REF_LABEL (y); case SYMBOL_REF: return XSTR (x, 0) == XSTR (y, 0); diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c index e5ac8d6..00dab3e 100644 --- a/gcc/cfgbuild.c +++ b/gcc/cfgbuild.c @@ -277,7 +277,7 @@ make_edges (basic_block min, basic_block max, int update_p) && GET_CODE (SET_SRC (tmp)) == IF_THEN_ELSE && GET_CODE (XEXP (SET_SRC (tmp), 2)) == LABEL_REF) make_label_edge (edge_cache, bb, - XEXP (XEXP (SET_SRC (tmp), 2), 0), 0); + LABEL_REF_LABEL (XEXP (SET_SRC (tmp), 2)), 0); } /* If this is a computed jump, then mark it as reaching @@ -415,7 +415,7 @@ purge_dead_tablejump_edges (basic_block bb, rtx_jump_table_data *table) && SET_DEST (tmp) == pc_rtx && GET_CODE (SET_SRC (tmp)) == IF_THEN_ELSE && GET_CODE (XEXP (SET_SRC (tmp), 2)) == LABEL_REF) - mark_tablejump_edge (XEXP (XEXP (SET_SRC (tmp), 2), 0)); + mark_tablejump_edge (LABEL_REF_LABEL (XEXP (SET_SRC (tmp), 2))); for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); ) { diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 8916305..f95981b 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -3624,7 +3624,7 @@ convert_debug_memory_address (enum machine_mode mode, rtx x, return SUBREG_REG (x); break; case LABEL_REF: - temp = gen_rtx_LABEL_REF (mode, XEXP (x, 0)); + temp = gen_rtx_LABEL_REF (mode, LABEL_REF_LABEL (x)); LABEL_REF_NONLOCAL_P (temp) = LABEL_REF_NONLOCAL_P (x); return temp; case SYMBOL_REF: diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c index bc6c965..04c7d63 100644 --- a/gcc/cfgrtl.c +++ b/gcc/cfgrtl.c @@ -1202,7 +1202,7 @@ patch_jump_insn (rtx_insn *insn, rtx_insn *old_label, basic_block new_bb) && SET_DEST (tmp) == pc_rtx && GET_CODE (SET_SRC (tmp)) == IF_THEN_ELSE && GET_CODE (XEXP (SET_SRC (tmp), 2)) == LABEL_REF - && XEXP (XEXP (SET_SRC (tmp), 2), 0) == old_label) + && LABEL_REF_LABEL (XEXP (SET_SRC (tmp), 2)) == old_label) { XEXP (SET_SRC (tmp), 2) = gen_rtx_LABEL_REF (Pmode, new_label); diff --git a/gcc/combine.c b/gcc/combine.c index 0ec7f85..151e948 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -13403,14 +13403,14 @@ distribute_notes (rtx notes, rtx_insn *from_insn, rtx_insn *i3, rtx_insn *i2, if (reg_mentioned_p (XEXP (note, 0), PATTERN (i3)) || ((tem_note = find_reg_note (i3, REG_EQUAL, NULL_RTX)) && GET_CODE (XEXP (tem_note, 0)) == LABEL_REF - && XEXP (XEXP (tem_note, 0), 0) == XEXP (note, 0))) + && LABEL_REF_LABEL (XEXP (tem_note, 0)) == XEXP (note, 0))) place = i3; if (i2 && (reg_mentioned_p (XEXP (note, 0), PATTERN (i2)) || ((tem_note = find_reg_note (i2, REG_EQUAL, NULL_RTX)) && GET_CODE (XEXP (tem_note, 0)) == LABEL_REF - && XEXP (XEXP (tem_note, 0), 0) == XEXP (note, 0)))) + && LABEL_REF_LABEL (XEXP (tem_note, 0)) == XEXP (note, 0)))) { if (place) place2 = i2; diff --git a/gcc/cse.c b/gcc/cse.c index 90b08b6..be2f31b 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -2349,7 +2349,7 @@ hash_rtx_cb (const_rtx x, enum machine_mode mode, /* We don't hash on the address of the CODE_LABEL to avoid bootstrap differences and differences between each stage's debugging dumps. */ hash += (((unsigned int) LABEL_REF << 7) - + CODE_LABEL_NUMBER (XEXP (x, 0))); + + CODE_LABEL_NUMBER (LABEL_REF_LABEL (x))); return hash; case SYMBOL_REF: @@ -2602,7 +2602,7 @@ exp_equiv_p (const_rtx x, const_rtx y, int validate, bool for_gcse) return x == y; case LABEL_REF: - return XEXP (x, 0) == XEXP (y, 0); + return LABEL_REF_LABEL (x) == LABEL_REF_LABEL (y); case SYMBOL_REF: return XSTR (x, 0) == XSTR (y, 0); @@ -3486,7 +3486,7 @@ fold_rtx (rtx x, rtx_insn *insn) : lookup_as_function (folded_arg0, MINUS); if (y != 0 && GET_CODE (XEXP (y, 1)) == LABEL_REF - && XEXP (XEXP (y, 1), 0) == XEXP (const_arg1, 0)) + && LABEL_REF_LABEL (XEXP (y, 1)) == LABEL_REF_LABEL (const_arg1)) return XEXP (y, 0); /* Now try for a CONST of a MINUS like the above. */ @@ -3494,7 +3494,7 @@ fold_rtx (rtx x, rtx_insn *insn) : lookup_as_function (folded_arg0, CONST))) != 0 && GET_CODE (XEXP (y, 0)) == MINUS && GET_CODE (XEXP (XEXP (y, 0), 1)) == LABEL_REF - && XEXP (XEXP (XEXP (y, 0), 1), 0) == XEXP (const_arg1, 0)) + && LABEL_REF_LABEL (XEXP (XEXP (y, 0), 1)) == LABEL_REF_LABEL (const_arg1)) return XEXP (XEXP (y, 0), 0); } @@ -3506,7 +3506,7 @@ fold_rtx (rtx x, rtx_insn *insn) : lookup_as_function (folded_arg1, MINUS); if (y != 0 && GET_CODE (XEXP (y, 1)) == LABEL_REF - && XEXP (XEXP (y, 1), 0) == XEXP (const_arg0, 0)) + && LABEL_REF_LABEL (XEXP (y, 1)) == LABEL_REF_LABEL (const_arg0)) return XEXP (y, 0); /* Now try for a CONST of a MINUS like the above. */ @@ -3514,7 +3514,7 @@ fold_rtx (rtx x, rtx_insn *insn) : lookup_as_function (folded_arg1, CONST))) != 0 && GET_CODE (XEXP (y, 0)) == MINUS && GET_CODE (XEXP (XEXP (y, 0), 1)) == LABEL_REF - && XEXP (XEXP (XEXP (y, 0), 1), 0) == XEXP (const_arg0, 0)) + && LABEL_REF_LABEL (XEXP (XEXP (y, 0), 1)) == LABEL_REF_LABEL (const_arg0)) return XEXP (XEXP (y, 0), 0); } @@ -6374,10 +6374,10 @@ check_for_label_ref (rtx_insn *insn) if (GET_CODE (x) == LABEL_REF && !LABEL_REF_NONLOCAL_P (x) && (!JUMP_P (insn) - || !label_is_jump_target_p (XEXP (x, 0), insn)) - && LABEL_P (XEXP (x, 0)) - && INSN_UID (XEXP (x, 0)) != 0 - && !find_reg_note (insn, REG_LABEL_OPERAND, XEXP (x, 0))) + || !label_is_jump_target_p (LABEL_REF_LABEL (x), insn)) + && LABEL_P (LABEL_REF_LABEL (x)) + && INSN_UID (LABEL_REF_LABEL (x)) != 0 + && !find_reg_note (insn, REG_LABEL_OPERAND, LABEL_REF_LABEL (x))) return true; } return false; diff --git a/gcc/cselib.c b/gcc/cselib.c index 68d4284..d06a1d5 100644 --- a/gcc/cselib.c +++ b/gcc/cselib.c @@ -961,7 +961,7 @@ rtx_equal_for_cselib_1 (rtx x, rtx y, enum machine_mode memmode) return rtx_equal_p (ENTRY_VALUE_EXP (x), ENTRY_VALUE_EXP (y)); case LABEL_REF: - return XEXP (x, 0) == XEXP (y, 0); + return LABEL_REF_LABEL (x) == LABEL_REF_LABEL (y); case MEM: /* We have to compare any autoinc operations in the addresses @@ -1167,7 +1167,7 @@ cselib_hash_rtx (rtx x, int create, enum machine_mode memmode) /* We don't hash on the address of the CODE_LABEL to avoid bootstrap differences and differences between each stage's debugging dumps. */ hash += (((unsigned int) LABEL_REF << 7) - + CODE_LABEL_NUMBER (XEXP (x, 0))); + + CODE_LABEL_NUMBER (LABEL_REF_LABEL (x))); return hash ? hash : (unsigned int) LABEL_REF; case SYMBOL_REF: diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 34bf271..99cd209 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -3584,8 +3584,8 @@ mark_label_nuses (rtx x) const char *fmt; code = GET_CODE (x); - if (code == LABEL_REF && LABEL_P (XEXP (x, 0))) - LABEL_NUSES (XEXP (x, 0))++; + if (code == LABEL_REF && LABEL_P (LABEL_REF_LABEL (x))) + LABEL_NUSES (LABEL_REF_LABEL (x))++; fmt = GET_RTX_FORMAT (code); for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) diff --git a/gcc/explow.c b/gcc/explow.c index 91de639..8470691 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -357,7 +357,7 @@ convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED, break; case LABEL_REF: - temp = gen_rtx_LABEL_REF (to_mode, XEXP (x, 0)); + temp = gen_rtx_LABEL_REF (to_mode, LABEL_REF_LABEL (x)); LABEL_REF_NONLOCAL_P (temp) = LABEL_REF_NONLOCAL_P (x); return temp; break; diff --git a/gcc/final.c b/gcc/final.c index 9275a48..1b50e74 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -3802,7 +3802,7 @@ output_asm_label (rtx x) char buf[256]; if (GET_CODE (x) == LABEL_REF) - x = XEXP (x, 0); + x = LABEL_REF_LABEL (x); if (LABEL_P (x) || (NOTE_P (x) && NOTE_KIND (x) == NOTE_INSN_DELETED_LABEL)) @@ -3892,7 +3892,7 @@ output_addr_const (FILE *file, rtx x) break; case LABEL_REF: - x = XEXP (x, 0); + x = LABEL_REF_LABEL (x); /* Fall through. */ case CODE_LABEL: ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (x)); diff --git a/gcc/gcse.c b/gcc/gcse.c index b7c4788..15d026b 100644 --- a/gcc/gcse.c +++ b/gcc/gcse.c @@ -2816,10 +2816,10 @@ add_label_notes (rtx x, rtx insn) such a LABEL_REF, so we don't have to handle REG_LABEL_TARGET notes. */ gcc_assert (!JUMP_P (insn)); - add_reg_note (insn, REG_LABEL_OPERAND, XEXP (x, 0)); + add_reg_note (insn, REG_LABEL_OPERAND, LABEL_REF_LABEL (x)); - if (LABEL_P (XEXP (x, 0))) - LABEL_NUSES (XEXP (x, 0))++; + if (LABEL_P (LABEL_REF_LABEL (x))) + LABEL_NUSES (LABEL_REF_LABEL (x))++; return; } diff --git a/gcc/genconfig.c b/gcc/genconfig.c index d1996c3..ae08d1e 100644 --- a/gcc/genconfig.c +++ b/gcc/genconfig.c @@ -98,8 +98,8 @@ walk_insn_part (rtx part, int recog_p, int non_pc_set_src) break; case LABEL_REF: - if (GET_CODE (XEXP (part, 0)) == MATCH_OPERAND - || GET_CODE (XEXP (part, 0)) == MATCH_DUP) + if (GET_CODE (LABEL_REF_LABEL (part)) == MATCH_OPERAND + || GET_CODE (LABEL_REF_LABEL (part)) == MATCH_DUP) break; return; diff --git a/gcc/genrecog.c b/gcc/genrecog.c index 1f09dd6..dbdefb0 100644 --- a/gcc/genrecog.c +++ b/gcc/genrecog.c @@ -617,10 +617,10 @@ validate_pattern (rtx pattern, rtx insn, rtx set, int set_code) return; case LABEL_REF: - if (GET_MODE (XEXP (pattern, 0)) != VOIDmode) + if (GET_MODE (LABEL_REF_LABEL (pattern)) != VOIDmode) error_with_line (pattern_lineno, "operand to label_ref %smode not VOIDmode", - GET_MODE_NAME (GET_MODE (XEXP (pattern, 0)))); + GET_MODE_NAME (GET_MODE (LABEL_REF_LABEL (pattern)))); break; default: diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index 6c801d3..6bcc23a 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -443,7 +443,7 @@ cond_exec_get_condition (rtx_insn *jump) /* If this branches to JUMP_LABEL when the condition is false, reverse the condition. */ if (GET_CODE (XEXP (test_if, 2)) == LABEL_REF - && XEXP (XEXP (test_if, 2), 0) == JUMP_LABEL (jump)) + && LABEL_REF_LABEL (XEXP (test_if, 2)) == JUMP_LABEL (jump)) { enum rtx_code rev = reversed_comparison_code (cond, jump); if (rev == UNKNOWN) @@ -847,7 +847,7 @@ noce_emit_store_flag (struct noce_if_info *if_info, rtx x, int reversep, rtx set = pc_set (if_info->jump); cond = XEXP (SET_SRC (set), 0); if (GET_CODE (XEXP (SET_SRC (set), 2)) == LABEL_REF - && XEXP (XEXP (SET_SRC (set), 2), 0) == JUMP_LABEL (if_info->jump)) + && LABEL_REF_LABEL (XEXP (SET_SRC (set), 2)) == JUMP_LABEL (if_info->jump)) reversep = !reversep; if (if_info->then_else_reversed) reversep = !reversep; @@ -1777,7 +1777,7 @@ noce_get_alt_condition (struct noce_if_info *if_info, rtx target, cond = XEXP (SET_SRC (set), 0); reverse = GET_CODE (XEXP (SET_SRC (set), 2)) == LABEL_REF - && XEXP (XEXP (SET_SRC (set), 2), 0) == JUMP_LABEL (if_info->jump); + && LABEL_REF_LABEL (XEXP (SET_SRC (set), 2)) == JUMP_LABEL (if_info->jump); if (if_info->then_else_reversed) reverse = !reverse; @@ -2351,7 +2351,7 @@ noce_get_condition (rtx_insn *jump, rtx_insn **earliest, bool then_else_reversed /* If this branches to JUMP_LABEL when the condition is false, reverse the condition. */ reverse = (GET_CODE (XEXP (SET_SRC (set), 2)) == LABEL_REF - && XEXP (XEXP (SET_SRC (set), 2), 0) == JUMP_LABEL (jump)); + && LABEL_REF_LABEL (XEXP (SET_SRC (set), 2)) == JUMP_LABEL (jump)); /* We may have to reverse because the caller's if block is not canonical, i.e. the THEN block isn't the fallthrough block for the TEST block diff --git a/gcc/jump.c b/gcc/jump.c index ef2f9e5..34466b6 100644 --- a/gcc/jump.c +++ b/gcc/jump.c @@ -264,7 +264,7 @@ maybe_propagate_label_ref (rtx_insn *jump_insn, rtx_insn *prev_nonjump_insn) CODE_LABEL in the LABEL_REF of the "set". We can conveniently use it for the marker function, which requires a LABEL_REF wrapping. */ - gcc_assert (XEXP (label_note, 0) == XEXP (SET_SRC (label_set), 0)); + gcc_assert (XEXP (label_note, 0) == LABEL_REF_LABEL (SET_SRC (label_set))); mark_jump_label_1 (label_set, jump_insn, false, true); @@ -1141,7 +1141,7 @@ mark_jump_label_1 (rtx x, rtx insn, bool in_mem, bool is_target) case LABEL_REF: { - rtx label = XEXP (x, 0); + rtx label = LABEL_REF_LABEL (x); /* Ignore remaining references to unreachable labels that have been deleted. */ @@ -1155,7 +1155,7 @@ mark_jump_label_1 (rtx x, rtx insn, bool in_mem, bool is_target) if (LABEL_REF_NONLOCAL_P (x)) break; - XEXP (x, 0) = label; + LABEL_REF_LABEL (x) = label; if (! insn || ! INSN_DELETED_P (insn)) ++LABEL_NUSES (label); @@ -1454,7 +1454,7 @@ redirect_exp_1 (rtx *loc, rtx olabel, rtx nlabel, rtx insn) int i; const char *fmt; - if ((code == LABEL_REF && XEXP (x, 0) == olabel) + if ((code == LABEL_REF && LABEL_REF_LABEL (x) == olabel) || x == olabel) { x = redirect_target (nlabel); @@ -1467,7 +1467,7 @@ redirect_exp_1 (rtx *loc, rtx olabel, rtx nlabel, rtx insn) if (code == SET && SET_DEST (x) == pc_rtx && ANY_RETURN_P (nlabel) && GET_CODE (SET_SRC (x)) == LABEL_REF - && XEXP (SET_SRC (x), 0) == olabel) + && LABEL_REF_LABEL (SET_SRC (x)) == olabel) { validate_change (insn, loc, nlabel, 1); return; @@ -1791,12 +1791,12 @@ rtx_renumbered_equal_p (const_rtx x, const_rtx y) case LABEL_REF: /* We can't assume nonlocal labels have their following insns yet. */ if (LABEL_REF_NONLOCAL_P (x) || LABEL_REF_NONLOCAL_P (y)) - return XEXP (x, 0) == XEXP (y, 0); + return LABEL_REF_LABEL (x) == LABEL_REF_LABEL (y); /* Two label-refs are equivalent if they point at labels in the same position in the instruction stream. */ - return (next_real_insn (XEXP (x, 0)) - == next_real_insn (XEXP (y, 0))); + return (next_real_insn (LABEL_REF_LABEL (x)) + == next_real_insn (LABEL_REF_LABEL (y))); case SYMBOL_REF: return XSTR (x, 0) == XSTR (y, 0); diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index d848954..5f68399 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -735,7 +735,7 @@ operands_match_p (rtx x, rtx y, int y_hard_regno) return false; case LABEL_REF: - return XEXP (x, 0) == XEXP (y, 0); + return LABEL_REF_LABEL (x) == LABEL_REF_LABEL (y); case SYMBOL_REF: return XSTR (x, 0) == XSTR (y, 0); diff --git a/gcc/reload.c b/gcc/reload.c index 529cd14..3e563d0 100644 --- a/gcc/reload.c +++ b/gcc/reload.c @@ -2321,7 +2321,7 @@ operands_match_p (rtx x, rtx y) return 0; case LABEL_REF: - return XEXP (x, 0) == XEXP (y, 0); + return LABEL_REF_LABEL (x) == LABEL_REF_LABEL (y); case SYMBOL_REF: return XSTR (x, 0) == XSTR (y, 0); @@ -4221,16 +4221,17 @@ find_reloads (rtx_insn *insn, int replace, int ind_levels, int live_known, this instruction. */ if (GET_CODE (substitution) == LABEL_REF && !find_reg_note (insn, REG_LABEL_OPERAND, - XEXP (substitution, 0)) + LABEL_REF_LABEL (substitution)) /* For a JUMP_P, if it was a branch target it must have already been recorded as such. */ && (!JUMP_P (insn) - || !label_is_jump_target_p (XEXP (substitution, 0), + || !label_is_jump_target_p (LABEL_REF_LABEL (substitution), insn))) { - add_reg_note (insn, REG_LABEL_OPERAND, XEXP (substitution, 0)); - if (LABEL_P (XEXP (substitution, 0))) - ++LABEL_NUSES (XEXP (substitution, 0)); + add_reg_note (insn, REG_LABEL_OPERAND, + LABEL_REF_LABEL (substitution)); + if (LABEL_P (LABEL_REF_LABEL (substitution))) + ++LABEL_NUSES (LABEL_REF_LABEL (substitution)); } } diff --git a/gcc/reload1.c b/gcc/reload1.c index f09f8b7..3f3541a 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -2358,7 +2358,7 @@ set_label_offsets (rtx x, rtx_insn *insn, int initial_p) if (LABEL_REF_NONLOCAL_P (x)) return; - x = XEXP (x, 0); + x = LABEL_REF_LABEL (x); /* ... fall through ... */ @@ -2460,13 +2460,13 @@ set_label_offsets (rtx x, rtx_insn *insn, int initial_p) case IF_THEN_ELSE: tem = XEXP (SET_SRC (x), 1); if (GET_CODE (tem) == LABEL_REF) - set_label_offsets (XEXP (tem, 0), insn, initial_p); + set_label_offsets (LABEL_REF_LABEL (tem), insn, initial_p); else if (GET_CODE (tem) != PC && GET_CODE (tem) != RETURN) break; tem = XEXP (SET_SRC (x), 2); if (GET_CODE (tem) == LABEL_REF) - set_label_offsets (XEXP (tem, 0), insn, initial_p); + set_label_offsets (LABEL_REF_LABEL (tem), insn, initial_p); else if (GET_CODE (tem) != PC && GET_CODE (tem) != RETURN) break; return; diff --git a/gcc/reorg.c b/gcc/reorg.c index c37ae1e..28401dd 100644 --- a/gcc/reorg.c +++ b/gcc/reorg.c @@ -923,20 +923,20 @@ get_branch_condition (const rtx_insn *insn, rtx target) return 0; src = SET_SRC (pat); - if (GET_CODE (src) == LABEL_REF && XEXP (src, 0) == target) + if (GET_CODE (src) == LABEL_REF && LABEL_REF_LABEL (src) == target) return const_true_rtx; else if (GET_CODE (src) == IF_THEN_ELSE && XEXP (src, 2) == pc_rtx && ((GET_CODE (XEXP (src, 1)) == LABEL_REF - && XEXP (XEXP (src, 1), 0) == target) + && LABEL_REF_LABEL (XEXP (src, 1)) == target) || (ANY_RETURN_P (XEXP (src, 1)) && XEXP (src, 1) == target))) return XEXP (src, 0); else if (GET_CODE (src) == IF_THEN_ELSE && XEXP (src, 1) == pc_rtx && ((GET_CODE (XEXP (src, 2)) == LABEL_REF - && XEXP (XEXP (src, 2), 0) == target) + && LABEL_REF_LABEL (XEXP (src, 2)) == target) || (ANY_RETURN_P (XEXP (src, 2)) && XEXP (src, 2) == target))) { enum rtx_code rev; diff --git a/gcc/rtl.c b/gcc/rtl.c index 3363eeb..c61c365 100644 --- a/gcc/rtl.c +++ b/gcc/rtl.c @@ -422,7 +422,7 @@ rtx_equal_p_cb (const_rtx x, const_rtx y, rtx_equal_p_callback_function cb) return (REGNO (x) == REGNO (y)); case LABEL_REF: - return XEXP (x, 0) == XEXP (y, 0); + return LABEL_REF_LABEL (x) == LABEL_REF_LABEL (y); case SYMBOL_REF: return XSTR (x, 0) == XSTR (y, 0); @@ -559,7 +559,7 @@ rtx_equal_p (const_rtx x, const_rtx y) return (REGNO (x) == REGNO (y)); case LABEL_REF: - return XEXP (x, 0) == XEXP (y, 0); + return LABEL_REF_LABEL (x) == LABEL_REF_LABEL (y); case SYMBOL_REF: return XSTR (x, 0) == XSTR (y, 0); diff --git a/gcc/rtl.h b/gcc/rtl.h index 56a06e1..aaca3dc 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -1673,6 +1673,10 @@ inline rtx_insn *JUMP_LABEL_AS_INSN (const rtx_insn *insn) goes through all the LABEL_REFs that jump to that label. The chain eventually winds up at the CODE_LABEL: it is circular. */ #define LABEL_REFS(LABEL) XCEXP (LABEL, 3, CODE_LABEL) + +/* Get the label that a LABEL_REF references. */ +#define LABEL_REF_LABEL(LABREF) XCEXP (LABREF, 0, LABEL_REF) + /* For a REG rtx, REGNO extracts the register number. REGNO can only be used on RHS. Use SET_REGNO to change the value. */ diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index d3a3e02..299b816 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -785,7 +785,7 @@ reg_mentioned_p (const_rtx reg, const_rtx in) return 1; if (GET_CODE (in) == LABEL_REF) - return reg == XEXP (in, 0); + return reg == LABEL_REF_LABEL (in); code = GET_CODE (in); @@ -2847,7 +2847,9 @@ rtx_referenced_p (const_rtx x, const_rtx body) if (const_rtx y = *iter) { /* Check if a label_ref Y refers to label X. */ - if (GET_CODE (y) == LABEL_REF && LABEL_P (x) && XEXP (y, 0) == x) + if (GET_CODE (y) == LABEL_REF + && LABEL_P (x) + && LABEL_REF_LABEL (y) == x) return true; if (rtx_equal_p (x, y)) @@ -5320,7 +5322,7 @@ get_condition (rtx_insn *jump, rtx_insn **earliest, int allow_cc_mode, the condition. */ reverse = GET_CODE (XEXP (SET_SRC (set), 2)) == LABEL_REF - && XEXP (XEXP (SET_SRC (set), 2), 0) == JUMP_LABEL (jump); + && LABEL_REF_LABEL (XEXP (SET_SRC (set), 2)) == JUMP_LABEL (jump); return canonicalize_condition (jump, cond, reverse, earliest, NULL_RTX, allow_cc_mode, valid_at_insn_p); diff --git a/gcc/sched-vis.c b/gcc/sched-vis.c index 1dca799..dabe880 100644 --- a/gcc/sched-vis.c +++ b/gcc/sched-vis.c @@ -468,7 +468,7 @@ print_value (pretty_printer *pp, const_rtx x, int verbose) pp_printf (pp, "`%s'", XSTR (x, 0)); break; case LABEL_REF: - pp_printf (pp, "L%d", INSN_UID (XEXP (x, 0))); + pp_printf (pp, "L%d", INSN_UID (LABEL_REF_LABEL (x))); break; case CONST: case HIGH: diff --git a/gcc/varasm.c b/gcc/varasm.c index de4479c..cd4a230 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -2922,7 +2922,8 @@ const_hash_1 (const tree exp) break; case LABEL_REF: - hi = value.offset + CODE_LABEL_NUMBER (XEXP (value.base, 0)) * 13; + hi = (value.offset + + CODE_LABEL_NUMBER (LABEL_REF_LABEL (value.base)) * 13); break; default: @@ -3112,8 +3113,8 @@ compare_constant (const tree t1, const tree t2) break; case LABEL_REF: - ret = (CODE_LABEL_NUMBER (XEXP (value1.base, 0)) - == CODE_LABEL_NUMBER (XEXP (value2.base, 0))); + ret = (CODE_LABEL_NUMBER (LABEL_REF_LABEL (value1.base)) + == CODE_LABEL_NUMBER (LABEL_REF_LABEL (value2.base))); break; default: @@ -3547,7 +3548,7 @@ const_rtx_hash_1 (const_rtx x) break; case LABEL_REF: - h = h * 251 + CODE_LABEL_NUMBER (XEXP (x, 0)); + h = h * 251 + CODE_LABEL_NUMBER (LABEL_REF_LABEL (x)); break; case UNSPEC: @@ -3835,7 +3836,7 @@ output_constant_pool_1 (struct constant_descriptor_rtx *desc, /* FALLTHRU */ case LABEL_REF: - tmp = XEXP (tmp, 0); + tmp = LABEL_REF_LABEL (tmp); gcc_assert (!INSN_DELETED_P (tmp)); gcc_assert (!NOTE_P (tmp) || NOTE_KIND (tmp) != NOTE_INSN_DELETED); -- 1.8.5.3