Index: contrib/gcc_update
===================================================================
--- contrib/gcc_update	(revision 182386)
+++ contrib/gcc_update	(working copy)
@@ -82,6 +82,8 @@ gcc/fixinc/fixincl.x: gcc/fixinc/fixincl
 gcc/config/arm/arm-tune.md: gcc/config/arm/arm-cores.def gcc/config/arm/gentune.sh
 gcc/config/arm/arm-tables.opt: gcc/config/arm/arm-arches.def gcc/config/arm/arm-cores.def gcc/config/arm/arm-fpus.def gcc/config/arm/genopt.sh
 gcc/config/avr/avr-tables.opt: gcc/config/avr/avr-mcus.def gcc/config/avr/genopt.sh
+gcc/config/avr/t-multilib: gcc/config/avr/avr-mcus.def gcc/config/avr/genmultilib.awk
+gcc/config/avr/multilib.h: gcc/config/avr/avr-mcus.def gcc/config/avr/genmultilib.awk
 gcc/config/c6x/c6x-tables.opt: gcc/config/c6x/c6x-isas.def gcc/config/c6x/genopt.sh
 gcc/config/c6x/c6x-sched.md: gcc/config/c6x/c6x-sched.md.in gcc/config/c6x/gensched.sh
 gcc/config/c6x/c6x-mult.md: gcc/config/c6x/c6x-mult.md.in gcc/config/c6x/genmult.sh
Index: libgcc/config/avr/lib1funcs.S
===================================================================
--- libgcc/config/avr/lib1funcs.S	(revision 182386)
+++ libgcc/config/avr/lib1funcs.S	(working copy)
@@ -1253,11 +1253,12 @@ ENDF __divmodsi4
 
 ;; Use Speed-optimized Version on "big" Devices, i.e. Devices with
 ;; at least 16k of Program Memory.  For smaller Devices, depend
-;; on MOVW.
+;; on MOVW and SP Size.  There is a Connexion between SP Size and
+;; Flash Size so that SP Size can be used to test for Flash Size.
 
 #if defined (__AVR_HAVE_JMP_CALL__)
 #   define SPEED_DIV 8
-#elif defined (__AVR_HAVE_MOVW__)
+#elif defined (__AVR_HAVE_MOVW__) && !defined (__AVR_HAVE_8BIT_SP__)
 #   define SPEED_DIV 16
 #else
 #   define SPEED_DIV 0
@@ -1540,9 +1541,6 @@ DEFUN  __divdi3_moddi3
 4:  ;; Epilogue: Restore the Z = 12 Registers and return
     in r28, __SP_L__
 #if defined (__AVR_HAVE_8BIT_SP__)
-;; FIXME: __AVR_HAVE_8BIT_SP__ is set on device level, not on core level
-;;        so this lines are dead code.  To make it work, devices without
-;;        SP_H must get their own multilib(s).
     clr r29
 #else
     in r29, __SP_H__
@@ -1627,9 +1625,6 @@ DEFUN __prologue_saves__
 	push r28
 	push r29
 #if defined (__AVR_HAVE_8BIT_SP__)
-;; FIXME: __AVR_HAVE_8BIT_SP__ is set on device level, not on core level
-;;        so this lines are dead code.  To make it work, devices without
-;;        SP_H must get their own multilib(s).
 	in	r28,__SP_L__
 	sub	r28,r26
 	out	__SP_L__,r28
@@ -1679,9 +1674,6 @@ DEFUN __epilogue_restores__
 	ldd	r17,Y+3
 	ldd	r26,Y+2
 #if defined (__AVR_HAVE_8BIT_SP__)
-;; FIXME: __AVR_HAVE_8BIT_SP__ is set on device level, not on core level
-;;        so this lines are dead code.  To make it work, devices without
-;;        SP_H must get their own multilib(s).
 	ldd	r29,Y+1
 	add	r28,r30
 	out	__SP_L__,r28
Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	(revision 182386)
+++ gcc/config.gcc	(working copy)
@@ -909,13 +909,14 @@ arm*-wince-pe*)
 	extra_objs="pe.o"
 	;;
 avr-*-rtems*)
-	tm_file="elfos.h avr/elf.h avr/avr.h dbxelf.h avr/rtems.h rtems.h newlib-stdint.h"
-	tmake_file="avr/t-avr t-rtems avr/t-rtems"
+	tm_file="elfos.h avr/elf.h avr/avr.h avr/multilib.h dbxelf.h avr/rtems.h rtems.h newlib-stdint.h"
+	tmake_file="avr/t-avr avr/t-multilib t-rtems avr/t-rtems"
 	extra_gcc_objs="driver-avr.o avr-devices.o"
 	extra_objs="avr-devices.o avr-log.o"
 	;;
 avr-*-*)
-	tm_file="elfos.h avr/elf.h avr/avr.h dbxelf.h newlib-stdint.h"
+	tm_file="elfos.h avr/elf.h avr/avr.h avr/multilib.h dbxelf.h newlib-stdint.h"
+	tmake_file="avr/t-avr avr/t-multilib"
 	use_gcc_stdint=wrap
 	extra_gcc_objs="driver-avr.o avr-devices.o"
 	extra_objs="avr-devices.o avr-log.o"
