MIPS: default output r6 obj if the triple is r6
authorYunQiang Su <yunqiang.su@cipunited.com>
Tue, 18 Apr 2023 13:49:22 +0000 (21:49 +0800)
committerYunQiang Su <yunqiang.su@cipunited.com>
Sun, 23 Apr 2023 06:32:43 +0000 (14:32 +0800)
If the triple is mipsisa32r6* or mipsisa64r6*, ld/as should output
r6 objects by default.
The triples with vendor `img` should do same.

The examples include:
as xx.s -o xx.o
ld -r -b binary xx.dat -o xx.o

bfd/config.bfd
bfd/elfxx-mips.c
bfd/elfxx-mips.h
gas/configure
gas/configure.ac

index 1e4bea191dd80ccd838c1fed2ba006e266869468..78752994456204a3c1184f9bca457f2d966afc29 100644 (file)
@@ -1535,3 +1535,9 @@ case "${targ_defvec} ${targ_selvecs}" in
     targ_archs="$targ_archs bfd_iamcu_arch"
     ;;
 esac
+
+case "${targ}" in
+  mipsisa32r6* | mipsisa64r6* | mips*-img-*)
+    targ_cflags="$targ_cflags -DMIPS_DEFAULT_R6=1"
+    ;;
+esac
index 13a89953293380c12bb4d02a52df360848fca2d4..c9cd2f8099f30e24a8353eaf3d61c4905cd5fcac 100644 (file)
@@ -12327,9 +12327,9 @@ mips_set_isa_flags (bfd *abfd)
     {
     default:
       if (ABI_N32_P (abfd) || ABI_64_P (abfd))
-        val = E_MIPS_ARCH_3;
+        val = MIPS_DEFAULT_R6 ? E_MIPS_ARCH_64R6 : E_MIPS_ARCH_3;
       else
-        val = E_MIPS_ARCH_1;
+        val = MIPS_DEFAULT_R6 ? E_MIPS_ARCH_32R6 : E_MIPS_ARCH_1;
       break;
 
     case bfd_mach_mips3000:
index 4addf6f5d1abb65f40c31a0667e2ba3a9132c5ac..f15dceac48e62c18bcb3c805cdc12231da290133 100644 (file)
@@ -29,6 +29,10 @@ enum reloc_check
   check_shuffle
 };
 
+#ifndef MIPS_DEFAULT_R6
+#define MIPS_DEFAULT_R6 0
+#endif
+
 extern bool _bfd_mips_elf_mkobject
   (bfd *);
 extern bool _bfd_mips_elf_close_and_cleanup
index 868f4a911a9d261c18afeefb70726e46e56d04af..0daa80d5b4cb5e03f4d8f5a8170c23df3dbc3a18 100755 (executable)
@@ -12211,6 +12211,15 @@ _ACEOF
            use_e_mips_abi_o32=1
            ;;
        esac
+       # If Vendor is IMG, then MIPSr6 is used
+       case ${target} in
+         mips*64*-img-*)
+           mips_cpu=mips64r6
+           ;;
+         mips*-img-*)
+           mips_cpu=mips32r6
+           ;;
+       esac
        # Decide whether to generate 32-bit or 64-bit code by default.
        # Used to resolve -march=from-abi when an embedded ABI is selected.
        case ${target} in
index 03728ffce4de1285696577b933c734bf53d01380..2b91f9ec6167325904ca17d540b64cd6a57602d1 100644 (file)
@@ -380,6 +380,15 @@ changequote([,])dnl
            use_e_mips_abi_o32=1
            ;;
        esac
+       # If Vendor is IMG, then MIPSr6 is used
+       case ${target} in
+         mips*64*-img-*)
+           mips_cpu=mips64r6
+           ;;
+         mips*-img-*)
+           mips_cpu=mips32r6
+           ;;
+       esac
        # Decide whether to generate 32-bit or 64-bit code by default.
        # Used to resolve -march=from-abi when an embedded ABI is selected.
        case ${target} in