001
002 /*
003 * THIS FILE IS MACHINE_GENERATED. DO NOT EDIT.
004 * See InstructionFormats.template, InstructionFormatList.dat,
005 * OperatorList.dat, etc.
006 */
007
008 package org.jikesrvm.compilers.opt.ir;
009
010 import org.jikesrvm.Configuration;
011 import org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand; //NOPMD
012 import org.jikesrvm.compilers.opt.ir.operand.*;
013
014 /**
015 * The LowTableSwitch InstructionFormat class.
016 *
017 * The header comment for {@link Instruction} contains
018 * an explanation of the role of InstructionFormats in the
019 * opt compiler's IR.
020 */
021 @SuppressWarnings("unused") // Machine generated code is never 100% clean
022 public final class LowTableSwitch extends InstructionFormat {
023 /**
024 * InstructionFormat identification method for LowTableSwitch.
025 * @param i an instruction
026 * @return <code>true</code> if the InstructionFormat of the argument
027 * instruction is LowTableSwitch or <code>false</code>
028 * if it is not.
029 */
030 public static boolean conforms(Instruction i) {
031 return conforms(i.operator);
032 }
033 /**
034 * InstructionFormat identification method for LowTableSwitch.
035 * @param o an instruction
036 * @return <code>true</code> if the InstructionFormat of the argument
037 * operator is LowTableSwitch or <code>false</code>
038 * if it is not.
039 */
040 public static boolean conforms(Operator o) {
041 return o.format == LowTableSwitch_format;
042 }
043
044 /**
045 * Get the operand called Index from the
046 * argument instruction. Note that the returned operand
047 * will still point to its containing instruction.
048 * @param i the instruction to fetch the operand from
049 * @return the operand called Index
050 */
051 public static RegisterOperand getIndex(Instruction i) {
052 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
053 return (RegisterOperand) i.getOperand(0);
054 }
055 /**
056 * Get the operand called Index from the argument
057 * instruction clearing its instruction pointer. The returned
058 * operand will not point to any containing instruction.
059 * @param i the instruction to fetch the operand from
060 * @return the operand called Index
061 */
062 public static RegisterOperand getClearIndex(Instruction i) {
063 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
064 return (RegisterOperand) i.getClearOperand(0);
065 }
066 /**
067 * Set the operand called Index in the argument
068 * instruction to the argument operand. The operand will
069 * now point to the argument instruction as its containing
070 * instruction.
071 * @param i the instruction in which to store the operand
072 * @param Index the operand to store
073 */
074 public static void setIndex(Instruction i, RegisterOperand Index) {
075 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
076 i.putOperand(0, Index);
077 }
078 /**
079 * Return the index of the operand called Index
080 * in the argument instruction.
081 * @param i the instruction to access.
082 * @return the index of the operand called Index
083 * in the argument instruction
084 */
085 public static int indexOfIndex(Instruction i) {
086 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
087 return 0;
088 }
089 /**
090 * Does the argument instruction have a non-null
091 * operand named Index?
092 * @param i the instruction to access.
093 * @return <code>true</code> if the instruction has an non-null
094 * operand named Index or <code>false</code>
095 * if it does not.
096 */
097 public static boolean hasIndex(Instruction i) {
098 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
099 return i.getOperand(0) != null;
100 }
101
102 /**
103 * Get the k'th operand called Target from the
104 * argument instruction. Note that the returned operand
105 * will still point to its containing instruction.
106 * @param i the instruction to fetch the operand from
107 * @param k the index of the operand
108 * @return the k'th operand called Target
109 */
110 public static BranchOperand getTarget(Instruction i, int k) {
111 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
112 return (BranchOperand) i.getOperand(1+k*2+0);
113 }
114 /**
115 * Get the k'th operand called Target from the argument
116 * instruction clearing its instruction pointer. The returned
117 * operand will not point to any containing instruction.
118 * @param i the instruction to fetch the operand from
119 * @param k the index of the operand
120 * @return the k'th operand called Target
121 */
122 public static BranchOperand getClearTarget(Instruction i, int k) {
123 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
124 return (BranchOperand) i.getClearOperand(1+k*2+0);
125 }
126 /**
127 * Set the k'th operand called Target in the argument
128 * instruction to the argument operand. The operand will
129 * now point to the argument instruction as its containing
130 * instruction.
131 * @param i the instruction in which to store the operand
132 * @param k the index of the operand
133 * @param o the operand to store
134 */
135 public static void setTarget(Instruction i, int k, BranchOperand o) {
136 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
137 i.putOperand(1+k*2+0, o);
138 }
139 /**
140 * Return the index of the k'th operand called Target
141 * in the argument instruction.
142 * @param i the instruction to access.
143 * @param k the index of the operand.
144 * @return the index of the k'th operand called Target
145 * in the argument instruction
146 */
147 public static int indexOfTarget(Instruction i, int k) {
148 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
149 return 1+k*2+0;
150 }
151 /**
152 * Does the argument instruction have a non-null
153 * k'th operand named Target?
154 * @param i the instruction to access.
155 * @param k the index of the operand.
156 * @return <code>true</code> if the instruction has an non-null
157 * k'th operand named Target or <code>false</code>
158 * if it does not.
159 */
160 public static boolean hasTarget(Instruction i, int k) {
161 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
162 return i.getOperand(1+k*2+0) != null;
163 }
164
165 /**
166 * Return the index of the first operand called Target
167 * in the argument instruction.
168 * @param i the instruction to access.
169 * @return the index of the first operand called Target
170 * in the argument instruction
171 */
172 public static int indexOfTargets(Instruction i)
173 {
174 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
175 return 1;
176 }
177 /**
178 * Does the argument instruction have any operands
179 * named Target?
180 * @param i the instruction to access.
181 * @return <code>true</code> if the instruction has operands
182 * named Target or <code>false</code> if it does not.
183 */
184 public static boolean hasTargets(Instruction i)
185 {
186 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
187 return i.getNumberOfOperands()-1 > 0 && i.getOperand(1) != null;
188 }
189
190 /**
191 * How many variable-length operands called Targets
192 * does the argument instruction have?
193 * @param i the instruction to access
194 * @return the number of operands called Targets the instruction has
195 */
196 public static int getNumberOfTargets(Instruction i)
197 {
198 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
199 return (i.getNumberOfOperands()-1)/2;
200 }
201
202 /**
203 * Change the number of Targets that may be stored in
204 * the argument instruction to numVarOps.
205 * @param i the instruction to access
206 * @param numVarOps the new number of variable operands called Targets
207 * that may be stored in the instruction
208 */
209 public static void resizeNumberOfTargets(Instruction i, int numVarOps)
210 {
211 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
212 if (1+numVarOps*2>MIN_OPERAND_ARRAY_LENGTH)
213 i.resizeNumberOfOperands(1+numVarOps*2);
214 else
215 for (int j = 1+numVarOps*2; j < MIN_OPERAND_ARRAY_LENGTH; j++)
216 i.putOperand(j, null);
217 }
218 /**
219 * Get the k'th operand called BranchProfile from the
220 * argument instruction. Note that the returned operand
221 * will still point to its containing instruction.
222 * @param i the instruction to fetch the operand from
223 * @param k the index of the operand
224 * @return the k'th operand called BranchProfile
225 */
226 public static BranchProfileOperand getBranchProfile(Instruction i, int k) {
227 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
228 return (BranchProfileOperand) i.getOperand(1+k*2+1);
229 }
230 /**
231 * Get the k'th operand called BranchProfile from the argument
232 * instruction clearing its instruction pointer. The returned
233 * operand will not point to any containing instruction.
234 * @param i the instruction to fetch the operand from
235 * @param k the index of the operand
236 * @return the k'th operand called BranchProfile
237 */
238 public static BranchProfileOperand getClearBranchProfile(Instruction i, int k) {
239 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
240 return (BranchProfileOperand) i.getClearOperand(1+k*2+1);
241 }
242 /**
243 * Set the k'th operand called BranchProfile in the argument
244 * instruction to the argument operand. The operand will
245 * now point to the argument instruction as its containing
246 * instruction.
247 * @param i the instruction in which to store the operand
248 * @param k the index of the operand
249 * @param o the operand to store
250 */
251 public static void setBranchProfile(Instruction i, int k, BranchProfileOperand o) {
252 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
253 i.putOperand(1+k*2+1, o);
254 }
255 /**
256 * Return the index of the k'th operand called BranchProfile
257 * in the argument instruction.
258 * @param i the instruction to access.
259 * @param k the index of the operand.
260 * @return the index of the k'th operand called BranchProfile
261 * in the argument instruction
262 */
263 public static int indexOfBranchProfile(Instruction i, int k) {
264 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
265 return 1+k*2+1;
266 }
267 /**
268 * Does the argument instruction have a non-null
269 * k'th operand named BranchProfile?
270 * @param i the instruction to access.
271 * @param k the index of the operand.
272 * @return <code>true</code> if the instruction has an non-null
273 * k'th operand named BranchProfile or <code>false</code>
274 * if it does not.
275 */
276 public static boolean hasBranchProfile(Instruction i, int k) {
277 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
278 return i.getOperand(1+k*2+1) != null;
279 }
280
281 /**
282 * Return the index of the first operand called BranchProfile
283 * in the argument instruction.
284 * @param i the instruction to access.
285 * @return the index of the first operand called BranchProfile
286 * in the argument instruction
287 */
288 public static int indexOfBranchProfiles(Instruction i)
289 {
290 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
291 return 2;
292 }
293 /**
294 * Does the argument instruction have any operands
295 * named BranchProfile?
296 * @param i the instruction to access.
297 * @return <code>true</code> if the instruction has operands
298 * named BranchProfile or <code>false</code> if it does not.
299 */
300 public static boolean hasBranchProfiles(Instruction i)
301 {
302 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
303 return i.getNumberOfOperands()-2 > 0 && i.getOperand(2) != null;
304 }
305
306 /**
307 * How many variable-length operands called BranchProfiles
308 * does the argument instruction have?
309 * @param i the instruction to access
310 * @return the number of operands called BranchProfiles the instruction has
311 */
312 public static int getNumberOfBranchProfiles(Instruction i)
313 {
314 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
315 return (i.getNumberOfOperands()-1)/2;
316 }
317
318 /**
319 * Change the number of BranchProfiles that may be stored in
320 * the argument instruction to numVarOps.
321 * @param i the instruction to access
322 * @param numVarOps the new number of variable operands called BranchProfiles
323 * that may be stored in the instruction
324 */
325 public static void resizeNumberOfBranchProfiles(Instruction i, int numVarOps)
326 {
327 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LowTableSwitch");
328 if (1+numVarOps*2>MIN_OPERAND_ARRAY_LENGTH)
329 i.resizeNumberOfOperands(1+numVarOps*2);
330 else
331 for (int j = 1+numVarOps*2; j < MIN_OPERAND_ARRAY_LENGTH; j++)
332 i.putOperand(j, null);
333 }
334
335 /**
336 * Create an instruction of the LowTableSwitch instruction format.
337 * @param o the instruction's operator
338 * @param Index the instruction's Index operand
339 * @param numVarOps the number of variable length operands that
340 * will be stored in the insruction.
341 * @return the newly created LowTableSwitch instruction
342 */
343 public static Instruction create(Operator o
344 , RegisterOperand Index
345 , int numVarOps
346 )
347 {
348 if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "LowTableSwitch");
349 Instruction i = new Instruction(o, Math.max(1+numVarOps*2, MIN_OPERAND_ARRAY_LENGTH));
350 i.putOperand(0, Index);
351 return i;
352 }
353
354 /**
355 * Mutate the argument instruction into an instruction of the
356 * LowTableSwitch instruction format having the specified
357 * operator and operands.
358 * @param i the instruction to mutate
359 * @param o the instruction's operator
360 * @param Index the instruction's Index operand
361 * @param numVarOps the number of variable length operands that
362 * will be stored in the insruction.
363 * @return the mutated instruction
364 */
365 public static Instruction mutate(Instruction i, Operator o
366 , RegisterOperand Index
367 , int numVarOps
368 )
369 {
370 if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "LowTableSwitch");
371 if (1+numVarOps*2>MIN_OPERAND_ARRAY_LENGTH)
372 i.resizeNumberOfOperands(1+numVarOps*2);
373
374 i.operator = o;
375 i.putOperand(0, Index);
376 return i;
377 }
378 }
379