This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: [patch,avr]: Part3 and 4: Fix various problems with specs and specs file generation.


This is just a small addendum to the option and specs handling:

- Document new avr-gcc command options

- Change -march= to -mmcu= in some test cases

- Add comfigure test to detect whether gas supports -mrmw and --mlink-relax.

- Use result of these tests in specs generatio, i.e. omit respective options if they are not supported.


Ok to apply?


Two issues remain:

- The tests that add -mmcu= to the command options will fail because there must not be more than one -mmcu=. Supporting several, incompatible MCUs makes no sense (same for incompatible -march + -mmcu which was the case). In 4.9 this works per accident with unspecified definitions for built-in macros or when the options differ in default settings, for example.

- Spaces in the installation path are not supported. It's possible to recover from spaces in -specs= by escaping them in spec function device-specs-file. However this is almost impossible for the device library without changing gcc.c which can use convert_white_space() as needed. Adding more than one escape level is not possible because the '\' would be interpreted as part of the path.


Johann


gcc/
	PR target/65296
	* configure.ac [avr]: Check as for options -mrmw, --mlink-relax.
	* configure: Regenerate.
	* config.in: Regenerate.
	* config/avr/gen-avr-mmcu-specs.c (config.h): Include it.
	(*asm_relax): Only define spec if HAVE_AS_AVR_MLINK_RELAX_OPTION.
	(*asm_rmw): Only define spec if HAVE_AS_AVR_MRMW_OPTION.


gcc/
	PR target/65296
	* doc/invoke.texi (AVR Options) [-mrmw]: Document it.
	[-mn-flash]: Document it.
	[__AVR_DEVICE_NAME__]: Document it.
	[__ARV_ARCH__]: Document avrtiny.

gcc/testsuite/
	PR target/65296
	* gcc.target/avr/tiny-memx: Use -mmcu instead of -march.
	* gcc.target/avr/tiny-caller-save.c: Same.


gcc/
	PR target/65296
	* configure.ac [avr]: Check as for option -mrmw.
	* configure: Regenerate.
	* config.in: Regenerate.
	* config/avr/driver-avr.c (avr_device_to_as): Don't add -mrmw to
	assembler options if not HAVE_AS_AVR_MRMW_OPTION.

Index: configure.ac
===================================================================
--- configure.ac	(revision 221318)
+++ configure.ac	(working copy)
@@ -3623,6 +3623,18 @@ [	.set nomacro
   [Define if your assembler supports the lituse_jsrdirect relocation.])])
     ;;
 
+  avr-*-*)
+    gcc_GAS_CHECK_FEATURE([--mlink-relax option], gcc_cv_as_avr_mlink_relax,,
+      [--mlink-relax], [.text],,
+      [AC_DEFINE(HAVE_AS_AVR_MLINK_RELAX_OPTION, 1,
+		[Define if your assembler supports --mlink-relax option.])])
+
+    gcc_GAS_CHECK_FEATURE([-mrmw option], gcc_cv_as_avr_mrmw,,
+      [-mrmw], [.text],,
+      [AC_DEFINE(HAVE_AS_AVR_MRMW_OPTION, 1,
+		[Define if your assembler supports -mrmw option.])])
+    ;;
+
   cris-*-*)
     gcc_GAS_CHECK_FEATURE([-no-mul-bug-abort option],
       gcc_cv_as_cris_no_mul_bug,[2,15,91],
Index: configure
===================================================================
--- configure	(revision 221318)
+++ configure	(working copy)
@@ -24185,6 +24185,70 @@ $as_echo "#define HAVE_AS_JSRDIRECT_RELO
 fi
     ;;
 
+  avr-*-*)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for --mlink-relax option" >&5
+$as_echo_n "checking assembler for --mlink-relax option... " >&6; }
+if test "${gcc_cv_as_avr_mlink_relax+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  gcc_cv_as_avr_mlink_relax=no
+  if test x$gcc_cv_as != x; then
+    $as_echo '.text' > conftest.s
+    if { ac_try='$gcc_cv_as $gcc_cv_as_flags --mlink-relax -o conftest.o conftest.s >&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }
+    then
+	gcc_cv_as_avr_mlink_relax=yes
+    else
+      echo "configure: failed program was" >&5
+      cat conftest.s >&5
+    fi
+    rm -f conftest.o conftest.s
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_avr_mlink_relax" >&5
+$as_echo "$gcc_cv_as_avr_mlink_relax" >&6; }
+if test $gcc_cv_as_avr_mlink_relax = yes; then
+
+$as_echo "#define HAVE_AS_AVR_MLINK_RELAX_OPTION 1" >>confdefs.h
+
+fi
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -mrmw option" >&5
+$as_echo_n "checking assembler for -mrmw option... " >&6; }
+if test "${gcc_cv_as_avr_mrmw+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  gcc_cv_as_avr_mrmw=no
+  if test x$gcc_cv_as != x; then
+    $as_echo '.text' > conftest.s
+    if { ac_try='$gcc_cv_as $gcc_cv_as_flags -mrmw -o conftest.o conftest.s >&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }
+    then
+	gcc_cv_as_avr_mrmw=yes
+    else
+      echo "configure: failed program was" >&5
+      cat conftest.s >&5
+    fi
+    rm -f conftest.o conftest.s
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_avr_mrmw" >&5
+$as_echo "$gcc_cv_as_avr_mrmw" >&6; }
+if test $gcc_cv_as_avr_mrmw = yes; then
+
+$as_echo "#define HAVE_AS_AVR_MRMW_OPTION 1" >>confdefs.h
+
+fi
+    ;;
+
   cris-*-*)
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -no-mul-bug-abort option" >&5
 $as_echo_n "checking assembler for -no-mul-bug-abort option... " >&6; }
