From 0c9dc4ae5963c1e752a04c8fb9d1bb3f37df7290 Mon Sep 17 00:00:00 2001 From: Georg-Johann Lay Date: Wed, 11 Mar 2015 18:51:09 +0000 Subject: [PATCH] re PR target/65296 ([avr] fix various issues with specs file generation) gcc/ PR target/65296 * configure.ac [avr]: Check as for options -mrmw, --mlink-relax. * configure: Regenerate. * config.in: Regenerate. * doc/invoke.texi (AVR Options) [-mrmw]: Document it. [-mn-flash]: Document it. [__AVR_ARCH__]: Document avrtiny. * 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/testsuite/ PR target/65296 * gcc.target/avr/tiny-memx: Use -mmcu instead of -march. * gcc.target/avr/tiny-caller-save.c: Same. From-SVN: r221355 --- gcc/ChangeLog | 14 ++++ gcc/config.in | 12 ++++ gcc/config/avr/gen-avr-mmcu-specs.c | 6 ++ gcc/configure | 64 +++++++++++++++++++ gcc/configure.ac | 12 ++++ gcc/doc/invoke.texi | 36 ++++++++--- gcc/testsuite/ChangeLog | 6 ++ .../gcc.target/avr/tiny-caller-save.c | 4 +- gcc/testsuite/gcc.target/avr/tiny-memx.c | 2 +- 9 files changed, 143 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7a2a9b01f58..6512b30fa44 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2015-03-10 Georg-Johann Lay + + PR target/65296 + * configure.ac [avr]: Check as for options -mrmw, --mlink-relax. + * configure: Regenerate. + * config.in: Regenerate. + * doc/invoke.texi (AVR Options) [-mrmw]: Document it. + [-mn-flash]: Document it. + [__AVR_ARCH__]: Document avrtiny. + + * 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. + 2015-03-11 Andreas Krebbel * doc/invoke.texi: Add missing cpu values (z196, zEC12). diff --git a/gcc/config.in b/gcc/config.in index 7bde5b1509d..f2ed301a480 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -247,6 +247,18 @@ #endif +/* Define if your avr assembler supports --mlink-relax option. */ +#ifndef USED_FOR_TARGET +#undef HAVE_AS_AVR_MLINK_RELAX_OPTION +#endif + + +/* Define if your avr 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 diff --git a/gcc/config/avr/gen-avr-mmcu-specs.c b/gcc/config/avr/gen-avr-mmcu-specs.c index bdc747c6580..29f865e1b9a 100644 --- a/gcc/config/avr/gen-avr-mmcu-specs.c +++ b/gcc/config/avr/gen-avr-mmcu-specs.c @@ -21,6 +21,8 @@ #include #include +#include "config.h" + #define IN_GEN_AVR_MMCU_TEXI #include "avr-devices.c" @@ -155,11 +157,15 @@ print_mcu (const avr_mcu_t *mcu) 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}" diff --git a/gcc/configure b/gcc/configure index 1a35d5a186a..20dbce69736 100755 --- a/gcc/configure +++ b/gcc/configure @@ -24182,6 +24182,70 @@ if test $gcc_cv_as_alpha_jsrdirect_relocs = yes; then $as_echo "#define HAVE_AS_JSRDIRECT_RELOCS 1" >>confdefs.h +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 ;; diff --git a/gcc/configure.ac b/gcc/configure.ac index a553a653f92..68b0ee83fac 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -3623,6 +3623,18 @@ AS_HELP_STRING([--disable-fix-cortex-a53-835769], [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 avr 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 avr assembler supports -mrmw option.])]) + ;; + cris-*-*) gcc_GAS_CHECK_FEATURE([-no-mul-bug-abort option], gcc_cv_as_cris_no_mul_bug,[2,15,91], diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index d979415c11f..bc0525720ab 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -571,8 +571,8 @@ Objective-C and Objective-C++ Dialects}. @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 note that this option does not 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 assembler code. 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,13 +13780,18 @@ architecture and depends on the @option{-mmcu=@var{mcu}} 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}. @@ -13795,7 +13811,7 @@ the device name as from the AVR user manual. The difference between 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}. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cd4c9a4003a..e69d5051883 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-03-11 Georg-Johann Lay + + PR target/65296 + * gcc.target/avr/tiny-memx: Use -mmcu instead of -march. + * gcc.target/avr/tiny-caller-save.c: Same. + 2015-03-11 Michael Meissner PR target/65242 diff --git a/gcc/testsuite/gcc.target/avr/tiny-caller-save.c b/gcc/testsuite/gcc.target/avr/tiny-caller-save.c index 0e46ee06594..63fad3a1205 100644 --- a/gcc/testsuite/gcc.target/avr/tiny-caller-save.c +++ b/gcc/testsuite/gcc.target/avr/tiny-caller-save.c @@ -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) diff --git a/gcc/testsuite/gcc.target/avr/tiny-memx.c b/gcc/testsuite/gcc.target/avr/tiny-memx.c index 3ad164dfed4..cdda86b14bf 100644 --- a/gcc/testsuite/gcc.target/avr/tiny-memx.c +++ b/gcc/testsuite/gcc.target/avr/tiny-memx.c @@ -1,4 +1,4 @@ /* { dg-do compile } */ -/* { dg-options "-march=avrtiny" } */ +/* { dg-options "-mmcu=avrtiny" } */ const __memx char ascmonth[] = "Jan"; /* { dg-error "not supported" } */ -- 2.30.2