From 4dea3bff792b49a1eb72ee9ef15d7961fa9150c8 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 13 Jun 2018 13:43:32 +0000 Subject: emit-rtl.c: more typesafety This patch converts various rtx to rtx_insn * (or rtx_code_label *). It also convert the various "_loc" params from int to location_t gcc/ChangeLog: * config/arc/arc.c (hwloop_optimize): Strengthen local "end_label" from rtx to rtx_insn *. * config/bfin/bfin.c (hwloop_optimize): Likewise for local "label". (add_sched_insns_for_speculation): Likewise for local "target", converting usage of JUMP_LABEL to JUMP_LABEL_AS_INSN. * config/c6x/c6x.c (reorg_split_calls): Strengthen param "call_labels" from rtx_insn ** to rtx_code_label **. (reorg_emit_nops): Likewise. (c6x_reorg): Likewise for local "call_labels". * config/sh/sh-protos.h (get_dest_uid): Strengthen 1st param from rtx to rtx_insn *. * config/sh/sh.c (dump_table): Strengthen local "lab" from rtx to rtx_code_label *, adding safe_as_a casts to the loops over LABEL_REFS. (fixup_addr_diff_vecs): Add as_a to usage of braf_label. (barrier_align): Convert usage of JUMP_LABEL to JUMP_LABEL_AS_INSN. (get_dest_uid): Strengthen param "label" from rtx to rtx_insn *. (split_branches): Strengthen local "olabel" from rtx to rtx_insn *, adding a safe_as_a cast. * emit-rtl.c (next_real_insn): Strengthen param from "rtx" to "rtx_insn *". (add_insn_after): Likewise for first two params. (add_insn_before): Likewise. (remove_insn): Likewise for param. (emit_pattern_before_noloc): Likewise for second and third params. (emit_jump_insn_before_noloc): Convert NULL_RTX to NULL. (emit_call_insn_before_noloc): Likewise. (emit_debug_insn_before_noloc): Strengthen "before" param from "rtx" to "rtx_insn *". (emit_barrier_before): Likewise. (emit_label_before): Strengthen "label" param from "rtx" to "rtx_code_label *". Strengthen "before" param from "rtx" to "rtx_insn *". (emit_insn_after_1): Strengthen "after" param from "rtx" to "rtx_insn *". (emit_pattern_after_noloc): Likewise. (emit_insn_after_noloc): Likewise. (emit_jump_insn_after_noloc): Likewise. (emit_call_insn_after_noloc): Likewise. (emit_debug_insn_after_noloc): Likewise. (emit_barrier_after): Likewise. (emit_label_after): Likewise for both params. (emit_pattern_after_setloc): Likewise for "after" param. Convert "loc" param from "int" to "location_t". (emit_insn_after_setloc): Likewise. (emit_jump_insn_after_setloc): Likewise. (emit_call_insn_after_setloc): Likewise. (emit_debug_insn_after_setloc): Likewise. (emit_pattern_before_setloc): Likewise for "before" param. Convert "loc" param from "int" to "location_t". (emit_pattern_before): Convert NULL_RTX to NULL. (emit_insn_before_setloc): Convert "loc" param from "int" to "location_t". (emit_jump_insn_before_setloc): Likewise. (emit_call_insn_before_setloc): Likewise. (emit_debug_insn_before_setloc): Strengthen "before" param from rtx to rtx_insn *. Convert "loc" param from "int" to "location_t". * rtl.h (emit_insn_before_setloc, emit_jump_insn_before_setloc, emit_call_insn_before_setloc, emit_debug_insn_before_setloc): Convert 3rd param from "int" to "location_t". (emit_barrier_before, emit_barrier_after, next_real_insn): Strengthen param from rtx to rtx_insn *. (emit_label_before): Strengthen 1st param from "rtx" to "rtx_code_label *". Strengthen 2nd param from "rtx" to "rtx_insn *". (emit_insn_after_noloc, emit_jump_insn_after_noloc, emit_call_insn_after_noloc, emit_debug_insn_after_noloc): Strengthen 2nd param from "rtx" to "rtx_insn *". (emit_insn_after_setloc, emit_jump_insn_after_setloc) emit_call_insn_after_setloc, emit_debug_insn_after_setloc): Likewise. Convert 3rd param from "int" to "location_t". (emit_label_after): Strengthen 1st param from "rtx" to "rtx_code_label *". (next_real_insn, remove_insn): Strengthen param from "rtx" to "rtx_insn *". (add_insn_before, add_insn_after): Strengthen 1st and 2nd params from "rtx" to "rtx_insn *". From-SVN: r261547 --- gcc/config/sh/sh.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'gcc/config/sh/sh.c') diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index ced6640..5f6fbb3 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -4583,7 +4583,7 @@ dump_table (rtx_insn *start, rtx_insn *barrier) { rtx_insn *scan = barrier; bool need_align = true; - rtx lab; + rtx_code_label *lab; label_ref_list_t ref; bool have_df = false; @@ -4600,7 +4600,8 @@ dump_table (rtx_insn *start, rtx_insn *barrier) scan = emit_insn_after (gen_align_2 (), scan); need_align = false; } - for (lab = p->label; lab; lab = LABEL_REFS (lab)) + for (lab = p->label; lab; + lab = safe_as_a (LABEL_REFS (lab))) scan = emit_label_after (lab, scan); scan = emit_insn_after (gen_consttable_2 (p->value, const0_rtx), scan); @@ -4627,7 +4628,7 @@ dump_table (rtx_insn *start, rtx_insn *barrier) rtx src = SET_SRC (XVECEXP (PATTERN (start), 0, 0)); rtx lab = XEXP (XVECEXP (src, 0, 3), 0); - scan = emit_label_after (lab, scan); + scan = emit_label_after (as_a (lab), scan); } } if (TARGET_FMOVD && TARGET_ALIGN_DOUBLE && have_df) @@ -4650,7 +4651,8 @@ dump_table (rtx_insn *start, rtx_insn *barrier) case E_SFmode: if (align_insn && !p->part_of_sequence_p) { - for (lab = p->label; lab; lab = LABEL_REFS (lab)) + for (lab = p->label; lab; + lab = safe_as_a (LABEL_REFS (lab))) emit_label_before (lab, align_insn); emit_insn_before (gen_consttable_4 (p->value, const0_rtx), align_insn); @@ -4666,7 +4668,8 @@ dump_table (rtx_insn *start, rtx_insn *barrier) } else { - for (lab = p->label; lab; lab = LABEL_REFS (lab)) + for (lab = p->label; lab; + lab = safe_as_a (LABEL_REFS (lab))) scan = emit_label_after (lab, scan); scan = emit_insn_after (gen_consttable_4 (p->value, const0_rtx), scan); @@ -4682,7 +4685,8 @@ dump_table (rtx_insn *start, rtx_insn *barrier) } /* FALLTHRU */ case E_DImode: - for (lab = p->label; lab; lab = LABEL_REFS (lab)) + for (lab = p->label; lab; + lab = safe_as_a (LABEL_REFS (lab))) scan = emit_label_after (lab, scan); scan = emit_insn_after (gen_consttable_8 (p->value, const0_rtx), scan); @@ -4721,7 +4725,8 @@ dump_table (rtx_insn *start, rtx_insn *barrier) scan = emit_label_after (gen_label_rtx (), scan); scan = emit_insn_after (gen_align_4 (), scan); } - for (lab = p->label; lab; lab = LABEL_REFS (lab)) + for (lab = p->label; lab; + lab = safe_as_a (LABEL_REFS (lab))) scan = emit_label_after (lab, scan); scan = emit_insn_after (gen_consttable_4 (p->value, const0_rtx), scan); @@ -4734,7 +4739,8 @@ dump_table (rtx_insn *start, rtx_insn *barrier) scan = emit_label_after (gen_label_rtx (), scan); scan = emit_insn_after (gen_align_4 (), scan); } - for (lab = p->label; lab; lab = LABEL_REFS (lab)) + for (lab = p->label; lab; + lab = safe_as_a (LABEL_REFS (lab))) scan = emit_label_after (lab, scan); scan = emit_insn_after (gen_consttable_8 (p->value, const0_rtx), scan); @@ -5706,7 +5712,7 @@ fixup_addr_diff_vecs (rtx_insn *first) /* Emit the reference label of the braf where it belongs, right after the casesi_jump_2 (i.e. braf). */ braf_label = XEXP (XEXP (SET_SRC (XVECEXP (prevpat, 0, 0)), 1), 0); - emit_label_after (braf_label, prev); + emit_label_after (as_a (braf_label), prev); /* Fix up the ADDR_DIF_VEC to be relative to the reference address of the braf. */ @@ -5810,7 +5816,7 @@ barrier_align (rtx_insn *barrier_or_label) { rtx_insn *x; if (jump_to_next - || next_real_insn (JUMP_LABEL (prev)) == next + || next_real_insn (JUMP_LABEL_AS_INSN (prev)) == next /* If relax_delay_slots() decides NEXT was redundant with some previous instruction, it will have redirected PREV's jump to the following insn. */ @@ -6310,7 +6316,7 @@ sh_reorg (void) /* Return the UID of the insn that follows the specified label. */ int -get_dest_uid (rtx label, int max_uid) +get_dest_uid (rtx_insn *label, int max_uid) { rtx_insn *dest = next_real_insn (label); @@ -6370,7 +6376,7 @@ split_branches (rtx_insn *first) if (get_attr_length (insn) > 4) { rtx src = SET_SRC (PATTERN (insn)); - rtx olabel = XEXP (XEXP (src, 1), 0); + rtx_insn *olabel = safe_as_a (XEXP (XEXP (src, 1), 0)); int addr = INSN_ADDRESSES (INSN_UID (insn)); rtx_insn *label = 0; int dest_uid = get_dest_uid (olabel, max_uid); -- cgit v1.1