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 OsrBarrier 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 OsrBarrier extends InstructionFormat {
022  /**
023   * InstructionFormat identification method for OsrBarrier.
024   * @param i an instruction
025   * @return <code>true</code> if the InstructionFormat of the argument
026   *         instruction is OsrBarrier 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 OsrBarrier.
034   * @param o an instruction
035   * @return <code>true</code> if the InstructionFormat of the argument
036   *         operator is OsrBarrier or <code>false</code>
037   *         if it is not.
038   */
039  public static boolean conforms(Operator o) {
040    return o.format == OsrBarrier_format;
041  }
042
043  /**
044   * Get the operand called TypeInfo 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 TypeInfo
049   */
050  public static OsrTypeInfoOperand getTypeInfo(Instruction i) {
051    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "OsrBarrier");
052    return (OsrTypeInfoOperand) i.getOperand(0);
053  }
054  /**
055   * Get the operand called TypeInfo 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 TypeInfo
060   */
061  public static OsrTypeInfoOperand getClearTypeInfo(Instruction i) {
062    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "OsrBarrier");
063    return (OsrTypeInfoOperand) i.getClearOperand(0);
064  }
065  /**
066   * Set the operand called TypeInfo 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 TypeInfo the operand to store
072   */
073  public static void setTypeInfo(Instruction i, OsrTypeInfoOperand TypeInfo) {
074    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "OsrBarrier");
075    i.putOperand(0, TypeInfo);
076  }
077  /**
078   * Return the index of the operand called TypeInfo
079   * in the argument instruction.
080   * @param i the instruction to access.
081   * @return the index of the operand called TypeInfo
082   *         in the argument instruction
083   */
084  public static int indexOfTypeInfo(Instruction i) {
085    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "OsrBarrier");
086    return 0;
087  }
088  /**
089   * Does the argument instruction have a non-null
090   * operand named TypeInfo?
091   * @param i the instruction to access.
092   * @return <code>true</code> if the instruction has an non-null
093   *         operand named TypeInfo or <code>false</code>
094   *         if it does not.
095   */
096  public static boolean hasTypeInfo(Instruction i) {
097    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "OsrBarrier");
098    return i.getOperand(0) != null;
099  }
100
101  /**
102   * Get the k'th operand called Element 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 Element
108   */
109  public static Operand getElement(Instruction i, int k) {
110    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "OsrBarrier");
111    return (Operand) i.getOperand(1+k);
112  }
113  /**
114   * Get the k'th operand called Element 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 Element
120   */
121  public static Operand getClearElement(Instruction i, int k) {
122    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "OsrBarrier");
123    return (Operand) i.getClearOperand(1+k);
124  }
125  /**
126   * Set the k'th operand called Element 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 setElement(Instruction i, int k, Operand o) {
135    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "OsrBarrier");
136    i.putOperand(1+k, o);
137  }
138  /**
139   * Return the index of the k'th operand called Element
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 Element
144   *         in the argument instruction
145   */
146  public static int indexOfElement(Instruction i, int k) {
147    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "OsrBarrier");
148    return 1+k;
149  }
150  /**
151   * Does the argument instruction have a non-null
152   * k'th operand named Element?
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 Element or <code>false</code>
157   *         if it does not.
158   */
159  public static boolean hasElement(Instruction i, int k) {
160    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "OsrBarrier");
161    return i.getOperand(1+k) != null;
162  }
163
164  /**
165   * Return the index of the first operand called Element
166   * in the argument instruction.
167   * @param i the instruction to access.
168   * @return the index of the first operand called Element
169   *         in the argument instruction
170   */
171  public static int indexOfElements(Instruction i)
172  {
173    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "OsrBarrier");
174    return 1;
175  }
176  /**
177   * Does the argument instruction have any operands
178   * named Element?
179   * @param i the instruction to access.
180   * @return <code>true</code> if the instruction has operands
181   *         named Element or <code>false</code> if it does not.
182   */
183  public static boolean hasElements(Instruction i)
184  {
185    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "OsrBarrier");
186    return i.getNumberOfOperands()-1 > 0 && i.getOperand(1) != null;
187  }
188
189  /**
190   * How many variable-length operands called Elements
191   * does the argument instruction have?
192   * @param i the instruction to access
193   * @return the number of operands called Elements the instruction has
194   */
195  public static int getNumberOfElements(Instruction i)
196  {
197    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "OsrBarrier");
198    return i.getNumberOfOperands()-1;
199  }
200
201  /**
202   * Change the number of Elements 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 Elements
206   *        that may be stored in the instruction
207   */
208  public static void resizeNumberOfElements(Instruction i, int numVarOps)
209  {
210    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "OsrBarrier");
211  if (1+numVarOps>MIN_OPERAND_ARRAY_LENGTH)
212    i.resizeNumberOfOperands(1+numVarOps);
213  else
214    for (int j = 1+numVarOps; j < MIN_OPERAND_ARRAY_LENGTH; j++)
215      i.putOperand(j, null);
216  }
217
218  /**
219   * Create an instruction of the OsrBarrier instruction format.
220   * @param o the instruction's operator
221   * @param TypeInfo the instruction's TypeInfo operand
222   * @param numVarOps the number of variable length operands that
223   *                 will be stored in the insruction.
224   * @return the newly created OsrBarrier instruction
225   */
226  public static Instruction create(Operator o
227                   , OsrTypeInfoOperand TypeInfo
228                   , int numVarOps
229                )
230  {
231    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "OsrBarrier");
232    Instruction i = Instruction.create(o, Math.max(1+numVarOps, MIN_OPERAND_ARRAY_LENGTH));
233    i.putOperand(0, TypeInfo);
234    return i;
235  }
236
237  /**
238   * Mutate the argument instruction into an instruction of the
239   * OsrBarrier instruction format having the specified
240   * operator and operands.
241   * @param i the instruction to mutate
242   * @param o the instruction's operator
243   * @param TypeInfo the instruction's TypeInfo operand
244   * @param numVarOps the number of variable length operands that
245   *                  will be stored in the instruction.
246   * @return the mutated instruction
247   */
248  public static Instruction mutate(Instruction i, Operator o
249                   , OsrTypeInfoOperand TypeInfo
250                   , int numVarOps
251                )
252  {
253    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "OsrBarrier");
254    if (1+numVarOps>MIN_OPERAND_ARRAY_LENGTH)
255      i.resizeNumberOfOperands(1+numVarOps);
256
257    i.changeOperatorTo(o);
258    i.putOperand(0, TypeInfo);
259    return i;
260  }
261}
262