Mercurial > hg > CbC > CbC_gcc
comparison gcc/params.c @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | 77e2b8dfacca |
children | 04ced10e8804 |
comparison
equal
deleted
inserted
replaced
65:65488c3d617d | 67:f6334be47118 |
---|---|
1 /* params.c - Run-time parameters. | 1 /* params.c - Run-time parameters. |
2 Copyright (C) 2001, 2003, 2004, 2005, 2007, 2008 | 2 Copyright (C) 2001, 2003, 2004, 2005, 2007, 2008, 2009, 2010 |
3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
4 Written by Mark Mitchell <mark@codesourcery.com>. | 4 Written by Mark Mitchell <mark@codesourcery.com>. |
5 | 5 |
6 This file is part of GCC. | 6 This file is part of GCC. |
7 | 7 |
22 #include "config.h" | 22 #include "config.h" |
23 #include "system.h" | 23 #include "system.h" |
24 #include "coretypes.h" | 24 #include "coretypes.h" |
25 #include "tm.h" | 25 #include "tm.h" |
26 #include "params.h" | 26 #include "params.h" |
27 #include "toplev.h" | 27 #include "diagnostic-core.h" |
28 | 28 |
29 /* An array containing the compiler parameters and their current | 29 /* An array containing the compiler parameters and their current |
30 values. */ | 30 values. */ |
31 | 31 |
32 param_info *compiler_params; | 32 param_info *compiler_params; |
33 | 33 |
34 /* The number of entries in the table. */ | 34 /* The number of entries in the table. */ |
35 static size_t num_compiler_params; | 35 static size_t num_compiler_params; |
36 | 36 |
37 /* Whether the parameters have all been initialized and had their | |
38 default values determined. */ | |
39 static bool params_finished; | |
40 | |
37 /* Add the N PARAMS to the current list of compiler parameters. */ | 41 /* Add the N PARAMS to the current list of compiler parameters. */ |
38 | 42 |
39 void | 43 void |
40 add_params (const param_info params[], size_t n) | 44 add_params (const param_info params[], size_t n) |
41 { | 45 { |
46 gcc_assert (!params_finished); | |
47 | |
42 /* Allocate enough space for the new parameters. */ | 48 /* Allocate enough space for the new parameters. */ |
43 compiler_params = XRESIZEVEC (param_info, compiler_params, | 49 compiler_params = XRESIZEVEC (param_info, compiler_params, |
44 num_compiler_params + n); | 50 num_compiler_params + n); |
45 /* Copy them into the table. */ | 51 /* Copy them into the table. */ |
46 memcpy (compiler_params + num_compiler_params, | 52 memcpy (compiler_params + num_compiler_params, |
48 n * sizeof (param_info)); | 54 n * sizeof (param_info)); |
49 /* Keep track of how many parameters we have. */ | 55 /* Keep track of how many parameters we have. */ |
50 num_compiler_params += n; | 56 num_compiler_params += n; |
51 } | 57 } |
52 | 58 |
53 /* Set the VALUE associated with the parameter given by NAME. */ | 59 /* Note that all parameters have been added and all default values |
60 set. */ | |
54 | 61 |
55 void | 62 void |
56 set_param_value (const char *name, int value) | 63 finish_params (void) |
64 { | |
65 params_finished = true; | |
66 } | |
67 | |
68 /* Set the value of the parameter given by NUM to VALUE in PARAMS and | |
69 PARAMS_SET. If EXPLICIT_P, this is being set by the user; | |
70 otherwise it is being set implicitly by the compiler. */ | |
71 | |
72 static void | |
73 set_param_value_internal (compiler_param num, int value, | |
74 int *params, int *params_set, | |
75 bool explicit_p) | |
76 { | |
77 size_t i = (size_t) num; | |
78 | |
79 gcc_assert (params_finished); | |
80 | |
81 params[i] = value; | |
82 if (explicit_p) | |
83 params_set[i] = true; | |
84 } | |
85 | |
86 /* Set the VALUE associated with the parameter given by NAME in PARAMS | |
87 and PARAMS_SET. */ | |
88 | |
89 void | |
90 set_param_value (const char *name, int value, | |
91 int *params, int *params_set) | |
57 { | 92 { |
58 size_t i; | 93 size_t i; |
59 | 94 |
60 /* Make sure nobody tries to set a parameter to an invalid value. */ | 95 /* Make sure nobody tries to set a parameter to an invalid value. */ |
61 gcc_assert (value != INVALID_PARAM_VAL); | 96 gcc_assert (value != INVALID_PARAM_VAL); |
72 && value > compiler_params[i].max_value) | 107 && value > compiler_params[i].max_value) |
73 error ("maximum value of parameter %qs is %u", | 108 error ("maximum value of parameter %qs is %u", |
74 compiler_params[i].option, | 109 compiler_params[i].option, |
75 compiler_params[i].max_value); | 110 compiler_params[i].max_value); |
76 else | 111 else |
77 { | 112 set_param_value_internal ((compiler_param) i, value, |
78 compiler_params[i].value = value; | 113 params, params_set, true); |
79 compiler_params[i].set = true; | |
80 } | |
81 return; | 114 return; |
82 } | 115 } |
83 | 116 |
84 /* If we didn't find this parameter, issue an error message. */ | 117 /* If we didn't find this parameter, issue an error message. */ |
85 error ("invalid parameter %qs", name); | 118 error ("invalid parameter %qs", name); |
119 } | |
120 | |
121 /* Set the value of the parameter given by NUM to VALUE in PARAMS and | |
122 PARAMS_SET, implicitly, if it has not been set explicitly by the | |
123 user. */ | |
124 | |
125 void | |
126 maybe_set_param_value (compiler_param num, int value, | |
127 int *params, int *params_set) | |
128 { | |
129 if (!params_set[(int) num]) | |
130 set_param_value_internal (num, value, params, params_set, false); | |
131 } | |
132 | |
133 /* Set the default value of a parameter given by NUM to VALUE, before | |
134 option processing. */ | |
135 | |
136 void | |
137 set_default_param_value (compiler_param num, int value) | |
138 { | |
139 gcc_assert (!params_finished); | |
140 | |
141 compiler_params[(int) num].default_value = value; | |
142 } | |
143 | |
144 /* Return the default value of parameter NUM. */ | |
145 | |
146 int | |
147 default_param_value (compiler_param num) | |
148 { | |
149 return compiler_params[(int) num].default_value; | |
150 } | |
151 | |
152 /* Initialize an array PARAMS with default values of the | |
153 parameters. */ | |
154 | |
155 void | |
156 init_param_values (int *params) | |
157 { | |
158 size_t i; | |
159 | |
160 gcc_assert (params_finished); | |
161 | |
162 for (i = 0; i < num_compiler_params; i++) | |
163 params[i] = compiler_params[i].default_value; | |
86 } | 164 } |
87 | 165 |
88 /* Return the current value of num_compiler_params, for the benefit of | 166 /* Return the current value of num_compiler_params, for the benefit of |
89 plugins that use parameters as features. */ | 167 plugins that use parameters as features. */ |
90 | 168 |