PIPS
control.c
Go to the documentation of this file.
1 /*
2 
3  $Id: control.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 /* -- control.c
28  *
29  * package atomizer : Alexis Platonoff, juillet 91
30  * --
31  *
32  * Functions for the manipulations and modifications of the control graph.
33  */
34 
35 #include "local.h"
36 
37 /*============================================================================*/
38 /* void modify_blocks(control c): Adds a node to the control graph when the
39  * statement of "c" is not an "instruction_block".
40  *
41  * This node is added just before "c". "c" predecessor became the new node.
42  * The latter's predecessors are those of "c", its successor is "c".
43  *
44  * "l_inst" keep the reference to the instructions for which a new node is
45  * added. It is a global variable that will be used when we will generate
46  * new statements (see atomizer_of_statement(), in atomizer.c).
47  *
48  * Called functions :
49  * _ make_empty_statement() : ri-util/statement.c
50  */
52 control c;
53 {
54 extern list l_inst;
55 
56 control nc;
58 
60  {
61  if (! instruction_in_list_p(inst, l_inst))
62  {
65 
68 
70 
71  l_inst = CONS(INSTRUCTION, inst, l_inst);
72  }
73  }
74 }
75 
76 
77 
78 /*============================================================================*/
79 /* void atom_get_blocs(control c, cons **l): Almost the get_blocs() of
80  * the file control/control.h; the only modification is the call to
81  * modify_blocks() which adds a node to the control graph that will contain
82  * the instructions created by the translation of the statement contained
83  * in "c".
84  */
85 void atom_get_blocs( c, l )
86 control c ;
87 cons **l ;
88 {
89 MAPL( cs, {if( CONTROL( CAR( cs )) == c ) return ;}, *l ) ;
90 *l = CONS( CONTROL, c, *l ) ;
91 
92 modify_blocks(c);
93 
94 MAPL( cs, {atom_get_blocs( CONTROL( CAR( cs )), l );},
95  control_successors( c )) ;
96 
97 MAPL( ps, {atom_get_blocs( CONTROL( CAR( ps )), l );},
98  control_predecessors( c )) ;
99 }
100 
101 
102 
103 /*============================================================================*/
104 /* control find_control_block(control c): Returns the current control found
105  * in the static variable "cont_block".
106  *
107  * The use of this function is:
108  * _ first, in order to initialize the static "cont_block" this function is
109  * called with the control we want to memorize.
110  * _ then, when we need to get this control, this function is called
111  * with the argument "control_undefined".
112  *
113  * This is used by atomizer_of_statement() when we generate new statements.
114  */
116 control c;
117 {
118 static control cont_block;
119 
120 if(c != control_undefined)
121  {
124  cont_block = CONTROL(CAR(control_predecessors(c)));
125  else
126  cont_block = control_undefined;
127  }
128 
129 return(cont_block);
130 }
131 
control make_control(statement a1, list a2, list a3)
Definition: ri.c:523
list l_inst
The list "first" is a truncated list from the first to the current statement (not included).
Definition: atomizer.h:87
void atom_get_blocs(c, l)
===========================================================================
Definition: control.c:85
control find_control_block(control c)
===========================================================================
Definition: control.c:115
void modify_blocks(control c)
– control.c
Definition: control.c:51
bool instruction_in_list_p(instruction, list)
utils.c
Definition: utils.c:50
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203
#define is_instruction_block
soft block->sequence transition
#define make_empty_statement
An alias for make_empty_block_statement.
#define control_undefined
Definition: ri.h:916
#define control_predecessors(x)
Definition: ri.h:943
#define INSTRUCTION(x)
INSTRUCTION.
Definition: ri.h:1448
#define CONTROL(x)
CONTROL.
Definition: ri.h:910
#define instruction_tag(x)
Definition: ri.h:1511
#define control_successors(x)
Definition: ri.h:945
#define statement_instruction(x)
Definition: ri.h:2458
#define control_statement(x)
Definition: ri.h:941
The structure used to build lists in NewGen.
Definition: newgen_list.h:41