This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: MIPS JAL/JALR to BAL transformation for Linux (o32 ABI)


Richard Sandiford wrote:
> "Fu, Chao-Ying" <fu@mips.com> writes:
> > @@ -5590,11 +5601,12 @@ mips_elf_perform_relocation (struct bfd_
> >       prediction hardware.  If we are linking for the RM9000, and we
> >       see jal, and bal fits, use it instead.  Note that this
> >       transformation should be safe for all architectures.  */
> 
> You need to update this comment too.  With the new macros, it can
> be a lot simpler, such as:
> 
>   /* Try converting JAL and JALR to BAL, if the target is in 
> range.  */

  Yes.

> 
> > -  if (bfd_get_mach (input_bfd) == bfd_mach_mips9000
> > -      && !info->relocatable
> > +  if (!info->relocatable
> >        && !require_jalx
> > -      && ((r_type == R_MIPS_26 && (x >> 26) == 0x3)	
>     /* jal addr */
> > -	  || (r_type == R_MIPS_JALR && x == 0x0320f809)))   /* 
> jalr t9 */
> > +      && ((JAL_TO_BAL_P (input_bfd)
> > +	   && (r_type == R_MIPS_26 && (x >> 26) == 0x3))	
> /* jal addr */
> > +	  || (JALR_TO_BAL_P (input_bfd) && (r_type == R_MIPS_JALR
> > +	      && x == 0x0320f809))))	/* jalr t9 */
> 
> Odd formatting.  I think it should be:
> 
>   if (!info->relocatable
>       && !require_jalx
>       && ((JAL_TO_BAL_P (input_bfd)
> 	   && r_type == R_MIPS_26
> 	   && (x >> 26) == 0x3)		/* jal addr */
> 	  || (JALR_TO_BAL_P (input_bfd)
> 	      && r_type == R_MIPS_JALR
> 	      && x == 0x0320f809)))	/* jalr t9 */

  Yes.

> More importantly, I think we should be checking the output_bfd
> rather than the input bfd.  E.g. if you were linking legacy MIPS 3
> n32 objects with MIPS64 objects, you'd want the MIPS64-related
> optimisations to be applied to both.
> 
> Looks good to me with those changes.

  Yes, I checked in the patch with the first two changes.  

  To check output_bfd, we need to add a new parameter of output_bfd to
mips_elf_perform_relocation.  But now because JALR_TO_BAL_P is true for all
and JAL_TO_BAL_P is true for RM9000, checking input_bfd should be the same
as checking output_bfd for non-RM9000 objects.  We still can change to check
output_bfd later.  Thanks a lot!

Regards,
Chao-ying


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]