OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [params.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
/* params.c - Run-time parameters.
2
   Copyright (C) 2001, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
3
   Written by Mark Mitchell <mark@codesourcery.com>.
4
 
5
This file is part of GCC.
6
 
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 3, or (at your option) any later
10
version.
11
 
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.
16
 
17
You should have received a copy of the GNU General Public License
18
along with GCC; see the file COPYING3.  If not see
19
<http://www.gnu.org/licenses/>.  */
20
 
21
#include "config.h"
22
#include "system.h"
23
#include "coretypes.h"
24
#include "tm.h"
25
#include "params.h"
26
#include "toplev.h"
27
 
28
/* An array containing the compiler parameters and their current
29
   values.  */
30
 
31
param_info *compiler_params;
32
 
33
/* The number of entries in the table.  */
34
 
35
static size_t num_compiler_params;
36
 
37
/* Add the N PARAMS to the current list of compiler parameters.  */
38
 
39
void
40
add_params (const param_info params[], size_t n)
41
{
42
  /* Allocate enough space for the new parameters.  */
43
  compiler_params = xrealloc (compiler_params,
44
                              (num_compiler_params + n) * sizeof (param_info));
45
  /* Copy them into the table.  */
46
  memcpy (compiler_params + num_compiler_params,
47
          params,
48
          n * sizeof (param_info));
49
  /* Keep track of how many parameters we have.  */
50
  num_compiler_params += n;
51
}
52
 
53
/* Set the VALUE associated with the parameter given by NAME.  */
54
 
55
void
56
set_param_value (const char *name, int value)
57
{
58
  size_t i;
59
 
60
  /* Make sure nobody tries to set a parameter to an invalid value.  */
61
  gcc_assert (value != INVALID_PARAM_VAL);
62
 
63
  /* Scan the parameter table to find a matching entry.  */
64
  for (i = 0; i < num_compiler_params; ++i)
65
    if (strcmp (compiler_params[i].option, name) == 0)
66
      {
67
        if (value < compiler_params[i].min_value)
68
          error ("minimum value of parameter %qs is %u",
69
                 compiler_params[i].option,
70
                 compiler_params[i].min_value);
71
        else if (compiler_params[i].max_value > compiler_params[i].min_value
72
                 && value > compiler_params[i].max_value)
73
          error ("maximum value of parameter %qs is %u",
74
                 compiler_params[i].option,
75
                 compiler_params[i].max_value);
76
        else
77
          compiler_params[i].value = value;
78
        return;
79
      }
80
 
81
  /* If we didn't find this parameter, issue an error message.  */
82
  error ("invalid parameter %qs", name);
83
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.