[PATCH 1/2] [MIPS] default output as r6 when default target as r6
YunQiang Su
syq@debian.org
Sat Jan 18 14:25:00 GMT 2020
From: YunQiang Su <ysu@wavecomp.com>
currently we find 2 usecases with problem:
1. mipsisa32r6el-linux-gnu-ld -r -b binary xx.dat -o xx.o
the output will be MIPS I, while we expect MIPS32r6.
2. mipsisa32r6el-linux-gnu-as -march=from-abi xx.s
the output will be MIPS I, while we expect MIPS32r6.
---
bfd/config.bfd | 5 +++++
bfd/configure | 1 +
bfd/configure.ac | 1 +
bfd/elfxx-mips.c | 6 ++++++
gas/config.in | 3 +++
gas/config/tc-mips.c | 19 +++++++++++++------
gas/configure | 13 +++++++++++++
gas/configure.ac | 10 ++++++++++
8 files changed, 52 insertions(+), 6 deletions(-)
diff --git a/bfd/config.bfd b/bfd/config.bfd
index b96931f52e..6014a52b57 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -1439,6 +1439,11 @@ case "${targ_defvec} ${targ_selvecs}" in
want64=true
;;
esac
+case "${targ}" in
+ mipsisa32r6* | mipsisa64r6*)
+ mips_default_r6=true
+ ;;
+esac
case "${host64}${want64}" in
*true*)
diff --git a/bfd/configure b/bfd/configure
index a38f215798..8304d37b24 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -14622,6 +14622,7 @@ do
TDEFINES="$TDEFINES $targ_cflags"
fi
done
+test -n "${mips_default_r6}" && TDEFINES="$TDEFINES -DMIPS_DEFAULT_R6=1"
# This processing still needs to be done if we're to decide properly whether
diff --git a/bfd/configure.ac b/bfd/configure.ac
index c5bfbd5d12..e2a2409709 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -358,6 +358,7 @@ do
TDEFINES="$TDEFINES $targ_cflags"
fi
done
+test -n "${mips_default_r6}" && TDEFINES="$TDEFINES -DMIPS_DEFAULT_R6=1"
AC_SUBST(TDEFINES)
# This processing still needs to be done if we're to decide properly whether
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index d7e3aed3b6..98161218df 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -12240,9 +12240,15 @@ mips_set_isa_flags (bfd *abfd)
{
default:
if (ABI_N32_P (abfd) || ABI_64_P (abfd))
+#ifdef MIPS_DEFAULT_R6
+ val = E_MIPS_ARCH_64R6;
+ else
+ val = E_MIPS_ARCH_32R6;
+#else
val = E_MIPS_ARCH_3;
else
val = E_MIPS_ARCH_1;
+#endif
break;
case bfd_mach_mips3000:
diff --git a/gas/config.in b/gas/config.in
index 8724eb153a..d12dba2514 100644
--- a/gas/config.in
+++ b/gas/config.in
@@ -204,6 +204,9 @@
/* Choose a default ABI for MIPS targets. */
#undef MIPS_DEFAULT_ABI
+/* Generate code for MIPSr6 by default on MIPS targets. */
+#undef MIPS_DEFAULT_R6
+
/* Define value for nds32_arch_name */
#undef NDS32_DEFAULT_ARCH_NAME
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index fc6898834e..1e0fa884af 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -9059,7 +9059,7 @@ macro_build (expressionS *ep, const char *name, const char *fmt, ...)
|| *r == BFD_RELOC_HI16_S
|| *r == BFD_RELOC_LO16
|| *r == BFD_RELOC_MIPS_GOT_OFST
- || (mips_opts.micromips
+ || ((mips_opts.micromips || ISA_IS_R6 (mips_opts.isa))
&& (*r == BFD_RELOC_16
|| *r == BFD_RELOC_MIPS_GOT16
|| *r == BFD_RELOC_MIPS_CALL16
@@ -20208,6 +20208,13 @@ static const struct mips_cpu_info *
mips_parse_cpu (const char *option, const char *cpu_string)
{
const struct mips_cpu_info *p;
+#if MIPS_DEFAULT_R6
+ int default_isa32 = ISA_MIPS32R6;
+ int default_isa64 = ISA_MIPS64R6;
+#else
+ int default_isa32 = ISA_MIPS1;
+ int default_isa64 = ISA_MIPS3;
+#endif
/* 'from-abi' selects the most compatible architecture for the given
ABI: MIPS I for 32-bit ABIs and MIPS III for 64-bit ABIs. For the
@@ -20222,18 +20229,18 @@ mips_parse_cpu (const char *option, const char *cpu_string)
if (strcasecmp (cpu_string, "from-abi") == 0)
{
if (ABI_NEEDS_32BIT_REGS (mips_abi))
- return mips_cpu_info_from_isa (ISA_MIPS1);
+ return mips_cpu_info_from_isa (default_isa32);
if (ABI_NEEDS_64BIT_REGS (mips_abi))
- return mips_cpu_info_from_isa (ISA_MIPS3);
+ return mips_cpu_info_from_isa (default_isa64);
if (file_mips_opts.gp >= 0)
return mips_cpu_info_from_isa (file_mips_opts.gp == 32
- ? ISA_MIPS1 : ISA_MIPS3);
+ ? default_isa32 : default_isa64);
return mips_cpu_info_from_isa (MIPS_DEFAULT_64BIT
- ? ISA_MIPS3
- : ISA_MIPS1);
+ ? default_isa64
+ : default_isa32);
}
/* 'default' has traditionally been a no-op. Probably not very useful. */
diff --git a/gas/configure b/gas/configure
index 144ead49c4..9382a97c7b 100755
--- a/gas/configure
+++ b/gas/configure
@@ -12780,6 +12780,14 @@ _ACEOF
mips_default_abi=NO_ABI
;;
esac
+ case ${target} in
+ mipsisa32r6* | mipsisa64r6*)
+ mips_default_r6=1
+ ;;
+ *)
+ mips_default_r6=0
+ ;;
+ esac
cat >>confdefs.h <<_ACEOF
#define MIPS_CPU_STRING_DEFAULT "$mips_cpu"
@@ -12800,6 +12808,11 @@ cat >>confdefs.h <<_ACEOF
#define MIPS_DEFAULT_ABI $mips_default_abi
_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define MIPS_DEFAULT_R6 $mips_default_r6
+_ACEOF
+
;;
esac
diff --git a/gas/configure.ac b/gas/configure.ac
index 6f32e55a1a..7937a944e0 100644
--- a/gas/configure.ac
+++ b/gas/configure.ac
@@ -391,6 +391,14 @@ changequote([,])dnl
mips_default_abi=NO_ABI
;;
esac
+ case ${target} in
+ mipsisa32r6* | mipsisa64r6*)
+ mips_default_r6=1
+ ;;
+ *)
+ mips_default_r6=0
+ ;;
+ esac
AC_DEFINE_UNQUOTED(MIPS_CPU_STRING_DEFAULT, "$mips_cpu",
[Default CPU for MIPS targets. ])
AC_DEFINE_UNQUOTED(USE_E_MIPS_ABI_O32, $use_e_mips_abi_o32,
@@ -399,6 +407,8 @@ changequote([,])dnl
[Generate 64-bit code by default on MIPS targets. ])
AC_DEFINE_UNQUOTED(MIPS_DEFAULT_ABI, $mips_default_abi,
[Choose a default ABI for MIPS targets. ])
+ AC_DEFINE_UNQUOTED(MIPS_DEFAULT_R6, $mips_default_r6,
+ [Choose default ISA as r6 by default. ])
;;
esac
--
2.25.0
More information about the Binutils
mailing list