Index: gcc/config/avr/t-multilib
===================================================================
--- gcc/config/avr/t-multilib	(revision 0)
+++ gcc/config/avr/t-multilib	(revision 0)
@@ -0,0 +1,192 @@
+# Auto-generated Makefile Snip
+# Generated by    : ./gcc/config/avr/genmultilib.awk
+# Generated from  : ./gcc/config/avr/avr-mcus.def
+# Used by         : tmake_file from Makefile and genmultilib
+
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# 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 3, or (at your option) any later
+# version.
+#
+# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of 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 COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+MULTILIB_OPTIONS = mmcu=avr2/mmcu=avr25/mmcu=avr3/mmcu=avr31/mmcu=avr35/mmcu=avr4/mmcu=avr5/mmcu=avr51/mmcu=avr6 mtiny-stack
+
+MULTILIB_DIRNAMES =  avr2 avr25 avr3 avr31 avr35 avr4 avr5 avr51 avr6 tiny-stack avr25/tiny-stack
+
+MULTILIB_EXCEPTIONS = \
+	mmcu=avr3/mtiny-stack \
+	mmcu=avr31/mtiny-stack \
+	mmcu=avr35/mtiny-stack \
+	mmcu=avr4/mtiny-stack \
+	mmcu=avr5/mtiny-stack \
+	mmcu=avr51/mtiny-stack \
+	mmcu=avr6/mtiny-stack
+
+MULTILIB_MATCHES = \
+	mmcu?at90s2313=mmcu?at90s2313 \
+	mmcu?at90s2323=mmcu?at90s2323 \
+	mmcu?at90s2333=mmcu?at90s2333 \
+	mmcu?at90s2343=mmcu?at90s2343 \
+	mmcu?attiny22=mmcu?attiny22 \
+	mmcu?attiny26=mmcu?attiny26 \
+	mmcu?at90s4433=mmcu?at90s4433 \
+	mmcu?avr25=mmcu?ata6289 \
+	mmcu?attiny13=mmcu?attiny13 \
+	mmcu?avr25=mmcu?attiny13 \
+	mmcu?attiny13a=mmcu?attiny13a \
+	mmcu?avr25=mmcu?attiny13a \
+	mmcu?attiny2313=mmcu?attiny2313 \
+	mmcu?avr25=mmcu?attiny2313 \
+	mmcu?attiny2313a=mmcu?attiny2313a \
+	mmcu?avr25=mmcu?attiny2313a \
+	mmcu?attiny24=mmcu?attiny24 \
+	mmcu?avr25=mmcu?attiny24 \
+	mmcu?attiny24a=mmcu?attiny24a \
+	mmcu?avr25=mmcu?attiny24a \
+	mmcu?avr25=mmcu?attiny4313 \
+	mmcu?avr25=mmcu?attiny44 \
+	mmcu?avr25=mmcu?attiny44a \
+	mmcu?avr25=mmcu?attiny84 \
+	mmcu?avr25=mmcu?attiny84a \
+	mmcu?attiny25=mmcu?attiny25 \
+	mmcu?avr25=mmcu?attiny25 \
+	mmcu?avr25=mmcu?attiny45 \
+	mmcu?avr25=mmcu?attiny85 \
+	mmcu?attiny261=mmcu?attiny261 \
+	mmcu?avr25=mmcu?attiny261 \
+	mmcu?attiny261a=mmcu?attiny261a \
+	mmcu?avr25=mmcu?attiny261a \
+	mmcu?avr25=mmcu?attiny461 \
+	mmcu?avr25=mmcu?attiny461a \
+	mmcu?avr25=mmcu?attiny861 \
+	mmcu?avr25=mmcu?attiny861a \
+	mmcu?avr25=mmcu?attiny43u \
+	mmcu?avr25=mmcu?attiny87 \
+	mmcu?avr25=mmcu?attiny48 \
+	mmcu?avr25=mmcu?attiny88 \
+	mmcu?avr25=mmcu?at86rf401 \
+	mmcu?avr3=mmcu?at43usb355 \
+	mmcu?avr3=mmcu?at76c711 \
+	mmcu?avr31=mmcu?atmega103 \
+	mmcu?avr31=mmcu?at43usb320 \
+	mmcu?avr35=mmcu?at90usb82 \
+	mmcu?avr35=mmcu?at90usb162 \
+	mmcu?avr35=mmcu?atmega8u2 \
+	mmcu?avr35=mmcu?atmega16u2 \
+	mmcu?avr35=mmcu?atmega32u2 \
+	mmcu?avr35=mmcu?attiny167 \
+	mmcu?avr4=mmcu?atmega8 \
+	mmcu?avr4=mmcu?atmega48 \
+	mmcu?avr4=mmcu?atmega48a \
+	mmcu?avr4=mmcu?atmega48p \
+	mmcu?avr4=mmcu?atmega88 \
+	mmcu?avr4=mmcu?atmega88a \
+	mmcu?avr4=mmcu?atmega88p \
+	mmcu?avr4=mmcu?atmega88pa \
+	mmcu?avr4=mmcu?atmega8515 \
+	mmcu?avr4=mmcu?atmega8535 \
+	mmcu?avr4=mmcu?atmega8hva \
+	mmcu?avr4=mmcu?at90pwm1 \
+	mmcu?avr4=mmcu?at90pwm2 \
+	mmcu?avr4=mmcu?at90pwm2b \
+	mmcu?avr4=mmcu?at90pwm3 \
+	mmcu?avr4=mmcu?at90pwm3b \
+	mmcu?avr4=mmcu?at90pwm81 \
+	mmcu?avr5=mmcu?atmega16 \
+	mmcu?avr5=mmcu?atmega16a \
+	mmcu?avr5=mmcu?atmega161 \
+	mmcu?avr5=mmcu?atmega162 \
+	mmcu?avr5=mmcu?atmega163 \
+	mmcu?avr5=mmcu?atmega164a \
+	mmcu?avr5=mmcu?atmega164p \
+	mmcu?avr5=mmcu?atmega165 \
+	mmcu?avr5=mmcu?atmega165a \
+	mmcu?avr5=mmcu?atmega165p \
+	mmcu?avr5=mmcu?atmega168 \
+	mmcu?avr5=mmcu?atmega168a \
+	mmcu?avr5=mmcu?atmega168p \
+	mmcu?avr5=mmcu?atmega169 \
+	mmcu?avr5=mmcu?atmega169a \
+	mmcu?avr5=mmcu?atmega169p \
+	mmcu?avr5=mmcu?atmega169pa \
+	mmcu?avr5=mmcu?atmega32 \
+	mmcu?avr5=mmcu?atmega323 \
+	mmcu?avr5=mmcu?atmega324a \
+	mmcu?avr5=mmcu?atmega324p \
+	mmcu?avr5=mmcu?atmega324pa \
+	mmcu?avr5=mmcu?atmega325 \
+	mmcu?avr5=mmcu?atmega325a \
+	mmcu?avr5=mmcu?atmega325p \
+	mmcu?avr5=mmcu?atmega3250 \
+	mmcu?avr5=mmcu?atmega3250a \
+	mmcu?avr5=mmcu?atmega3250p \
+	mmcu?avr5=mmcu?atmega328 \
+	mmcu?avr5=mmcu?atmega328p \
+	mmcu?avr5=mmcu?atmega329 \
+	mmcu?avr5=mmcu?atmega329a \
+	mmcu?avr5=mmcu?atmega329p \
+	mmcu?avr5=mmcu?atmega329pa \
+	mmcu?avr5=mmcu?atmega3290 \
+	mmcu?avr5=mmcu?atmega3290a \
+	mmcu?avr5=mmcu?atmega3290p \
+	mmcu?avr5=mmcu?atmega406 \
+	mmcu?avr5=mmcu?atmega64 \
+	mmcu?avr5=mmcu?atmega640 \
+	mmcu?avr5=mmcu?atmega644 \
+	mmcu?avr5=mmcu?atmega644a \
+	mmcu?avr5=mmcu?atmega644p \
+	mmcu?avr5=mmcu?atmega644pa \
+	mmcu?avr5=mmcu?atmega645 \
+	mmcu?avr5=mmcu?atmega645a \
+	mmcu?avr5=mmcu?atmega645p \
+	mmcu?avr5=mmcu?atmega6450 \
+	mmcu?avr5=mmcu?atmega6450a \
+	mmcu?avr5=mmcu?atmega6450p \
+	mmcu?avr5=mmcu?atmega649 \
+	mmcu?avr5=mmcu?atmega649a \
+	mmcu?avr5=mmcu?atmega649p \
+	mmcu?avr5=mmcu?atmega6490 \
+	mmcu?avr5=mmcu?atmega16hva \
+	mmcu?avr5=mmcu?atmega16hva2 \
+	mmcu?avr5=mmcu?atmega16hvb \
+	mmcu?avr5=mmcu?atmega32hvb \
+	mmcu?avr5=mmcu?atmega64hve \
+	mmcu?avr5=mmcu?at90can32 \
+	mmcu?avr5=mmcu?at90can64 \
+	mmcu?avr5=mmcu?at90pwm216 \
+	mmcu?avr5=mmcu?at90pwm316 \
+	mmcu?avr5=mmcu?atmega32c1 \
+	mmcu?avr5=mmcu?atmega64c1 \
+	mmcu?avr5=mmcu?atmega16m1 \
+	mmcu?avr5=mmcu?atmega32m1 \
+	mmcu?avr5=mmcu?atmega64m1 \
+	mmcu?avr5=mmcu?atmega16u4 \
+	mmcu?avr5=mmcu?atmega32u4 \
+	mmcu?avr5=mmcu?atmega32u6 \
+	mmcu?avr5=mmcu?at90scr100 \
+	mmcu?avr5=mmcu?at90usb646 \
+	mmcu?avr5=mmcu?at90usb647 \
+	mmcu?avr5=mmcu?at94k \
+	mmcu?avr5=mmcu?m3000 \
+	mmcu?avr51=mmcu?atmega128 \
+	mmcu?avr51=mmcu?atmega1280 \
+	mmcu?avr51=mmcu?atmega1281 \
+	mmcu?avr51=mmcu?atmega1284p \
+	mmcu?avr51=mmcu?atmega128rfa1 \
+	mmcu?avr51=mmcu?at90can128 \
+	mmcu?avr51=mmcu?at90usb1286 \
+	mmcu?avr51=mmcu?at90usb1287 \
+	mmcu?avr6=mmcu?atmega2560 \
+	mmcu?avr6=mmcu?atmega2561
Index: gcc/config/avr/t-avr
===================================================================
--- gcc/config/avr/t-avr	(revision 182386)
+++ gcc/config/avr/t-avr	(working copy)
@@ -34,156 +34,29 @@ avr-log.o: $(srcdir)/config/avr/avr-log.
   $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(INPUT_H)
 	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
 
