]> gcc.gnu.org Git - gcc.git/blame - gcc/params.c
Update Copyright years for files modified in 2008 and/or 2009.
[gcc.git] / gcc / params.c
CommitLineData
c6d9a88c 1/* params.c - Run-time parameters.
66647d44
JJ
2 Copyright (C) 2001, 2003, 2004, 2005, 2007, 2008
3 Free Software Foundation, Inc.
c6d9a88c
MM
4 Written by Mark Mitchell <mark@codesourcery.com>.
5
1322177d 6This file is part of GCC.
c6d9a88c 7
1322177d
LB
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
9dcd6f09 10Software Foundation; either version 3, or (at your option) any later
1322177d 11version.
c6d9a88c 12
1322177d
LB
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
c6d9a88c
MM
17
18You should have received a copy of the GNU General Public License
9dcd6f09
NC
19along with GCC; see the file COPYING3. If not see
20<http://www.gnu.org/licenses/>. */
c6d9a88c
MM
21
22#include "config.h"
23#include "system.h"
4977bab6
ZW
24#include "coretypes.h"
25#include "tm.h"
c6d9a88c
MM
26#include "params.h"
27#include "toplev.h"
28
29/* An array containing the compiler parameters and their current
30 values. */
31
32param_info *compiler_params;
33
34/* The number of entries in the table. */
35
36static size_t num_compiler_params;
37
38/* Add the N PARAMS to the current list of compiler parameters. */
39
6a4d6760 40void
3d7aafde 41add_params (const param_info params[], size_t n)
c6d9a88c
MM
42{
43 /* Allocate enough space for the new parameters. */
d3bfe4de
KG
44 compiler_params = XRESIZEVEC (param_info, compiler_params,
45 num_compiler_params + n);
c6d9a88c
MM
46 /* Copy them into the table. */
47 memcpy (compiler_params + num_compiler_params,
48 params,
49 n * sizeof (param_info));
50 /* Keep track of how many parameters we have. */
51 num_compiler_params += n;
52}
53
54/* Set the VALUE associated with the parameter given by NAME. */
55
56void
3d7aafde 57set_param_value (const char *name, int value)
c6d9a88c
MM
58{
59 size_t i;
60
61 /* Make sure nobody tries to set a parameter to an invalid value. */
e16acfcd 62 gcc_assert (value != INVALID_PARAM_VAL);
c6d9a88c
MM
63
64 /* Scan the parameter table to find a matching entry. */
65 for (i = 0; i < num_compiler_params; ++i)
66 if (strcmp (compiler_params[i].option, name) == 0)
67 {
e06c0feb
NS
68 if (value < compiler_params[i].min_value)
69 error ("minimum value of parameter %qs is %u",
70 compiler_params[i].option,
71 compiler_params[i].min_value);
72 else if (compiler_params[i].max_value > compiler_params[i].min_value
73 && value > compiler_params[i].max_value)
74 error ("maximum value of parameter %qs is %u",
75 compiler_params[i].option,
76 compiler_params[i].max_value);
77 else
47eb5b32
ZD
78 {
79 compiler_params[i].value = value;
80 compiler_params[i].set = true;
81 }
c6d9a88c
MM
82 return;
83 }
84
85 /* If we didn't find this parameter, issue an error message. */
971801ff 86 error ("invalid parameter %qs", name);
c6d9a88c 87}
This page took 2.464493 seconds and 5 git commands to generate.