update copyright dates
[deliverable/binutils-gdb.git] / gas / config / tc-avr.c
index 7a95033d53a37cd55b91ff345b48ecfe32ab1e54..5f243b43cb5b687ed606cdc10731d9be0440b2de 100644 (file)
@@ -1,6 +1,6 @@
 /* tc-avr.c -- Assembler code for the ATMEL AVR
 
-   Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2006
+   Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
    Contributed by Denis Chertykov <denisc@overta.ru>
 
@@ -8,7 +8,7 @@
 
    GAS is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
+   the Free Software Foundation; either version 3, or (at your option)
    any later version.
 
    GAS is distributed in the hope that it will be useful,
    the Free Software Foundation, 51 Franklin Street - Fifth Floor,
    Boston, MA 02110-1301, USA.  */
 
-#include <stdio.h>
 #include "as.h"
 #include "safe-ctype.h"
 #include "subsegs.h"
-#include "libiberty.h"
 
 struct avr_opcodes_s
 {
@@ -58,99 +56,170 @@ struct mcu_type_s
 };
 
 /* XXX - devices that don't seem to exist (renamed, replaced with larger
-   ones, or planned but never produced), left here for compatibility.
-   TODO: hide them in show_mcu_list output?  */
+   ones, or planned but never produced), left here for compatibility.  */
 
 static struct mcu_type_s mcu_types[] =
 {
-  {"avr1",      AVR_ISA_TINY1,    bfd_mach_avr1},
-  {"avr2",      AVR_ISA_TINY2,    bfd_mach_avr2},
-  {"avr3",      AVR_ISA_M103,     bfd_mach_avr3},
-  {"avr4",      AVR_ISA_M8,       bfd_mach_avr4},
-  {"avr5",      AVR_ISA_ALL,      bfd_mach_avr5},
-  {"at90s1200", AVR_ISA_1200,     bfd_mach_avr1},
-  {"attiny10",  AVR_ISA_TINY1,    bfd_mach_avr1}, /* XXX -> tn11 */
-  {"attiny11",  AVR_ISA_TINY1,    bfd_mach_avr1},
-  {"attiny12",  AVR_ISA_TINY1,    bfd_mach_avr1},
-  {"attiny15",  AVR_ISA_TINY1,    bfd_mach_avr1},
-  {"attiny28",  AVR_ISA_TINY1,    bfd_mach_avr1},
-  {"at90s2313", AVR_ISA_2xxx,     bfd_mach_avr2},
-  {"at90s2323", AVR_ISA_2xxx,     bfd_mach_avr2},
-  {"at90s2333", AVR_ISA_2xxx,     bfd_mach_avr2}, /* XXX -> 4433 */
-  {"at90s2343", AVR_ISA_2xxx,     bfd_mach_avr2},
-  {"attiny22",  AVR_ISA_2xxx,     bfd_mach_avr2}, /* XXX -> 2343 */
-  {"attiny26",  AVR_ISA_2xxx,     bfd_mach_avr2},
-  {"at90s4433", AVR_ISA_2xxx,     bfd_mach_avr2},
-  {"at90s4414", AVR_ISA_2xxx,     bfd_mach_avr2}, /* XXX -> 8515 */
-  {"at90s4434", AVR_ISA_2xxx,     bfd_mach_avr2}, /* XXX -> 8535 */
-  {"at90s8515", AVR_ISA_2xxx,     bfd_mach_avr2},
-  {"at90s8535", AVR_ISA_2xxx,     bfd_mach_avr2},
-  {"at90c8534", AVR_ISA_2xxx,     bfd_mach_avr2},
-  {"at86rf401", AVR_ISA_2xxx,     bfd_mach_avr2},
-  {"attiny13",  AVR_ISA_TINY2,    bfd_mach_avr2},
-  {"attiny2313",AVR_ISA_TINY2,    bfd_mach_avr2},
-  {"attiny261", AVR_ISA_TINY2,    bfd_mach_avr2},
-  {"attiny461", AVR_ISA_TINY2,    bfd_mach_avr2},
-  {"attiny861", AVR_ISA_TINY2,    bfd_mach_avr2},
-  {"attiny24",  AVR_ISA_TINY2,    bfd_mach_avr2},
-  {"attiny44",  AVR_ISA_TINY2,    bfd_mach_avr2},
-  {"attiny84",  AVR_ISA_TINY2,    bfd_mach_avr2},
-  {"attiny25",  AVR_ISA_TINY2,    bfd_mach_avr2},
-  {"attiny45",  AVR_ISA_TINY2,    bfd_mach_avr2},
-  {"attiny85",  AVR_ISA_TINY2,    bfd_mach_avr2},
-  {"atmega603", AVR_ISA_M603,     bfd_mach_avr3}, /* XXX -> m103 */
-  {"atmega103", AVR_ISA_M103,     bfd_mach_avr3},
-  {"at43usb320",AVR_ISA_M103,     bfd_mach_avr3},
-  {"at43usb355",AVR_ISA_M603,     bfd_mach_avr3},
-  {"at76c711",  AVR_ISA_M603,     bfd_mach_avr3},
-  {"atmega48",  AVR_ISA_PWMx,     bfd_mach_avr4},
-  {"atmega8",   AVR_ISA_M8,       bfd_mach_avr4},
-  {"atmega83",  AVR_ISA_M8,       bfd_mach_avr4}, /* XXX -> m8535 */
-  {"atmega85",  AVR_ISA_M8,       bfd_mach_avr4}, /* XXX -> m8 */
-  {"atmega88",  AVR_ISA_PWMx,     bfd_mach_avr4},
-  {"atmega8515",AVR_ISA_M8,       bfd_mach_avr4},
-  {"atmega8535",AVR_ISA_M8,       bfd_mach_avr4},
-  {"at90pwm2",  AVR_ISA_PWMx,     bfd_mach_avr4},
-  {"at90pwm3",  AVR_ISA_PWMx,     bfd_mach_avr4},
-  {"atmega16",  AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega161", AVR_ISA_M161,     bfd_mach_avr5},
-  {"atmega162", AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega163", AVR_ISA_M161,     bfd_mach_avr5},
-  {"atmega164", AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega165", AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega168", AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega169", AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega32",  AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega323", AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega324", AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega325", AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega329", AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega3250",AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega3290",AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega406", AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega64",  AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega640", AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega644", AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega128", AVR_ISA_M128,     bfd_mach_avr5},
-  {"atmega1280",AVR_ISA_M128,     bfd_mach_avr5},
-  {"atmega1281",AVR_ISA_M128,     bfd_mach_avr5},
-  {"atmega645", AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega649", AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega6450",AVR_ISA_M323,     bfd_mach_avr5},
-  {"atmega6490",AVR_ISA_M323,     bfd_mach_avr5},
-  {"at90can32" ,AVR_ISA_M323,     bfd_mach_avr5},
-  {"at90can64" ,AVR_ISA_M323,     bfd_mach_avr5},
-  {"at90can128",AVR_ISA_M128,     bfd_mach_avr5},
-  {"at90usb646", AVR_ISA_M323,    bfd_mach_avr5},
-  {"at90usb647", AVR_ISA_M323,    bfd_mach_avr5},
-  {"at90usb1286",AVR_ISA_M128,    bfd_mach_avr5},
-  {"at90usb1287",AVR_ISA_M128,    bfd_mach_avr5},
-  {"at94k",     AVR_ISA_94K,      bfd_mach_avr5},
+  {"avr1",       AVR_ISA_AVR1,    bfd_mach_avr1},
+/* TODO: insruction set for avr2 architecture should be AVR_ISA_AVR2,
+ but set to AVR_ISA_AVR25 for some following version 
+ of GCC (from 4.3) for backward compatibility.  */  
+  {"avr2",       AVR_ISA_AVR25,   bfd_mach_avr2},
+  {"avr25",      AVR_ISA_AVR25,   bfd_mach_avr25},
+/* TODO: insruction set for avr3 architecture should be AVR_ISA_AVR3, 
+ but set to AVR_ISA_AVR3_ALL for some following version 
+ of GCC (from 4.3) for backward compatibility.  */
+  {"avr3",       AVR_ISA_AVR3_ALL, bfd_mach_avr3},
+  {"avr31",      AVR_ISA_AVR31,   bfd_mach_avr31},
+  {"avr35",      AVR_ISA_AVR35,   bfd_mach_avr35},
+  {"avr4",       AVR_ISA_AVR4,    bfd_mach_avr4},
+/* TODO: insruction set for avr5 architecture should be AVR_ISA_AVR5, 
+ but set to AVR_ISA_AVR51 for some following version 
+ of GCC (from 4.3) for backward compatibility.  */
+  {"avr5",       AVR_ISA_AVR51,   bfd_mach_avr5},
+  {"avr51",      AVR_ISA_AVR51,   bfd_mach_avr51},
+  {"avr6",       AVR_ISA_AVR6,    bfd_mach_avr6},
+  {"at90s1200",  AVR_ISA_1200,    bfd_mach_avr1},
+  {"attiny11",   AVR_ISA_AVR1,    bfd_mach_avr1},
+  {"attiny12",   AVR_ISA_AVR1,    bfd_mach_avr1},
+  {"attiny15",   AVR_ISA_AVR1,    bfd_mach_avr1},
+  {"attiny28",   AVR_ISA_AVR1,    bfd_mach_avr1},
+  {"at90s2313",  AVR_ISA_AVR2,    bfd_mach_avr2},
+  {"at90s2323",  AVR_ISA_AVR2,    bfd_mach_avr2},
+  {"at90s2333",  AVR_ISA_AVR2,    bfd_mach_avr2}, /* XXX -> 4433 */
+  {"at90s2343",  AVR_ISA_AVR2,    bfd_mach_avr2},
+  {"attiny22",   AVR_ISA_AVR2,    bfd_mach_avr2}, /* XXX -> 2343 */
+  {"attiny26",   AVR_ISA_2xxe,    bfd_mach_avr2},
+  {"at90s4414",  AVR_ISA_AVR2,    bfd_mach_avr2}, /* XXX -> 8515 */
+  {"at90s4433",  AVR_ISA_AVR2,    bfd_mach_avr2},
+  {"at90s4434",  AVR_ISA_AVR2,    bfd_mach_avr2}, /* XXX -> 8535 */
+  {"at90s8515",  AVR_ISA_AVR2,    bfd_mach_avr2},
+  {"at90c8534",  AVR_ISA_AVR2,    bfd_mach_avr2},
+  {"at90s8535",  AVR_ISA_AVR2,    bfd_mach_avr2},
+  {"attiny13",   AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny13a",  AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny2313", AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny2313a",AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny24",   AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny24a",  AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny4313", AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny44",   AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny44a",  AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny84",   AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny25",   AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny45",   AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny85",   AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny261",  AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny261a", AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny461",  AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny861",  AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny861a", AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny87",   AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny43u",  AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny48",   AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"attiny88",   AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"at86rf401",  AVR_ISA_RF401,   bfd_mach_avr25},
+  {"ata6289",    AVR_ISA_AVR25,   bfd_mach_avr25},
+  {"at43usb355", AVR_ISA_AVR3,    bfd_mach_avr3},
+  {"at76c711",   AVR_ISA_AVR3,    bfd_mach_avr3},
+  {"atmega103",  AVR_ISA_AVR31,   bfd_mach_avr31},
+  {"at43usb320", AVR_ISA_AVR31,   bfd_mach_avr31},
+  {"attiny167",  AVR_ISA_AVR35,   bfd_mach_avr35},
+  {"attiny327",  AVR_ISA_AVR35,   bfd_mach_avr35},
+  {"at90usb82",  AVR_ISA_AVR35,   bfd_mach_avr35},
+  {"at90usb162", AVR_ISA_AVR35,   bfd_mach_avr35},
+  {"atmega8u2",  AVR_ISA_AVR35,   bfd_mach_avr35},
+  {"atmega16u2", AVR_ISA_AVR35,   bfd_mach_avr35},
+  {"atmega32u2", AVR_ISA_AVR35,   bfd_mach_avr35},
+  {"atmega8",    AVR_ISA_M8,      bfd_mach_avr4},
+  {"atmega48",   AVR_ISA_AVR4,    bfd_mach_avr4},
+  {"atmega48p",  AVR_ISA_AVR4,    bfd_mach_avr4},
+  {"atmega88",   AVR_ISA_AVR4,    bfd_mach_avr4},
+  {"atmega88p",  AVR_ISA_AVR4,    bfd_mach_avr4},
+  {"atmega8515", AVR_ISA_M8,      bfd_mach_avr4},
+  {"atmega8535", AVR_ISA_M8,      bfd_mach_avr4},
+  {"atmega8hva", AVR_ISA_AVR4,    bfd_mach_avr4},
+  {"atmega4hvd", AVR_ISA_AVR4,    bfd_mach_avr4},
+  {"atmega8hvd", AVR_ISA_AVR4,    bfd_mach_avr4},
+  {"atmega8c1",  AVR_ISA_AVR4,    bfd_mach_avr4},
+  {"atmega8m1",  AVR_ISA_AVR4,    bfd_mach_avr4},
+  {"at90pwm1",   AVR_ISA_AVR4,    bfd_mach_avr4},
+  {"at90pwm2",   AVR_ISA_AVR4,    bfd_mach_avr4},
+  {"at90pwm2b",  AVR_ISA_AVR4,    bfd_mach_avr4},
+  {"at90pwm3",   AVR_ISA_AVR4,    bfd_mach_avr4},
+  {"at90pwm3b",  AVR_ISA_AVR4,    bfd_mach_avr4},
+  {"at90pwm81",  AVR_ISA_AVR4,    bfd_mach_avr4},
+  {"atmega16",   AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega161",  AVR_ISA_M161,    bfd_mach_avr5},
+  {"atmega162",  AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega163",  AVR_ISA_M161,    bfd_mach_avr5},
+  {"atmega164p", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega165",  AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega165p", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega168",  AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega168p", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega169",  AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega169p", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega16c1", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega32",   AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega323",  AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega324p", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega325",  AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega325p", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega3250", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega3250p",AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega328p", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega329",  AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega329p", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega3290", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega3290p",AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega406",  AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega64",   AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega640",  AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega644",  AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega644p", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega644pa",AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega645",  AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega649",  AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega6450", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega6490", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega16hva",AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega16hvb",AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega32hvb",AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"at90can32" , AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"at90can64" , AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"at90pwm216", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"at90pwm316", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega32c1", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega64c1", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega16m1", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega32m1", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega64m1", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega16u4", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega32u4", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"atmega32u6", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"at90usb646", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"at90usb647", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"at90scr100", AVR_ISA_AVR5,    bfd_mach_avr5},
+  {"at94k",      AVR_ISA_94K,     bfd_mach_avr5},
+  {"atmega128",  AVR_ISA_AVR51,   bfd_mach_avr51},
+  {"atmega1280", AVR_ISA_AVR51,   bfd_mach_avr51},
+  {"atmega1281", AVR_ISA_AVR51,   bfd_mach_avr51},
+  {"atmega1284p",AVR_ISA_AVR51,   bfd_mach_avr51},
+  {"atmega128rfa1",AVR_ISA_AVR51, bfd_mach_avr51},
+  {"at90can128", AVR_ISA_AVR51,   bfd_mach_avr51},
+  {"at90usb1286",AVR_ISA_AVR51,   bfd_mach_avr51},
+  {"at90usb1287",AVR_ISA_AVR51,   bfd_mach_avr51},
+  {"m3000f",     AVR_ISA_AVR51,   bfd_mach_avr51},
+  {"m3000s",     AVR_ISA_AVR51,   bfd_mach_avr51},
+  {"m3001b",     AVR_ISA_AVR51,   bfd_mach_avr51},
+  {"atmega2560", AVR_ISA_AVR6,    bfd_mach_avr6},
+  {"atmega2561", AVR_ISA_AVR6,    bfd_mach_avr6},
   {NULL, 0, 0}
 };
 
 /* Current MCU type.  */
-static struct mcu_type_s   default_mcu = {"avr2", AVR_ISA_2xxx,bfd_mach_avr2};
+static struct mcu_type_s   default_mcu = {"avr2", AVR_ISA_AVR2, bfd_mach_avr2};
 static struct mcu_type_s * avr_mcu = & default_mcu;
 
 /* AVR target-specific switches.  */
@@ -311,11 +380,18 @@ md_show_usage (FILE *stream)
       _("AVR options:\n"
        "  -mmcu=[avr-name] select microcontroller variant\n"
        "                   [avr-name] can be:\n"
-       "                   avr1 - AT90S1200, ATtiny1x, ATtiny28\n"
-       "                   avr2 - AT90S2xxx, AT90S4xxx, AT90S8xxx, ATtiny22\n"
-       "                   avr3 - ATmega103, ATmega603\n"
-       "                   avr4 - ATmega83, ATmega85\n"
-       "                   avr5 - ATmega161, ATmega163, ATmega32, AT94K\n"
+       "                   avr1  - classic AVR core without data RAM\n"
+       "                   avr2  - classic AVR core with up to 8K program memory\n"
+       "                   avr25 - classic AVR core with up to 8K program memory\n"
+       "                           plus the MOVW instruction\n"
+       "                   avr3  - classic AVR core with up to 64K program memory\n"
+       "                   avr31 - classic AVR core with up to 128K program memory\n"
+       "                   avr35 - classic AVR core with up to 64K program memory\n"
+       "                           plus the MOVW instruction\n"
+       "                   avr4  - enhanced AVR core with up to 8K program memory\n"
+       "                   avr5  - enhanced AVR core with up to 64K program memory\n"
+       "                   avr51 - enhanced AVR core with up to 128K program memory\n"
+       "                   avr6  - enhanced AVR core with up to 256K program memory\n"
        "                   or immediate microcontroller name.\n"));
   fprintf (stream,
       _("  -mall-opcodes    accept all AVR opcodes, even if not supported by MCU\n"
@@ -395,46 +471,10 @@ md_undefined_symbol (char *name ATTRIBUTE_UNUSED)
   return NULL;
 }
 
-/* Turn a string in input_line_pointer into a floating point constant
-   of type TYPE, and store the appropriate bytes in *LITP.  The number
-   of LITTLENUMS emitted is stored in *SIZEP.  An error message is
-   returned, or NULL on OK.  */
-
 char *
 md_atof (int type, char *litP, int *sizeP)
 {
-  int prec;
-  LITTLENUM_TYPE words[4];
-  LITTLENUM_TYPE *wordP;
-  char *t;
-
-  switch (type)
-    {
-    case 'f':
-      prec = 2;
-      break;
-    case 'd':
-      prec = 4;
-      break;
-    default:
-      *sizeP = 0;
-      return _("bad call to md_atof");
-    }
-
-  t = atof_ieee (input_line_pointer, type, words);
-  if (t)
-    input_line_pointer = t;
-
-  *sizeP = prec * sizeof (LITTLENUM_TYPE);
-
-  /* This loop outputs the LITTLENUMs in REVERSE order.  */
-  for (wordP = words + prec - 1; prec--;)
-    {
-      md_number_to_chars (litP, (valueT) (*wordP--), sizeof (LITTLENUM_TYPE));
-      litP += sizeof (LITTLENUM_TYPE);
-    }
-
-  return NULL;
+  return ieee_md_atof (type, litP, sizeP, FALSE);
 }
 
 void
@@ -488,7 +528,7 @@ avr_get_constant (char *str, int max)
     as_bad (_("constant value required"));
 
   if (ex.X_add_number > max || ex.X_add_number < 0)
-    as_bad (_("number must be less than %d"), max + 1);
+    as_bad (_("number must be positive and less than %d"), max + 1);
 
   return ex.X_add_number;
 }
@@ -512,7 +552,7 @@ avr_offset_expression (expressionS *exp)
   if (exp->X_op == O_constant)
     {
       int x = exp->X_add_number;
-      
+
       if (x < -255 || x > 255)
        as_warn (_("constant out of 8-bit range: %d"), x);
     }
@@ -544,6 +584,8 @@ avr_ldi_expression (expressionS *exp)
   char *tmp;
   char op[8];
   int mod;
+  int linker_stubs_should_be_generated = 0;
+
   tmp = str;
 
   str = extract_word (str, op, sizeof (op));
@@ -551,7 +593,7 @@ avr_ldi_expression (expressionS *exp)
   if (op[0])
     {
       mod_index m;
-      
+
       m.ptr = hash_find (avr_mod_hash, op);
       mod = m.index;
 
@@ -564,11 +606,14 @@ avr_ldi_expression (expressionS *exp)
 
          if (*str == '(')
            {
+             bfd_reloc_code_real_type  reloc_to_return;
              int neg_p = 0;
 
              ++str;
 
              if (strncmp ("pm(", str, 3) == 0
+                  || strncmp ("gs(",str,3) == 0
+                  || strncmp ("-(gs(",str,5) == 0
                  || strncmp ("-(pm(", str, 5) == 0)
                {
                  if (HAVE_PM_P (mod))
@@ -579,6 +624,9 @@ avr_ldi_expression (expressionS *exp)
                  else
                    as_bad (_("illegal expression"));
 
+                  if (str[0] == 'g' || str[2] == 'g')
+                    linker_stubs_should_be_generated = 1;
+
                  if (*str == '-')
                    {
                      neg_p = 1;
@@ -610,7 +658,26 @@ avr_ldi_expression (expressionS *exp)
                }
              while (closes--);
 
-             return neg_p ? EXP_MOD_NEG_RELOC (mod) : EXP_MOD_RELOC (mod);
+             reloc_to_return =
+               neg_p ? EXP_MOD_NEG_RELOC (mod) : EXP_MOD_RELOC (mod);
+             if (linker_stubs_should_be_generated)
+               {
+                 switch (reloc_to_return)
+                   {
+                   case BFD_RELOC_AVR_LO8_LDI_PM:
+                     reloc_to_return = BFD_RELOC_AVR_LO8_LDI_GS;
+                     break;
+                   case BFD_RELOC_AVR_HI8_LDI_PM:
+                     reloc_to_return = BFD_RELOC_AVR_HI8_LDI_GS;
+                     break;
+
+                   default:
+                     /* PR 5523: Do not generate a warning here,
+                        legitimate code can trigger this case.  */
+                     break;
+                   }
+               }
+             return reloc_to_return;
            }
        }
     }
@@ -754,6 +821,12 @@ avr_operand (struct avr_opcodes_s *opcode,
          ++str;
          op_mask |= 1;
        }
+
+      /* attiny26 can do "lpm" and "lpm r,Z" but not "lpm r,Z+".  */
+      if (!avr_opt.all_opcodes
+         && (op_mask & 0x0001)
+         && !(avr_mcu->isa & AVR_ISA_MOVW))
+       as_bad (_("postincrement not supported"));
       break;
 
     case 'b':
@@ -1184,7 +1257,7 @@ md_apply_fix (fixS *fixP, valueT * valP, segT seg)
     }
   else
     {
-      switch (fixP->fx_r_type)
+      switch ((int) fixP->fx_r_type)
        {
        case -BFD_RELOC_AVR_HI8_LDI_NEG:
        case -BFD_RELOC_AVR_HI8_LDI:
@@ -1227,7 +1300,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED,
           return NULL;
         }
 
-      /* We are dealing with two symbols defined in the same section. 
+      /* We are dealing with two symbols defined in the same section.
          Let us fix-up them here.  */
       value += S_GET_VALUE (fixp->fx_addsy);
       value -= S_GET_VALUE (fixp->fx_subsy);
@@ -1310,7 +1383,8 @@ md_assemble (char *str)
 static int exp_mod_pm = 0;
 
 /* Parse special CONS expression: pm (expression)
-   which is used for addressing to a program memory.
+   or alternatively: gs (expression).
+   These are used for addressing program memory.
    Relocation: BFD_RELOC_AVR_16_PM.  */
 
 void
@@ -1324,10 +1398,13 @@ avr_parse_cons_expression (expressionS *exp, int nbytes)
 
   if (nbytes == 2)
     {
-      char *pm_name = "pm";
-      int len = strlen (pm_name);
+      char *pm_name1 = "pm";
+      char *pm_name2 = "gs";
+      int len = strlen (pm_name1);
+      /* len must be the same for both pm identifiers.  */
 
-      if (strncasecmp (input_line_pointer, pm_name, len) == 0)
+      if (strncasecmp (input_line_pointer, pm_name1, len) == 0
+          || strncasecmp (input_line_pointer, pm_name2, len) == 0)
        {
          input_line_pointer = skip_space (input_line_pointer + len);
 
This page took 0.028863 seconds and 4 git commands to generate.