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)


"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.  */

> -  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 */

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.

Richard


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