1 /* Copyright (C) 1998-2014 Free Software Foundation, Inc.
2 Contributed by Joern Rennecke
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
24 #define IN_GEN_AVR_MMCU_TEXI
27 #include "avr-devices.c"
30 print_mcu (const avr_mcu_t
*mcu
)
32 const avr_mcu_t
*arch_mcu
;
34 for (arch_mcu
= mcu
; arch_mcu
->macro
; )
36 if (arch_mcu
->arch
!= mcu
->arch
)
40 if (snprintf (name
, sizeof name
, "specs-%s", mcu
->name
) >= sizeof name
)
43 FILE *f
= fopen (name
,"w");
45 const char *sp8
, *errata_skip
, *rmw
;
46 /* Leave "avr2" and "avr25" alone. These two architectures are
47 the only ones that mix devices with 8-bit SP and 16-bit SP. */
48 if (mcu
->macro
== NULL
49 && (mcu
->arch
== ARCH_AVR2
|| mcu
->arch
== ARCH_AVR25
))
52 sp8
= ((mcu
->dev_attribute
& AVR_SHORT_SP
)
53 ? " -msp8" : " %<msp8");
55 errata_skip
= (mcu
->dev_attribute
& AVR_ERRATA_SKIP
) ? " -mskip-bug" : "";
56 rmw
= (mcu
->dev_attribute
& AVR_ISA_RMW
) ? "%%{!mno-rmw: -mrmw}" : "";
58 const char *arch_name
= avr_arch_types
[mcu
->arch
].arch_name
;
60 fprintf (f
, "*self_spec:\n%%{!march=*:-march=%s}%s\n\n", arch_name
, sp8
);
63 fprintf (f
, "*cpp:\n-D__AVR_DEV_LIB_NAME__=%s -D%s "
64 "-D__AVR_DEVICE_NAME__=%s\n\n",
65 mcu
->library_name
, mcu
->macro
, mcu
->name
);
67 fprintf (f
, "*cc1:\n%s%s", errata_skip
, rmw
);
68 if (mcu
->n_flash
!= arch_mcu
->n_flash
)
69 fprintf (f
, " %%{!mn-flash:-mn-flash=%d}", mcu
->n_flash
);
71 fprintf (f
, "*cc1plus:\n%s%s ", errata_skip
, rmw
);
72 if (mcu
->n_flash
!= arch_mcu
->n_flash
)
73 fprintf (f
, "%%{!mn-flash:-mn-flash=%d}", mcu
->n_flash
);
74 fprintf (f
, "%%{!frtti: -fno-rtti}"
75 "%%{!fenforce-eh-specs: -fno-enforce-eh-specs}"
76 "%%{!fexceptions: -fno-exceptions}\n\n");
78 fprintf (f
, "*asm:\n%%{march=*:-mmcu=%%*}%{mrelax: --mlink-relax}%s\n\n",
79 *errata_skip
? "" : " -mno-skip-bug");
81 fprintf (f
, "*link:\n%%{mrelax:--relax");
82 if (strncmp (mcu
->name
, "at90usb8", strlen ("at90usb8")) == 0)
83 fprintf (f
, "%%{mpmem-wrap-around: --pmem-wrap-around=8k}");
84 if (strncmp (mcu
->name
, "atmega16", strlen ("atmega16")) == 0)
85 fprintf (f
, "%%{mpmem-wrap-around: --pmem-wrap-around=16k}");
86 if (strncmp (mcu
->name
, "atmega32", strlen ("atmega32")) == 0
87 || strncmp (mcu
->name
, "at90can32", strlen ("at90can32")) == 0)
88 fprintf (f
, "%%{mpmem-wrap-around: --pmem-wrap-around=32k}");
89 if (strncmp (mcu
->name
, "atmega64", strlen ("atmega64")) == 0
90 || strncmp (mcu
->name
, "at90can64", strlen ("at90can64")) == 0
91 || strncmp (mcu
->name
, "at90usb64", strlen ("at90usb64")) == 0)
92 fprintf (f
, "%%{mpmem-wrap-around: --pmem-wrap-around=64k}");
93 fprintf (f
, "} %%{march=*:-m%%*}");
94 if (mcu
->data_section_start
95 != avr_arch_types
[mcu
->arch
].default_data_section_start
)
96 fprintf (f
, " -Tdata 0x%lX", 0x800000UL
+ mcu
->data_section_start
);
97 if (mcu
->text_section_start
!= 0x0)
98 fprintf (f
, " -Ttext 0x%lX", mcu
->text_section_start
);
100 fprintf (f
, " %%{shared:%%eshared is not supported}\n\n");
102 fprintf (f
, "*lib:\n");
103 if (strncmp (mcu
->name
, "mmcu=at90s1", strlen ("mmcu=at90s1")) != 0
104 && strncmp (mcu
->name
, "mmcu=attiny11", strlen ("mmcu=attiny11")) != 0
105 && strncmp (mcu
->name
, "mmcu=attiny12", strlen ("mmcu=attiny12")) != 0
106 && strncmp (mcu
->name
, "mmcu=attiny15", strlen ("mmcu=attiny15")) != 0
107 && strncmp (mcu
->name
, "mmcu=attiny28", strlen ("mmcu=attiny28")) != 0)
111 fprintf (f
, " dev/%s/libdev.a%%s", mcu
->name
);
115 fprintf (f
, "*libgcc:\n");
116 if (strncmp (mcu
->name
, "mmcu=at90s1", strlen ("mmcu=at90s1")) != 0
117 && strncmp (mcu
->name
, "mmcu=attiny11", strlen ("mmcu=attiny11")) != 0
118 && strncmp (mcu
->name
, "mmcu=attiny12", strlen ("mmcu=attiny12")) != 0
119 && strncmp (mcu
->name
, "mmcu=attiny15", strlen ("mmcu=attiny15")) != 0
120 && strncmp (mcu
->name
, "mmcu=attiny28", strlen ("mmcu=attiny28")) != 0)
121 fprintf (f
, "-lgcc");
124 fprintf (f
, "*startfile:\ndev/%s/crt1.o%%s\n\n", mcu
->name
);
129 enum avr_arch arch
= ARCH_UNKNOWN
;
130 size_t i
, n_mcus
= 0;
131 const avr_mcu_t
*mcu
;
133 for (mcu
= avr_mcu_types
; mcu
->name
; mcu
++)