PIPS
misc.c
Go to the documentation of this file.
1 /*
2 
3  $Id: misc.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27  /* low level routines which should be added to other packages
28  *
29  * Francois Irigoin, April 1990
30  *
31  * Modifications:
32  * - passage a l'utilisation de database
33  */
34 
35 #include <stdio.h>
36 
37 #include "genC.h"
38 #include "misc.h"
39 #include "linear.h"
40 #include "ri.h"
41 #include "effects.h"
42 #include "text-util.h"
43 #include "ri-util.h"
44 #include "prettyprint.h"
45 #include "effects-util.h"
46 #include "semantics.h"
47 #include "properties.h"
48 
49 /* probably to add to the future callgraph library */
50 
52 entity m;
53 {
54  /* number of "call to m" sites within the current program;
55  they are all in m's CALLERS */
56  pips_assert("call_site_count", value_code_p(entity_initial(m)));
57  /* I do not know yet; let's return 1 to please the semantic analysis */
58  user_warning("call_site_count",
59  "not implemented yet, always returns 1\n");
60  return 1;
61 }
62 
64 entity m;
65 {
66  /* number of modules calling m within the current program;
67  i.e. number of modules containing at least one call site to m */
68  pips_assert("caller_count", value_code_p(entity_initial(m)));
69  /* I do not know yet; let's return 1 to please the semantic analysis */
70  user_warning("caller_count",
71  "not implemented yet, always returns 1\n");
72  return 1;
73 }
74 
76 {
77  /* number of call to m during the current program execution;
78  return 0 if m is never called, either because it's a call
79  graph root or because it was linked by mistake;
80  return -1 if the dynamic call count is unknow, for instance
81  because one of m's call site is located in a loop of unknown
82  bounds;
83  return k when it can be evaluated */
84  pips_assert("Entity m is a function with defined code",
86  /* I do not know yet; let's return 1 to please the semantic analysis */
87  pips_internal_error("Not implemented yet, always returns -1.\n");
88  return -1;
89 }
90 
91 /* Some other warnings include the pass name
92  */
94  const char * func_name,
95  const char * format,
96  va_list * args)
97 {
98  if (get_bool_property("NO_USER_WARNING"))
99  return;
100 
102  int ln = statement_undefined_p(cs)? -1: statement_number(cs);
103 
104  // this may be big... truncate?
105  const string scs = proper_statement_to_string(cs);
106 
108  warning_log,
110  (const string) func_name, NULL, -1,
111  (string) get_current_module_name(), NULL, ln, -1,
112  (const string) scs, NULL, (const string) format, args);
113 
114  free(scs);
115  return;
116 }
117 
119  const char * func_name,
120  const char * format,
121  ...)
122 {
123  va_list args;
124  va_start(args, format);
125  semantics_user_warning_alist(func_name, format, &args);
126  va_end(args);
127 }
128 
130  const char * format,
131  ...)
132 {
133  va_list args;
134  va_start(args, format);
136  va_end(args);
137 }
void pips_log_alist(const pips_log_t tag, const string pips_pass, const string pips_owner, const string pips_func, const string pips_file, const int pips_line, const string user_func, const string user_file, const int user_line, const int user_line2, const string stmt, const string suggestion, const string format, va_list *args)
log entry with unprocessed format/alist arguments
Definition: message.c:1200
string get_pips_current_pass_name(void)
Export this piece of information to customize warning functions in passes.
Definition: message.c:77
string get_pips_current_module(void)
Definition: message.c:82
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
void free(void *)
const char * get_current_module_name(void)
Get the name of the current module.
Definition: static.c:121
#define pips_unknown_function
Definition: misc-local.h:63
@ warning_log
Definition: misc-local.h:34
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define pips_internal_error
Definition: misc-local.h:149
#define user_warning(fn,...)
Definition: misc-local.h:262
string proper_statement_to_string(statement)
statement get_current_statement_from_statement_global_stack(void)
Definition: static.c:344
#define value_code_p(x)
Definition: ri.h:3065
#define statement_undefined_p(x)
Definition: ri.h:2420
#define statement_number(x)
Definition: ri.h:2452
#define entity_initial(x)
Definition: ri.h:2796
void semantics_user_warning_func2(const char *format,...)
Definition: misc.c:129
int dynamic_call_count(entity m)
Definition: misc.c:75
int call_site_count(entity m)
low level routines which should be added to other packages
Definition: misc.c:51
void semantics_user_warning_func(const char *func_name, const char *format,...)
Definition: misc.c:118
static void semantics_user_warning_alist(const char *func_name, const char *format, va_list *args)
Some other warnings include the pass name.
Definition: misc.c:93
int caller_count(entity m)
Definition: misc.c:63