OSDN Git Service

* config/avr/avr.c (avr_mcu_t): Add atmega8c1, atmega16c1 and
[pf3gnuchains/gcc-fork.git] / gcc / config / avr / avr.h
index f1c6da0..54c607a 100644 (file)
@@ -1,14 +1,14 @@
 /* Definitions of target machine for GNU compiler,
    for ATMEL AVR at90s8515, ATmega103/103L, ATmega603/603L microcontrollers.
-   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
-   Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 
+   2008, 2009 Free Software Foundation, Inc.
    Contributed by Denis Chertykov (denisc@overta.ru)
 
 This file is part of GCC.
 
 GCC 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.
 
 GCC is distributed in the hope that it will be useful,
@@ -17,90 +17,101 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 /* Names to predefine in the preprocessor for this target machine.  */
 
+struct base_arch_s {
+  /* Assembler only.  */
+  int asm_only;
+
+  /* Core have 'MUL*' instructions.  */
+  int have_mul;
+
+  /* Core have 'CALL' and 'JMP' instructions.  */
+  int have_jmp_call;
+
+  /* Core have 'MOVW' and 'LPM Rx,Z' instructions.  */
+  int have_movw_lpmx;
+
+  /* Core have 'ELPM' instructions.  */
+  int have_elpm;
+
+  /* Core have 'ELPM Rx,Z' instructions.  */
+  int have_elpmx;
+
+  /* Core have 'EICALL' and 'EIJMP' instructions.  */
+  int have_eijmp_eicall;
+
+  /* Reserved. */
+  int reserved;
+  
+  const char *const macro;
+};
+
+extern const struct base_arch_s *avr_current_arch;
+
 #define TARGET_CPU_CPP_BUILTINS()              \
   do                                           \
     {                                          \
       builtin_define_std ("AVR");              \
-      if (avr_base_arch_macro)                 \
-       builtin_define (avr_base_arch_macro);   \
+      if (avr_current_arch->macro)             \
+       builtin_define (avr_current_arch->macro);       \
       if (avr_extra_arch_macro)                        \
        builtin_define (avr_extra_arch_macro);  \
-      if (avr_asm_only_p)                      \
+      if (avr_current_arch->have_elpm)         \
+       builtin_define ("__AVR_HAVE_RAMPZ__");  \
+      if (avr_current_arch->have_elpm)         \
+       builtin_define ("__AVR_HAVE_ELPM__");   \
+      if (avr_current_arch->have_elpmx)                \
+       builtin_define ("__AVR_HAVE_ELPMX__");  \
+      if (avr_current_arch->have_movw_lpmx)    \
+       {                                       \
+         builtin_define ("__AVR_HAVE_MOVW__"); \
+         builtin_define ("__AVR_HAVE_LPMX__"); \
+       }                                       \
+      if (avr_current_arch->asm_only)          \
        builtin_define ("__AVR_ASM_ONLY__");    \
-      if (avr_enhanced_p)                      \
-       builtin_define ("__AVR_ENHANCED__");    \
-      if (avr_mega_p)                          \
-       builtin_define ("__AVR_MEGA__");        \
+      if (avr_current_arch->have_mul)          \
+       {                                       \
+         builtin_define ("__AVR_ENHANCED__");  \
+         builtin_define ("__AVR_HAVE_MUL__");  \
+       }                                       \
+      if (avr_current_arch->have_jmp_call)     \
+       {                                       \
+         builtin_define ("__AVR_MEGA__");      \
+         builtin_define ("__AVR_HAVE_JMP_CALL__");     \
+       }                                       \
+      if (avr_current_arch->have_eijmp_eicall) \
+        {                                      \
+         builtin_define ("__AVR_HAVE_EIJMP_EICALL__"); \
+         builtin_define ("__AVR_3_BYTE_PC__"); \
+       }                                       \
+      else                                     \
+        {                                      \
+         builtin_define ("__AVR_2_BYTE_PC__"); \
+       }                                       \
       if (TARGET_NO_INTERRUPTS)                        \
        builtin_define ("__NO_INTERRUPTS__");   \
     }                                          \
   while (0)
 
