simplify-rtx.c (simplify_rtx): Use simplify_subreg rather than simplify_gen_subreg.
[official-gcc.git] / gcc / params.c
blobfee0657cd59eeeb7f7e8054d3a54c53dc12dea37
1 /* params.c - Run-time parameters.
2 Copyright (C) 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
3 Written by Mark Mitchell <mark@codesourcery.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
20 02110-1301, USA.
24 #include "config.h"
25 #include "system.h"
26 #include "coretypes.h"
27 #include "tm.h"
28 #include "params.h"
29 #include "toplev.h"
31 /* An array containing the compiler parameters and their current
32 values. */
34 param_info *compiler_params;
36 /* The number of entries in the table. */
38 static size_t num_compiler_params;
40 /* Add the N PARAMS to the current list of compiler parameters. */
42 void
43 add_params (const param_info params[], size_t n)
45 /* Allocate enough space for the new parameters. */
46 compiler_params = xrealloc (compiler_params,
47 (num_compiler_params + n) * sizeof (param_info));
48 /* Copy them into the table. */
49 memcpy (compiler_params + num_compiler_params,
50 params,
51 n * sizeof (param_info));
52 /* Keep track of how many parameters we have. */
53 num_compiler_params += n;
56 /* Set the VALUE associated with the parameter given by NAME. */
58 void
59 set_param_value (const char *name, int value)
61 size_t i;
63 /* Make sure nobody tries to set a parameter to an invalid value. */
64 gcc_assert (value != INVALID_PARAM_VAL);
66 /* Scan the parameter table to find a matching entry. */
67 for (i = 0; i < num_compiler_params; ++i)
68 if (strcmp (compiler_params[i].option, name) == 0)
70 if (value < compiler_params[i].min_value)
71 error ("minimum value of parameter %qs is %u",
72 compiler_params[i].option,
73 compiler_params[i].min_value);
74 else if (compiler_params[i].max_value > compiler_params[i].min_value
75 && value > compiler_params[i].max_value)
76 error ("maximum value of parameter %qs is %u",
77 compiler_params[i].option,
78 compiler_params[i].max_value);
79 else
81 compiler_params[i].value = value;
82 compiler_params[i].set = true;
84 return;
87 /* If we didn't find this parameter, issue an error message. */
88 error ("invalid parameter %qs", name);