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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [input.c] - Blame information for rev 708

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 684 jeremybenn
/* Data and functions related to line maps and input files.
2
   Copyright (C) 2004, 2007, 2008, 2009, 2010, 2011
3
   Free Software Foundation, Inc.
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 "intl.h"
25
#include "input.h"
26
 
27
/* Current position in real source file.  */
28
 
29
location_t input_location;
30
 
31
struct line_maps *line_table;
32
 
33
/* Expand the source location LOC into a human readable location.  If
34
   LOC resolves to a builtin location, the file name of the readable
35
   location is set to the string "<built-in>".  */
36
 
37
expanded_location
38
expand_location (source_location loc)
39
{
40
  expanded_location xloc;
41
  const struct line_map *map;
42
 
43
  loc = linemap_resolve_location (line_table, loc,
44
                                  LRK_SPELLING_LOCATION, &map);
45
  xloc = linemap_expand_location (line_table, map, loc);
46
 
47
  if (loc <= BUILTINS_LOCATION)
48
    xloc.file = loc == UNKNOWN_LOCATION ? NULL : _("<built-in>");
49
 
50
  return xloc;
51
}
52
 
53
#define ONE_K 1024
54
#define ONE_M (ONE_K * ONE_K)
55
 
56
/* Display a number as an integer multiple of either:
57
   - 1024, if said integer is >= to 10 K (in base 2)
58
   - 1024 * 1024, if said integer is >= 10 M in (base 2)
59
 */
60
#define SCALE(x) ((unsigned long) ((x) < 10 * ONE_K \
61
                  ? (x) \
62
                  : ((x) < 10 * ONE_M \
63
                     ? (x) / ONE_K \
64
                     : (x) / ONE_M)))
65
 
66
/* For a given integer, display either:
67
   - the character 'k', if the number is higher than 10 K (in base 2)
68
     but strictly lower than 10 M (in base 2)
69
   - the character 'M' if the number is higher than 10 M (in base2)
70
   - the charcter ' ' if the number is strictly lower  than 10 K  */
71
#define STAT_LABEL(x) ((x) < 10 * ONE_K ? ' ' : ((x) < 10 * ONE_M ? 'k' : 'M'))
72
 
73
/* Display an integer amount as multiple of 1K or 1M (in base 2).
74
   Display the correct unit (either k, M, or ' ') after the amout, as
75
   well.  */
76
#define FORMAT_AMOUNT(size) SCALE (size), STAT_LABEL (size)
77
 
78
/* Dump statistics to stderr about the memory usage of the line_table
79
   set of line maps.  This also displays some statistics about macro
80
   expansion.  */
81
 
82
void
83
dump_line_table_statistics (void)
84
{
85
  struct linemap_stats s;
86
  long total_used_map_size,
87
    macro_maps_size,
88
    total_allocated_map_size;
89
 
90
  memset (&s, 0, sizeof (s));
91
 
92
  linemap_get_statistics (line_table, &s);
93
 
94
  macro_maps_size = s.macro_maps_used_size
95
    + s.macro_maps_locations_size;
96
 
97
  total_allocated_map_size = s.ordinary_maps_allocated_size
98
    + s.macro_maps_allocated_size
99
    + s.macro_maps_locations_size;
100
 
101
  total_used_map_size = s.ordinary_maps_used_size
102
    + s.macro_maps_used_size
103
    + s.macro_maps_locations_size;
104
 
105
  fprintf (stderr, "Number of expanded macros:                     %5ld\n",
106
           s.num_expanded_macros);
107
  if (s.num_expanded_macros != 0)
108
    fprintf (stderr, "Average number of tokens per macro expansion:  %5ld\n",
109
             s.num_macro_tokens / s.num_expanded_macros);
110
  fprintf (stderr,
111
           "\nLine Table allocations during the "
112
           "compilation process\n");
113
  fprintf (stderr, "Number of ordinary maps used:        %5ld%c\n",
114
           SCALE (s.num_ordinary_maps_used),
115
           STAT_LABEL (s.num_ordinary_maps_used));
116
  fprintf (stderr, "Ordinary map used size:              %5ld%c\n",
117
           SCALE (s.ordinary_maps_used_size),
118
           STAT_LABEL (s.ordinary_maps_used_size));
119
  fprintf (stderr, "Number of ordinary maps allocated:   %5ld%c\n",
120
           SCALE (s.num_ordinary_maps_allocated),
121
           STAT_LABEL (s.num_ordinary_maps_allocated));
122
  fprintf (stderr, "Ordinary maps allocated size:        %5ld%c\n",
123
           SCALE (s.ordinary_maps_allocated_size),
124
           STAT_LABEL (s.ordinary_maps_allocated_size));
125
  fprintf (stderr, "Number of macro maps used:           %5ld%c\n",
126
           SCALE (s.num_macro_maps_used),
127
           STAT_LABEL (s.num_macro_maps_used));
128
  fprintf (stderr, "Macro maps used size:                %5ld%c\n",
129
           SCALE (s.macro_maps_used_size),
130
           STAT_LABEL (s.macro_maps_used_size));
131
  fprintf (stderr, "Macro maps locations size:           %5ld%c\n",
132
           SCALE (s.macro_maps_locations_size),
133
           STAT_LABEL (s.macro_maps_locations_size));
134
  fprintf (stderr, "Macro maps size:                     %5ld%c\n",
135
           SCALE (macro_maps_size),
136
           STAT_LABEL (macro_maps_size));
137
  fprintf (stderr, "Duplicated maps locations size:      %5ld%c\n",
138
           SCALE (s.duplicated_macro_maps_locations_size),
139
           STAT_LABEL (s.duplicated_macro_maps_locations_size));
140
  fprintf (stderr, "Total allocated maps size:           %5ld%c\n",
141
           SCALE (total_allocated_map_size),
142
           STAT_LABEL (total_allocated_map_size));
143
  fprintf (stderr, "Total used maps size:                %5ld%c\n",
144
           SCALE (total_used_map_size),
145
           STAT_LABEL (total_used_map_size));
146
  fprintf (stderr, "\n");
147
}

powered by: WebSVN 2.1.0

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