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.ppc;
009
010import org.jikesrvm.Configuration;
011import org.jikesrvm.compilers.opt.ir.operand.ppc.PowerPCConditionOperand;
012import org.jikesrvm.compilers.opt.ir.operand.ppc.PowerPCTrapOperand;
013import org.jikesrvm.compilers.opt.ir.operand.*;
014import org.jikesrvm.compilers.opt.ir.Instruction;
015import org.jikesrvm.compilers.opt.ir.Operator;
016
017/**
018 * The MIR_Trap InstructionFormat class.
019 *
020 * The header comment for {@link Instruction} contains
021 * an explanation of the role of InstructionFormats in the
022 * opt compiler's IR.
023 */
024@SuppressWarnings("unused")  // Machine generated code is never 100% clean
025public final class MIR_Trap extends ArchInstructionFormat {
026  /**
027   * InstructionFormat identification method for MIR_Trap.
028   * @param i an instruction
029   * @return <code>true</code> if the InstructionFormat of the argument
030   *         instruction is MIR_Trap or <code>false</code>
031   *         if it is not.
032   */
033  public static boolean conforms(Instruction i) {
034    return conforms(i.operator());
035  }
036  /**
037   * InstructionFormat identification method for MIR_Trap.
038   * @param o an instruction
039   * @return <code>true</code> if the InstructionFormat of the argument
040   *         operator is MIR_Trap or <code>false</code>
041   *         if it is not.
042   */
043  public static boolean conforms(Operator o) {
044    return o.format == MIR_Trap_format;
045  }
046
047  /**
048   * Get the operand called GuardResult from the
049   * argument instruction. Note that the returned operand
050   * will still point to its containing instruction.
051   * @param i the instruction to fetch the operand from
052   * @return the operand called GuardResult
053   */
054  public static RegisterOperand getGuardResult(Instruction i) {
055    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
056    return (RegisterOperand) i.getOperand(0);
057  }
058  /**
059   * Get the operand called GuardResult from the argument
060   * instruction clearing its instruction pointer. The returned
061   * operand will not point to any containing instruction.
062   * @param i the instruction to fetch the operand from
063   * @return the operand called GuardResult
064   */
065  public static RegisterOperand getClearGuardResult(Instruction i) {
066    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
067    return (RegisterOperand) i.getClearOperand(0);
068  }
069  /**
070   * Set the operand called GuardResult in the argument
071   * instruction to the argument operand. The operand will
072   * now point to the argument instruction as its containing
073   * instruction.
074   * @param i the instruction in which to store the operand
075   * @param GuardResult the operand to store
076   */
077  public static void setGuardResult(Instruction i, RegisterOperand GuardResult) {
078    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
079    i.putOperand(0, GuardResult);
080  }
081  /**
082   * Return the index of the operand called GuardResult
083   * in the argument instruction.
084   * @param i the instruction to access.
085   * @return the index of the operand called GuardResult
086   *         in the argument instruction
087   */
088  public static int indexOfGuardResult(Instruction i) {
089    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
090    return 0;
091  }
092  /**
093   * Does the argument instruction have a non-null
094   * operand named GuardResult?
095   * @param i the instruction to access.
096   * @return <code>true</code> if the instruction has an non-null
097   *         operand named GuardResult or <code>false</code>
098   *         if it does not.
099   */
100  public static boolean hasGuardResult(Instruction i) {
101    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
102    return i.getOperand(0) != null;
103  }
104
105  /**
106   * Get the operand called Cond from the
107   * argument instruction. Note that the returned operand
108   * will still point to its containing instruction.
109   * @param i the instruction to fetch the operand from
110   * @return the operand called Cond
111   */
112  public static PowerPCTrapOperand getCond(Instruction i) {
113    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
114    return (PowerPCTrapOperand) i.getOperand(1);
115  }
116  /**
117   * Get the operand called Cond from the argument
118   * instruction clearing its instruction pointer. The returned
119   * operand will not point to any containing instruction.
120   * @param i the instruction to fetch the operand from
121   * @return the operand called Cond
122   */
123  public static PowerPCTrapOperand getClearCond(Instruction i) {
124    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
125    return (PowerPCTrapOperand) i.getClearOperand(1);
126  }
127  /**
128   * Set the operand called Cond in the argument
129   * instruction to the argument operand. The operand will
130   * now point to the argument instruction as its containing
131   * instruction.
132   * @param i the instruction in which to store the operand
133   * @param Cond the operand to store
134   */
135  public static void setCond(Instruction i, PowerPCTrapOperand Cond) {
136    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
137    i.putOperand(1, Cond);
138  }
139  /**
140   * Return the index of the operand called Cond
141   * in the argument instruction.
142   * @param i the instruction to access.
143   * @return the index of the operand called Cond
144   *         in the argument instruction
145   */
146  public static int indexOfCond(Instruction i) {
147    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
148    return 1;
149  }
150  /**
151   * Does the argument instruction have a non-null
152   * operand named Cond?
153   * @param i the instruction to access.
154   * @return <code>true</code> if the instruction has an non-null
155   *         operand named Cond or <code>false</code>
156   *         if it does not.
157   */
158  public static boolean hasCond(Instruction i) {
159    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
160    return i.getOperand(1) != null;
161  }
162
163  /**
164   * Get the operand called Value1 from the
165   * argument instruction. Note that the returned operand
166   * will still point to its containing instruction.
167   * @param i the instruction to fetch the operand from
168   * @return the operand called Value1
169   */
170  public static RegisterOperand getValue1(Instruction i) {
171    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
172    return (RegisterOperand) i.getOperand(2);
173  }
174  /**
175   * Get the operand called Value1 from the argument
176   * instruction clearing its instruction pointer. The returned
177   * operand will not point to any containing instruction.
178   * @param i the instruction to fetch the operand from
179   * @return the operand called Value1
180   */
181  public static RegisterOperand getClearValue1(Instruction i) {
182    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
183    return (RegisterOperand) i.getClearOperand(2);
184  }
185  /**
186   * Set the operand called Value1 in the argument
187   * instruction to the argument operand. The operand will
188   * now point to the argument instruction as its containing
189   * instruction.
190   * @param i the instruction in which to store the operand
191   * @param Value1 the operand to store
192   */
193  public static void setValue1(Instruction i, RegisterOperand Value1) {
194    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
195    i.putOperand(2, Value1);
196  }
197  /**
198   * Return the index of the operand called Value1
199   * in the argument instruction.
200   * @param i the instruction to access.
201   * @return the index of the operand called Value1
202   *         in the argument instruction
203   */
204  public static int indexOfValue1(Instruction i) {
205    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
206    return 2;
207  }
208  /**
209   * Does the argument instruction have a non-null
210   * operand named Value1?
211   * @param i the instruction to access.
212   * @return <code>true</code> if the instruction has an non-null
213   *         operand named Value1 or <code>false</code>
214   *         if it does not.
215   */
216  public static boolean hasValue1(Instruction i) {
217    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
218    return i.getOperand(2) != null;
219  }
220
221  /**
222   * Get the operand called Value2 from the
223   * argument instruction. Note that the returned operand
224   * will still point to its containing instruction.
225   * @param i the instruction to fetch the operand from
226   * @return the operand called Value2
227   */
228  public static Operand getValue2(Instruction i) {
229    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
230    return (Operand) i.getOperand(3);
231  }
232  /**
233   * Get the operand called Value2 from the argument
234   * instruction clearing its instruction pointer. The returned
235   * operand will not point to any containing instruction.
236   * @param i the instruction to fetch the operand from
237   * @return the operand called Value2
238   */
239  public static Operand getClearValue2(Instruction i) {
240    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
241    return (Operand) i.getClearOperand(3);
242  }
243  /**
244   * Set the operand called Value2 in the argument
245   * instruction to the argument operand. The operand will
246   * now point to the argument instruction as its containing
247   * instruction.
248   * @param i the instruction in which to store the operand
249   * @param Value2 the operand to store
250   */
251  public static void setValue2(Instruction i, Operand Value2) {
252    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
253    i.putOperand(3, Value2);
254  }
255  /**
256   * Return the index of the operand called Value2
257   * in the argument instruction.
258   * @param i the instruction to access.
259   * @return the index of the operand called Value2
260   *         in the argument instruction
261   */
262  public static int indexOfValue2(Instruction i) {
263    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
264    return 3;
265  }
266  /**
267   * Does the argument instruction have a non-null
268   * operand named Value2?
269   * @param i the instruction to access.
270   * @return <code>true</code> if the instruction has an non-null
271   *         operand named Value2 or <code>false</code>
272   *         if it does not.
273   */
274  public static boolean hasValue2(Instruction i) {
275    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
276    return i.getOperand(3) != null;
277  }
278
279  /**
280   * Get the operand called TCode from the
281   * argument instruction. Note that the returned operand
282   * will still point to its containing instruction.
283   * @param i the instruction to fetch the operand from
284   * @return the operand called TCode
285   */
286  public static TrapCodeOperand getTCode(Instruction i) {
287    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
288    return (TrapCodeOperand) i.getOperand(4);
289  }
290  /**
291   * Get the operand called TCode from the argument
292   * instruction clearing its instruction pointer. The returned
293   * operand will not point to any containing instruction.
294   * @param i the instruction to fetch the operand from
295   * @return the operand called TCode
296   */
297  public static TrapCodeOperand getClearTCode(Instruction i) {
298    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
299    return (TrapCodeOperand) i.getClearOperand(4);
300  }
301  /**
302   * Set the operand called TCode in the argument
303   * instruction to the argument operand. The operand will
304   * now point to the argument instruction as its containing
305   * instruction.
306   * @param i the instruction in which to store the operand
307   * @param TCode the operand to store
308   */
309  public static void setTCode(Instruction i, TrapCodeOperand TCode) {
310    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
311    i.putOperand(4, TCode);
312  }
313  /**
314   * Return the index of the operand called TCode
315   * in the argument instruction.
316   * @param i the instruction to access.
317   * @return the index of the operand called TCode
318   *         in the argument instruction
319   */
320  public static int indexOfTCode(Instruction i) {
321    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
322    return 4;
323  }
324  /**
325   * Does the argument instruction have a non-null
326   * operand named TCode?
327   * @param i the instruction to access.
328   * @return <code>true</code> if the instruction has an non-null
329   *         operand named TCode or <code>false</code>
330   *         if it does not.
331   */
332  public static boolean hasTCode(Instruction i) {
333    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Trap");
334    return i.getOperand(4) != null;
335  }
336
337
338  /**
339   * Create an instruction of the MIR_Trap instruction format.
340   * @param o the instruction's operator
341   * @param GuardResult the instruction's GuardResult operand
342   * @param Cond the instruction's Cond operand
343   * @param Value1 the instruction's Value1 operand
344   * @param Value2 the instruction's Value2 operand
345   * @param TCode the instruction's TCode operand
346   * @return the newly created MIR_Trap instruction
347   */
348  public static Instruction create(Operator o
349                   , RegisterOperand GuardResult
350                   , PowerPCTrapOperand Cond
351                   , RegisterOperand Value1
352                   , Operand Value2
353                   , TrapCodeOperand TCode
354                )
355  {
356    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_Trap");
357    Instruction i = Instruction.create(o, 5);
358    i.putOperand(0, GuardResult);
359    i.putOperand(1, Cond);
360    i.putOperand(2, Value1);
361    i.putOperand(3, Value2);
362    i.putOperand(4, TCode);
363    return i;
364  }
365
366  /**
367   * Mutate the argument instruction into an instruction of the
368   * MIR_Trap instruction format having the specified
369   * operator and operands.
370   * @param i the instruction to mutate
371   * @param o the instruction's operator
372   * @param GuardResult the instruction's GuardResult operand
373   * @param Cond the instruction's Cond operand
374   * @param Value1 the instruction's Value1 operand
375   * @param Value2 the instruction's Value2 operand
376   * @param TCode the instruction's TCode operand
377   * @return the mutated instruction
378   */
379  public static Instruction mutate(Instruction i, Operator o
380                   , RegisterOperand GuardResult
381                   , PowerPCTrapOperand Cond
382                   , RegisterOperand Value1
383                   , Operand Value2
384                   , TrapCodeOperand TCode
385                )
386  {
387    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_Trap");
388    i.changeOperatorTo(o);
389    i.putOperand(0, GuardResult);
390    i.putOperand(1, Cond);
391    i.putOperand(2, Value1);
392    i.putOperand(3, Value2);
393    i.putOperand(4, TCode);
394    return i;
395  }
396  /**
397   * Create an instruction of the MIR_Trap instruction format.
398   * @param o the instruction's operator
399   * @param Cond the instruction's Cond operand
400   * @param Value1 the instruction's Value1 operand
401   * @param Value2 the instruction's Value2 operand
402   * @param TCode the instruction's TCode operand
403   * @return the newly created MIR_Trap instruction
404   */
405  public static Instruction create(Operator o
406                   , PowerPCTrapOperand Cond
407                   , RegisterOperand Value1
408                   , Operand Value2
409                   , TrapCodeOperand TCode
410                )
411  {
412    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_Trap");
413    Instruction i = Instruction.create(o, 5);
414    i.putOperand(1, Cond);
415    i.putOperand(2, Value1);
416    i.putOperand(3, Value2);
417    i.putOperand(4, TCode);
418    return i;
419  }
420
421  /**
422   * Mutate the argument instruction into an instruction of the
423   * MIR_Trap instruction format having the specified
424   * operator and operands.
425   * @param i the instruction to mutate
426   * @param o the instruction's operator
427   * @param Cond the instruction's Cond operand
428   * @param Value1 the instruction's Value1 operand
429   * @param Value2 the instruction's Value2 operand
430   * @param TCode the instruction's TCode operand
431   * @return the mutated instruction
432   */
433  public static Instruction mutate(Instruction i, Operator o
434                   , PowerPCTrapOperand Cond
435                   , RegisterOperand Value1
436                   , Operand Value2
437                   , TrapCodeOperand TCode
438                )
439  {
440    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_Trap");
441    i.changeOperatorTo(o);
442    i.putOperand(0, null);
443    i.putOperand(1, Cond);
444    i.putOperand(2, Value1);
445    i.putOperand(3, Value2);
446    i.putOperand(4, TCode);
447    return i;
448  }
449}
450