-/* This declaration should be present.  */
-extern int target_flags;
-
-#define MASK_ALL_DEBUG         0x00000FE0
-#define MASK_ORDER_1           0x00001000
-#define MASK_INSN_SIZE_DUMP    0x00002000
-#define MASK_ORDER_2           0x00004000
-#define MASK_NO_TABLEJUMP      0x00008000
-#define MASK_INT8              0x00010000
-#define MASK_NO_INTERRUPTS     0x00020000
-#define MASK_CALL_PROLOGUES    0x00040000
-#define MASK_TINY_STACK                0x00080000
-#define MASK_SHORT_CALLS       0x00100000
-
-#define TARGET_ORDER_1         (target_flags & MASK_ORDER_1)
-#define TARGET_ORDER_2         (target_flags & MASK_ORDER_2)
-#define TARGET_INT8            (target_flags & MASK_INT8)
-#define TARGET_NO_INTERRUPTS   (target_flags & MASK_NO_INTERRUPTS)
-#define TARGET_INSN_SIZE_DUMP  (target_flags & MASK_INSN_SIZE_DUMP)
-#define TARGET_CALL_PROLOGUES  (target_flags & MASK_CALL_PROLOGUES)
-#define TARGET_TINY_STACK      (target_flags & MASK_TINY_STACK)
-#define TARGET_NO_TABLEJUMP    (target_flags & MASK_NO_TABLEJUMP)
-#define TARGET_SHORT_CALLS     (target_flags & MASK_SHORT_CALLS)
-#define TARGET_ALL_DEBUG       (target_flags & MASK_ALL_DEBUG)
-
-#define TARGET_SWITCHES {                                              \
-  { "order1", MASK_ORDER_1, NULL },                                    \
-  { "order2", MASK_ORDER_2, NULL },                                    \
-  { "int8", MASK_INT8, N_("Assume int to be 8 bit integer") },         \
-  { "no-interrupts", MASK_NO_INTERRUPTS,                               \
-    N_("Change the stack pointer without disabling interrupts") },     \
-  { "call-prologues", MASK_CALL_PROLOGUES,                             \
-    N_("Use subroutines for function prologue/epilogue") },            \
-  { "tiny-stack", MASK_TINY_STACK,                                     \
-    N_("Change only the low 8 bits of the stack pointer") },           \
-  { "no-tablejump", MASK_NO_TABLEJUMP,                                 \
-    N_("Do not generate tablejump insns") },                           \
-  { "short-calls", MASK_SHORT_CALLS,                                   \
-    N_("Use rjmp/rcall (limited range) on >8K devices") },             \
-  { "size", MASK_INSN_SIZE_DUMP,                                       \
-    N_("Output instruction sizes to the asm file") },                  \
-  { "deb", MASK_ALL_DEBUG, NULL },                                     \
-  { "", 0, NULL } }
-
-extern const char *avr_init_stack;
-extern const char *avr_mcu_name;
-
-extern const char *avr_base_arch_macro;
 extern const char *avr_extra_arch_macro;
-extern int avr_mega_p;
-extern int avr_enhanced_p;
-extern int avr_asm_only_p;
 
-#define AVR_MEGA (avr_mega_p && !TARGET_SHORT_CALLS)
-#define AVR_ENHANCED (avr_enhanced_p)
+#if !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS)
+extern GTY(()) section *progmem_section;
+#endif
+
+#define AVR_HAVE_JMP_CALL (avr_current_arch->have_jmp_call && !TARGET_SHORT_CALLS)
+#define AVR_HAVE_MUL (avr_current_arch->have_mul)
+#define AVR_HAVE_MOVW (avr_current_arch->have_movw_lpmx)
+#define AVR_HAVE_LPMX (avr_current_arch->have_movw_lpmx)
+#define AVR_HAVE_RAMPZ (avr_current_arch->have_elpm)
+#define AVR_HAVE_EIJMP_EICALL (avr_current_arch->have_eijmp_eicall)
 
-#define TARGET_OPTIONS {                                                     \
- { "init-stack=", &avr_init_stack, N_("Specify the initial stack address"), 0}, \
- { "mcu=", &avr_mcu_name, N_("Specify the MCU name"), 0} }
+#define AVR_2_BYTE_PC (!AVR_HAVE_EIJMP_EICALL)
+#define AVR_3_BYTE_PC (AVR_HAVE_EIJMP_EICALL)
 
 #define TARGET_VERSION fprintf (stderr, " (GNU assembler syntax)");
 
@@ -136,6 +147,9 @@ extern int avr_asm_only_p;
 /* No data type wants to be aligned rounder than this.  */
 #define BIGGEST_ALIGNMENT 8
 
+#define MAX_OFILE_ALIGNMENT (32768 * 8)
+
+#define TARGET_VTABLE_ENTRY_ALIGN 8
 
 #define STRICT_ALIGNMENT 0
 
@@ -216,7 +230,7 @@ extern int avr_asm_only_p;
 
 #define HARD_REGNO_MODE_OK(REGNO, MODE) avr_hard_regno_mode_ok(REGNO, MODE)
 
