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 InstanceOf 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 InstanceOf extends InstructionFormat {
022  /**
023   * InstructionFormat identification method for InstanceOf.
024   * @param i an instruction
025   * @return <code>true</code> if the InstructionFormat of the argument
026   *         instruction is InstanceOf 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 InstanceOf.
034   * @param o an instruction
035   * @return <code>true</code> if the InstructionFormat of the argument
036   *         operator is InstanceOf or <code>false</code>
037   *         if it is not.
038   */
039  public static boolean conforms(Operator o) {
040    return o.format == InstanceOf_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, "InstanceOf");
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, "InstanceOf");
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, "InstanceOf");
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, "InstanceOf");
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, "InstanceOf");
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, "InstanceOf");
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, "InstanceOf");
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, "InstanceOf");
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, "InstanceOf");
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, "InstanceOf");
156    return i.getOperand(1) != null;
157  }
158
159  /**
160   * Get the operand called Ref 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   * @return the operand called Ref
165   */
166  public static Operand getRef(Instruction i) {
167    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "InstanceOf");
168    return (Operand) i.getOperand(2);
169  }
170  /**
171   * Get the operand called Ref from the argument
172   * instruction clearing its instruction pointer. The returned
173   * operand will not point to any containing instruction.
174   * @param i the instruction to fetch the operand from
175   * @return the operand called Ref
176   */
177  public static Operand getClearRef(Instruction i) {
178    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "InstanceOf");
179    return (Operand) i.getClearOperand(2);
180  }
181  /**
182   * Set the operand called Ref in the argument
183   * instruction to the argument operand. The operand will
184   * now point to the argument instruction as its containing
185   * instruction.
186   * @param i the instruction in which to store the operand
187   * @param Ref the operand to store
188   */
189  public static void setRef(Instruction i, Operand Ref) {
190    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "InstanceOf");
191    i.putOperand(2, Ref);
192  }
193  /**
194   * Return the index of the operand called Ref
195   * in the argument instruction.
196   * @param i the instruction to access.
197   * @return the index of the operand called Ref
198   *         in the argument instruction
199   */
200  public static int indexOfRef(Instruction i) {
201    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "InstanceOf");
202    return 2;
203  }
204  /**
205   * Does the argument instruction have a non-null
206   * operand named Ref?
207   * @param i the instruction to access.
208   * @return <code>true</code> if the instruction has an non-null
209   *         operand named Ref or <code>false</code>
210   *         if it does not.
211   */
212  public static boolean hasRef(Instruction i) {
213    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "InstanceOf");
214    return i.getOperand(2) != null;
215  }
216
217  /**
218   * Get the operand called Guard from the
219   * argument instruction. Note that the returned operand
220   * will still point to its containing instruction.
221   * @param i the instruction to fetch the operand from
222   * @return the operand called Guard
223   */
224  public static Operand getGuard(Instruction i) {
225    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "InstanceOf");
226    return (Operand) i.getOperand(3);
227  }
228  /**
229   * Get the operand called Guard from the argument
230   * instruction clearing its instruction pointer. The returned
231   * operand will not point to any containing instruction.
232   * @param i the instruction to fetch the operand from
233   * @return the operand called Guard
234   */
235  public static Operand getClearGuard(Instruction i) {
236    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "InstanceOf");
237    return (Operand) i.getClearOperand(3);
238  }
239  /**
240   * Set the operand called Guard in the argument
241   * instruction to the argument operand. The operand will
242   * now point to the argument instruction as its containing
243   * instruction.
244   * @param i the instruction in which to store the operand
245   * @param Guard the operand to store
246   */
247  public static void setGuard(Instruction i, Operand Guard) {
248    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "InstanceOf");
249    i.putOperand(3, Guard);
250  }
251  /**
252   * Return the index of the operand called Guard
253   * in the argument instruction.
254   * @param i the instruction to access.
255   * @return the index of the operand called Guard
256   *         in the argument instruction
257   */
258  public static int indexOfGuard(Instruction i) {
259    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "InstanceOf");
260    return 3;
261  }
262  /**
263   * Does the argument instruction have a non-null
264   * operand named Guard?
265   * @param i the instruction to access.
266   * @return <code>true</code> if the instruction has an non-null
267   *         operand named Guard or <code>false</code>
268   *         if it does not.
269   */
270  public static boolean hasGuard(Instruction i) {
271    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "InstanceOf");
272    return i.getOperand(3) != null;
273  }
274
275
276  /**
277   * Create an instruction of the InstanceOf 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 Ref the instruction's Ref operand
282   * @param Guard the instruction's Guard operand
283   * @return the newly created InstanceOf instruction
284   */
285  public static Instruction create(Operator o
286                   , RegisterOperand Result
287                   , TypeOperand Type
288                   , Operand Ref
289                   , Operand Guard
290                )
291  {
292    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "InstanceOf");
293    Instruction i = Instruction.create(o, 5);
294    i.putOperand(0, Result);
295    i.putOperand(1, Type);
296    i.putOperand(2, Ref);
297    i.putOperand(3, Guard);
298    return i;
299  }
300
301  /**
302   * Mutate the argument instruction into an instruction of the
303   * InstanceOf instruction format having the specified
304   * operator and operands.
305   * @param i the instruction to mutate
306   * @param o the instruction's operator
307   * @param Result the instruction's Result operand
308   * @param Type the instruction's Type operand
309   * @param Ref the instruction's Ref operand
310   * @param Guard the instruction's Guard operand
311   * @return the mutated instruction
312   */
313  public static Instruction mutate(Instruction i, Operator o
314                   , RegisterOperand Result
315                   , TypeOperand Type
316                   , Operand Ref
317                   , Operand Guard
318                )
319  {
320    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "InstanceOf");
321    i.changeOperatorTo(o);
322    i.putOperand(0, Result);
323    i.putOperand(1, Type);
324    i.putOperand(2, Ref);
325    i.putOperand(3, Guard);
326    return i;
327  }
328  /**
329   * Create an instruction of the InstanceOf instruction format.
330   * @param o the instruction's operator
331   * @param Result the instruction's Result operand
332   * @param Type the instruction's Type operand
333   * @param Ref the instruction's Ref operand
334   * @return the newly created InstanceOf instruction
335   */
336  public static Instruction create(Operator o
337                   , RegisterOperand Result
338                   , TypeOperand Type
339                   , Operand Ref
340                )
341  {
342    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "InstanceOf");
343    Instruction i = Instruction.create(o, 5);
344    i.putOperand(0, Result);
345    i.putOperand(1, Type);
346    i.putOperand(2, Ref);
347    return i;
348  }
349
350  /**
351   * Mutate the argument instruction into an instruction of the
352   * InstanceOf instruction format having the specified
353   * operator and operands.
354   * @param i the instruction to mutate
355   * @param o the instruction's operator
356   * @param Result the instruction's Result operand
357   * @param Type the instruction's Type operand
358   * @param Ref the instruction's Ref operand
359   * @return the mutated instruction
360   */
361  public static Instruction mutate(Instruction i, Operator o
362                   , RegisterOperand Result
363                   , TypeOperand Type
364                   , Operand Ref
365                )
366  {
367    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "InstanceOf");
368    i.changeOperatorTo(o);
369    i.putOperand(0, Result);
370    i.putOperand(1, Type);
371    i.putOperand(2, Ref);
372    i.putOperand(3, null);
373    return i;
374  }
375}
376