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 LookupSwitch 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 LookupSwitch extends InstructionFormat {
023 /**
024 * InstructionFormat identification method for LookupSwitch.
025 * @param i an instruction
026 * @return <code>true</code> if the InstructionFormat of the argument
027 * instruction is LookupSwitch 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 LookupSwitch.
035 * @param o an instruction
036 * @return <code>true</code> if the InstructionFormat of the argument
037 * operator is LookupSwitch or <code>false</code>
038 * if it is not.
039 */
040 public static boolean conforms(Operator o) {
041 return o.format == LookupSwitch_format;
042 }
043
044 /**
045 * Get the operand called Value 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 Value
050 */
051 public static Operand getValue(Instruction i) {
052 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
053 return (Operand) i.getOperand(0);
054 }
055 /**
056 * Get the operand called Value 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 Value
061 */
062 public static Operand getClearValue(Instruction i) {
063 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
064 return (Operand) i.getClearOperand(0);
065 }
066 /**
067 * Set the operand called Value 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 Value the operand to store
073 */
074 public static void setValue(Instruction i, Operand Value) {
075 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
076 i.putOperand(0, Value);
077 }
078 /**
079 * Return the index of the operand called Value
080 * in the argument instruction.
081 * @param i the instruction to access.
082 * @return the index of the operand called Value
083 * in the argument instruction
084 */
085 public static int indexOfValue(Instruction i) {
086 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
087 return 0;
088 }
089 /**
090 * Does the argument instruction have a non-null
091 * operand named Value?
092 * @param i the instruction to access.
093 * @return <code>true</code> if the instruction has an non-null
094 * operand named Value or <code>false</code>
095 * if it does not.
096 */
097 public static boolean hasValue(Instruction i) {
098 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
099 return i.getOperand(0) != null;
100 }
101
102 /**
103 * Get the operand called Unknown1 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 * @return the operand called Unknown1
108 */
109 public static Operand getUnknown1(Instruction i) {
110 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
111 return (Operand) i.getOperand(1);
112 }
113 /**
114 * Get the operand called Unknown1 from the argument
115 * instruction clearing its instruction pointer. The returned
116 * operand will not point to any containing instruction.
117 * @param i the instruction to fetch the operand from
118 * @return the operand called Unknown1
119 */
120 public static Operand getClearUnknown1(Instruction i) {
121 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
122 return (Operand) i.getClearOperand(1);
123 }
124 /**
125 * Set the operand called Unknown1 in the argument
126 * instruction to the argument operand. The operand will
127 * now point to the argument instruction as its containing
128 * instruction.
129 * @param i the instruction in which to store the operand
130 * @param Unknown1 the operand to store
131 */
132 public static void setUnknown1(Instruction i, Operand Unknown1) {
133 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
134 i.putOperand(1, Unknown1);
135 }
136 /**
137 * Return the index of the operand called Unknown1
138 * in the argument instruction.
139 * @param i the instruction to access.
140 * @return the index of the operand called Unknown1
141 * in the argument instruction
142 */
143 public static int indexOfUnknown1(Instruction i) {
144 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
145 return 1;
146 }
147 /**
148 * Does the argument instruction have a non-null
149 * operand named Unknown1?
150 * @param i the instruction to access.
151 * @return <code>true</code> if the instruction has an non-null
152 * operand named Unknown1 or <code>false</code>
153 * if it does not.
154 */
155 public static boolean hasUnknown1(Instruction i) {
156 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
157 return i.getOperand(1) != null;
158 }
159
160 /**
161 * Get the operand called Unknown2 from the
162 * argument instruction. Note that the returned operand
163 * will still point to its containing instruction.
164 * @param i the instruction to fetch the operand from
165 * @return the operand called Unknown2
166 */
167 public static Operand getUnknown2(Instruction i) {
168 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
169 return (Operand) i.getOperand(2);
170 }
171 /**
172 * Get the operand called Unknown2 from the argument
173 * instruction clearing its instruction pointer. The returned
174 * operand will not point to any containing instruction.
175 * @param i the instruction to fetch the operand from
176 * @return the operand called Unknown2
177 */
178 public static Operand getClearUnknown2(Instruction i) {
179 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
180 return (Operand) i.getClearOperand(2);
181 }
182 /**
183 * Set the operand called Unknown2 in the argument
184 * instruction to the argument operand. The operand will
185 * now point to the argument instruction as its containing
186 * instruction.
187 * @param i the instruction in which to store the operand
188 * @param Unknown2 the operand to store
189 */
190 public static void setUnknown2(Instruction i, Operand Unknown2) {
191 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
192 i.putOperand(2, Unknown2);
193 }
194 /**
195 * Return the index of the operand called Unknown2
196 * in the argument instruction.
197 * @param i the instruction to access.
198 * @return the index of the operand called Unknown2
199 * in the argument instruction
200 */
201 public static int indexOfUnknown2(Instruction i) {
202 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
203 return 2;
204 }
205 /**
206 * Does the argument instruction have a non-null
207 * operand named Unknown2?
208 * @param i the instruction to access.
209 * @return <code>true</code> if the instruction has an non-null
210 * operand named Unknown2 or <code>false</code>
211 * if it does not.
212 */
213 public static boolean hasUnknown2(Instruction i) {
214 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
215 return i.getOperand(2) != null;
216 }
217
218 /**
219 * Get the operand called Default 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 * @return the operand called Default
224 */
225 public static BranchOperand getDefault(Instruction i) {
226 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
227 return (BranchOperand) i.getOperand(3);
228 }
229 /**
230 * Get the operand called Default from the argument
231 * instruction clearing its instruction pointer. The returned
232 * operand will not point to any containing instruction.
233 * @param i the instruction to fetch the operand from
234 * @return the operand called Default
235 */
236 public static BranchOperand getClearDefault(Instruction i) {
237 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
238 return (BranchOperand) i.getClearOperand(3);
239 }
240 /**
241 * Set the operand called Default in the argument
242 * instruction to the argument operand. The operand will
243 * now point to the argument instruction as its containing
244 * instruction.
245 * @param i the instruction in which to store the operand
246 * @param Default the operand to store
247 */
248 public static void setDefault(Instruction i, BranchOperand Default) {
249 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
250 i.putOperand(3, Default);
251 }
252 /**
253 * Return the index of the operand called Default
254 * in the argument instruction.
255 * @param i the instruction to access.
256 * @return the index of the operand called Default
257 * in the argument instruction
258 */
259 public static int indexOfDefault(Instruction i) {
260 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
261 return 3;
262 }
263 /**
264 * Does the argument instruction have a non-null
265 * operand named Default?
266 * @param i the instruction to access.
267 * @return <code>true</code> if the instruction has an non-null
268 * operand named Default or <code>false</code>
269 * if it does not.
270 */
271 public static boolean hasDefault(Instruction i) {
272 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
273 return i.getOperand(3) != null;
274 }
275
276 /**
277 * Get the operand called DefaultBranchProfile from the
278 * argument instruction. Note that the returned operand
279 * will still point to its containing instruction.
280 * @param i the instruction to fetch the operand from
281 * @return the operand called DefaultBranchProfile
282 */
283 public static BranchProfileOperand getDefaultBranchProfile(Instruction i) {
284 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
285 return (BranchProfileOperand) i.getOperand(4);
286 }
287 /**
288 * Get the operand called DefaultBranchProfile from the argument
289 * instruction clearing its instruction pointer. The returned
290 * operand will not point to any containing instruction.
291 * @param i the instruction to fetch the operand from
292 * @return the operand called DefaultBranchProfile
293 */
294 public static BranchProfileOperand getClearDefaultBranchProfile(Instruction i) {
295 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
296 return (BranchProfileOperand) i.getClearOperand(4);
297 }
298 /**
299 * Set the operand called DefaultBranchProfile in the argument
300 * instruction to the argument operand. The operand will
301 * now point to the argument instruction as its containing
302 * instruction.
303 * @param i the instruction in which to store the operand
304 * @param DefaultBranchProfile the operand to store
305 */
306 public static void setDefaultBranchProfile(Instruction i, BranchProfileOperand DefaultBranchProfile) {
307 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
308 i.putOperand(4, DefaultBranchProfile);
309 }
310 /**
311 * Return the index of the operand called DefaultBranchProfile
312 * in the argument instruction.
313 * @param i the instruction to access.
314 * @return the index of the operand called DefaultBranchProfile
315 * in the argument instruction
316 */
317 public static int indexOfDefaultBranchProfile(Instruction i) {
318 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
319 return 4;
320 }
321 /**
322 * Does the argument instruction have a non-null
323 * operand named DefaultBranchProfile?
324 * @param i the instruction to access.
325 * @return <code>true</code> if the instruction has an non-null
326 * operand named DefaultBranchProfile or <code>false</code>
327 * if it does not.
328 */
329 public static boolean hasDefaultBranchProfile(Instruction i) {
330 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
331 return i.getOperand(4) != null;
332 }
333
334 /**
335 * Get the k'th operand called Match from the
336 * argument instruction. Note that the returned operand
337 * will still point to its containing instruction.
338 * @param i the instruction to fetch the operand from
339 * @param k the index of the operand
340 * @return the k'th operand called Match
341 */
342 public static IntConstantOperand getMatch(Instruction i, int k) {
343 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
344 return (IntConstantOperand) i.getOperand(5+k*3+0);
345 }
346 /**
347 * Get the k'th operand called Match from the argument
348 * instruction clearing its instruction pointer. The returned
349 * operand will not point to any containing instruction.
350 * @param i the instruction to fetch the operand from
351 * @param k the index of the operand
352 * @return the k'th operand called Match
353 */
354 public static IntConstantOperand getClearMatch(Instruction i, int k) {
355 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
356 return (IntConstantOperand) i.getClearOperand(5+k*3+0);
357 }
358 /**
359 * Set the k'th operand called Match in the argument
360 * instruction to the argument operand. The operand will
361 * now point to the argument instruction as its containing
362 * instruction.
363 * @param i the instruction in which to store the operand
364 * @param k the index of the operand
365 * @param o the operand to store
366 */
367 public static void setMatch(Instruction i, int k, IntConstantOperand o) {
368 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
369 i.putOperand(5+k*3+0, o);
370 }
371 /**
372 * Return the index of the k'th operand called Match
373 * in the argument instruction.
374 * @param i the instruction to access.
375 * @param k the index of the operand.
376 * @return the index of the k'th operand called Match
377 * in the argument instruction
378 */
379 public static int indexOfMatch(Instruction i, int k) {
380 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
381 return 5+k*3+0;
382 }
383 /**
384 * Does the argument instruction have a non-null
385 * k'th operand named Match?
386 * @param i the instruction to access.
387 * @param k the index of the operand.
388 * @return <code>true</code> if the instruction has an non-null
389 * k'th operand named Match or <code>false</code>
390 * if it does not.
391 */
392 public static boolean hasMatch(Instruction i, int k) {
393 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
394 return i.getOperand(5+k*3+0) != null;
395 }
396
397 /**
398 * Return the index of the first operand called Matches
399 * in the argument instruction.
400 * @param i the instruction to access.
401 * @return the index of the first operand called Matches
402 * in the argument instruction
403 */
404 public static int indexOfMatches(Instruction i)
405 {
406 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
407 return 5;
408 }
409 /**
410 * Does the argument instruction have any Matches
411 * operands?
412 * @param i the instruction to access.
413 * @return <code>true</code> if the instruction has
414 * Matches operands or <code>false</code>
415 * if it does not.
416 */
417 public static boolean hasMatches(Instruction i)
418 {
419 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
420 return i.getNumberOfOperands()-5 > 0 && i.getOperand(5) != null;
421 }
422
423 /**
424 * How many variable-length operands called Matches
425 * does the argument instruction have?
426 * @param i the instruction to access
427 * @return the number of Matches operands the instruction has
428 */
429 public static int getNumberOfMatches(Instruction i)
430 {
431 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
432 return (i.getNumberOfOperands()-5)/3;
433 }
434
435 /**
436 * Change the number of Matches operands that may be stored in
437 * the argument instruction to numVarOps.
438 * @param i the instruction to access
439 * @param numVarOps the new number of variable operands called Matches
440 * that may be stored in the instruction
441 */
442 public static void resizeNumberOfMatches(Instruction i, int numVarOps)
443 {
444 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
445 if (5+numVarOps*3>MIN_OPERAND_ARRAY_LENGTH)
446 i.resizeNumberOfOperands(5+numVarOps*3);
447 else
448 for (int j = 5+numVarOps*3; j < MIN_OPERAND_ARRAY_LENGTH; j++)
449 i.putOperand(j, null);
450 }
451 /**
452 * Get the k'th operand called Target from the
453 * argument instruction. Note that the returned operand
454 * will still point to its containing instruction.
455 * @param i the instruction to fetch the operand from
456 * @param k the index of the operand
457 * @return the k'th operand called Target
458 */
459 public static BranchOperand getTarget(Instruction i, int k) {
460 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
461 return (BranchOperand) i.getOperand(5+k*3+1);
462 }
463 /**
464 * Get the k'th operand called Target from the argument
465 * instruction clearing its instruction pointer. The returned
466 * operand will not point to any containing instruction.
467 * @param i the instruction to fetch the operand from
468 * @param k the index of the operand
469 * @return the k'th operand called Target
470 */
471 public static BranchOperand getClearTarget(Instruction i, int k) {
472 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
473 return (BranchOperand) i.getClearOperand(5+k*3+1);
474 }
475 /**
476 * Set the k'th operand called Target in the argument
477 * instruction to the argument operand. The operand will
478 * now point to the argument instruction as its containing
479 * instruction.
480 * @param i the instruction in which to store the operand
481 * @param k the index of the operand
482 * @param o the operand to store
483 */
484 public static void setTarget(Instruction i, int k, BranchOperand o) {
485 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
486 i.putOperand(5+k*3+1, o);
487 }
488 /**
489 * Return the index of the k'th operand called Target
490 * in the argument instruction.
491 * @param i the instruction to access.
492 * @param k the index of the operand.
493 * @return the index of the k'th operand called Target
494 * in the argument instruction
495 */
496 public static int indexOfTarget(Instruction i, int k) {
497 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
498 return 5+k*3+1;
499 }
500 /**
501 * Does the argument instruction have a non-null
502 * k'th operand named Target?
503 * @param i the instruction to access.
504 * @param k the index of the operand.
505 * @return <code>true</code> if the instruction has an non-null
506 * k'th operand named Target or <code>false</code>
507 * if it does not.
508 */
509 public static boolean hasTarget(Instruction i, int k) {
510 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
511 return i.getOperand(5+k*3+1) != null;
512 }
513
514 /**
515 * Return the index of the first operand called Target
516 * in the argument instruction.
517 * @param i the instruction to access.
518 * @return the index of the first operand called Target
519 * in the argument instruction
520 */
521 public static int indexOfTargets(Instruction i)
522 {
523 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
524 return 6;
525 }
526 /**
527 * Does the argument instruction have any operands
528 * named Target?
529 * @param i the instruction to access.
530 * @return <code>true</code> if the instruction has operands
531 * named Target or <code>false</code> if it does not.
532 */
533 public static boolean hasTargets(Instruction i)
534 {
535 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
536 return i.getNumberOfOperands()-6 > 0 && i.getOperand(6) != null;
537 }
538
539 /**
540 * How many variable-length operands called Targets
541 * does the argument instruction have?
542 * @param i the instruction to access
543 * @return the number of operands called Targets the instruction has
544 */
545 public static int getNumberOfTargets(Instruction i)
546 {
547 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
548 return (i.getNumberOfOperands()-5)/3;
549 }
550
551 /**
552 * Change the number of Targets that may be stored in
553 * the argument instruction to numVarOps.
554 * @param i the instruction to access
555 * @param numVarOps the new number of variable operands called Targets
556 * that may be stored in the instruction
557 */
558 public static void resizeNumberOfTargets(Instruction i, int numVarOps)
559 {
560 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
561 if (5+numVarOps*3>MIN_OPERAND_ARRAY_LENGTH)
562 i.resizeNumberOfOperands(5+numVarOps*3);
563 else
564 for (int j = 5+numVarOps*3; j < MIN_OPERAND_ARRAY_LENGTH; j++)
565 i.putOperand(j, null);
566 }
567 /**
568 * Get the k'th operand called BranchProfile from the
569 * argument instruction. Note that the returned operand
570 * will still point to its containing instruction.
571 * @param i the instruction to fetch the operand from
572 * @param k the index of the operand
573 * @return the k'th operand called BranchProfile
574 */
575 public static BranchProfileOperand getBranchProfile(Instruction i, int k) {
576 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
577 return (BranchProfileOperand) i.getOperand(5+k*3+2);
578 }
579 /**
580 * Get the k'th operand called BranchProfile from the argument
581 * instruction clearing its instruction pointer. The returned
582 * operand will not point to any containing instruction.
583 * @param i the instruction to fetch the operand from
584 * @param k the index of the operand
585 * @return the k'th operand called BranchProfile
586 */
587 public static BranchProfileOperand getClearBranchProfile(Instruction i, int k) {
588 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
589 return (BranchProfileOperand) i.getClearOperand(5+k*3+2);
590 }
591 /**
592 * Set the k'th operand called BranchProfile in the argument
593 * instruction to the argument operand. The operand will
594 * now point to the argument instruction as its containing
595 * instruction.
596 * @param i the instruction in which to store the operand
597 * @param k the index of the operand
598 * @param o the operand to store
599 */
600 public static void setBranchProfile(Instruction i, int k, BranchProfileOperand o) {
601 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
602 i.putOperand(5+k*3+2, o);
603 }
604 /**
605 * Return the index of the k'th operand called BranchProfile
606 * in the argument instruction.
607 * @param i the instruction to access.
608 * @param k the index of the operand.
609 * @return the index of the k'th operand called BranchProfile
610 * in the argument instruction
611 */
612 public static int indexOfBranchProfile(Instruction i, int k) {
613 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
614 return 5+k*3+2;
615 }
616 /**
617 * Does the argument instruction have a non-null
618 * k'th operand named BranchProfile?
619 * @param i the instruction to access.
620 * @param k the index of the operand.
621 * @return <code>true</code> if the instruction has an non-null
622 * k'th operand named BranchProfile or <code>false</code>
623 * if it does not.
624 */
625 public static boolean hasBranchProfile(Instruction i, int k) {
626 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
627 return i.getOperand(5+k*3+2) != null;
628 }
629
630 /**
631 * Return the index of the first operand called BranchProfile
632 * in the argument instruction.
633 * @param i the instruction to access.
634 * @return the index of the first operand called BranchProfile
635 * in the argument instruction
636 */
637 public static int indexOfBranchProfiles(Instruction i)
638 {
639 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
640 return 7;
641 }
642 /**
643 * Does the argument instruction have any operands
644 * named BranchProfile?
645 * @param i the instruction to access.
646 * @return <code>true</code> if the instruction has operands
647 * named BranchProfile or <code>false</code> if it does not.
648 */
649 public static boolean hasBranchProfiles(Instruction i)
650 {
651 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
652 return i.getNumberOfOperands()-7 > 0 && i.getOperand(7) != null;
653 }
654
655 /**
656 * How many variable-length operands called BranchProfiles
657 * does the argument instruction have?
658 * @param i the instruction to access
659 * @return the number of operands called BranchProfiles the instruction has
660 */
661 public static int getNumberOfBranchProfiles(Instruction i)
662 {
663 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
664 return (i.getNumberOfOperands()-5)/3;
665 }
666
667 /**
668 * Change the number of BranchProfiles that may be stored in
669 * the argument instruction to numVarOps.
670 * @param i the instruction to access
671 * @param numVarOps the new number of variable operands called BranchProfiles
672 * that may be stored in the instruction
673 */
674 public static void resizeNumberOfBranchProfiles(Instruction i, int numVarOps)
675 {
676 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "LookupSwitch");
677 if (5+numVarOps*3>MIN_OPERAND_ARRAY_LENGTH)
678 i.resizeNumberOfOperands(5+numVarOps*3);
679 else
680 for (int j = 5+numVarOps*3; j < MIN_OPERAND_ARRAY_LENGTH; j++)
681 i.putOperand(j, null);
682 }
683
684 /**
685 * Create an instruction of the LookupSwitch instruction format.
686 * @param o the instruction's operator
687 * @param Value the instruction's Value operand
688 * @param Unknown1 the instruction's Unknown1 operand
689 * @param Unknown2 the instruction's Unknown2 operand
690 * @param Default the instruction's Default operand
691 * @param DefaultBranchProfile the instruction's DefaultBranchProfile operand
692 * @param numVarOps the number of variable length operands that
693 * will be stored in the insruction.
694 * @return the newly created LookupSwitch instruction
695 */
696 public static Instruction create(Operator o
697 , Operand Value
698 , Operand Unknown1
699 , Operand Unknown2
700 , BranchOperand Default
701 , BranchProfileOperand DefaultBranchProfile
702 , int numVarOps
703 )
704 {
705 if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "LookupSwitch");
706 Instruction i = new Instruction(o, Math.max(5+numVarOps*3, MIN_OPERAND_ARRAY_LENGTH));
707 i.putOperand(0, Value);
708 i.putOperand(1, Unknown1);
709 i.putOperand(2, Unknown2);
710 i.putOperand(3, Default);
711 i.putOperand(4, DefaultBranchProfile);
712 return i;
713 }
714
715 /**
716 * Mutate the argument instruction into an instruction of the
717 * LookupSwitch instruction format having the specified
718 * operator and operands.
719 * @param i the instruction to mutate
720 * @param o the instruction's operator
721 * @param Value the instruction's Value operand
722 * @param Unknown1 the instruction's Unknown1 operand
723 * @param Unknown2 the instruction's Unknown2 operand
724 * @param Default the instruction's Default operand
725 * @param DefaultBranchProfile the instruction's DefaultBranchProfile operand
726 * @param numVarOps the number of variable length operands that
727 * will be stored in the insruction.
728 * @return the mutated instruction
729 */
730 public static Instruction mutate(Instruction i, Operator o
731 , Operand Value
732 , Operand Unknown1
733 , Operand Unknown2
734 , BranchOperand Default
735 , BranchProfileOperand DefaultBranchProfile
736 , int numVarOps
737 )
738 {
739 if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "LookupSwitch");
740 if (5+numVarOps*3>MIN_OPERAND_ARRAY_LENGTH)
741 i.resizeNumberOfOperands(5+numVarOps*3);
742
743 i.operator = o;
744 i.putOperand(0, Value);
745 i.putOperand(1, Unknown1);
746 i.putOperand(2, Unknown2);
747 i.putOperand(3, Default);
748 i.putOperand(4, DefaultBranchProfile);
749 return i;
750 }
751 }
752