From f32360c7226f7216f67970073a98cca0705a529d Mon Sep 17 00:00:00 2001 From: Vladimir Makarov Date: Wed, 9 Apr 2003 18:50:03 +0000 Subject: [PATCH] ia64.c (issue_nops_and_insn): Add new parameter. 2003-04-09 Vladimir Makarov * config/ia64/ia64.c (issue_nops_and_insn): Add new parameter. Check that asm insn starts on a new cycle. Add nops after asm insn to end bundle. (bundling): Move insn type evaluation from the loop. Call issue_nops_and_insn with the new parameter. Ignore changing position for nops after asm insn. From-SVN: r65401 --- gcc/ChangeLog | 9 ++++ gcc/config/ia64/ia64.c | 97 +++++++++++++++++++++++++----------------- 2 files changed, 68 insertions(+), 38 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 62a4853972c..21a02490315 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2003-04-09 Vladimir Makarov + + * config/ia64/ia64.c (issue_nops_and_insn): Add new parameter. + Check that asm insn starts on a new cycle. Add nops after asm + insn to end bundle. + (bundling): Move insn type evaluation from the loop. Call + issue_nops_and_insn with the new parameter. Ignore changing + position for nops after asm insn. + 2003-04-09 Alexandre Oliva * optabs.c: Comment that gen_add2_insn and others may actually diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index 0f14818e716..bbcd90dcae0 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -230,7 +230,7 @@ static void finish_bundle_state_table PARAMS ((void)); static int try_issue_nops PARAMS ((struct bundle_state *, int)); static int try_issue_insn PARAMS ((struct bundle_state *, rtx)); static void issue_nops_and_insn PARAMS ((struct bundle_state *, int, - rtx, int)); + rtx, int, int)); static int get_max_pos PARAMS ((state_t)); static int get_template PARAMS ((state_t, int)); @@ -6316,17 +6316,18 @@ try_issue_insn (curr_state, insn) /* The following function tries to issue BEFORE_NOPS_NUM nops and INSN starting with ORIGINATOR without advancing processor cycle. If - TRY_BUNDLE_END_P is TRUE, the function also tries to issue nops to - fill all bundle. If it was successful, the function creates new - bundle state and insert into the hash table and into - `index_to_bundle_states'. */ + TRY_BUNDLE_END_P is TRUE, the function also/only (if + ONLY_BUNDLE_END_P is TRUE) tries to issue nops to fill all bundle. + If it was successful, the function creates new bundle state and + insert into the hash table and into `index_to_bundle_states'. */ static void -issue_nops_and_insn (originator, before_nops_num, insn, try_bundle_end_p) +issue_nops_and_insn (originator, before_nops_num, insn, try_bundle_end_p, + only_bundle_end_p) struct bundle_state *originator; int before_nops_num; rtx insn; - int try_bundle_end_p; + int try_bundle_end_p, only_bundle_end_p; { struct bundle_state *curr_state; @@ -6365,9 +6366,10 @@ issue_nops_and_insn (originator, before_nops_num, insn, try_bundle_end_p) return; if (!try_issue_insn (curr_state, insn)) return; - if (GET_CODE (PATTERN (insn)) != ASM_INPUT - && asm_noperands (PATTERN (insn)) < 0) - curr_state->accumulated_insns_num++; + curr_state->accumulated_insns_num++; + if (GET_CODE (PATTERN (insn)) == ASM_INPUT + || asm_noperands (PATTERN (insn)) >= 0) + abort (); if (ia64_safe_type (insn) == TYPE_L) curr_state->accumulated_insns_num++; } @@ -6380,10 +6382,17 @@ issue_nops_and_insn (originator, before_nops_num, insn, try_bundle_end_p) return; if (!try_issue_insn (curr_state, insn)) return; - if (GET_CODE (PATTERN (insn)) != ASM_INPUT - && asm_noperands (PATTERN (insn)) < 0) - curr_state->accumulated_insns_num++; - if (ia64_safe_type (insn) == TYPE_L) + curr_state->accumulated_insns_num++; + if (GET_CODE (PATTERN (insn)) == ASM_INPUT + || asm_noperands (PATTERN (insn)) >= 0) + { + /* Finish bundle containing asm insn. */ + curr_state->after_nops_num + = 3 - curr_state->accumulated_insns_num % 3; + curr_state->accumulated_insns_num + += 3 - curr_state->accumulated_insns_num % 3; + } + else if (ia64_safe_type (insn) == TYPE_L) curr_state->accumulated_insns_num++; } if (ia64_safe_type (insn) == TYPE_B) @@ -6391,7 +6400,7 @@ issue_nops_and_insn (originator, before_nops_num, insn, try_bundle_end_p) += 2 - (curr_state->accumulated_insns_num - 1) % 3; if (try_bundle_end_p && curr_state->accumulated_insns_num % 3 != 0) { - if (insert_bundle_state (curr_state)) + if (!only_bundle_end_p && insert_bundle_state (curr_state)) { state_t dfa_state; struct bundle_state *curr_state1; @@ -6538,7 +6547,7 @@ bundling (dump, verbose, prev_head_insn, tail) struct bundle_state *curr_state, *next_state, *best_state; rtx insn, next_insn; int insn_num; - int i, bundle_end_p; + int i, bundle_end_p, only_bundle_end_p, asm_p; int pos, max_pos, template0, template1; rtx b; rtx nop; @@ -6602,6 +6611,7 @@ bundling (dump, verbose, prev_head_insn, tail) || GET_CODE (PATTERN (insn)) == USE || GET_CODE (PATTERN (insn)) == CLOBBER) abort (); + type = ia64_safe_type (insn); next_insn = get_next_important_insn (NEXT_INSN (insn), tail); insn_num++; index_to_bundle_states [insn_num] = NULL; @@ -6610,10 +6620,15 @@ bundling (dump, verbose, prev_head_insn, tail) curr_state = next_state) { pos = curr_state->accumulated_insns_num % 3; - type = ia64_safe_type (insn); next_state = curr_state->next; + /* Finish the current bundle in order to start a subsequent + asm insn in a new bundle. */ + only_bundle_end_p + = (next_insn != NULL_RTX + && INSN_CODE (insn) == CODE_FOR_insn_group_barrier + && ia64_safe_type (next_insn) == TYPE_UNKNOWN); bundle_end_p - = (next_insn == NULL_RTX + = (only_bundle_end_p || next_insn == NULL_RTX || (GET_MODE (next_insn) == TImode && INSN_CODE (insn) != CODE_FOR_insn_group_barrier)); if (type == TYPE_F || type == TYPE_B || type == TYPE_L @@ -6621,9 +6636,12 @@ bundling (dump, verbose, prev_head_insn, tail) /* We need to insert 2 Nops for cases like M_MII. */ || (type == TYPE_M && ia64_tune == PROCESSOR_ITANIUM && !bundle_end_p && pos == 1)) - issue_nops_and_insn (curr_state, 2, insn, bundle_end_p); - issue_nops_and_insn (curr_state, 1, insn, bundle_end_p); - issue_nops_and_insn (curr_state, 0, insn, bundle_end_p); + issue_nops_and_insn (curr_state, 2, insn, bundle_end_p, + only_bundle_end_p); + issue_nops_and_insn (curr_state, 1, insn, bundle_end_p, + only_bundle_end_p); + issue_nops_and_insn (curr_state, 0, insn, bundle_end_p, + only_bundle_end_p); } if (index_to_bundle_states [insn_num] == NULL) abort (); @@ -6680,6 +6698,8 @@ bundling (dump, verbose, prev_head_insn, tail) curr_state = curr_state->originator) { insn = curr_state->insn; + asm_p = (GET_CODE (PATTERN (insn)) == ASM_INPUT + || asm_noperands (PATTERN (insn)) >= 0); insn_num++; if (verbose >= 2 && dump) { @@ -6724,23 +6744,24 @@ bundling (dump, verbose, prev_head_insn, tail) template1 = get_template (curr_state->dfa_state, 3); pos += 3; } - for (i = 0; i < curr_state->after_nops_num; i++) - { - nop = gen_nop (); - emit_insn_after (nop, insn); - pos--; - if (pos < 0) - abort (); - if (pos % 3 == 0) - { - if (template0 < 0) - abort (); - b = gen_bundle_selector (GEN_INT (template0)); - ia64_emit_insn_before (b, nop); - template0 = template1; - template1 = -1; - } - } + if (!asm_p) + for (i = 0; i < curr_state->after_nops_num; i++) + { + nop = gen_nop (); + emit_insn_after (nop, insn); + pos--; + if (pos < 0) + abort (); + if (pos % 3 == 0) + { + if (template0 < 0) + abort (); + b = gen_bundle_selector (GEN_INT (template0)); + ia64_emit_insn_before (b, nop); + template0 = template1; + template1 = -1; + } + } if (INSN_CODE (insn) != CODE_FOR_insn_group_barrier && GET_CODE (PATTERN (insn)) != ASM_INPUT && asm_noperands (PATTERN (insn)) < 0)