KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > shimple > PhiExpr


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2003 Navindra Umanee <navindra@cs.mcgill.ca>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 package soot.shimple;
21
22 import soot.*;
23 import soot.util.*;
24 import java.util.*;
25 import soot.jimple.*;
26 import soot.toolkits.scalar.*;
27 import soot.toolkits.graph.*;
28
29 /**
30  * A fully defined PhiExpr usually consists of a list of Values for
31  * the arguments alongst with the corresponding control flow
32  * predecessor for each argument. This may be provided either as a
33  * Soot CFG Block or more directly as the Unit at the end of the
34  * corresponding CFG block.
35  *
36  * <p> As much as possible we try to conform to the semantics as
37  * described by Cytron et al., TOPLAS Oct. 91. A Phi node such as
38  * "x_1 = Phi(x_2, x_3)" is eliminated by respectively adding the
39  * statements "x_1 = x_2" and "x_1 = x_3" at the end of the
40  * corresponding control flow predecessor.
41  *
42  * <p> However, due to the fact that each argument is explicitly
43  * associated with the control flow predecessor, there may be some
44  * subtle differences. We tried to make the behaviour as robust and
45  * transparent as possible by handling the common cases of Unit chain
46  * manipulations in the Shimple internal implementation of
47  * PatchingChain.
48  *
49  * @author Navindra Umanee
50  * @see
51  <a
52  * HREF="http://citeseer.nj.nec.com/cytron91efficiently.html">Efficiently
53  * Computing Static Single Assignment Form and the Control Dependence
54  * Graph</a>
55  * @see Shimple#newPhiExpr(List, List)
56  * @see Shimple#newPhiExpr(Local, List)
57  **/

58 public interface PhiExpr extends ShimpleExpr
59 {
60     /**
61      * Returns an unmodifiable, backed view of the arguments to this PhiExpr.
62      * Each argument is a ValueUnitPair.
63      *
64      * @see soot.toolkits.scalar.ValueUnitPair
65      **/

66     public List getArgs();
67
68     /**
69      * Returns a list of the values used by this PhiExpr.
70      **/

71     public List getValues();
72
73     /**
74      * Returns a list of the control flow predecessor Units being
75      * tracked by this PhiExpr
76      **/

77     public List getPreds();
78
79     /**
80      * Returns the number of arguments in this PhiExpr.
81      **/

82     public int getArgCount();
83
84     /**
85      * Returns the argument pair for the given index. Null if
86      * out-of-bounds.
87      **/

88     public ValueUnitPair getArgBox(int index);
89
90     /**
91      * Returns the value for the given index into the PhiExpr. Null
92      * if out-of-bounds.
93      **/

94     public Value getValue(int index);
95
96     /**
97      * Returns the control flow predecessor Unit for the given index
98      * into the PhiExpr. Null if out-of-bounds.
99      **/

100     public Unit getPred(int index);
101
102     /**
103      * Returns the index of the argument associated with the given
104      * control flow predecessor Unit. Returns -1 if not found.
105      **/

106     public int getArgIndex(Unit predTailUnit);
107
108     /**
109      * Returns the argument pair corresponding to the given CFG
110      * predecessor. Returns null if not found.
111      **/

112     public ValueUnitPair getArgBox(Unit predTailUnit);
113     
114     /**
115      * Get the PhiExpr argument corresponding to the given control
116      * flow predecessor, returns null if not available.
117      **/

118     public Value getValue(Unit predTailUnit);
119     
120     /**
121      * Returns the index of the argument associated with the given
122      * control flow predecessor. Returns -1 if not found.
123      **/

124     public int getArgIndex(Block pred);
125
126     /**
127      * Returns the argument pair corresponding to the given CFG
128      * predecessor. Returns null if not found.
129      **/

130     public ValueUnitPair getArgBox(Block pred);
131     
132     /**
133      * Get the PhiExpr argument corresponding to the given control flow
134      * predecessor, returns null if not available.
135      **/

136     public Value getValue(Block pred);
137
138     /**
139      * Modify the PhiExpr argument at the given index with the given
140      * information. Returns false on failure.
141      **/

142     public boolean setArg(int index, Value arg, Unit predTailUnit);
143
144     /**
145      * Modify the PhiExpr argument at the given index with the given
146      * information. Returns false on failure.
147      **/

148     public boolean setArg(int index, Value arg, Block pred);
149
150     /**
151      * Set the value at the given index into the PhiExpr. Returns
152      * false on failure.
153      **/

154     public boolean setValue(int index, Value arg);
155
156     /**
157      * Locate the argument assocatiated with the given CFG predecessor unit
158      * and set the value. Returns false on failure.
159      **/

160     public boolean setValue(Unit predTailUnit, Value arg);
161
162     /**
163      * Locate the argument assocatiated with the given CFG predecessor
164      * and set the value. Returns false on failure.
165      **/

166     public boolean setValue(Block pred, Value arg);
167     
168     /**
169      * Update the CFG predecessor associated with the PhiExpr
170      * argument at the given index. Returns false on failure.
171      **/

172     public boolean setPred(int index, Unit predTailUnit);
173
174     /**
175      * Update the CFG predecessor associated with the PhiExpr
176      * argument at the given index. Returns false on failure.
177      **/

178     public boolean setPred(int index, Block pred);
179
180     /**
181      * Remove the argument at the given index. Returns false on
182      * failure.
183      **/

184     public boolean removeArg(int index);
185
186     /**
187      * Remove the argument corresponding to the given CFG predecessor.
188      * Returns false on failure.
189      **/

190     public boolean removeArg(Unit predTailUnit);
191
192     /**
193      * Remove the argument corresponding to the given CFG predecessor.
194      * Returns false on failure.
195      **/

196     public boolean removeArg(Block pred);
197
198     /**
199      * Remove the given argument. Returns false on failure.
200      **/

201     public boolean removeArg(ValueUnitPair arg);
202
203     /**
204      * Add the given argument associated with the given CFG
205      * predecessor. Returns false on failure.
206      **/

207     public boolean addArg(Value arg, Block pred);
208
209     /**
210      * Add the given argument associated with the given CFG
211      * predecessor. Returns false on failure.
212      **/

213     public boolean addArg(Value arg, Unit predTailUnit);
214         
215     /**
216      * Set the block number of the Phi node.
217      **/

218     public void setBlockId(int blockId);
219      
220     /**
221      * Returns the id number of the block from which the Phi node
222      * originated from.
223      **/

224     public int getBlockId();
225
226     /**
227      * The type of the PhiExpr is usually the same as the type of its
228      * arguments.
229      **/

230     public Type getType();
231
232     public void apply(Switch sw);
233 }
234
Popular Tags