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