Index: config.in
===================================================================
--- config.in	(revision 221321)
+++ config.in	(working copy)
@@ -247,6 +247,18 @@ that are supported for each access macro
 #endif
 
 
+/* Define if your assembler supports --mlink-relax option. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_AVR_MLINK_RELAX_OPTION
+#endif
+
+
+/* Define if your assembler supports -mrmw option. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_AVR_MRMW_OPTION
+#endif
+
+
 /* Define if your assembler supports cmpb. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_CMPB
Index: config/avr/gen-avr-mmcu-specs.c
===================================================================
--- config/avr/gen-avr-mmcu-specs.c	(revision 221316)
+++ config/avr/gen-avr-mmcu-specs.c	(working copy)
@@ -21,6 +21,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "config.h"
+
 #define IN_GEN_AVR_MMCU_TEXI
 
 #include "avr-devices.c"
@@ -155,11 +157,15 @@ bool is_arch = NULL == mcu->macro;
 
   fprintf (f, "*asm_arch:\n\t-mmcu=%s\n\n", arch->name);
 
+#ifdef HAVE_AS_AVR_MLINK_RELAX_OPTION                   \
   fprintf (f, "*asm_relax:\n\t%s\n\n", ASM_RELAX_SPEC);
+#endif // have as --mlink-relax
 
+#ifdef HAVE_AS_AVR_MRMW_OPTION
   fprintf (f, "*asm_rmw:\n%s\n\n", rmw
            ? "\t%{!mno-rmw: -mrmw}"
            : "\t%{mrmw}");
+#endif // have as -mrmw
 
   fprintf (f, "*asm_errata_skip:\n%s\n\n", errata_skip
            ? "\t%{mno-skip-bug}"
Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(revision 221324)
+++ doc/invoke.texi	(working copy)
@@ -571,8 +571,8 @@ -remap -trigraphs  -undef  -U@var{macro}
 
 @emph{AVR Options}
 @gccoptlist{-mmcu=@var{mcu} -maccumulate-args -mbranch-cost=@var{cost} @gol
--mcall-prologues -mint8 -mno-interrupts -mrelax @gol
--mstrict-X -mtiny-stack -Waddr-space-convert}
+-mcall-prologues -mint8 -mn_flash=@var{size} -mno-interrupts @gol
+-mrelax -mrmw -mstrict-X -mtiny-stack -Waddr-space-convert}
 
 @emph{Blackfin Options}
 @gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} @gol
@@ -13509,6 +13509,11 @@ and @code{long long} is 4 bytes.  Please
 conform to the C standards, but it results in smaller code
 size.
 
+@item -mn-flash=@var{num}
+@opindex mn-flash
+Assume that the flash memory has a size of 
+@var{num} times 64@tie{}KiB.
+
 @item -mno-interrupts
 @opindex mno-interrupts
 Generated code is not compatible with hardware interrupts.
@@ -13518,8 +13523,9 @@ Code size is smaller.
 @opindex mrelax
 Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter
 @code{RCALL} resp.@: @code{RJMP} instruction if applicable.
-Setting @option{-mrelax} just adds the @option{--relax} option to the
-linker command line when the linker is called.
+Setting @option{-mrelax} just adds the @option{--mlink-relax} option to
+the assembler's command line and the @option{--relax} option to the
+linker's command line.
 
 Jump relaxing is performed by the linker because jump offsets are not
 known before code is located. Therefore, the assembler code generated by the
@@ -13529,6 +13535,11 @@ differ from instructions in the assemble
 Relaxing must be turned on if linker stubs are needed, see the
 section on @code{EIND} and linker stubs below.
 
+@item -mrmw
+@opindex mrmw
+Assume that the device supports the Read-Modify-Write
+instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}.
+
 @item -msp8
 @opindex msp8
 Treat the stack pointer register as an 8-bit register,
@@ -13769,17 +13780,27 @@ architecture and depends on the @option{
 Possible values are:
 
 @code{2}, @code{25}, @code{3}, @code{31}, @code{35},
-@code{4}, @code{5}, @code{51}, @code{6}, @code{102}, @code{104},
+@code{4}, @code{5}, @code{51}, @code{6}
+
+for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31},
+@code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6},
+
+respectively and
+
+@code{100}, @code{102}, @code{104},
 @code{105}, @code{106}, @code{107}
 
-for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3},
-@code{avr31}, @code{avr35}, @code{avr4}, @code{avr5}, @code{avr51},
-@code{avr6}, @code{avrxmega2}, @code{avrxmega4}, @code{avrxmega5},
-@code{avrxmega6}, @code{avrxmega7}, respectively.
+for @var{mcu}=@code{avrtiny}, @code{avrxmega2}, @code{avrxmega4},
+@code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively.
 If @var{mcu} specifies a device, this built-in macro is set
 accordingly. For example, with @option{-mmcu=atmega8} the macro is
 defined to @code{4}.
 
+@item __AVR_DEVICE_NAME__
+If @var{mcu} in @option{-mmcu=@var{mcu}} specifies a device, this macro
+is defined to @var{mcu}.  If @var{mcu} is a core architecture like
+@code{avr51} this macro is not defined.
+
 @item __AVR_@var{Device}__
 Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects
 the device's name. For example, @option{-mmcu=atmega8} defines the
@@ -13795,7 +13816,7 @@ @var{Device} in the built-in macro and @
 If @var{device} is not a device but only a core architecture like
 @samp{avr51}, this macro is not defined.
 
-@item   __AVR_DEVICE_NAME__
+@item __AVR_DEVICE_NAME__
 Setting @option{-mmcu=@var{device}} defines this built-in macro to
 the device's name. For example, with @option{-mmcu=atmega8} the macro
 is defined to @code{atmega8}.
Index: testsuite/gcc.target/avr/tiny-caller-save.c
===================================================================
--- testsuite/gcc.target/avr/tiny-caller-save.c	(revision 221324)
+++ testsuite/gcc.target/avr/tiny-caller-save.c	(working copy)
@@ -1,8 +1,8 @@
 /* { dg-do compile } */
