From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 34930 invoked by alias); 10 Mar 2015 15:02:52 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 34916 invoked by uid 89); 10 Mar 2015 15:02:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL,BAYES_50,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-HELO: mo4-p00-ob.smtp.rzone.de Received: from mo4-p00-ob.smtp.rzone.de (HELO mo4-p00-ob.smtp.rzone.de) (81.169.146.162) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 10 Mar 2015 15:02:41 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT3ol15ykJcYwTPbBBR62PQx1xqvTHw== X-RZG-CLASS-ID: mo00 Received: from [192.168.0.22] (ip5b43a95f.dynamic.kabel-deutschland.de [91.67.169.95]) by smtp.strato.de (RZmta 37.3 DYNA|AUTH) with ESMTPSA id w006a5r2AF2XLpW (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate); Tue, 10 Mar 2015 16:02:33 +0100 (CET) Message-ID: <54FF0788.6050108@gjlay.de> Date: Tue, 10 Mar 2015 15:02:00 -0000 From: Georg-Johann Lay User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Denis Chertykov CC: Senthil Kumar Selvaraj , GCC Patches , Joerg Wunsch Subject: Re: [patch,avr]: Part3 and 4: Fix various problems with specs and specs file generation. References: <54F4BCA1.7080707@gjlay.de> <20150303132144.GC24277@atmel.com> <54FDC417.1000008@gjlay.de> In-Reply-To: Content-Type: multipart/mixed; boundary="------------060305050900060702080306" X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg00566.txt.bz2 This is a multi-part message in MIME format. --------------060305050900060702080306 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 2028 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. --------------060305050900060702080306 Content-Type: text/x-patch; name="pr65296-part3.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr65296-part3.diff" Content-length: 4812 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 #include +#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}" --------------060305050900060702080306 Content-Type: text/x-patch; name="pr65296-part4.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr65296-part4.diff" Content-length: 4993 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" } */ --------------060305050900060702080306 Content-Type: text/x-patch; name="pr65296-49.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr65296-49.diff" Content-length: 3743 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],, --------------060305050900060702080306--