]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/avr/gen-avr-mmcu-specs.c
Update copyright years.
[thirdparty/gcc.git] / gcc / config / avr / gen-avr-mmcu-specs.c
CommitLineData
5624e564 1/* Copyright (C) 1998-2015 Free Software Foundation, Inc.
f9d29866
JR
2 Contributed by Joern Rennecke
3
4 This file is part of GCC.
5
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)
9 any later version.
10
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.
15
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/>. */
19
20#include <stdlib.h>
21#include <stdio.h>
22#include <string.h>
23
24#define IN_GEN_AVR_MMCU_TEXI
25
26#include "avr-arch.h"
27#include "avr-devices.c"
28
29static void
30print_mcu (const avr_mcu_t *mcu)
31{
32 const avr_mcu_t *arch_mcu;
33
34 for (arch_mcu = mcu; arch_mcu->macro; )
35 arch_mcu--;
36 if (arch_mcu->arch != mcu->arch)
37 exit (EXIT_FAILURE);
38
39 char name[100];
40 if (snprintf (name, sizeof name, "specs-%s", mcu->name) >= sizeof name)
41 exit (EXIT_FAILURE);
42
43 FILE *f = fopen (name ,"w");
44
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))
50 sp8 = "";
51
52 sp8 = ((mcu->dev_attribute & AVR_SHORT_SP)
53 ? " -msp8" : " %<msp8");
54
55 errata_skip = (mcu->dev_attribute & AVR_ERRATA_SKIP) ? " -mskip-bug" : "";
8bc991d4 56 rmw = (mcu->dev_attribute & AVR_ISA_RMW) ? "%{!mno-rmw: -mrmw}" : "";
f9d29866
JR
57
58 const char *arch_name = avr_arch_types[mcu->arch].arch_name;
59
60 fprintf (f, "*self_spec:\n%%{!march=*:-march=%s}%s\n\n", arch_name, sp8);
61
62 if (mcu->macro)
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);
66
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);
70 fprintf (f, "\n\n");
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");
77
78 fprintf (f, "*asm:\n%%{march=*:-mmcu=%%*}%{mrelax: --mlink-relax}%s\n\n",
79 *errata_skip ? "" : " -mno-skip-bug");
80
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);
99
100 fprintf (f, " %%{shared:%%eshared is not supported}\n\n");
101
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)
108 {
109 fprintf (f, "-lc");
110 if (mcu->macro)
111 fprintf (f, " dev/%s/libdev.a%%s", mcu->name);
112 }
113 fprintf (f, "\n\n");
114
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");
122 fprintf (f, "\n\n");
123
124 fprintf (f, "*startfile:\ndev/%s/crt1.o%%s\n\n", mcu->name);
125}
126
127int main (void)
128{
129 enum avr_arch arch = ARCH_UNKNOWN;
130 size_t i, n_mcus = 0;
131 const avr_mcu_t *mcu;
132
133 for (mcu = avr_mcu_types; mcu->name; mcu++)
134 print_mcu (mcu);
135
136 return EXIT_SUCCESS;
137}