PIPS
utils.c
Go to the documentation of this file.
1 /*
2 
3  $Id: utils.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 /* -- utils.c
28  *
29  * package atomizer : Alexis Platonoff, juillet 91
30  * --
31  *
32  * Miscellaneous functions
33  */
34 
35 #include "local.h"
36 #include "prettyprint.h"
37 
38 #define NLC_PREFIX "NLC"
39 #define ENTITY_NLC_P(e) (strncmp(entity_local_name(e), NLC_PREFIX, 3) == 0)
40 
41 
42 
43 
44 /*============================================================================*/
45 /* bool instruction_in_list_p(instruction inst, list l): Returns true if "inst"
46  * is in "l".
47  *
48  * Note: "l" must be a list of instructions.
49  */
50 bool instruction_in_list_p(inst, l)
51 instruction inst;
52 list l;
53 {
54 bool not_found = true;
55 
56 while((not_found) && (l != NIL))
57  {
58  instruction current_inst = INSTRUCTION(CAR(l));
59  if (inst == current_inst)
60  not_found = false;
61  else
62  l = CDR(l);
63  }
64 return (! not_found);
65 }
66 
67 
68 
69 /*============================================================================*/
70 /* bool nlc_linear_expression_p(expression exp): returns true if "exp" is an
71  * integer linear expression with only NLCs variables.
72  *
73  * NLC means Normalized Loop Counter.
74  *
75  * Called functions :
76  * _ unnormalize_expression() : loop_normalize/utils.c
77  */
80 {
81 Pvecteur vect;
82 bool ONLY_NLCs;
83 
84 pips_debug(7, "exp : %s\n", expression_to_string(exp));
85 
87  ONLY_NLCs = false;
88 else
89  {
91  ONLY_NLCs = true;
92 
93  for(; !VECTEUR_NUL_P(vect) && ONLY_NLCs ; vect = vect->succ)
94  {
95  entity var = (entity) vect->var;
96 
97  if( ! term_cst(vect) )
98  if( ! (ENTITY_NLC_P(var)) )
99  ONLY_NLCs = false;
100  }
101  }
102 
103 /* We unnormalize the expression, otherwise, it causes an error when we
104  * normalize an expression with sub-expressions already normalized.
105  * (cf. NormalizedExpression() in normalize/normalize.c).
106  *
107  * This unnormalization is done recursively upon all the sub-expressions of
108  * "exp".
109  */
111 
112 debug(7, "nlc_linear_expression_p", " result : %d\n", ONLY_NLCs);
113 
114 return(ONLY_NLCs);
115 }
116 
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
bool nlc_linear_expression_p(expression exp)
===========================================================================
Definition: utils.c:78
#define ENTITY_NLC_P(e)
Definition: utils.c:39
bool instruction_in_list_p(instruction inst, list l)
===========================================================================
Definition: utils.c:50
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
void unnormalize_expression(void *st)
void unnormalize_expression(expression exp): puts all the normalized field of expressions in "st" to ...
Definition: normalize.c:452
string expression_to_string(expression e)
Definition: expression.c:77
#define NORMALIZE_EXPRESSION(e)
#define INSTRUCTION(x)
INSTRUCTION.
Definition: ri.h:1448
#define normalized_tag(x)
Definition: ri.h:1778
#define expression_normalized(x)
Definition: ri.h:1249
#define normalized_linear(x)
Definition: ri.h:1781
@ is_normalized_complex
Definition: ri.h:1761
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207
struct Svecteur * Pvecteur
#define VECTEUR_NUL_P(v)
#define term_cst(varval)