annotate gcc/opt-read.awk @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
kono
parents:
diff changeset
1 # Copyright (C) 2003-2017 Free Software Foundation, Inc.
kono
parents:
diff changeset
2 # Contributed by Kelley Cook, June 2004.
kono
parents:
diff changeset
3 # Original code from Neil Booth, May 2003.
kono
parents:
diff changeset
4 #
kono
parents:
diff changeset
5 # This program is free software; you can redistribute it and/or modify it
kono
parents:
diff changeset
6 # under the terms of the GNU General Public License as published by the
kono
parents:
diff changeset
7 # Free Software Foundation; either version 3, or (at your option) any
kono
parents:
diff changeset
8 # later version.
kono
parents:
diff changeset
9 #
kono
parents:
diff changeset
10 # This program is distributed in the hope that it will be useful,
kono
parents:
diff changeset
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
13 # GNU General Public License for more details.
kono
parents:
diff changeset
14 #
kono
parents:
diff changeset
15 # You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
16 # along with this program; see the file COPYING3. If not see
kono
parents:
diff changeset
17 # <http://www.gnu.org/licenses/>.
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 # Read in the option records generated from opt-gather.awk.
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 BEGIN {
kono
parents:
diff changeset
22 n_opts = 0
kono
parents:
diff changeset
23 n_langs = 0
kono
parents:
diff changeset
24 n_target_save = 0
kono
parents:
diff changeset
25 n_extra_vars = 0
kono
parents:
diff changeset
26 n_extra_target_vars = 0
kono
parents:
diff changeset
27 n_extra_masks = 0
kono
parents:
diff changeset
28 n_extra_c_includes = 0
kono
parents:
diff changeset
29 n_extra_h_includes = 0
kono
parents:
diff changeset
30 n_enums = 0
kono
parents:
diff changeset
31 have_save = 0;
kono
parents:
diff changeset
32 quote = "\042"
kono
parents:
diff changeset
33 comma = ","
kono
parents:
diff changeset
34 FS=SUBSEP
kono
parents:
diff changeset
35 # Default the name of header created from opth-gen.awk to options.h
kono
parents:
diff changeset
36 if (header_name == "") header_name="options.h"
kono
parents:
diff changeset
37 }
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 # Collect the text and flags of each option into an array
kono
parents:
diff changeset
40 {
kono
parents:
diff changeset
41 if ($1 == "Language") {
kono
parents:
diff changeset
42 langs[n_langs] = $2
kono
parents:
diff changeset
43 lang_numbers[$2] = n_langs
kono
parents:
diff changeset
44 n_langs++;
kono
parents:
diff changeset
45 }
kono
parents:
diff changeset
46 else if ($1 == "TargetSave") {
kono
parents:
diff changeset
47 # Make sure the declarations are put in source order
kono
parents:
diff changeset
48 target_save_decl[n_target_save] = $2
kono
parents:
diff changeset
49 n_target_save++
kono
parents:
diff changeset
50 }
kono
parents:
diff changeset
51 else if ($1 == "Variable") {
kono
parents:
diff changeset
52 extra_vars[n_extra_vars] = $2
kono
parents:
diff changeset
53 n_extra_vars++
kono
parents:
diff changeset
54 name = host_wide_int_var_name($2)
kono
parents:
diff changeset
55 if (name != "")
kono
parents:
diff changeset
56 host_wide_int[name] = "yes"
kono
parents:
diff changeset
57 }
kono
parents:
diff changeset
58 else if ($1 == "TargetVariable") {
kono
parents:
diff changeset
59 # Combination of TargetSave and Variable
kono
parents:
diff changeset
60 extra_vars[n_extra_vars] = $2
kono
parents:
diff changeset
61 n_extra_vars++
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 var = $2
kono
parents:
diff changeset
64 sub(" *=.*", "", var)
kono
parents:
diff changeset
65 orig_var = var
kono
parents:
diff changeset
66 name = var
kono
parents:
diff changeset
67 type = var
kono
parents:
diff changeset
68 sub("^.*[ *]", "", name)
kono
parents:
diff changeset
69 sub(" *" name "$", "", type)
kono
parents:
diff changeset
70 target_save_decl[n_target_save] = type " x_" name
kono
parents:
diff changeset
71 n_target_save++
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 extra_target_vars[n_extra_target_vars] = name
kono
parents:
diff changeset
74 n_extra_target_vars++
kono
parents:
diff changeset
75 }
kono
parents:
diff changeset
76 else if ($1 == "HeaderInclude") {
kono
parents:
diff changeset
77 extra_h_includes[n_extra_h_includes++] = $2;
kono
parents:
diff changeset
78 }
kono
parents:
diff changeset
79 else if ($1 == "SourceInclude") {
kono
parents:
diff changeset
80 extra_c_includes[n_extra_c_includes++] = $2;
kono
parents:
diff changeset
81 }
kono
parents:
diff changeset
82 else if ($1 == "Enum") {
kono
parents:
diff changeset
83 props = $2
kono
parents:
diff changeset
84 name = opt_args("Name", props)
kono
parents:
diff changeset
85 type = opt_args("Type", props)
kono
parents:
diff changeset
86 unknown_error = opt_args("UnknownError", props)
kono
parents:
diff changeset
87 enum_names[n_enums] = name
kono
parents:
diff changeset
88 enum_type[name] = type
kono
parents:
diff changeset
89 enum_index[name] = n_enums
kono
parents:
diff changeset
90 enum_unknown_error[name] = unknown_error
kono
parents:
diff changeset
91 enum_help[name] = $3
kono
parents:
diff changeset
92 n_enums++
kono
parents:
diff changeset
93 }
kono
parents:
diff changeset
94 else if ($1 == "EnumValue") {
kono
parents:
diff changeset
95 props = $2
kono
parents:
diff changeset
96 enum_name = opt_args("Enum", props)
kono
parents:
diff changeset
97 string = opt_args("String", props)
kono
parents:
diff changeset
98 value = opt_args("Value", props)
kono
parents:
diff changeset
99 val_flags = "0"
kono
parents:
diff changeset
100 val_flags = val_flags \
kono
parents:
diff changeset
101 test_flag("Canonical", props, "| CL_ENUM_CANONICAL") \
kono
parents:
diff changeset
102 test_flag("DriverOnly", props, "| CL_ENUM_DRIVER_ONLY")
kono
parents:
diff changeset
103 enum_data[enum_name] = enum_data[enum_name] \
kono
parents:
diff changeset
104 " { " quote string quote ", " value ", " val_flags \
kono
parents:
diff changeset
105 " },\n"
kono
parents:
diff changeset
106 }
kono
parents:
diff changeset
107 else {
kono
parents:
diff changeset
108 name = opt_args("Mask", $1)
kono
parents:
diff changeset
109 if (name == "") {
kono
parents:
diff changeset
110 opts[n_opts] = $1
kono
parents:
diff changeset
111 opt_numbers[$1] = n_opts
kono
parents:
diff changeset
112 flags[n_opts] = $2
kono
parents:
diff changeset
113 help[n_opts] = $3
kono
parents:
diff changeset
114 for (i = 4; i <= NF; i++)
kono
parents:
diff changeset
115 help[n_opts] = help[n_opts] " " $i
kono
parents:
diff changeset
116 n_opts++;
kono
parents:
diff changeset
117 }
kono
parents:
diff changeset
118 else {
kono
parents:
diff changeset
119 extra_masks[n_extra_masks++] = name
kono
parents:
diff changeset
120 }
kono
parents:
diff changeset
121 }
kono
parents:
diff changeset
122 }
kono
parents:
diff changeset
123