]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/avr/gen-avr-mmcu-texi.c
[4/4] ARMv8.2-A testsuite for new scalar intrinsics
[thirdparty/gcc.git] / gcc / config / avr / gen-avr-mmcu-texi.c
CommitLineData
818ab71a 1/* Copyright (C) 2012-2016 Free Software Foundation, Inc.
04d170d2
GJL
2 Contributed by Georg-Johann Lay (avr@gjlay.de)
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
e3cf7a95
GJL
20#include <stdlib.h>
21#include <stdio.h>
22
23#define IN_GEN_AVR_MMCU_TEXI
24
04d170d2
GJL
25#include "avr-devices.c"
26
5be35a61
GJL
27static const char*
28mcu_name[sizeof avr_mcu_types / sizeof avr_mcu_types[0]];
29
e3cf7a95
GJL
30static int letter (char c)
31{
32 return c >= 'a' && c <= 'z';
33}
34
35static int digit (char c)
36{
37 return c >= '0' && c <= '9';
38}
39
5be35a61
GJL
40static int
41comparator (const void *va, const void *vb)
42{
e3cf7a95
GJL
43 const char *a = *(const char* const*) va;
44 const char *b = *(const char* const*) vb;
45
46 while (*a && *b)
47 {
48 /* Make letters smaller than digits so that `atmega16a' follows
49 `atmega16' without `atmega161' etc. between them. */
50
51 if (letter (*a) && digit (*b))
52 return -1;
53
54 if (digit (*a) && letter (*b))
55 return 1;
56
57 if (*a != *b)
58 return *a - *b;
59
60 a++;
61 b++;
62 }
5be35a61 63
e3cf7a95 64 return *a - *b;
5be35a61
GJL
65}
66
67static void
68print_mcus (size_t n_mcus)
69{
5219b232 70 int duplicate = 0;
5be35a61
GJL
71 size_t i;
72
73 if (!n_mcus)
74 return;
75
76 qsort (mcu_name, n_mcus, sizeof (char*), comparator);
77
78 printf ("@*@var{mcu}@tie{}=");
79
80 for (i = 0; i < n_mcus; i++)
5219b232
GJL
81 {
82 printf (" @code{%s}%s", mcu_name[i], i == n_mcus-1 ? ".\n\n" : ",");
83
84 if (i && !strcmp (mcu_name[i], mcu_name[i-1]))
85 {
86 /* Sanity-check: Fail on devices that are present more than once. */
87
88 duplicate = 1;
89 fprintf (stderr, "error: duplicate device: %s\n", mcu_name[i]);
90 }
91 }
92
93 if (duplicate)
94 exit (1);
5be35a61
GJL
95}
96
04d170d2
GJL
97int main (void)
98{
4a2caf6c 99 enum avr_arch_id arch_id = ARCH_UNKNOWN;
5be35a61 100 size_t i, n_mcus = 0;
1c494c6a 101 const avr_mcu_t *mcu;
04d170d2 102
818ab71a 103 printf ("@c Copyright (C) 2012-2016 Free Software Foundation, Inc.\n");
04d170d2
GJL
104 printf ("@c This is part of the GCC manual.\n");
105 printf ("@c For copying conditions, see the file "
106 "gcc/doc/include/fdl.texi.\n\n");
107
108 printf ("@c This file is generated automatically using\n");
109 printf ("@c gcc/config/avr/gen-avr-mmcu-texi.c from:\n");
e3cf7a95 110 printf ("@c gcc/config/avr/avr-arch.h\n");
04d170d2
GJL
111 printf ("@c gcc/config/avr/avr-devices.c\n");
112 printf ("@c gcc/config/avr/avr-mcus.def\n\n");
113
114 printf ("@c Please do not edit manually.\n\n");
115
116 printf ("@table @code\n\n");
117
118 for (mcu = avr_mcu_types; mcu->name; mcu++)
119 {
120 if (mcu->macro == NULL)
121 {
4a2caf6c 122 arch_id = mcu->arch_id;
04d170d2 123
5be35a61
GJL
124 /* Start a new architecture: Flush the MCUs collected so far. */
125
126 print_mcus (n_mcus);
127 n_mcus = 0;
128
04d170d2 129 for (i = 0; i < sizeof (avr_texinfo) / sizeof (*avr_texinfo); i++)
4a2caf6c 130 if (arch_id == avr_texinfo[i].arch_id)
5be35a61 131 printf ("@item %s\n%s\n", mcu->name, avr_texinfo[i].texinfo);
04d170d2 132 }
4a2caf6c 133 else if (arch_id == (enum avr_arch_id) mcu->arch_id)
04d170d2 134 {
5be35a61 135 mcu_name[n_mcus++] = mcu->name;
04d170d2
GJL
136 }
137 }
138
5be35a61 139 print_mcus (n_mcus);
04d170d2
GJL
140 printf ("@end table\n");
141
142 return EXIT_SUCCESS;
143}