diff mbox

MIPS r5900, --with-llsc=?

Message ID 87fvwi1kga.fsf@talisman.default
State New
Headers show

Commit Message

Richard Sandiford June 16, 2013, 9:19 a.m. UTC
"Jürgen Urban" <JuergenUrban@gmx.de> writes:
> Hello Richard,
>
>> >> > How much other changes will be currently accepted here? There is other
>> >> > stuff which I want to prepare and submit here, e.g.:
>
>> >> > 3. fix use of ll/sc in libgomp, either increase mips ISA level or use
>> >> > syscall (which is broken in Linux 2.6.35.4).
>
> The attached patch fixes problem 3. libgomp was not the cause of the
> problem. When linux is detected in gcc/config.gcc, the variable
> "with_llsc" is set to "yes". This happens before the CPU is checked. I
> fixed this by storing the original parameter. I think this is better
> than moving the code up.

I think this shows that the current mips*-linux* targets are setting
with_llsc in the wrong place.  They should be doing it further down,
where other with_foo defaults are set.

Also, I only just noticed that VxWorks and R5900 were setting with_arch
in the with_cpu block.  --with-cpu isn't supported/meaningful for MIPS.

Is the second patch below OK for your target?  (Not yet applied.)

> The patch for gcc/config/mips/mips.h fixes that ".set mips2" wasn't used
> when with_llsc=yes was configured.
>
> The patch for gcc/config/mips/mips.c gets lld and scd working. These
> instructions are normally not emulated by the Linux kernel and the
> syscall only supports 32 bit. So I changed my kernel to support lld and
> scd.

Looks good, thanks.  I tweaked the mips.c change to follow coding
conventions and kept !TARGET_MIPS16 last.  Applied as follows.

Thanks,
Richard

[Applied patch]

gcc/
2013-06-16  Jürgen Urban  <JuergenUrban@gmx.de>

	* config/mips/mips.h (ISA_HAS_LL_SC): Exclude TARGET_MIPS5900.
	* config/mips/mips.c (mips_start_ll_sc_sync_block): Output
	".set mips3" for 64-bit targets.

[Suggested config.gcc patch]

gcc/
	* config.gcc (mips*-mti-linux*, mips64*-*-linux*, mipsisa64*-*-linux*)
	(mips*-*-linux*): Move default with_llsc setting to where other
	defaults are set.
	(mips*-*-vxworks*): Move with_arch default from with_cpu block to
	with_arch block.
	(mips64r5900-*-*, mips64r5900el-*-*, mipsr5900-*-*, mipsr5900el-*-*):
	Likewise.  Remove default with_tune setting.  Move default float
	setting to its own block.  Handle with_llsc in the same block as above.

Comments

Jürgen Urban June 16, 2013, 3:11 p.m. UTC | #1
Hello Richard,

> >
> >> >> > How much other changes will be currently accepted here? There is other
> >> >> > stuff which I want to prepare and submit here, e.g.:
> >
> >> >> > 3. fix use of ll/sc in libgomp, either increase mips ISA level or use
> >> >> > syscall (which is broken in Linux 2.6.35.4).
> >
> > The attached patch fixes problem 3. libgomp was not the cause of the
> > problem. When linux is detected in gcc/config.gcc, the variable
> > "with_llsc" is set to "yes". This happens before the CPU is checked. I
> > fixed this by storing the original parameter. I think this is better
> > than moving the code up.
>
> I think this shows that the current mips*-linux* targets are setting
> with_llsc in the wrong place.  They should be doing it further down,
> where other with_foo defaults are set.
>
> Also, I only just noticed that VxWorks and R5900 were setting with_arch
> in the with_cpu block.  --with-cpu isn't supported/meaningful for MIPS.
>
> Is the second patch below OK for your target?  (Not yet applied.)
>
> > The patch for gcc/config/mips/mips.h fixes that ".set mips2" wasn't used
> > when with_llsc=yes was configured.
> >
> > The patch for gcc/config/mips/mips.c gets lld and scd working. These
> > instructions are normally not emulated by the Linux kernel and the
> > syscall only supports 32 bit. So I changed my kernel to support lld and
> > scd.
>
> Looks good, thanks.  I tweaked the mips.c change to follow coding
> conventions and kept !TARGET_MIPS16 last.

