RE: [Patch,AVR]: Supply and use information on skip core bug
> -Original Message- > From: Georg-Johann Lay [mailto:a...@gjlay.de] > Sent: Monday, August 01, 2011 9:45 AM > To: Weddington, Eric > Cc: gcc-patches@gcc.gnu.org; Anatoly Sokolov; Denis Chertykov > Subject: Re: [Patch,AVR]: Supply and use information on skip core bug > > > Ok, I removed the separate file. Thanks! > Luckily AVRs have very little core bugs > and I hope we will never need such a file... Well, we've been lucky so far. ;-) When we add the xmega support to gcc (IIRC, it should be in binutils), then we may have to revisit the errata list. Eric Weddington
Re: [Patch,AVR]: Supply and use information on skip core bug
Weddington, Eric wrote: >> -Original Message- >> From: Georg-Johann Lay [mailto:a...@gjlay.de] >> Sent: Monday, August 01, 2011 8:38 AM >> To: gcc-patches@gcc.gnu.org >> Cc: Anatoly Sokolov; Denis Chertykov; Weddington, Eric >> Subject: [Patch,AVR]: Supply and use information on skip core bug >> >> Some AVR devices have the skip bug, i.e. they must not use any skip >> instruction to bypass a 2-word instruction. >> >> Affected devices are AT90S8515 (core avr2) and ATmega103 (core avr31). >> >> For information see the new file errata.txt. >> >> This patch supplies new built-in macros so that a user can test if that >> erratum might be active. Moreover, libgcc.S uses the new built-in macros >> because they allow for more exact test for the bug. >> >> struct mcu_type_s has a new field "errata_bug" which is set to one for the >> following devices: >> >> * avr2 and none (as avr2 is default if no -mmcu is given) >> * avr31 >> * at90s8515 >> * atmega103 >> >> avr-tables.opt does not change and needs not to be regenerated. >> >> Ok to install? > > > Hi Johann, > > It all looks fine to me, except that I don't think we really need to have a > separate errata.txt file, do we? The information in errata.txt could be > condensed (we don't need the full email response back from Atmel, just the > information that it is the 2 devices that have this errata) and put it in a > comment in avr-devices.c or avr-mcus.def. Approved with that small change. > > Thanks for doing this. > > Eric Weddington Ok, I removed the separate file. Luckily AVRs have very little core bugs and I hope we will never need such a file... The original mail was much longer, I now added the relevant parts at the place where I would expect them: the structure definition in avr.h. I added parts from the mail header, too, in particular the subject so that someone else can refer to it. Applied with that change: http://gcc.gnu.org/viewcvs?view=revision&revision=177049 Johann * config/avr/avr.h (mcu_type_s): Add errata_skip field. * config/avr/avr-devices.c (avr_mcu_types): Use it. * config/avr/avr-mcus.def (AVR_MCU): Use it. * config/avr/avr-c.c (avr_cpu_cpp_builtins): Use it to builtin define __AVR_ERRATA_SKIP__ and __AVR_ERRATA_SKIP_JMP_CALL__. * config/avr/libgcc.S (__mulshisi3, __ffshi2, __fmulsu_exit): Use __AVR_ERRATA_SKIP_JMP_CALL__ instead of __AVR_HAVE_JMP_CALL__ to detect if XJMP must not be skipped.
RE: [Patch,AVR]: Supply and use information on skip core bug
> -Original Message- > From: Georg-Johann Lay [mailto:a...@gjlay.de] > Sent: Monday, August 01, 2011 8:38 AM > To: gcc-patches@gcc.gnu.org > Cc: Anatoly Sokolov; Denis Chertykov; Weddington, Eric > Subject: [Patch,AVR]: Supply and use information on skip core bug > > Some AVR devices have the skip bug, i.e. they must not use any skip > instruction to bypass a 2-word instruction. > > Affected devices are AT90S8515 (core avr2) and ATmega103 (core avr31). > > For information see the new file errata.txt. > > This patch supplies new built-in macros so that a user can test if that > erratum might be active. Moreover, libgcc.S uses the new built-in macros > because they allow for more exact test for the bug. > > struct mcu_type_s has a new field "errata_bug" which is set to one for the > following devices: > > * avr2 and none (as avr2 is default if no -mmcu is given) > * avr31 > * at90s8515 > * atmega103 > > avr-tables.opt does not change and needs not to be regenerated. > > Ok to install? Hi Johann, It all looks fine to me, except that I don't think we really need to have a separate errata.txt file, do we? The information in errata.txt could be condensed (we don't need the full email response back from Atmel, just the information that it is the 2 devices that have this errata) and put it in a comment in avr-devices.c or avr-mcus.def. Approved with that small change. Thanks for doing this. Eric Weddington
[Patch,AVR]: Supply and use information on skip core bug
Some AVR devices have the skip bug, i.e. they must not use any skip instruction to bypass a 2-word instruction. Affected devices are AT90S8515 (core avr2) and ATmega103 (core avr31). For information see the new file errata.txt. This patch supplies new built-in macros so that a user can test if that erratum might be active. Moreover, libgcc.S uses the new built-in macros because they allow for more exact test for the bug. struct mcu_type_s has a new field "errata_bug" which is set to one for the following devices: * avr2 and none (as avr2 is default if no -mmcu is given) * avr31 * at90s8515 * atmega103 avr-tables.opt does not change and needs not to be regenerated. Ok to install? Johann * config/avr/errata.txt: New text file. * config/avr/avr.h (mcu_type_s): Add errata_skip field. * config/avr/avr-devices.c (avr_mcu_types): Use it. * config/avr/avr-mcus.def (AVR_MCU): Use it. * config/avr/avr-c.c (avr_cpu_cpp_builtins): Use it to builtin define __AVR_ERRATA_SKIP__ and __AVR_ERRATA_SKIP_JMP_CALL__. * config/avr/libgcc.S (__mulshisi3, __ffshi2, __fmulsu_exit): Use __AVR_ERRATA_SKIP_JMP_CALL__ instead of __AVR_HAVE_JMP_CALL__ to detect if XJMP must not be skipped. Index: config/avr/libgcc.S === --- config/avr/libgcc.S (revision 177011) +++ config/avr/libgcc.S (working copy) @@ -361,7 +361,7 @@ ENDF __umulhisi3 ;;; (C3:C0) = (signed long) A1:A0 * B3:B0 ;;; Clobbers: __tmp_reg__ DEFUN __mulshisi3 -#ifdef __AVR_HAVE_JMP_CALL__ +#ifdef __AVR_ERRATA_SKIP_JMP_CALL__ ;; Some cores have problem skipping 2-word instruction tst A1 brmi__mulohisi3 @@ -1074,7 +1074,7 @@ ENDF __ffssi2 ;; clobbers: r26 DEFUN __ffshi2 clr r26 -#ifdef __AVR_HAVE_JMP_CALL__ +#ifdef __AVR_ERRATA_SKIP_JMP_CALL__ ;; Some cores have problem skipping 2-word instruction tst r24 breq 2f @@ -1480,7 +1480,7 @@ DEFUN __fmulsu_exit ;; A1 = |A1| sbrc A1, 7 neg A1 -#ifdef __AVR_HAVE_JMP_CALL__ +#ifdef __AVR_ERRATA_SKIP_JMP_CALL__ ;; Some cores have problem skipping 2-word instruction tst A0 brmi 1f Index: config/avr/avr-c.c === --- config/avr/avr-c.c (revision 177011) +++ config/avr/avr-c.c (working copy) @@ -82,6 +82,14 @@ avr_cpu_cpp_builtins (struct cpp_reader if (TARGET_NO_INTERRUPTS) cpp_define (pfile, "__NO_INTERRUPTS__"); + if (avr_current_device->errata_skip) +{ + cpp_define (pfile, "__AVR_ERRATA_SKIP__"); + + if (avr_current_arch->have_jmp_call) +cpp_define (pfile, "__AVR_ERRATA_SKIP_JMP_CALL__"); +} + /* Define builtin macros so that the user can easily query if or if not a specific builtin is available. */ Index: config/avr/avr-devices.c === --- config/avr/avr-devices.c (revision 177011) +++ config/avr/avr-devices.c (working copy) @@ -40,11 +40,11 @@ const struct base_arch_s avr_arch_types[ }; const struct mcu_type_s avr_mcu_types[] = { -#define AVR_MCU(NAME, ARCH, MACRO, SHORT_SP, DATA_SEC, LIBRARY_NAME) \ - { NAME, ARCH, MACRO, SHORT_SP, DATA_SEC, LIBRARY_NAME }, +#define AVR_MCU(NAME, ARCH, MACRO, SHORT_SP, ERRATA_SKIP, DATA_SEC, LIBRARY_NAME) \ + { NAME, ARCH, MACRO, SHORT_SP, ERRATA_SKIP, DATA_SEC, LIBRARY_NAME }, #include "avr-mcus.def" #undef AVR_MCU /* End of list. */ - { NULL, ARCH_UNKNOWN, NULL, 0, 0, NULL } + { NULL, ARCH_UNKNOWN, NULL, 0, 0, 0, NULL } }; Index: config/avr/avr-mcus.def === --- config/avr/avr-mcus.def (revision 177011) +++ config/avr/avr-mcus.def (working copy) @@ -27,185 +27,185 @@ Before including this file, define a macro: - AVR_MCU (NAME, ARCH, MACRO, SHORT_SP, DATA_SEC, LIBRARY_NAME) + AVR_MCU (NAME, ARCH, MACRO, SHORT_SP, ERRATA_SKIP, DATA_SEC, LIBRARY_NAME) where the arguments are the fields of struct mcu_type_s. */ /* "avr2" must be first for the "0" default to work as intended. */ /* Classic, <= 8K. */ -AVR_MCU ("avr2", ARCH_AVR2, NULL,0, 0x0060, "s8515") -AVR_MCU ("at90s2313",ARCH_AVR2, "__AVR_AT90S2313__", 1, 0x0060, "s2313") -AVR_MCU ("at90s2323",ARCH_AVR2, "__AVR_AT90S2323__", 1, 0x0060, "s2323") -AVR_MCU ("at90s2333",ARCH_AVR2, "__AVR_AT90S2333__", 1, 0x0060, "s2333") -AVR_MCU ("at90s2343",ARCH_AVR2, "__AVR_AT90S2343__", 1, 0x0060, "s2343") -AVR_MCU ("attiny22", ARCH_AVR2, "__AVR_ATtiny22__", 1, 0x0060, "tn22") -AVR_MCU ("attiny26", ARCH_AVR2, "__AVR_ATtiny26__", 1, 0x0060, "tn26") -AVR_MCU ("at90s4414",ARCH_AVR2, "__AVR_AT90S4414__", 0, 0x0060, "s4414") -AVR_MCU ("a