-/* { dg-options "-march=avrtiny -gdwarf -Os" } */
+/* { dg-options "-mmcu=avrtiny -gdwarf -Os" } */
 
 /* This is a stripped down piece of libgcc2.c that triggerd an ICE for avr with
-   "-march=avrtiny -g -Os"; replace_reg_with_saved_mem would generate:
+   "-mmcu=avrtiny -g -Os"; replace_reg_with_saved_mem would generate:
    (concatn:SI [
                     (reg:SI 18 r18)
                     (reg:SI 19 r19)
Index: testsuite/gcc.target/avr/tiny-memx.c
===================================================================
--- testsuite/gcc.target/avr/tiny-memx.c	(revision 221324)
+++ testsuite/gcc.target/avr/tiny-memx.c	(working copy)
@@ -1,4 +1,4 @@
 /* { dg-do compile } */
-/* { dg-options "-march=avrtiny" } */
+/* { dg-options "-mmcu=avrtiny" } */
 
 const __memx char ascmonth[] = "Jan"; /* { dg-error "not supported" } */
Index: config/avr/driver-avr.c
===================================================================
--- config/avr/driver-avr.c	(revision 221321)
+++ config/avr/driver-avr.c	(working copy)
@@ -60,7 +60,10 @@ avr_device_to_as (int argc, const char *
 
   return concat ("-mmcu=", avr_current_arch->arch_name,
     avr_current_device->dev_attribute & AVR_ERRATA_SKIP ? "" : " -mno-skip-bug",
-    avr_current_device->dev_attribute & AVR_ISA_RMW ? " -mrmw" : "", NULL);
+#ifdef HAVE_AS_AVR_MRMW_OPTION
+    avr_current_device->dev_attribute & AVR_ISA_RMW ? " -mrmw" : "",
+#endif // have as -mrmw
+    NULL);
 }
 
 /* Returns command line parameters to pass to ld.  */
