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