aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/mips/mips.h
diff options
context:
space:
mode:
authorFredrik Noring <noring@nocrew.org>2018-11-27 16:01:10 +0000
committerMaciej W. Rozycki <macro@gcc.gnu.org>2018-11-27 16:01:10 +0000
commitfb51a3a867e20f574bde3b929ec9ccfba6cc374b (patch)
tree0add77034e2751dfbb9c5579e20fb2200edb6415 /gcc/config/mips/mips.h
parent4d8da4df6b6c2c7b89a6cc402bc134b69911e922 (diff)
downloadgcc-fb51a3a867e20f574bde3b929ec9ccfba6cc374b.zip
gcc-fb51a3a867e20f574bde3b929ec9ccfba6cc374b.tar.gz
gcc-fb51a3a867e20f574bde3b929ec9ccfba6cc374b.tar.bz2
MIPS: Add `-mfix-r5900' option for the R5900 short loop erratum
The short loop bug under certain conditions causes loops to execute only once or twice, due to a hardware bug in the R5900 chip. `-march=r5900' already enables the R5900 short loop workaround. However, the R5900 ISA and most other MIPS ISAs are mutually exclusive since R5900-specific instructions are generated as well. The `-mfix-r5900' option can be used in combination with e.g. `-mips2' or `-mips3' to generate generic MIPS binaries that also work with the R5900 target. The workaround is implemented by GAS rather than by GCC. The following small `shortloop.c' file has been used as a test with GCC 8.2.0: void shortloop(void) { __asm__ __volatile__ ( " li $3, 300\n" "loop:\n" " addi $3, -1\n" " addi $4, -1\n" " bne $3, $0, loop\n" " li $4, 3\n" ::); } The following six combinations have been tested: % mipsr5900el-unknown-linux-gnu-gcc -O1 -c shortloop.c % mipsr5900el-unknown-linux-gnu-gcc -O1 -c shortloop.c -mfix-r5900 % mipsr5900el-unknown-linux-gnu-gcc -O1 -c shortloop.c -mno-fix-r5900 % mipsr4000el-unknown-linux-gnu-gcc -O1 -c shortloop.c % mipsr4000el-unknown-linux-gnu-gcc -O1 -c shortloop.c -mfix-r5900 % mipsr4000el-unknown-linux-gnu-gcc -O1 -c shortloop.c -mno-fix-r5900 The R5900 short loop erratum is corrected in exactly three cases: 1. for the target `mipsr5900el' by default; 2. for the target `mipsr5900el' with `-mfix-r5900'; 3. for any other MIPS target (e.g. `mipsr4000el') with `-mfix-r5900'. In all other cases the correction is not made. 2018-11-27 Fredrik Noring <noring@nocrew.org> gcc/ * config/mips/mips.c (mips_reorg_process_insns) (mips_option_override): Handle `-mfix-r5900'. * config/mips/mips.h (ASM_SPEC): Add `mfix-r5900' and `mno-fix-r5900'. * config/mips/mips.opt (mfix-r5900): New option. * doc/invoke.texi: Document the `r5900' processor name, and `-mfix-r5900' and `-mno-fix-r5900' options. From-SVN: r266519
Diffstat (limited to 'gcc/config/mips/mips.h')
-rw-r--r--gcc/config/mips/mips.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index 11ca364..d2205f0 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -1411,6 +1411,7 @@ struct mips_cpu_info {
%{mloongson-ext2} %{mno-loongson-ext2} \
%{msmartmips} %{mno-smartmips} \
%{mmt} %{mno-mt} \
+%{mfix-r5900} %{mno-fix-r5900} \
%{mfix-rm7000} %{mno-fix-rm7000} \
%{mfix-vr4120} %{mfix-vr4130} \
%{mfix-24k} \