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