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 Multianewarray 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 Multianewarray extends InstructionFormat {
022  /**
023   * InstructionFormat identification method for Multianewarray.
024   * @param i an instruction
025   * @return <code>true</code> if the InstructionFormat of the argument
026   *         instruction is Multianewarray 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 Multianewarray.
034   * @param o an instruction
035   * @return <code>true</code> if the InstructionFormat of the argument
036   *         operator is Multianewarray or <code>false</code>
037   *         if it is not.
038   */
039  public static boolean conforms(Operator o) {
040    return o.format == Multianewarray_format;
041  }
042
043  /**
044   * Get the operand called Result 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 Result
049   */
050  public static RegisterOperand getResult(Instruction i) {
051    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
052    return (RegisterOperand) i.getOperand(0);
053  }
054  /**
055   * Get the operand called Result 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 Result
060   */
061  public static RegisterOperand getClearResult(Instruction i) {
062    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
063    return (RegisterOperand) i.getClearOperand(0);
064  }
065  /**
066   * Set the operand called Result 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 Result the operand to store
072   */
073  public static void setResult(Instruction i, RegisterOperand Result) {
074    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
075    i.putOperand(0, Result);
076  }
077  /**
078   * Return the index of the operand called Result
079   * in the argument instruction.
080   * @param i the instruction to access.
081   * @return the index of the operand called Result
082   *         in the argument instruction
083   */
084  public static int indexOfResult(Instruction i) {
085    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
086    return 0;
087  }
088  /**
089   * Does the argument instruction have a non-null
090   * operand named Result?
091   * @param i the instruction to access.
092   * @return <code>true</code> if the instruction has an non-null
093   *         operand named Result or <code>false</code>
094   *         if it does not.
095   */
096  public static boolean hasResult(Instruction i) {
097    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
098    return i.getOperand(0) != null;
099  }
100
101  /**
102   * Get the operand called Type 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 Type
107   */
108  public static TypeOperand getType(Instruction i) {
109    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
110    return (TypeOperand) i.getOperand(1);
111  }
112  /**
113   * Get the operand called Type 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 Type
118   */
119  public static TypeOperand getClearType(Instruction i) {
120    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
121    return (TypeOperand) i.getClearOperand(1);
122  }
123  /**
124   * Set the operand called Type 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 Type the operand to store
130   */
131  public static void setType(Instruction i, TypeOperand Type) {
132    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
133    i.putOperand(1, Type);
134  }
135  /**
136   * Return the index of the operand called Type
137   * in the argument instruction.
138   * @param i the instruction to access.
139   * @return the index of the operand called Type
140   *         in the argument instruction
141   */
142  public static int indexOfType(Instruction i) {
143    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
144    return 1;
145  }
146  /**
147   * Does the argument instruction have a non-null
148   * operand named Type?
149   * @param i the instruction to access.
150   * @return <code>true</code> if the instruction has an non-null
151   *         operand named Type or <code>false</code>
152   *         if it does not.
153   */
154  public static boolean hasType(Instruction i) {
155    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
156    return i.getOperand(1) != null;
157  }
158
159  /**
160   * Get the k'th operand called Dimension 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   * @param k the index of the operand
165   * @return the k'th operand called Dimension
166   */
167  public static Operand getDimension(Instruction i, int k) {
168    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
169    return (Operand) i.getOperand(2+k);
170  }
171  /**
172   * Get the k'th operand called Dimension 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   * @param k the index of the operand
177   * @return the k'th operand called Dimension
178   */
179  public static Operand getClearDimension(Instruction i, int k) {
180    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
181    return (Operand) i.getClearOperand(2+k);
182  }
183  /**
184   * Set the k'th operand called Dimension in the argument
185   * instruction to the argument operand. The operand will
186   * now point to the argument instruction as its containing
187   * instruction.
188   * @param i the instruction in which to store the operand
189   * @param k the index of the operand
190   * @param o the operand to store
191   */
192  public static void setDimension(Instruction i, int k, Operand o) {
193    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
194    i.putOperand(2+k, o);
195  }
196  /**
197   * Return the index of the k'th operand called Dimension
198   * in the argument instruction.
199   * @param i the instruction to access.
200   * @param k the index of the operand.
201   * @return the index of the k'th operand called Dimension
202   *         in the argument instruction
203   */
204  public static int indexOfDimension(Instruction i, int k) {
205    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
206    return 2+k;
207  }
208  /**
209   * Does the argument instruction have a non-null
210   * k'th operand named Dimension?
211   * @param i the instruction to access.
212   * @param k the index of the operand.
213   * @return <code>true</code> if the instruction has an non-null
214   *         k'th operand named Dimension or <code>false</code>
215   *         if it does not.
216   */
217  public static boolean hasDimension(Instruction i, int k) {
218    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
219    return i.getOperand(2+k) != null;
220  }
221
222  /**
223   * Return the index of the first operand called Dimension
224   * in the argument instruction.
225   * @param i the instruction to access.
226   * @return the index of the first operand called Dimension
227   *         in the argument instruction
228   */
229  public static int indexOfDimensions(Instruction i)
230  {
231    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
232    return 2;
233  }
234  /**
235   * Does the argument instruction have any operands
236   * named Dimension?
237   * @param i the instruction to access.
238   * @return <code>true</code> if the instruction has operands
239   *         named Dimension or <code>false</code> if it does not.
240   */
241  public static boolean hasDimensions(Instruction i)
242  {
243    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
244    return i.getNumberOfOperands()-2 > 0 && i.getOperand(2) != null;
245  }
246
247  /**
248   * How many variable-length operands called Dimensions
249   * does the argument instruction have?
250   * @param i the instruction to access
251   * @return the number of operands called Dimensions the instruction has
252   */
253  public static int getNumberOfDimensions(Instruction i)
254  {
255    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
256    return i.getNumberOfOperands()-2;
257  }
258
259  /**
260   * Change the number of Dimensions that may be stored in
261   * the argument instruction to numVarOps.
262   * @param i the instruction to access
263   * @param numVarOps the new number of variable operands called Dimensions
264   *        that may be stored in the instruction
265   */
266  public static void resizeNumberOfDimensions(Instruction i, int numVarOps)
267  {
268    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
269  if (2+numVarOps>MIN_OPERAND_ARRAY_LENGTH)
270    i.resizeNumberOfOperands(2+numVarOps);
271  else
272    for (int j = 2+numVarOps; j < MIN_OPERAND_ARRAY_LENGTH; j++)
273      i.putOperand(j, null);
274  }
275
276  /**
277   * Create an instruction of the Multianewarray instruction format.
278   * @param o the instruction's operator
279   * @param Result the instruction's Result operand
280   * @param Type the instruction's Type operand
281   * @param numVarOps the number of variable length operands that
282   *                 will be stored in the insruction.
283   * @return the newly created Multianewarray instruction
284   */
285  public static Instruction create(Operator o
286                   , RegisterOperand Result
287                   , TypeOperand Type
288                   , int numVarOps
289                )
290  {
291    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "Multianewarray");
292    Instruction i = Instruction.create(o, Math.max(2+numVarOps, MIN_OPERAND_ARRAY_LENGTH));
293    i.putOperand(0, Result);
294    i.putOperand(1, Type);
295    return i;
296  }
297
298  /**
299   * Mutate the argument instruction into an instruction of the
300   * Multianewarray instruction format having the specified
301   * operator and operands.
302   * @param i the instruction to mutate
303   * @param o the instruction's operator
304   * @param Result the instruction's Result operand
305   * @param Type the instruction's Type operand
306   * @param numVarOps the number of variable length operands that
307   *                  will be stored in the instruction.
308   * @return the mutated instruction
309   */
310  public static Instruction mutate(Instruction i, Operator o
311                   , RegisterOperand Result
312                   , TypeOperand Type
313                   , int numVarOps
314                )
315  {
316    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "Multianewarray");
317    if (2+numVarOps>MIN_OPERAND_ARRAY_LENGTH)
318      i.resizeNumberOfOperands(2+numVarOps);
319
320    i.changeOperatorTo(o);
321    i.putOperand(0, Result);
322    i.putOperand(1, Type);
323    return i;
324  }
325}
326