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 MIR_LowTableSwitch 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 MIR_LowTableSwitch extends InstructionFormat {
023      /**
024       * InstructionFormat identification method for MIR_LowTableSwitch.
025       * @param i an instruction
026       * @return <code>true</code> if the InstructionFormat of the argument
027       *         instruction is MIR_LowTableSwitch 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 MIR_LowTableSwitch.
035       * @param o an instruction
036       * @return <code>true</code> if the InstructionFormat of the argument
037       *         operator is MIR_LowTableSwitch or <code>false</code>
038       *         if it is not.
039       */
040      public static boolean conforms(Operator o) {
041        return o.format == MIR_LowTableSwitch_format;
042      }
043    
044      /**
045       * Get the operand called Index 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 Index
050       */
051      public static RegisterOperand getIndex(Instruction i) {
052        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
053        return (RegisterOperand) i.getOperand(0);
054      }
055      /**
056       * Get the operand called Index 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 Index
061       */
062      public static RegisterOperand getClearIndex(Instruction i) {
063        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
064        return (RegisterOperand) i.getClearOperand(0);
065      }
066      /**
067       * Set the operand called Index 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 Index the operand to store
073       */
074      public static void setIndex(Instruction i, RegisterOperand Index) {
075        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
076        i.putOperand(0, Index);
077      }
078      /**
079       * Return the index of the operand called Index
080       * in the argument instruction.
081       * @param i the instruction to access.
082       * @return the index of the operand called Index
083       *         in the argument instruction
084       */
085      public static int indexOfIndex(Instruction i) {
086        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
087        return 0;
088      }
089      /**
090       * Does the argument instruction have a non-null
091       * operand named Index?
092       * @param i the instruction to access.
093       * @return <code>true</code> if the instruction has an non-null
094       *         operand named Index or <code>false</code>
095       *         if it does not.
096       */
097      public static boolean hasIndex(Instruction i) {
098        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
099        return i.getOperand(0) != null;
100      }
101    
102      /**
103       * Get the operand called MethodStart 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 MethodStart
108       */
109      public static RegisterOperand getMethodStart(Instruction i) {
110        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
111        return (RegisterOperand) i.getOperand(1);
112      }
113      /**
114       * Get the operand called MethodStart 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 MethodStart
119       */
120      public static RegisterOperand getClearMethodStart(Instruction i) {
121        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
122        return (RegisterOperand) i.getClearOperand(1);
123      }
124      /**
125       * Set the operand called MethodStart 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 MethodStart the operand to store
131       */
132      public static void setMethodStart(Instruction i, RegisterOperand MethodStart) {
133        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
134        i.putOperand(1, MethodStart);
135      }
136      /**
137       * Return the index of the operand called MethodStart
138       * in the argument instruction.
139       * @param i the instruction to access.
140       * @return the index of the operand called MethodStart
141       *         in the argument instruction
142       */
143      public static int indexOfMethodStart(Instruction i) {
144        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
145        return 1;
146      }
147      /**
148       * Does the argument instruction have a non-null
149       * operand named MethodStart?
150       * @param i the instruction to access.
151       * @return <code>true</code> if the instruction has an non-null
152       *         operand named MethodStart or <code>false</code>
153       *         if it does not.
154       */
155      public static boolean hasMethodStart(Instruction i) {
156        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
157        return i.getOperand(1) != null;
158      }
159    
160      /**
161       * Get the k'th operand called Target 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 Target
167       */
168      public static BranchOperand getTarget(Instruction i, int k) {
169        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
170        return (BranchOperand) i.getOperand(2+k*2+0);
171      }
172      /**
173       * Get the k'th operand called Target 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 Target
179       */
180      public static BranchOperand getClearTarget(Instruction i, int k) {
181        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
182        return (BranchOperand) i.getClearOperand(2+k*2+0);
183      }
184      /**
185       * Set the k'th operand called Target 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 setTarget(Instruction i, int k, BranchOperand o) {
194        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
195        i.putOperand(2+k*2+0, o);
196      }
197      /**
198       * Return the index of the k'th operand called Target
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 Target
203       *         in the argument instruction
204       */
205      public static int indexOfTarget(Instruction i, int k) {
206        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
207        return 2+k*2+0;
208      }
209      /**
210       * Does the argument instruction have a non-null
211       * k'th operand named Target?
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 Target or <code>false</code>
216       *         if it does not.
217       */
218      public static boolean hasTarget(Instruction i, int k) {
219        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
220        return i.getOperand(2+k*2+0) != null;
221      }
222    
223      /**
224       * Return the index of the first operand called Target
225       * in the argument instruction.
226       * @param i the instruction to access.
227       * @return the index of the first operand called Target
228       *         in the argument instruction
229       */
230      public static int indexOfTargets(Instruction i)
231      {
232        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
233        return 2;
234      }
235      /**
236       * Does the argument instruction have any operands
237       * named Target?
238       * @param i the instruction to access.
239       * @return <code>true</code> if the instruction has operands
240       *         named Target or <code>false</code> if it does not.
241       */
242      public static boolean hasTargets(Instruction i)
243      {
244        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
245        return i.getNumberOfOperands()-2 > 0 && i.getOperand(2) != null;
246      }
247    
248      /**
249       * How many variable-length operands called Targets
250       * does the argument instruction have?
251       * @param i the instruction to access
252       * @return the number of operands called Targets the instruction has
253       */
254      public static int getNumberOfTargets(Instruction i)
255      {
256        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
257        return (i.getNumberOfOperands()-2)/2;
258      }
259    
260      /**
261       * Change the number of Targets 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 Targets
265       *        that may be stored in the instruction
266       */
267      public static void resizeNumberOfTargets(Instruction i, int numVarOps)
268      {
269        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
270      if (2+numVarOps*2>MIN_OPERAND_ARRAY_LENGTH)
271        i.resizeNumberOfOperands(2+numVarOps*2);
272      else
273        for (int j = 2+numVarOps*2; j < MIN_OPERAND_ARRAY_LENGTH; j++)
274          i.putOperand(j, null);
275      }
276      /**
277       * Get the k'th operand called BranchProfile from the
278       * argument instruction. Note that the returned operand
279       * will still point to its containing instruction.
280       * @param i the instruction to fetch the operand from
281       * @param k the index of the operand
282       * @return the k'th operand called BranchProfile
283       */
284      public static BranchProfileOperand getBranchProfile(Instruction i, int k) {
285        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
286        return (BranchProfileOperand) i.getOperand(2+k*2+1);
287      }
288      /**
289       * Get the k'th operand called BranchProfile from the argument
290       * instruction clearing its instruction pointer. The returned
291       * operand will not point to any containing instruction.
292       * @param i the instruction to fetch the operand from
293       * @param k the index of the operand
294       * @return the k'th operand called BranchProfile
295       */
296      public static BranchProfileOperand getClearBranchProfile(Instruction i, int k) {
297        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
298        return (BranchProfileOperand) i.getClearOperand(2+k*2+1);
299      }
300      /**
301       * Set the k'th operand called BranchProfile in the argument
302       * instruction to the argument operand. The operand will
303       * now point to the argument instruction as its containing
304       * instruction.
305       * @param i the instruction in which to store the operand
306       * @param k the index of the operand
307       * @param o the operand to store
308       */
309      public static void setBranchProfile(Instruction i, int k, BranchProfileOperand o) {
310        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
311        i.putOperand(2+k*2+1, o);
312      }
313      /**
314       * Return the index of the k'th operand called BranchProfile
315       * in the argument instruction.
316       * @param i the instruction to access.
317       * @param k the index of the operand.
318       * @return the index of the k'th operand called BranchProfile
319       *         in the argument instruction
320       */
321      public static int indexOfBranchProfile(Instruction i, int k) {
322        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
323        return 2+k*2+1;
324      }
325      /**
326       * Does the argument instruction have a non-null
327       * k'th operand named BranchProfile?
328       * @param i the instruction to access.
329       * @param k the index of the operand.
330       * @return <code>true</code> if the instruction has an non-null
331       *         k'th operand named BranchProfile or <code>false</code>
332       *         if it does not.
333       */
334      public static boolean hasBranchProfile(Instruction i, int k) {
335        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
336        return i.getOperand(2+k*2+1) != null;
337      }
338    
339      /**
340       * Return the index of the first operand called BranchProfile
341       * in the argument instruction.
342       * @param i the instruction to access.
343       * @return the index of the first operand called BranchProfile
344       *         in the argument instruction
345       */
346      public static int indexOfBranchProfiles(Instruction i)
347      {
348        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
349        return 3;
350      }
351      /**
352       * Does the argument instruction have any operands
353       * named BranchProfile?
354       * @param i the instruction to access.
355       * @return <code>true</code> if the instruction has operands
356       *         named BranchProfile or <code>false</code> if it does not.
357       */
358      public static boolean hasBranchProfiles(Instruction i)
359      {
360        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
361        return i.getNumberOfOperands()-3 > 0 && i.getOperand(3) != null;
362      }
363    
364      /**
365       * How many variable-length operands called BranchProfiles
366       * does the argument instruction have?
367       * @param i the instruction to access
368       * @return the number of operands called BranchProfiles the instruction has
369       */
370      public static int getNumberOfBranchProfiles(Instruction i)
371      {
372        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
373        return (i.getNumberOfOperands()-2)/2;
374      }
375    
376      /**
377       * Change the number of BranchProfiles that may be stored in
378       * the argument instruction to numVarOps.
379       * @param i the instruction to access
380       * @param numVarOps the new number of variable operands called BranchProfiles
381       *        that may be stored in the instruction
382       */
383      public static void resizeNumberOfBranchProfiles(Instruction i, int numVarOps)
384      {
385        if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch");
386      if (2+numVarOps*2>MIN_OPERAND_ARRAY_LENGTH)
387        i.resizeNumberOfOperands(2+numVarOps*2);
388      else
389        for (int j = 2+numVarOps*2; j < MIN_OPERAND_ARRAY_LENGTH; j++)
390          i.putOperand(j, null);
391      }
392    
393      /**
394       * Create an instruction of the MIR_LowTableSwitch instruction format.
395       * @param o the instruction's operator
396       * @param Index the instruction's Index operand
397       * @param MethodStart the instruction's MethodStart operand
398       * @param numVarOps the number of variable length operands that
399       *                 will be stored in the insruction.
400       * @return the newly created MIR_LowTableSwitch instruction
401       */
402      public static Instruction create(Operator o
403                       , RegisterOperand Index
404                       , RegisterOperand MethodStart
405                       , int numVarOps
406                    )
407      {
408        if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_LowTableSwitch");
409        Instruction i = new Instruction(o, Math.max(2+numVarOps*2, MIN_OPERAND_ARRAY_LENGTH));
410        i.putOperand(0, Index);
411        i.putOperand(1, MethodStart);
412        return i;
413      }
414    
415      /**
416       * Mutate the argument instruction into an instruction of the
417       * MIR_LowTableSwitch instruction format having the specified
418       * operator and operands.
419       * @param i the instruction to mutate
420       * @param o the instruction's operator
421       * @param Index the instruction's Index operand
422       * @param MethodStart the instruction's MethodStart operand
423       * @param numVarOps the number of variable length operands that
424       *                  will be stored in the insruction.
425       * @return the mutated instruction
426       */
427      public static Instruction mutate(Instruction i, Operator o
428                       , RegisterOperand Index
429                       , RegisterOperand MethodStart
430                       , int numVarOps
431                    )
432      {
433        if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_LowTableSwitch");
434        if (2+numVarOps*2>MIN_OPERAND_ARRAY_LENGTH)
435          i.resizeNumberOfOperands(2+numVarOps*2);
436    
437        i.operator = o;
438        i.putOperand(0, Index);
439        i.putOperand(1, MethodStart);
440        return i;
441      }
442    }
443