Fix file cache tunables documentation
[official-gcc.git] / gcc / options-urls-cc-gen.awk
bloba4ad59ab4d489ce983f22090a2f589c616b98536
1 # Copyright (C) 2023-2025 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify it
4 # under the terms of the GNU General Public License as published by the
5 # Free Software Foundation; either version 3, or (at your option) any
6 # later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; see the file COPYING3. If not see
15 # <http://www.gnu.org/licenses/>.
17 # This Awk script reads in the option records generated from
18 # opt-gather.awk, and generates a C++ file containing an array
19 # of URL suffixes (possibly NULL), one per option.
21 # This program uses functions from opt-functions.awk and code from
22 # opt-read.awk.
24 # Usage: awk -f opt-functions.awk -f opt-read.awk -f options-urls-cc-gen.awk \
25 # [-v header_name=header.h] < inputfile > options-urls.cc
27 END {
30 print "/* This file is auto-generated by options-urls-cc-gen.awk. */"
31 print ""
32 print "#define INCLUDE_MEMORY"
33 n_headers = split(header_name, headers, " ")
34 for (i = 1; i <= n_headers; i++)
35 print "#include " quote headers[i] quote
36 print "#include " quote "opts.h" quote
37 print "#include " quote "intl.h" quote
38 print "#include " quote "insn-attr-common.h" quote
39 print ""
41 if (n_extra_c_includes > 0) {
42 for (i = 0; i < n_extra_c_includes; i++) {
43 print "#include " quote extra_c_includes[i] quote
45 print ""
48 print "const char *"
49 print "get_opt_url_suffix (int option_index, unsigned lang_mask)"
50 print "{"
51 print " switch (option_index)"
52 print " {"
55 optindex = 0
56 for (i = 0; i < n_opts; i++) {
57 # Combine the flags of identical switches. Switches
58 # appear many times if they are handled by many front
59 # ends, for example.
60 while( i + 1 != n_opts && opts[i] == opts[i + 1] ) {
61 flags[i + 1] = flags[i] " " flags[i + 1];
62 i++;
65 len = length (opts[i]);
66 enum = opt_enum(opts[i])
68 # Aliases do not get enumeration names.
69 if ((flag_set_p("Alias.*", flags[i]) \
70 && !flag_set_p("SeparateAlias", flags[i])) \
71 || flag_set_p("Ignore", flags[i])) {
72 show_case = 0;
73 } else {
74 show_case = 1;
77 if (show_case) {
78 printf(" case %s:\n", opt_enum(opts[i]))
80 # Handle any lang-specific LangUrlSuffix directives:
81 for (lang_idx = 0; lang_idx < n_langs; lang_idx++) {
82 lang_name = lang_sanitized_name(langs[lang_idx])
83 u = lang_url_suffix(flags[i], lang_name)
84 if (u != "") {
85 printf(" if (lang_mask & CL_%s)\n", lang_name)
86 printf(" return \"%s\";\n", u)
90 # Use any language-independent UrlSuffix directive:
91 u = url_suffix(flags[i])
92 if (u != "") {
93 printf(" return \"%s\";\n", u)
94 } else {
95 printf(" break;\n")
99 # Bump up the informational option index.
100 ++optindex
103 print " }"
104 print " return nullptr;"
105 print "}"