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