This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Unbreak md_estimate_size_before_relax for multi-pass relaxation, committed (tc-cris.c)
- To: binutils at sources dot redhat dot com
- Subject: Unbreak md_estimate_size_before_relax for multi-pass relaxation, committed (tc-cris.c)
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- Date: Wed, 4 Apr 2001 05:58:51 +0200
It is now necessary to set fr_var according to fr_subtype also
for other than the initially unknown state, or at least return
the corresponding value; the "we don't need to do anything"
comment is wrong. Or maybe relax_frag in write.c should adjust
fr_var. From the "Multi-pass relaxation (Break lots of ports)"
patch, it looks like at least tc-h8500.c, tc-mcore.c, tc-sh.c
and tc-w65.c need corresponding tweaks.
Patch sent here hoping to help other maintainers. The gist of
this patch is in the last hunk; the rest is mostly cleanups.
* config/tc-cris.c (md_estimate_size_before_relax) <case
ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_UNDF)>: Don't emit
32-bit branch, just set fragP->fr_subtype. Set fragP->fr_var.
<all cases>: Always set fragP->fr_var using md_cris_relax_table.
Add cases to cover all relax states.
Index: tc-cris.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-cris.c,v
retrieving revision 1.13
diff -p -c -r1.13 tc-cris.c
*** tc-cris.c 2001/03/30 00:06:10 1.13
--- tc-cris.c 2001/04/04 03:15:41
*************** md_estimate_size_before_relax (fragP, se
*** 357,391 ****
{
case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_UNDF):
if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type)
! {
! /* The symbol lies in the same segment - a relaxable case. */
! fragP->fr_subtype
! = ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_BYTE);
! }
else
! {
! /* Unknown or not the same segment, so not relaxable. */
! char *writep;
!
! /* A small branch-always (2 bytes) to the "real" branch
! instruction, plus a delay-slot nop (2 bytes), plus a
! jump (2 plus 4 bytes). See gen_cond_branch_32. */
! fragP->fr_fix += 2 + 2 + 2 + 4;
! writep = fragP->fr_literal + old_fr_fix;
! gen_cond_branch_32 (fragP->fr_opcode, writep, fragP,
! fragP->fr_symbol, (symbolS *) NULL,
! fragP->fr_offset);
! frag_wane (fragP);
! }
break;
- case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_BYTE):
- case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_WORD):
- /* We *might* give a better initial guess if we peek at offsets
- now, but the caller will relax correctly and without this, so
- don't bother. */
- break;
-
case ENCODE_RELAX (STATE_BASE_PLUS_DISP_PREFIX, STATE_UNDF):
/* Note that we can not do anything sane with relaxing
[rX + a_known_symbol_in_text], it will have to be a 32-bit
--- 357,372 ----
{
case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_UNDF):
if (S_GET_SEGMENT (fragP->fr_symbol) == segment_type)
! /* The symbol lies in the same segment - a relaxable case. */
! fragP->fr_subtype
! = ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_BYTE);
else
! /* Unknown or not the same segment, so not relaxable. */
! fragP->fr_subtype
! = ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_DWORD);
! fragP->fr_var = md_cris_relax_table[fragP->fr_subtype].rlx_length;
break;
case ENCODE_RELAX (STATE_BASE_PLUS_DISP_PREFIX, STATE_UNDF):
/* Note that we can not do anything sane with relaxing
[rX + a_known_symbol_in_text], it will have to be a 32-bit
*************** md_estimate_size_before_relax (fragP, se
*** 402,408 ****
/* Go for dword if not absolute or same segment. */
fragP->fr_subtype
= ENCODE_RELAX (STATE_BASE_PLUS_DISP_PREFIX, STATE_DWORD);
! fragP->fr_var += 4;
}
else
{
--- 383,389 ----
/* Go for dword if not absolute or same segment. */
fragP->fr_subtype
= ENCODE_RELAX (STATE_BASE_PLUS_DISP_PREFIX, STATE_DWORD);
! fragP->fr_var = md_cris_relax_table[fragP->fr_subtype].rlx_length;
}
else
{
*************** md_estimate_size_before_relax (fragP, se
*** 445,453 ****
}
break;
case ENCODE_RELAX (STATE_BASE_PLUS_DISP_PREFIX, STATE_DWORD):
/* When relaxing a section for the second time, we don't need to
! do anything. */
break;
default:
--- 426,440 ----
}
break;
+ case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_BYTE):
+ case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_WORD):
+ case ENCODE_RELAX (STATE_CONDITIONAL_BRANCH, STATE_DWORD):
+ case ENCODE_RELAX (STATE_BASE_PLUS_DISP_PREFIX, STATE_BYTE):
+ case ENCODE_RELAX (STATE_BASE_PLUS_DISP_PREFIX, STATE_WORD):
case ENCODE_RELAX (STATE_BASE_PLUS_DISP_PREFIX, STATE_DWORD):
/* When relaxing a section for the second time, we don't need to
! do anything except making sure that fr_var is set right. */
! fragP->fr_var = md_cris_relax_table[fragP->fr_subtype].rlx_length;
break;
default:
brgds, H-P