-#define MODES_TIEABLE_P(MODE1, MODE2) 0
+#define MODES_TIEABLE_P(MODE1, MODE2) 1
 
 enum reg_class {
   NO_REGS,
@@ -254,11 +268,6 @@ enum reg_class {
                   "GENERAL_REGS", /* r0 - r31 */               \
                   "ALL_REGS" }
 
-#define REG_X 26
-#define REG_Y 28
-#define REG_Z 30
-#define REG_W 24
-
 #define REG_CLASS_CONTENTS {                                           \
   {0x00000000,0x00000000},     /* NO_REGS */                           \
   {0x00000001,0x00000000},     /* R0_REG */                            \
@@ -282,12 +291,23 @@ enum reg_class {
 
 #define REGNO_REG_CLASS(R) avr_regno_reg_class(R)
 
+/* The following macro defines cover classes for Integrated Register
+   Allocator.  Cover classes is a set of non-intersected register
+   classes covering all hard registers used for register allocation
+   purpose.  Any move between two registers of a cover class should be
+   cheaper than load or store of the registers.  The macro value is
+   array of register classes with LIM_REG_CLASSES used as the end
+   marker.  */
+
+#define IRA_COVER_CLASSES               \
+{                                       \
+  GENERAL_REGS, LIM_REG_CLASSES         \
+}
+
 #define BASE_REG_CLASS (reload_completed ? BASE_POINTER_REGS : POINTER_REGS)
 
 #define INDEX_REG_CLASS NO_REGS
 
-#define REG_CLASS_FROM_LETTER(C) avr_reg_class_from_letter(C)
-
 #define REGNO_OK_FOR_BASE_P(r) (((r) < FIRST_PSEUDO_REGISTER           \
                                 && ((r) == REG_X                       \
                                     || (r) == REG_Y                    \
@@ -310,23 +330,6 @@ enum reg_class {
 
 #define CLASS_MAX_NREGS(CLASS, MODE)   class_max_nregs (CLASS, MODE)
 
-#define CONST_OK_FOR_LETTER_P(VALUE, C)                                \
-  ((C) == 'I' ? (VALUE) >= 0 && (VALUE) <= 63 :                        \
-   (C) == 'J' ? (VALUE) <= 0 && (VALUE) >= -63:                        \
-   (C) == 'K' ? (VALUE) == 2 :                                 \
-   (C) == 'L' ? (VALUE) == 0 :                                 \
-   (C) == 'M' ? (VALUE) >= 0 && (VALUE) <= 0xff :              \
-   (C) == 'N' ? (VALUE) == -1:                                 \
-   (C) == 'O' ? (VALUE) == 8 || (VALUE) == 16 || (VALUE) == 24:        \
-   (C) == 'P' ? (VALUE) == 1 :                                 \
-   0)
-
-#define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \
-  ((C) == 'G' ? (VALUE) == CONST0_RTX (SFmode) \
-   : 0)
-
-#define EXTRA_CONSTRAINT(x, c) extra_constraint(x, c)
-
 #define STACK_PUSH_CODE POST_DEC
 
 #define STACK_GROWS_DOWNWARD
@@ -349,6 +352,9 @@ enum reg_class {
 
 #define FRAME_POINTER_REQUIRED frame_pointer_required_p()
 
+/* Offset from the frame pointer register value to the top of the stack.  */
+#define FRAME_POINTER_CFA_OFFSET(FNDECL) 0
+
 #define ELIMINABLE_REGS {                                      \
       {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM},              \
        {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}            \
@@ -367,7 +373,9 @@ enum reg_class {
 #define RETURN_ADDR_RTX(count, x) \
   gen_rtx_MEM (Pmode, memory_address (Pmode, plus_constant (tem, 1)))
 
-#define PUSH_ROUNDING(NPUSHED) (NPUSHED)
+/* Don't use Push rounding. expr.c: emit_single_push_insn is broken 
+   for POST_DEC targets (PR27386).  */
+/*#define PUSH_ROUNDING(NPUSHED) (NPUSHED)*/
 
 #define RETURN_POPS_ARGS(FUNDECL, FUNTYPE, STACK_SIZE) 0
 
@@ -390,15 +398,13 @@ extern int avr_reg_order[];
 
 #define RET_REGISTER avr_ret_register ()
 
-#define FUNCTION_VALUE(VALTYPE, FUNC) avr_function_value (VALTYPE, FUNC)
-
 #define LIBCALL_VALUE(MODE)  avr_libcall_value (MODE)
 
 #define FUNCTION_VALUE_REGNO_P(N) ((int) (N) == RET_REGISTER)
 
 #define DEFAULT_PCC_STRUCT_RETURN 0
 
-#define EPILOGUE_USES(REGNO) 0
+#define EPILOGUE_USES(REGNO) avr_epilogue_uses(REGNO)
 
 #define HAVE_POST_INCREMENT 1
 #define HAVE_PRE_DECREMENT 1
@@ -442,6 +448,11 @@ extern int avr_reg_order[];
 }
 
 #define XEXP_(X,Y) (X)
+
+/* LEGITIMIZE_RELOAD_ADDRESS will allow register R26/27 to be used, where it
+   is no worse than normal base pointers R28/29 and R30/31. For example:
+   If base offset is greater than 63 bytes or for R++ or --R addressing.  */
+   
 #define LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_LEVELS, WIN)    \
 do {                                                                       \
   if (1&&(GET_CODE (X) == POST_INC || GET_CODE (X) == PRE_DEC))            \
@@ -453,6 +464,7 @@ do {                                                                            \
     }                                                                      \
   if (GET_CODE (X) == PLUS                                                 \
       && REG_P (XEXP (X, 0))                                               \
+      && reg_equiv_constant[REGNO (XEXP (X, 0))] == 0                      \
       && GET_CODE (XEXP (X, 1)) == CONST_INT                               \
       && INTVAL (XEXP (X, 1)) >= 1)                                        \
     {                                                                      \
@@ -471,10 +483,6 @@ do {                                                                           \
                           OPNUM, TYPE);                                    \
              goto WIN;                                                     \
            }                                                               \
-         push_reload (XEXP (X, 0), NULL_RTX, &XEXP (X, 0), NULL,           \
-                      BASE_POINTER_REGS, GET_MODE (X), VOIDmode, 0, 0,     \
-                      OPNUM, TYPE);                                        \
-          goto WIN;                                                        \
        }                                                                   \
       else if (! (frame_pointer_needed && XEXP (X,0) == frame_pointer_rtx)) \
        {                                                                   \
@@ -486,9 +494,7 @@ do {                                                                            \
     }                                                                      \
 } while(0)
 
-#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)                       \
-      if (GET_CODE (ADDR) == POST_INC || GET_CODE (ADDR) == PRE_DEC)   \
-        goto LABEL
+#define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR,LABEL)
 
 #define LEGITIMATE_CONSTANT_P(X) 1
 
@@ -501,7 +507,7 @@ do {                                                                            \
                                         (MODE)==SImode ? 8 :   \
                                         (MODE)==SFmode ? 8 : 16)
 
-#define BRANCH_COST 0
+#define BRANCH_COST(speed_p, predictable_p) 0
 
 #define SLOW_BYTE_ACCESS 0
 
@@ -527,25 +533,7 @@ do {                                                                           \
 
 #define TARGET_ASM_DESTRUCTOR avr_asm_out_dtor
 
-#define EXTRA_SECTIONS in_progmem
-
-#define EXTRA_SECTION_FUNCTIONS                                                      \
-                                                                             \
-void                                                                         \
-progmem_section (void)                                                       \
-{                                                                            \
-  if (in_section != in_progmem)                                                      \
-    {                                                                        \
-      fprintf (asm_out_file,                                                 \
-              "\t.section .progmem.gcc_sw_table, \"%s\", @progbits\n",       \
-              AVR_MEGA ? "a" : "ax");                                        \
-      /* Should already be aligned, this is just to be safe if it isn't.  */  \
-      fprintf (asm_out_file, "\t.p2align 1\n");                                      \
-      in_section = in_progmem;                                               \
-    }                                                                        \
-}
-
-#define READONLY_DATA_SECTION data_section
+#define SUPPORTS_INIT_PRIORITY 0
 
 #define JUMP_TABLES_IN_TEXT_SECTION 0
 
@@ -557,11 +545,11 @@ progmem_section (void)                                                          \
 
 /* Switch into a generic section.  */
 #define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
+#define TARGET_ASM_INIT_SECTIONS avr_asm_init_sections
 
 #define ASM_OUTPUT_ASCII(FILE, P, SIZE)         gas_output_ascii (FILE,P,SIZE)
 
-#define IS_ASM_LOGICAL_LINE_SEPARATOR(C) ((C) == '\n'                   \
-                                         || ((C) == '$'))
+#define IS_ASM_LOGICAL_LINE_SEPARATOR(C, STR) ((C) == '\n' || ((C) == '$'))
 
 #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED)                    \
 do {                                                                      \
@@ -602,10 +590,7 @@ do {                                                                       \
    specific tm.h file (depending upon the particulars of your assembler).  */
 
 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)            \
-do {                                                           \
-     ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function");       \
-     ASM_OUTPUT_LABEL (FILE, NAME);                            \
-} while (0)
+avr_asm_declare_function_name ((FILE), (NAME), (DECL))
 
 #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL)                   \
   do {                                                                 \
@@ -682,6 +667,8 @@ do {                                                                         \
 /* Globalizing directive for a label.  */
 #define GLOBAL_ASM_OP ".global\t"
 
+#define SET_ASM_OP     "\t.set\t"
+
 #define ASM_WEAKEN_LABEL(FILE, NAME)   \
   do                                   \
     {                                  \
@@ -703,31 +690,29 @@ sprintf (STRING, "*.%s%lu", PREFIX, (unsigned long)(NUM))
     "r8","r9","r10","r11","r12","r13","r14","r15",     \
     "r16","r17","r18","r19","r20","r21","r22","r23",   \
     "r24","r25","r26","r27","r28","r29","r30","r31",   \
-    "__SPL__","__SPH__","argL","argH"}
+    "__SP_L__","__SP_H__","argL","argH"}
 
 #define FINAL_PRESCAN_INSN(insn, operand, nop) final_prescan_insn (insn, operand,nop)
 
 #define PRINT_OPERAND(STREAM, X, CODE) print_operand (STREAM, X, CODE)
 
-#define PRINT_OPERAND_PUNCT_VALID_P(CODE) ((CODE) == '~')
+#define PRINT_OPERAND_PUNCT_VALID_P(CODE) ((CODE) == '~' || (CODE) == '!')
 
 #define PRINT_OPERAND_ADDRESS(STREAM, X) print_operand_address(STREAM, X)
 
 #define USER_LABEL_PREFIX ""
 
-#define ASSEMBLER_DIALECT AVR_ENHANCED
+#define ASSEMBLER_DIALECT AVR_HAVE_MOVW
 
 #define ASM_OUTPUT_REG_PUSH(STREAM, REGNO)     \
 {                                              \
-  if (REGNO > 31)                              \
-    abort ();                                  \
+  gcc_assert (REGNO < 32);                     \
   fprintf (STREAM, "\tpush\tr%d", REGNO);      \
 }
 
 #define ASM_OUTPUT_REG_POP(STREAM, REGNO)      \
 {                                              \
-  if (REGNO > 31)                              \
-    abort ();                                  \
+  gcc_assert (REGNO < 32);                     \
   fprintf (STREAM, "\tpop\tr%d", REGNO);       \
 }
 
@@ -735,12 +720,17 @@ sprintf (STRING, "*.%s%lu", PREFIX, (unsigned long)(NUM))
   avr_output_addr_vec_elt(STREAM, VALUE)
 
 #define ASM_OUTPUT_CASE_LABEL(STREAM, PREFIX, NUM, TABLE) \
-  progmem_section (), (*targetm.asm_out.internal_label) (STREAM, PREFIX, NUM)
+  (switch_to_section (progmem_section), \
+   (*targetm.asm_out.internal_label) (STREAM, PREFIX, NUM))
 
 #define ASM_OUTPUT_SKIP(STREAM, N)             \
 fprintf (STREAM, "\t.skip %lu,0\n", (unsigned long)(N))
 
-#define ASM_OUTPUT_ALIGN(STREAM, POWER)
+#define ASM_OUTPUT_ALIGN(STREAM, POWER)                        \
+  do {                                                 \
+      if ((POWER) > 1)                                 \
+          fprintf (STREAM, "\t.p2align\t%d\n", POWER); \
+  } while (0)
 
 #define CASE_VECTOR_MODE HImode
 
@@ -805,27 +795,130 @@ extern int avr_case_values_threshold;
 #define CC1PLUS_SPEC "%{!frtti:-fno-rtti} \
     %{!fenforce-eh-specs:-fno-enforce-eh-specs} \
     %{!fexceptions:-fno-exceptions}"
-/* A C string constant that tells the GCC drvier program options to
+/* A C string constant that tells the GCC driver program options to
    pass to `cc1plus'.  */
 
-#define ASM_SPEC "%{mmcu=*:-mmcu=%*}"
-
-#define LINK_SPEC " %{!mmcu*:-m avr2}\
-%{mmcu=at90s1200|mmcu=attiny1*|mmcu=attiny28:-m avr1} \
-%{mmcu=attiny22|mmcu=attiny26|mmcu=at90s2*|mmcu=at90s4*|mmcu=at90s8*|mmcu=at90c8*|mmcu=at86rf401:-m avr2}\
-%{mmcu=atmega103|mmcu=atmega603|mmcu=at43*|mmcu=at76*:-m avr3}\
-%{mmcu=atmega8*:-m avr4}\
-%{mmcu=atmega16*|mmcu=atmega32*|mmcu=atmega64|mmcu=atmega128|mmcu=at94k:-m avr5}\
-%{mmcu=atmega64|mmcu=atmega128|mmcu=atmega162|mmcu=atmega169: -Tdata 0x800100} "
+#define ASM_SPEC "%{mmcu=avr25:-mmcu=avr2;mmcu=avr35:-mmcu=avr3;mmcu=avr31:-mmcu=avr3;mmcu=avr51:-mmcu=avr5;\
+mmcu=*:-mmcu=%*}"
+
+#define LINK_SPEC "\
+%{mrelax:--relax\
+         %{mpmem-wrap-around:%{mmcu=at90usb8*:--pmem-wrap-around=8k}\
+                             %{mmcu=atmega16*:--pmem-wrap-around=16k}\
+                             %{mmcu=atmega32*|\
+                               mmcu=at90can32*:--pmem-wrap-around=32k}\
+                             %{mmcu=atmega64*|\
+                               mmcu=at90can64*|\
+                               mmcu=at90usb64*:--pmem-wrap-around=64k}}}\
+%{!mmcu*: -m avr2}\
+%{mmcu=at90s1200|\
+  mmcu=attiny11|\
+  mmcu=attiny12|\
+  mmcu=attiny15|\
+  mmcu=attiny28: -m avr1}\
+%{mmcu=attiny22|\
+  mmcu=attiny26|\
+  mmcu=at90s2*|\
+  mmcu=at90s4*|\
+  mmcu=at90s8*|\
+  mmcu=at90c8*|\
+  mmcu=at86rf401|\
+  mmcu=ata6289|\
+  mmcu=attiny13*|\
+  mmcu=attiny2313|\
+  mmcu=attiny24|\
+  mmcu=attiny25|\
+  mmcu=attiny261|\
+  mmcu=attiny4*|\
+  mmcu=attiny8*: -m avr2}\
+%{mmcu=atmega103|\
+  mmcu=at43*|\
+  mmcu=at76*|\
+  mmcu=at90usb82|\
+  mmcu=at90usb162|\
+  mmcu=attiny16*|\
+  mmcu=attiny32*: -m avr3}\
+%{mmcu=atmega8*|\
+  mmcu=atmega4*|\
+  mmcu=at90pwm1|\
+  mmcu=at90pwm2|\
+  mmcu=at90pwm2b|\
+  mmcu=at90pwm3|\
+  mmcu=at90pwm3b|\
+  mmcu=at90pwm81: -m avr4}\
+%{mmcu=atmega16*|\
+  mmcu=atmega32*|\
+  mmcu=atmega406|\
+  mmcu=atmega64*|\
+  mmcu=atmega128*|\
+  mmcu=at90can*|\
+  mmcu=at90pwm216|\
+  mmcu=at90pwm316|\
+  mmcu=at90scr100|\
+  mmcu=at90usb64*|\
+  mmcu=at90usb128*|\
+  mmcu=at94k|\
+  mmcu=m3000*|\
+  mmcu=m3001*: -m avr5}\
+%{mmcu=atmega256*:-m avr6}\
+%{mmcu=atmega324*|\
+  mmcu=atmega325*|\
+  mmcu=atmega328p|\
+  mmcu=atmega329*|\
+  mmcu=atmega406|\
+  mmcu=atmega48*|\
+  mmcu=atmega88*|\
+  mmcu=atmega64|\
+  mmcu=atmega644*|\
+  mmcu=atmega645*|\
+  mmcu=atmega649*|\
+  mmcu=atmega128|\
+  mmcu=atmega1284p|\
+  mmcu=atmega162|\
+  mmcu=atmega164*|\
+  mmcu=atmega165*|\
+  mmcu=atmega168*|\
+  mmcu=atmega169*|\
+  mmcu=atmega4hv*|\
+  mmcu=atmega8hv*|\
+  mmcu=atmega16hv*|\
+  mmcu=atmega32hv*|\
+  mmcu=attiny48|\
+  mmcu=attiny88|\
+  mmcu=attiny87|\
+  mmcu=attiny167|\
+  mmcu=attiny327|\
+  mmcu=at90can*|\
+  mmcu=at90pwm*|\
+  mmcu=atmega8c1|\
+  mmcu=atmega16c1|\
+  mmcu=atmega32c1|\
+  mmcu=atmega64c1|\
+  mmcu=atmega8m1|\
+  mmcu=atmega16m1|\
+  mmcu=atmega32m1|\
+  mmcu=atmega64m1|\
+  mmcu=atmega16u4|\
+  mmcu=atmega32u*|\
+  mmcu=at90scr100|\
+  mmcu=ata6289|\
+  mmcu=at90usb*: -Tdata 0x800100}\
+%{mmcu=atmega640|\
+  mmcu=atmega1280|\
+  mmcu=atmega1281|\
+  mmcu=atmega256*|\
+  mmcu=atmega128rfa1: -Tdata 0x800200}\
+%{mmcu=m3000*|\
+  mmcu=m3001*: -Tdata 0x801000}"
 
 #define LIB_SPEC \
-  "%{!mmcu=at90s1*:%{!mmcu=attiny1*:%{!mmcu=attiny28: -lc }}}"
+  "%{!mmcu=at90s1*:%{!mmcu=attiny11:%{!mmcu=attiny12:%{!mmcu=attiny15:%{!mmcu=attiny28: -lc }}}}}"
 
 #define LIBSTDCXX "-lgcc"
 /* No libstdc++ for now.  Empty string doesn't work.  */
 
 #define LIBGCC_SPEC \
-  "%{!mmcu=at90s1*:%{!mmcu=attiny1*:%{!mmcu=attiny28: -lgcc }}}"
+  "%{!mmcu=at90s1*:%{!mmcu=attiny11:%{!mmcu=attiny12:%{!mmcu=attiny15:%{!mmcu=attiny28: -lgcc }}}}}"
 
 #define STARTFILE_SPEC "%(crt_binutils)"
 
@@ -850,24 +943,114 @@ extern int avr_case_values_threshold;
 %{mmcu=at90c8534:crtc8534.o%s} \
 %{mmcu=at90s8535:crts8535.o%s} \
 %{mmcu=at86rf401:crt86401.o%s} \
-%{mmcu=atmega103|mmcu=avr3:crtm103.o%s} \
-%{mmcu=atmega603:crtm603.o%s} \
-%{mmcu=at43usb320:crt43320.o%s} \
-%{mmcu=at43usb355:crt43355.o%s} \
+%{mmcu=attiny13:crttn13.o%s} \
+%{mmcu=attiny13a:crttn13a.o%s} \
+%{mmcu=attiny2313|mmcu=avr25:crttn2313.o%s} \
+%{mmcu=attiny24:crttn24.o%s} \
+%{mmcu=attiny44:crttn44.o%s} \
+%{mmcu=attiny84:crttn84.o%s} \
+%{mmcu=attiny25:crttn25.o%s} \
+%{mmcu=attiny45:crttn45.o%s} \
+%{mmcu=attiny85:crttn85.o%s} \
+%{mmcu=attiny261:crttn261.o%s} \
+%{mmcu=attiny461:crttn461.o%s} \
+%{mmcu=attiny861:crttn861.o%s} \
+%{mmcu=attiny43u:crttn43u.o%s} \
+%{mmcu=attiny87:crttn87.o%s} \
+%{mmcu=attiny48:crttn48.o%s} \
+%{mmcu=attiny88:crttn88.o%s} \
+%{mmcu=ata6289:crta6289.o%s} \
+%{mmcu=at43usb355|mmcu=avr3:crt43355.o%s} \
 %{mmcu=at76c711:crt76711.o%s} \
+%{mmcu=atmega103|mmcu=avr31:crtm103.o%s} \
+%{mmcu=at43usb320:crt43320.o%s} \
+%{mmcu=at90usb162|mmcu=avr35:crtusb162.o%s} \
+%{mmcu=at90usb82:crtusb82.o%s} \
+%{mmcu=attiny167:crttn167.o%s} \
+%{mmcu=attiny327:crttn327.o%s} \
 %{mmcu=atmega8|mmcu=avr4:crtm8.o%s} \
+%{mmcu=atmega48:crtm48.o%s} \
+%{mmcu=atmega48p:crtm48p.o%s} \
+%{mmcu=atmega88:crtm88.o%s} \
+%{mmcu=atmega88p:crtm88p.o%s} \
 %{mmcu=atmega8515:crtm8515.o%s} \
 %{mmcu=atmega8535:crtm8535.o%s} \
+%{mmcu=atmega8c1:crtm8c1.o%s} \
+%{mmcu=atmega8m1:crtm8m1.o%s} \
+%{mmcu=at90pwm1:crt90pwm1.o%s} \
+%{mmcu=at90pwm2:crt90pwm2.o%s} \
+%{mmcu=at90pwm2b:crt90pwm2b.o%s} \
+%{mmcu=at90pwm3:crt90pwm3.o%s} \
+%{mmcu=at90pwm3b:crt90pwm3b.o%s} \
+%{mmcu=at90pwm81:crt90pwm81.o%s} \
 %{mmcu=atmega16:crtm16.o%s} \
 %{mmcu=atmega161|mmcu=avr5:crtm161.o%s} \
 %{mmcu=atmega162:crtm162.o%s} \
 %{mmcu=atmega163:crtm163.o%s} \
+%{mmcu=atmega164p:crtm164p.o%s} \
+%{mmcu=atmega165:crtm165.o%s} \
+%{mmcu=atmega165p:crtm165p.o%s} \
+%{mmcu=atmega168:crtm168.o%s} \
+%{mmcu=atmega168p:crtm168p.o%s} \
 %{mmcu=atmega169:crtm169.o%s} \
+%{mmcu=atmega169p:crtm169p.o%s} \
 %{mmcu=atmega32:crtm32.o%s} \
 %{mmcu=atmega323:crtm323.o%s} \
+%{mmcu=atmega324p:crtm324p.o%s} \
+%{mmcu=atmega325:crtm325.o%s} \
+%{mmcu=atmega325p:crtm325p.o%s} \
+%{mmcu=atmega3250:crtm3250.o%s} \
+%{mmcu=atmega3250p:crtm3250p.o%s} \
+%{mmcu=atmega328p:crtm328p.o%s} \
+%{mmcu=atmega329:crtm329.o%s} \
+%{mmcu=atmega329p:crtm329p.o%s} \
+%{mmcu=atmega3290:crtm3290.o%s} \
+%{mmcu=atmega3290p:crtm3290p.o%s} \
+%{mmcu=atmega406:crtm406.o%s} \
 %{mmcu=atmega64:crtm64.o%s} \
-%{mmcu=atmega128:crtm128.o%s} \
-%{mmcu=at94k:crtat94k.o%s}"
+%{mmcu=atmega640:crtm640.o%s} \
+%{mmcu=atmega644:crtm644.o%s} \
+%{mmcu=atmega644p:crtm644p.o%s} \
+%{mmcu=atmega645:crtm645.o%s} \
+%{mmcu=atmega6450:crtm6450.o%s} \
+%{mmcu=atmega649:crtm649.o%s} \
+%{mmcu=atmega6490:crtm6490.o%s} \
+%{mmcu=atmega8hva:crtm8hva.o%s} \
+%{mmcu=atmega16hva:crtm16hva.o%s} \
+%{mmcu=atmega16hvb:crtm16hvb.o%s} \
+%{mmcu=atmega32hvb:crtm32hvb.o%s} \
+%{mmcu=atmega4hvd:crtm4hvd.o%s} \
+%{mmcu=atmega8hvd:crtm8hvd.o%s} \
+%{mmcu=at90can32:crtcan32.o%s} \
+%{mmcu=at90can64:crtcan64.o%s} \
+%{mmcu=at90pwm216:crt90pwm216.o%s} \
+%{mmcu=at90pwm316:crt90pwm316.o%s} \
+%{mmcu=atmega16c1:crtm16c1.o%s} \
+%{mmcu=atmega32c1:crtm32c1.o%s} \
+%{mmcu=atmega64c1:crtm64c1.o%s} \
+%{mmcu=atmega16m1:crtm16m1.o%s} \
+%{mmcu=atmega32m1:crtm32m1.o%s} \
+%{mmcu=atmega64m1:crtm64m1.o%s} \
+%{mmcu=atmega16u4:crtm16u4.o%s} \
+%{mmcu=atmega32u4:crtm32u4.o%s} \
+%{mmcu=atmega32u6:crtm32u6.o%s} \
+%{mmcu=at90scr100:crt90scr100.o%s} \
+%{mmcu=at90usb646:crtusb646.o%s} \
+%{mmcu=at90usb647:crtusb647.o%s} \
+%{mmcu=at94k:crtat94k.o%s} \
+%{mmcu=atmega128|mmcu=avr51:crtm128.o%s} \
+%{mmcu=atmega1280:crtm1280.o%s} \
+%{mmcu=atmega1281:crtm1281.o%s} \
+%{mmcu=atmega1284p:crtm1284p.o%s} \
+%{mmcu=at90can128:crtcan128.o%s} \
+%{mmcu=atmega128rfa1:crtm128rfa1.o%s} \
+%{mmcu=at90usb1286:crtusb1286.o%s} \
+%{mmcu=at90usb1287:crtusb1287.o%s} \
+%{mmcu=m3000f:crtm3000f.o%s} \
+%{mmcu=m3000s:crtm3000s.o%s} \
+%{mmcu=m3001b:crtm3001b.o%s} \
+%{mmcu=atmega2560|mmcu=avr6:crtm2560.o%s} \
+%{mmcu=atmega2561:crtm2561.o%s}"
 
 #define EXTRA_SPECS {"crt_binutils", CRT_BINUTILS_SPECS},
 
@@ -898,10 +1081,40 @@ extern int avr_case_values_threshold;
 #define OUT_AS2(a,b,c) output_asm_insn (AS2(a,b,c), operands)
 #define CR_TAB "\n\t"
 
-/* Temporary register r0 */
-#define TMP_REGNO 0
+#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
 
-/* zero register r1 */
-#define ZERO_REGNO 1
+#define DWARF2_DEBUGGING_INFO 1
 
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
+#define DWARF2_ADDR_SIZE 4
+
+#define OBJECT_FORMAT_ELF
+
+#define HARD_REGNO_RENAME_OK(OLD_REG, NEW_REG) \
+  avr_hard_regno_rename_ok (OLD_REG, NEW_REG)
+
+/* A C structure for machine-specific, per-function data.
+   This is added to the cfun structure.  */
+struct machine_function GTY(())
+{
+  /* 'true' - if the current function is a leaf function.  */
+  int is_leaf;
+
+  /* 'true' - if current function is a naked function.  */
+  int is_naked;
+
+  /* 'true' - if current function is an interrupt function 
+     as specified by the "interrupt" attribute.  */
+  int is_interrupt;
+
+  /* 'true' - if current function is a signal function 
+     as specified by the "signal" attribute.  */
+  int is_signal;
+  
+  /* 'true' - if current function is a 'task' function 
+     as specified by the "OS_task" attribute.  */
+  int is_OS_task;
+
+  /* 'true' - if current function is a 'main' function 
+     as specified by the "OS_main" attribute.  */
+  int is_OS_main;
+};