-$(srcdir)/config/avr/avr-tables.opt: $(srcdir)/config/avr/genopt.sh \
-  $(srcdir)/config/avr/avr-mcus.def
-	$(SHELL) $(srcdir)/config/avr/genopt.sh $(srcdir)/config/avr > \
-		$(srcdir)/config/avr/avr-tables.opt
-
-MULTILIB_OPTIONS = mmcu=avr2/mmcu=avr25/mmcu=avr3/mmcu=avr31/mmcu=avr35/mmcu=avr4/mmcu=avr5/mmcu=avr51/mmcu=avr6
-MULTILIB_DIRNAMES = avr2 avr25 avr3 avr31 avr35 avr4 avr5 avr51 avr6
-
-# The many avr2 matches are not listed here - this is the default.
-MULTILIB_MATCHES = \
-	mmcu?avr25=mmcu?ata6289 \
-	mmcu?avr25=mmcu?attiny13 \
-	mmcu?avr25=mmcu?attiny13a \
-	mmcu?avr25=mmcu?attiny2313 \
-	mmcu?avr25=mmcu?attiny2313a \
-	mmcu?avr25=mmcu?attiny4313 \
-	mmcu?avr25=mmcu?attiny24 \
-	mmcu?avr25=mmcu?attiny24a \
-	mmcu?avr25=mmcu?attiny44 \
-	mmcu?avr25=mmcu?attiny44a \
-	mmcu?avr25=mmcu?attiny84 \
-	mmcu?avr25=mmcu?attiny84a \
-	mmcu?avr25=mmcu?attiny25 \
-	mmcu?avr25=mmcu?attiny45 \
-	mmcu?avr25=mmcu?attiny85 \
-	mmcu?avr25=mmcu?attiny261 \
-	mmcu?avr25=mmcu?attiny261a \
-	mmcu?avr25=mmcu?attiny461 \
-	mmcu?avr25=mmcu?attiny461a \
-	mmcu?avr25=mmcu?attiny861 \
-	mmcu?avr25=mmcu?attiny861a \
-	mmcu?avr25=mmcu?attiny43u \
-	mmcu?avr25=mmcu?attiny87 \
-	mmcu?avr25=mmcu?attiny48 \
-	mmcu?avr25=mmcu?attiny88 \
-	mmcu?avr25=mmcu?at86rf401 \
-	mmcu?avr3=mmcu?at43usb355 \
-	mmcu?avr3=mmcu?at76c711 \
-	mmcu?avr31=mmcu?atmega103 \
-	mmcu?avr31=mmcu?at43usb320 \
-	mmcu?avr35=mmcu?at90usb82 \
-	mmcu?avr35=mmcu?at90usb162 \
-	mmcu?avr35=mmcu?atmega8u2 \
-	mmcu?avr35=mmcu?atmega16u2 \
-	mmcu?avr35=mmcu?atmega32u2 \
-	mmcu?avr35=mmcu?attiny167 \
-	mmcu?avr4=mmcu?atmega48 \
-	mmcu?avr4=mmcu?atmega48a \
-	mmcu?avr4=mmcu?atmega48p \
-	mmcu?avr4=mmcu?atmega8 \
-	mmcu?avr4=mmcu?atmega8515 \
-	mmcu?avr4=mmcu?atmega8535 \
-	mmcu?avr4=mmcu?atmega88 \
-	mmcu?avr4=mmcu?atmega88a \
-	mmcu?avr4=mmcu?atmega88p \
-	mmcu?avr4=mmcu?atmega88pa \
-	mmcu?avr4=mmcu?atmega8hva \
-	mmcu?avr4=mmcu?at90pwm1 \
-	mmcu?avr4=mmcu?at90pwm2 \
-	mmcu?avr4=mmcu?at90pwm2b \
-	mmcu?avr4=mmcu?at90pwm3 \
-	mmcu?avr4=mmcu?at90pwm3b \
-	mmcu?avr4=mmcu?at90pwm81 \
-	mmcu?avr5=mmcu?atmega16 \
-	mmcu?avr5=mmcu?atmega16a \
-	mmcu?avr5=mmcu?atmega161 \
-	mmcu?avr5=mmcu?atmega162 \
-	mmcu?avr5=mmcu?atmega163 \
-	mmcu?avr5=mmcu?atmega164a \
-	mmcu?avr5=mmcu?atmega164p \
-	mmcu?avr5=mmcu?atmega165 \
-	mmcu?avr5=mmcu?atmega165a \
-	mmcu?avr5=mmcu?atmega165p \
-	mmcu?avr5=mmcu?atmega168 \
-	mmcu?avr5=mmcu?atmega168a \
-	mmcu?avr5=mmcu?atmega168p \
-	mmcu?avr5=mmcu?atmega169 \
-	mmcu?avr5=mmcu?atmega169a \
-	mmcu?avr5=mmcu?atmega169p \
-	mmcu?avr5=mmcu?atmega169pa \
-	mmcu?avr5=mmcu?atmega32 \
-	mmcu?avr5=mmcu?atmega323 \
-	mmcu?avr5=mmcu?atmega324a \
-	mmcu?avr5=mmcu?atmega324p \
-	mmcu?avr5=mmcu?atmega324pa \
-	mmcu?avr5=mmcu?atmega325 \
-	mmcu?avr5=mmcu?atmega325a \
-	mmcu?avr5=mmcu?atmega325p \
-	mmcu?avr5=mmcu?atmega3250 \
-	mmcu?avr5=mmcu?atmega3250a \
-	mmcu?avr5=mmcu?atmega3250p \
-	mmcu?avr5=mmcu?atmega328 \
-	mmcu?avr5=mmcu?atmega328p \
-	mmcu?avr5=mmcu?atmega329 \
-	mmcu?avr5=mmcu?atmega329a \
-	mmcu?avr5=mmcu?atmega329p \
-	mmcu?avr5=mmcu?atmega329pa \
-	mmcu?avr5=mmcu?atmega3290 \
-	mmcu?avr5=mmcu?atmega3290a \
-	mmcu?avr5=mmcu?atmega3290p \
-	mmcu?avr5=mmcu?atmega406 \
-	mmcu?avr5=mmcu?atmega64  \
-	mmcu?avr5=mmcu?atmega640 \
-	mmcu?avr5=mmcu?atmega644 \
-	mmcu?avr5=mmcu?atmega644a \
-	mmcu?avr5=mmcu?atmega644p \
-	mmcu?avr5=mmcu?atmega644pa \
-	mmcu?avr5=mmcu?atmega645 \
-	mmcu?avr5=mmcu?atmega645a \
-	mmcu?avr5=mmcu?atmega645p \
-	mmcu?avr5=mmcu?atmega6450 \
-	mmcu?avr5=mmcu?atmega6450a \
-	mmcu?avr5=mmcu?atmega6450p \
-	mmcu?avr5=mmcu?atmega649 \
-	mmcu?avr5=mmcu?atmega649a \
-	mmcu?avr5=mmcu?atmega649p \
-	mmcu?avr5=mmcu?atmega6490 \
-	mmcu?avr5=mmcu?atmega6490a \
-	mmcu?avr5=mmcu?atmega6490p \
-	mmcu?avr5=mmcu?atmega16hva \
-	mmcu?avr5=mmcu?atmega16hva2 \
-	mmcu?avr5=mmcu?atmega16hvb \
-	mmcu?avr5=mmcu?atmega32hvb \
-	mmcu?avr5=mmcu?atmega64hve \
-	mmcu?avr5=mmcu?at90can32 \
-	mmcu?avr5=mmcu?at90can64 \
-	mmcu?avr5=mmcu?at90pwm216 \
-	mmcu?avr5=mmcu?at90pwm316 \
-	mmcu?avr5=mmcu?atmega32c1 \
-	mmcu?avr5=mmcu?atmega64c1 \
-	mmcu?avr5=mmcu?atmega16m1 \
-	mmcu?avr5=mmcu?atmega32m1 \
-	mmcu?avr5=mmcu?atmega64m1 \
-	mmcu?avr5=mmcu?atmega16u4 \
-	mmcu?avr5=mmcu?atmega32u4 \
-	mmcu?avr5=mmcu?atmega32u6 \
-	mmcu?avr5=mmcu?at90scr100 \
-	mmcu?avr5=mmcu?at90usb646 \
-	mmcu?avr5=mmcu?at90usb647 \
-	mmcu?avr5=mmcu?at94k \
-	mmcu?avr5=mmcu?m3000 \
-	mmcu?avr51=mmcu?atmega128 \
-	mmcu?avr51=mmcu?atmega1280 \
-	mmcu?avr51=mmcu?atmega1281 \
-	mmcu?avr51=mmcu?atmega1284p \
-	mmcu?avr51=mmcu?atmega128rfa1 \
-	mmcu?avr51=mmcu?at90can128 \
-	mmcu?avr51=mmcu?at90usb1286 \
-	mmcu?avr51=mmcu?at90usb1287 \
-	mmcu?avr6=mmcu?atmega2560 \
-	mmcu?avr6=mmcu?atmega2561
+# Files and Variables auto-generated from avr-mcus.def
 