Index: configure
===================================================================
--- configure	(revision 221321)
+++ configure	(working copy)
@@ -24158,6 +24158,39 @@ $as_echo "#define HAVE_AS_NO_MUL_BUG_ABO
 fi
     ;;
 
+  avr-*-*)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -mrmw option" >&5
+$as_echo_n "checking assembler for -mrmw option... " >&6; }
+if test "${gcc_cv_as_avr_mrmw+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  gcc_cv_as_avr_mrmw=no
+  if test x$gcc_cv_as != x; then
+    $as_echo '.text' > conftest.s
+    if { ac_try='$gcc_cv_as $gcc_cv_as_flags -mrmw -o conftest.o conftest.s >&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }
+    then
+	gcc_cv_as_avr_mrmw=yes
+    else
+      echo "configure: failed program was" >&5
+      cat conftest.s >&5
+    fi
+    rm -f conftest.o conftest.s
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_avr_mrmw" >&5
+$as_echo "$gcc_cv_as_avr_mrmw" >&6; }
+if test $gcc_cv_as_avr_mrmw = yes; then
+
+$as_echo "#define HAVE_AS_AVR_MRMW_OPTION 1" >>confdefs.h
+
+fi
+    ;;
+
   sparc*-*-*)
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .register" >&5
 $as_echo_n "checking assembler for .register... " >&6; }
Index: config.in
===================================================================
--- config.in	(revision 221321)
+++ config.in	(working copy)
@@ -211,6 +211,12 @@ that are supported for each access macro
 #endif
 
 
+/* Define if your assembler supports -mrmw option. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_AVR_MRMW_OPTION
+#endif
+
+
 /* Define if your assembler supports cmpb. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_CMPB
@@ -235,6 +241,12 @@ that are supported for each access macro
 #endif
 
 
+/* Define if your assembler supports .module. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_DOT_MODULE
+#endif
+
+
 /* Define if your assembler supports DSPR1 mult. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_DSPR1_MULT
@@ -447,12 +459,6 @@ that are supported for each access macro
 #endif
 
 
-/* Define if the assembler understands .module. */
-#ifndef USED_FOR_TARGET
-#undef HAVE_AS_DOT_MODULE
-#endif
-
-
 /* Define if your assembler supports the -no-mul-bug-abort option. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_NO_MUL_BUG_ABORT_OPTION
Index: configure.ac
===================================================================
--- configure.ac	(revision 221321)
+++ configure.ac	(working copy)
@@ -3603,6 +3603,13 @@ [	.set nomacro
 		[Define if your assembler supports the -no-mul-bug-abort option.])])
     ;;
 
+  avr-*-*)
+    gcc_GAS_CHECK_FEATURE([-mrmw option], gcc_cv_as_avr_mrmw,,
+      [-mrmw], [.text],,
+      [AC_DEFINE(HAVE_AS_AVR_MRMW_OPTION, 1,
+		[Define if your assembler supports -mrmw option.])])
+    ;;
+
   sparc*-*-*)
     gcc_GAS_CHECK_FEATURE([.register], gcc_cv_as_sparc_register_op,,,
       [.register %g2, #scratch],,

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