Yes, the patch is OK. Checked, tested and working.

Best regards
Jürgen
diff mbox

Patch

Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	2013-06-16 09:41:57.518019616 +0100
+++ gcc/config.gcc	2013-06-16 09:59:57.660470388 +0100
@@ -1813,7 +1813,6 @@  mips*-mti-linux*)
 	tm_defines="${tm_defines} MIPS_ISA_DEFAULT=33 MIPS_ABI_DEFAULT=ABI_32"
 	gnu_ld=yes
 	gas=yes
-	test x$with_llsc != x || with_llsc=yes
 	;;
 mips64*-*-linux* | mipsisa64*-*-linux*)
 	tm_file="dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h ${tm_file} mips/gnu-user.h mips/gnu-user64.h mips/linux64.h mips/linux-common.h"
@@ -1834,7 +1833,6 @@  mips64*-*-linux* | mipsisa64*-*-linux*)
 	esac
 	gnu_ld=yes
 	gas=yes
-	test x$with_llsc != x || with_llsc=yes
 	;;
 mips*-*-linux*)				# Linux MIPS, either endian.
         tm_file="dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h ${tm_file} mips/gnu-user.h mips/linux.h"
@@ -1850,7 +1848,6 @@  mips*-*-linux*)				# Linux MIPS, either
         mipsisa32*)
 		tm_defines="${tm_defines} MIPS_ISA_DEFAULT=32"
         esac
-	test x$with_llsc != x || with_llsc=yes
 	;;
 mips*-mti-elf*)
 	tm_file="elfos.h newlib-stdint.h ${tm_file} mips/elf.h mips/sde.h mips/mti-elf.h"
@@ -2982,22 +2979,6 @@  if test x$with_cpu = x ; then
 	  ;;
       esac
       ;;
-    mips64r5900-*-* | mips64r5900el-*-* | mipsr5900-*-* | mipsr5900el-*-*)
-      with_arch=r5900
-      with_tune=r5900
-      if test x$with_llsc = x; then
-	# r5900 doesn't support ll, sc, lld and scd instructions:
-	with_llsc=no
-      fi
-      if test x$with_float = x; then
-	# r5900 doesn't support 64 bit float:
-	# 32 bit float doesn't comply with IEEE 754.
-	with_float=soft
-      fi
-      ;;
-    mips*-*-vxworks)
-      with_arch=mips2
-      ;;
     powerpc*-*-*spe*)
       if test x$enable_e500_double = xyes; then
          with_cpu=8548
@@ -3058,6 +3039,12 @@  if test x$with_arch = x ; then
     x86_64-*-*)
       with_arch=$arch
       ;;
+    mips64r5900-*-* | mips64r5900el-*-* | mipsr5900-*-* | mipsr5900el-*-*)
+      with_arch=r5900
+      ;;
+    mips*-*-vxworks)
+      with_arch=mips2
+      ;;
   esac
 
   # Avoid overriding --with-arch-32 and --with-arch-64 values.
@@ -3092,6 +3079,17 @@  if test x$with_arch = x ; then
   esac
 fi
 
+# Infer a default setting for --with-float.
+if test x$with_float = x; then
+  case ${target} in
+    mips64r5900-*-* | mips64r5900el-*-* | mipsr5900-*-* | mipsr5900el-*-*)
+      # The R5900 doesn't support 64-bit float.  32-bit float doesn't
+      # comply with IEEE 754.
+      with_float=soft
+      ;;
+  esac
+fi
+
 # Support --with-fpmath.
 if test x$with_fpmath != x; then
   case ${target} in
@@ -3126,6 +3124,20 @@  if test x$with_schedule = x; then
 	esac
 fi
 
+# Infer a default setting for --with-llsc.
+if test x$with_llsc = x; then
+  case ${target} in
+    mips64r5900-*-* | mips64r5900el-*-* | mipsr5900-*-* | mipsr5900el-*-*)
+      # The R5900 doesn't support LL(D) and SC(D).
+      with_llsc=no
+      ;;
+    mips*-*-linux*)
+      # The kernel emulates LL and SC where necessary.
+      with_llsc=yes
+      ;;
+  esac
+fi
+
 # Validate and mark as valid any --with options supported
 # by this target.  In order to use a particular --with option
 # you must list it in supported_defaults; validating the value