-MULTILIB_EXCEPTIONS =
+AVR_MCUS = $(srcdir)/config/avr/avr-mcus.def
+
+$(srcdir)/config/avr/avr-tables.opt: $(srcdir)/config/avr/genopt.sh $(AVR_MCUS)
+	$(SHELL) $< $(AVR_MCUS) > $@
+
+# MULTILIB_OPTIONS
+# MULTILIB_DIRNAMES
+# MULTILIB_EXCEPTIONS
+# MULTILIB_MATCHES
+$(srcdir)/config/avr/t-multilib: s-avr-mlib; @true
+
+# Override multilib_raw[] from multilib.h
+$(srcdir)/config/avr/multilib.h: s-avr-mlib; @true
+
+s-mlib: $(srcdir)/config/avr/t-multilib
+
+s-avr-mlib: $(srcdir)/config/avr/genmultilib.awk $(AVR_MCUS)
+	$(AWK) -f $< -v FORMAT=Makefile   $< $(AVR_MCUS) > tmp-avr-mlib
+	$(AWK) -f $< -v FORMAT=multilib.h $< $(AVR_MCUS) > tmp-avr-mlib.h
+	$(SHELL) $(srcdir)/../move-if-change \
+		tmp-avr-mlib.h 	$(srcdir)/config/avr/multilib.h
+	$(SHELL) $(srcdir)/../move-if-change \
+		tmp-avr-mlib 	$(srcdir)/config/avr/t-multilib
+	$(STAMP) $@
Index: gcc/config/avr/avr-c.c
===================================================================
--- gcc/config/avr/avr-c.c	(revision 182386)
+++ gcc/config/avr/avr-c.c	(working copy)
@@ -113,7 +113,7 @@ avr_cpu_cpp_builtins (struct cpp_reader
       cpp_define (pfile, "__AVR_2_BYTE_PC__");
     }
 
