compiler: Check for initialization cycles in bound method expressions.
[official-gcc.git] / gcc / timevar.h
blobf018e39ce07c72507ae99b1088bf5f543b87cd62
1 /* Timing variables for measuring compiler performance.
2 Copyright (C) 2000-2014 Free Software Foundation, Inc.
3 Contributed by Alex Samuel <samuel@codesourcery.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 License for more details.
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/>. */
21 #ifndef GCC_TIMEVAR_H
22 #define GCC_TIMEVAR_H
24 /* Timing variables are used to measure elapsed time in various
25 portions of the compiler. Each measures elapsed user, system, and
26 wall-clock time, as appropriate to and supported by the host
27 system.
29 Timing variables are defined using the DEFTIMEVAR macro in
30 timevar.def. Each has an enumeral identifier, used when referring
31 to the timing variable in code, and a character string name.
33 Timing variables can be used in two ways:
35 - On the timing stack, using timevar_push and timevar_pop.
36 Timing variables may be pushed onto the stack; elapsed time is
37 attributed to the topmost timing variable on the stack. When
38 another variable is pushed on, the previous topmost variable is
39 `paused' until the pushed variable is popped back off.
41 - As a standalone timer, using timevar_start and timevar_stop.
42 All time elapsed between the two calls is attributed to the
43 variable.
46 /* This structure stores the various varieties of time that can be
47 measured. Times are stored in seconds. The time may be an
48 absolute time or a time difference; in the former case, the time
49 base is undefined, except that the difference between two times
50 produces a valid time difference. */
52 struct timevar_time_def
54 /* User time in this process. */
55 double user;
57 /* System time (if applicable for this host platform) in this
58 process. */
59 double sys;
61 /* Wall clock time. */
62 double wall;
64 /* Garbage collector memory. */
65 size_t ggc_mem;
68 /* An enumeration of timing variable identifiers. Constructed from
69 the contents of timevar.def. */
71 #define DEFTIMEVAR(identifier__, name__) \
72 identifier__,
73 typedef enum
75 TV_NONE,
76 #include "timevar.def"
77 TIMEVAR_LAST
79 timevar_id_t;
80 #undef DEFTIMEVAR
82 /* True if timevars should be used. In GCC, this happens with
83 the -ftime-report flag. */
84 extern bool timevar_enable;
86 /* Total amount of memory allocated by garbage collector. */
87 extern size_t timevar_ggc_mem_total;
89 extern void timevar_init (void);
90 extern void timevar_push_1 (timevar_id_t);
91 extern void timevar_pop_1 (timevar_id_t);
92 extern void timevar_start (timevar_id_t);
93 extern void timevar_stop (timevar_id_t);
94 extern bool timevar_cond_start (timevar_id_t);
95 extern void timevar_cond_stop (timevar_id_t, bool);
96 extern void timevar_print (FILE *);
98 /* Provided for backward compatibility. */
99 static inline void
100 timevar_push (timevar_id_t tv)
102 if (timevar_enable)
103 timevar_push_1 (tv);
106 static inline void
107 timevar_pop (timevar_id_t tv)
109 if (timevar_enable)
110 timevar_pop_1 (tv);
113 // This is a simple timevar wrapper class that pushes a timevar in its
114 // constructor and pops the timevar in its destructor.
115 class auto_timevar
117 public:
118 auto_timevar (timevar_id_t tv)
119 : m_tv (tv)
121 timevar_push (m_tv);
124 ~auto_timevar ()
126 timevar_pop (m_tv);
129 private:
131 // Private to disallow copies.
132 auto_timevar (const auto_timevar &);
134 timevar_id_t m_tv;
137 extern void print_time (const char *, long);
139 #endif /* ! GCC_TIMEVAR_H */