-  if (avr_current_device->short_sp)
+  if (AVR_HAVE_8BIT_SP)
     cpp_define (pfile, "__AVR_HAVE_8BIT_SP__");
   else
     cpp_define (pfile, "__AVR_HAVE_16BIT_SP__");
Index: gcc/config/avr/avr-mcus.def
===================================================================
--- gcc/config/avr/avr-mcus.def	(revision 182386)
+++ gcc/config/avr/avr-mcus.def	(working copy)
@@ -21,7 +21,6 @@
 /* List of all known AVR MCU types - if updated, it has to be kept
    in sync in several places (FIXME: is there a better way?):
     - here;
-    - t-avr (MULTILIB_MATCHES);
     - gas/config/tc-avr.c;
     - avr-libc.
 
Index: gcc/config/avr/genmultilib.awk
===================================================================
--- gcc/config/avr/genmultilib.awk	(revision 0)
+++ gcc/config/avr/genmultilib.awk	(revision 0)
@@ -0,0 +1,310 @@
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# 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 3, or (at your option) any later
+# version.
+#
+# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of 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 COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+##################################################################
+#  
+# Transform Core/Device Information from avr-mcus.def to a
+# Representation that is understood by GCC's multilib Machinery.
+#
+# The Script works as a Filter from STDIN to STDOUT.
+# 
+# FORMAT = "Makefile": Generate Makefile Snipet that sets some
+#                      MULTILIB_* Variables as needed.
+#
+# FORMAT = "multilib.h": Generate C Header intended to override
+#                      (parts of) multilib.h used in gcc.c.
+#
+##################################################################
+
+BEGIN {
+    FS ="[(, \t]+"
+    option[""] = ""
+    tiny_stack[""] = 1
+    comment = 1
+
+    mtiny[0] = ""
+    mtiny[1] = "tiny-stack"
+    option["tiny-stack"] = "mtiny-stack"
+}
+
+##################################################################
+# Add some Comments to the generated Files and copy-paste
+# Copyright Notice from above.
+##################################################################
+
+/^#/ {
+    if (!comment)
+	next
+    else if (comment == 1)
+    {
+	if (FORMAT == "multilib.h")
+	{
+	    print "/*"
+	    print "   Auto-generated C header"
+	    print "   Generated by    : ./gcc/config/avr/genmultilib.awk"
+	    print "   Generated from  : ./gcc/config/avr/avr-mcus.def"
+	    print "   Used by         : ./gcc/gcc.c via tm.h"
+	    print "   Purpose         : Override multilib_raw[] from multilib.h"
+	    print "*/"
+	    print "/*"
+	}
+
+	if (FORMAT == "Makefile")
+	{
+	    print "# Auto-generated Makefile Snip"
+	    print "# Generated by    : ./gcc/config/avr/genmultilib.awk"
+	    print "# Generated from  : ./gcc/config/avr/avr-mcus.def"
+	    print "# Used by         : tmake_file from Makefile and genmultilib"
+	    print ""
+	}
+    }
+
+    comment = 2;
+
+    if (FORMAT == "multilib.h")
+	gsub ("#", "  ")
+
+    print
+}
+
+/^$/ {
+    if (comment && FORMAT == "multilib.h")
+	print "*/"
+
+    comment = 0
+}
+
+##################################################################
+# Run over all AVR_MCU Lines and gather Information:
+# cores[]     : Enumerates the Cores (avr2, avr25, ...)
+# mcu[]       : Enumerates the Devices
+# tiny_stack[]: Maps Core/Device to 0 (2-byte SP) or 1 (1-byte SP)
+# option[]    : Maps Core/Device to the mmcu= option to get it
+# toCore[]    : Maps Device to its Core
+##################################################################
+
+/^AVR_MCU/ {
+    name = $2
+    gsub ("\"", "", name)
+
+    if ($4 == "NULL")
+    {
+	core = name
+
+	# avr1 is supported for Assembler only:  It gets no multilib
+	if (core == "avr1")
+	    next
+
+	cores[length (cores)] = core
+	tiny_stack[core] = 0
+	option[core] = "mmcu=" core
+
+	next
+    }
+
+    # avr1 is supported for Assembler only:  Its Devices are ignored
+    if (core == "avr1")
+	next
+
+    tiny_stack[name]  = $5
+    mcu[length (mcu)] = name
+    option[name]      = "mmcu=" name
+    toCore[name]      = core
+
+    if (tiny_stack[name] == 1)
+	tiny_stack[core] = 1
+}
+
+##################################################################
+# 
+# We gathered all the Information, now build/output the following:
+#
+#    awk Variable         target Variable          FORMAT
+#  -----------------------------------------------------------
+#    m_options     <->    MULTILIB_OPTIONS         Makefile
+#    m_dirnames    <->    MULTILIB_DIRNAMES           "
+#    m_exceptions  <->    MULTILIB_EXCEPTIONS         "
+#    m_matches     <->    MULTILIB_MATCHES            "
+#    m_raw         <->    avr_multilib_raw         multilib.h
+#
+##################################################################
+
+END {
+    m_options    = "\nMULTILIB_OPTIONS = "
+    m_dirnames   = "\nMULTILIB_DIRNAMES ="
+    m_exceptions = "\nMULTILIB_EXCEPTIONS ="
+    m_matches    = "\nMULTILIB_MATCHES ="
+
+    m_raw = ""
+
+    ##############################################################
+    # Compose MULTILIB_OPTIONS.  This represents the Cross-Product
+    #    (avr2, avr25, ...) x mtiny-stack
+
+    sep = ""
+    for (c = 0; c < length (cores); c++)
+    {
+	m_options = m_options sep option[cores[c]]
+	sep = "/"
+    }
+
+    # The ... x mtiny-stack
+    m_options = m_options " " option[mtiny[1]]
+
+    ##############################################################
+    # Map Device to its multilib
+
+    # All Mappings that cannot be represented by GCC's genmultilib
+    # Machinery must be handcrafted.
+
+    dot_excludes = ""
+    m_raw_sp8 = ""
+
+    for (t = 0; t < length (mcu); t++)
+    {
+	core = toCore[mcu[t]]
+	
+	if (tiny_stack[mcu[t]] == 1)
+	{
+	    if (core == "avr2")
+		dir = mtiny[1]
+	    else
+		dir = core "/" mtiny[1]
+
+	    m_raw_sp8 = m_raw_sp8 "  \"" dir " " option[mcu[t]] ";\",\n"
+	    dot_excludes = dot_excludes " !" option[mcu[t]]
+
+	    line = option[mcu[t]] ":" option[mcu[t]]
+	    gsub ("=", "?", line)
+	    gsub (":", "=", line)
+
+	    m_matches = m_matches " \\\n\t" line
+	}
+
+	# The SP = 16 Devices are vanilla: Do the same as
+	# MULTILIB_MATCHES would yield.  Don't list avr2 (default)
+
+	if (core != "avr2")
+	{
+	    line = option[core] ":" option[mcu[t]]
+	    gsub ("=", "?", line)
+	    gsub (":", "=", line)
+
+	    m_matches = m_matches " \\\n\t" line
+	}
+    }
+
+    ####################################################################
+    # Compose MULTILIB_DIRNAMES, MULTILIB_EXEPTIONS and avr_multilib_raw
+
+    for (t = 0; t < length (mtiny); t++)
+	for (c = -1; c < length (cores); c++)
+	{
+	    if (c == -1)
+		core = ""
+	    else
+		core = cores[c]
+
+	    # The Directory Name for this multilib
+
+	    if (core != "" && mtiny[t] != "")
+	    {
+		mdir = core "/" mtiny[t]
+		mopt = option[core] "/" option[mtiny[t]]
+	    }
+	    else
+	    {
+		mdir = core mtiny[t]
+		mopt = option[core] option[mtiny[t]]
+	    }
+
+	    if (core != "" && tiny_stack[core] == 0 && mtiny[t] != "")
+	    {
+		# There's not a single SP = 8 Devices for this Core:
+		# Don't build respective multilib
+		m_exceptions = m_exceptions " \\\n\t" mopt
+		continue
+	    }
+
+	    if (core != "avr2" || mtiny[t] == "")
+		m_dirnames = m_dirnames " " mdir
+
+	    # Remainder deals with avr_multilib_raw Entries.
+	    # Each Entry looks like
+	    #     "multilib-dir option-to-match !option-to-avoid-match;"
+	    # for Example:
+	    #     "avr25/tiny-stack !mmcu=avr2 mmcu=avr25 !mmcu=avr3 ... mtiny-stack;"
+
+	    if (mdir == "")
+		mdir = "."
+
+	    line = mdir
+
+	    for (s = 0; s < length (cores); s++)
+	    {
+		if (cores[s] == core)
+		    line = line " " option[cores[s]]
+		else
+		    line = line " !" option[cores[s]]
+	    }
+
+	    if (tiny_stack[core] != 0)
+	    {
+		if (mtiny[t] == "")
+		    line = line " !" option[mtiny[1]]
+		else
+		    line = line " " option[mtiny[1]]
+	    }
+
+	    if (mdir == ".")
+		line = line dot_excludes
+
+	    m_raw = m_raw "  \"" line ";\",\n"
+	}
+
+    ############################################################
+    # Output that Stuff
+    ############################################################
+
+    if (FORMAT == "Makefile")
+    {
+	# Intended Target: ./gcc/config/avr/t-multilib
+
+	print m_options
+	print m_dirnames
+	print m_exceptions
+	print m_matches
+    }
+
+    if (FORMAT == "multilib.h")
+    {
+	# Intended Target: ./gcc/config/avr/multilib.h
+
+	print "#if defined NULL && !defined AVR_MULTILIB_H"
+	print "#define AVR_MULTILIB_H"
+
+	print "static const char* const avr_multilib_raw[] = {"
+	print m_raw_sp8
+	print m_raw
+	print "  NULL\n};"
+
+	print "#undef  multilib_raw"
+	print "#define multilib_raw avr_multilib_raw"
+	print "#endif /* AVR_MULTILIB_H */"
+    }
+}
Index: gcc/config/avr/genopt.sh
===================================================================
--- gcc/config/avr/genopt.sh	(revision 182386)
+++ gcc/config/avr/genopt.sh	(working copy)
@@ -56,4 +56,4 @@ awk -F'[(, 	]+' 'BEGIN {
     print "Enum(avr_mcu) String(" name ") Value(" value ")"
     print ""
     value++
-}' $1/avr-mcus.def
+}' $1
Index: gcc/config/avr/multilib.h
===================================================================
--- gcc/config/avr/multilib.h	(revision 0)
+++ gcc/config/avr/multilib.h	(revision 0)
@@ -0,0 +1,65 @@
+/*
+   Auto-generated C header
+   Generated by    : ./gcc/config/avr/genmultilib.awk
+   Generated from  : ./gcc/config/avr/avr-mcus.def
+   Used by         : ./gcc/gcc.c via tm.h
+   Purpose         : Override multilib_raw[] from multilib.h
+*/
+/*
+   Copyright (C) 2011 Free Software Foundation, Inc.
+  
+   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 3, or (at your option) any later
+   version.
+  
+   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of 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 COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.
+*/
+#if defined NULL && !defined AVR_MULTILIB_H
+#define AVR_MULTILIB_H
+static const char* const avr_multilib_raw[] = {
+  "tiny-stack mmcu=at90s2313;",
+  "tiny-stack mmcu=at90s2323;",
+  "tiny-stack mmcu=at90s2333;",
+  "tiny-stack mmcu=at90s2343;",
+  "tiny-stack mmcu=attiny22;",
+  "tiny-stack mmcu=attiny26;",
+  "tiny-stack mmcu=at90s4433;",
+  "avr25/tiny-stack mmcu=attiny13;",
+  "avr25/tiny-stack mmcu=attiny13a;",
+  "avr25/tiny-stack mmcu=attiny2313;",
+  "avr25/tiny-stack mmcu=attiny2313a;",
+  "avr25/tiny-stack mmcu=attiny24;",
+  "avr25/tiny-stack mmcu=attiny24a;",
+  "avr25/tiny-stack mmcu=attiny25;",
+  "avr25/tiny-stack mmcu=attiny261;",
+  "avr25/tiny-stack mmcu=attiny261a;",
+
+  ". !mmcu=avr2 !mmcu=avr25 !mmcu=avr3 !mmcu=avr31 !mmcu=avr35 !mmcu=avr4 !mmcu=avr5 !mmcu=avr51 !mmcu=avr6 !mtiny-stack !mmcu=at90s2313 !mmcu=at90s2323 !mmcu=at90s2333 !mmcu=at90s2343 !mmcu=attiny22 !mmcu=attiny26 !mmcu=at90s4433 !mmcu=attiny13 !mmcu=attiny13a !mmcu=attiny2313 !mmcu=attiny2313a !mmcu=attiny24 !mmcu=attiny24a !mmcu=attiny25 !mmcu=attiny261 !mmcu=attiny261a;",
+  "avr2 mmcu=avr2 !mmcu=avr25 !mmcu=avr3 !mmcu=avr31 !mmcu=avr35 !mmcu=avr4 !mmcu=avr5 !mmcu=avr51 !mmcu=avr6 !mtiny-stack;",
+  "avr25 !mmcu=avr2 mmcu=avr25 !mmcu=avr3 !mmcu=avr31 !mmcu=avr35 !mmcu=avr4 !mmcu=avr5 !mmcu=avr51 !mmcu=avr6 !mtiny-stack;",
+  "avr3 !mmcu=avr2 !mmcu=avr25 mmcu=avr3 !mmcu=avr31 !mmcu=avr35 !mmcu=avr4 !mmcu=avr5 !mmcu=avr51 !mmcu=avr6;",
+  "avr31 !mmcu=avr2 !mmcu=avr25 !mmcu=avr3 mmcu=avr31 !mmcu=avr35 !mmcu=avr4 !mmcu=avr5 !mmcu=avr51 !mmcu=avr6;",
+  "avr35 !mmcu=avr2 !mmcu=avr25 !mmcu=avr3 !mmcu=avr31 mmcu=avr35 !mmcu=avr4 !mmcu=avr5 !mmcu=avr51 !mmcu=avr6;",
+  "avr4 !mmcu=avr2 !mmcu=avr25 !mmcu=avr3 !mmcu=avr31 !mmcu=avr35 mmcu=avr4 !mmcu=avr5 !mmcu=avr51 !mmcu=avr6;",
+  "avr5 !mmcu=avr2 !mmcu=avr25 !mmcu=avr3 !mmcu=avr31 !mmcu=avr35 !mmcu=avr4 mmcu=avr5 !mmcu=avr51 !mmcu=avr6;",
+  "avr51 !mmcu=avr2 !mmcu=avr25 !mmcu=avr3 !mmcu=avr31 !mmcu=avr35 !mmcu=avr4 !mmcu=avr5 mmcu=avr51 !mmcu=avr6;",
+  "avr6 !mmcu=avr2 !mmcu=avr25 !mmcu=avr3 !mmcu=avr31 !mmcu=avr35 !mmcu=avr4 !mmcu=avr5 !mmcu=avr51 mmcu=avr6;",
+  "tiny-stack !mmcu=avr2 !mmcu=avr25 !mmcu=avr3 !mmcu=avr31 !mmcu=avr35 !mmcu=avr4 !mmcu=avr5 !mmcu=avr51 !mmcu=avr6 mtiny-stack;",
+  "avr2/tiny-stack mmcu=avr2 !mmcu=avr25 !mmcu=avr3 !mmcu=avr31 !mmcu=avr35 !mmcu=avr4 !mmcu=avr5 !mmcu=avr51 !mmcu=avr6 mtiny-stack;",
+  "avr25/tiny-stack !mmcu=avr2 mmcu=avr25 !mmcu=avr3 !mmcu=avr31 !mmcu=avr35 !mmcu=avr4 !mmcu=avr5 !mmcu=avr51 !mmcu=avr6 mtiny-stack;",
+
+  NULL
+};
+#undef  multilib_raw
+#define multilib_raw avr_multilib_raw
+#endif /* AVR_MULTILIB_H */
