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_Condition 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_Condition extends ArchInstructionFormat {
026  /**
027   * InstructionFormat identification method for MIR_Condition.
028   * @param i an instruction
029   * @return <code>true</code> if the InstructionFormat of the argument
030   *         instruction is MIR_Condition 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_Condition.
038   * @param o an instruction
039   * @return <code>true</code> if the InstructionFormat of the argument
040   *         operator is MIR_Condition or <code>false</code>
041   *         if it is not.
042   */
043  public static boolean conforms(Operator o) {
044    return o.format == MIR_Condition_format;
045  }
046
047  /**
048   * Get the operand called ResultBit 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 ResultBit
053   */
054  public static IntConstantOperand getResultBit(Instruction i) {
055    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Condition");
056    return (IntConstantOperand) i.getOperand(0);
057  }
058  /**
059   * Get the operand called ResultBit 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 ResultBit
064   */
065  public static IntConstantOperand getClearResultBit(Instruction i) {
066    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Condition");
067    return (IntConstantOperand) i.getClearOperand(0);
068  }
069  /**
070   * Set the operand called ResultBit 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 ResultBit the operand to store
076   */
077  public static void setResultBit(Instruction i, IntConstantOperand ResultBit) {
078    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Condition");
079    i.putOperand(0, ResultBit);
080  }
081  /**
082   * Return the index of the operand called ResultBit
083   * in the argument instruction.
084   * @param i the instruction to access.
085   * @return the index of the operand called ResultBit
086   *         in the argument instruction
087   */
088  public static int indexOfResultBit(Instruction i) {
089    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Condition");
090    return 0;
091  }
092  /**
093   * Does the argument instruction have a non-null
094   * operand named ResultBit?
095   * @param i the instruction to access.
096   * @return <code>true</code> if the instruction has an non-null
097   *         operand named ResultBit or <code>false</code>
098   *         if it does not.
099   */
100  public static boolean hasResultBit(Instruction i) {
101    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Condition");
102    return i.getOperand(0) != null;
103  }
104
105  /**
106   * Get the operand called Value1Bit 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 Value1Bit
111   */
112  public static IntConstantOperand getValue1Bit(Instruction i) {
113    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Condition");
114    return (IntConstantOperand) i.getOperand(1);
115  }
116  /**
117   * Get the operand called Value1Bit 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 Value1Bit
122   */
123  public static IntConstantOperand getClearValue1Bit(Instruction i) {
124    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Condition");
125    return (IntConstantOperand) i.getClearOperand(1);
126  }
127  /**
128   * Set the operand called Value1Bit 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 Value1Bit the operand to store
134   */
135  public static void setValue1Bit(Instruction i, IntConstantOperand Value1Bit) {
136    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Condition");
137    i.putOperand(1, Value1Bit);
138  }
139  /**
140   * Return the index of the operand called Value1Bit
141   * in the argument instruction.
142   * @param i the instruction to access.
143   * @return the index of the operand called Value1Bit
144   *         in the argument instruction
145   */
146  public static int indexOfValue1Bit(Instruction i) {
147    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Condition");
148    return 1;
149  }
150  /**
151   * Does the argument instruction have a non-null
152   * operand named Value1Bit?
153   * @param i the instruction to access.
154   * @return <code>true</code> if the instruction has an non-null
155   *         operand named Value1Bit or <code>false</code>
156   *         if it does not.
157   */
158  public static boolean hasValue1Bit(Instruction i) {
159    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Condition");
160    return i.getOperand(1) != null;
161  }
162
163  /**
164   * Get the operand called Value2Bit 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 Value2Bit
169   */
170  public static IntConstantOperand getValue2Bit(Instruction i) {
171    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Condition");
172    return (IntConstantOperand) i.getOperand(2);
173  }
174  /**
175   * Get the operand called Value2Bit 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 Value2Bit
180   */
181  public static IntConstantOperand getClearValue2Bit(Instruction i) {
182    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Condition");
183    return (IntConstantOperand) i.getClearOperand(2);
184  }
185  /**
186   * Set the operand called Value2Bit 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 Value2Bit the operand to store
192   */
193  public static void setValue2Bit(Instruction i, IntConstantOperand Value2Bit) {
194    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Condition");
195    i.putOperand(2, Value2Bit);
196  }
197  /**
198   * Return the index of the operand called Value2Bit
199   * in the argument instruction.
200   * @param i the instruction to access.
201   * @return the index of the operand called Value2Bit
202   *         in the argument instruction
203   */
204  public static int indexOfValue2Bit(Instruction i) {
205    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Condition");
206    return 2;
207  }
208  /**
209   * Does the argument instruction have a non-null
210   * operand named Value2Bit?
211   * @param i the instruction to access.
212   * @return <code>true</code> if the instruction has an non-null
213   *         operand named Value2Bit or <code>false</code>
214   *         if it does not.
215   */
216  public static boolean hasValue2Bit(Instruction i) {
217    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Condition");
218    return i.getOperand(2) != null;
219  }
220
221
222  /**
223   * Create an instruction of the MIR_Condition instruction format.
224   * @param o the instruction's operator
225   * @param ResultBit the instruction's ResultBit operand
226   * @param Value1Bit the instruction's Value1Bit operand
227   * @param Value2Bit the instruction's Value2Bit operand
228   * @return the newly created MIR_Condition instruction
229   */
230  public static Instruction create(Operator o
231                   , IntConstantOperand ResultBit
232                   , IntConstantOperand Value1Bit
233                   , IntConstantOperand Value2Bit
234                )
235  {
236    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_Condition");
237    Instruction i = Instruction.create(o, 5);
238    i.putOperand(0, ResultBit);
239    i.putOperand(1, Value1Bit);
240    i.putOperand(2, Value2Bit);
241    return i;
242  }
243
244  /**
245   * Mutate the argument instruction into an instruction of the
246   * MIR_Condition instruction format having the specified
247   * operator and operands.
248   * @param i the instruction to mutate
249   * @param o the instruction's operator
250   * @param ResultBit the instruction's ResultBit operand
251   * @param Value1Bit the instruction's Value1Bit operand
252   * @param Value2Bit the instruction's Value2Bit operand
253   * @return the mutated instruction
254   */
255  public static Instruction mutate(Instruction i, Operator o
256                   , IntConstantOperand ResultBit
257                   , IntConstantOperand Value1Bit
258                   , IntConstantOperand Value2Bit
259                )
260  {
261    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_Condition");
262    i.changeOperatorTo(o);
263    i.putOperand(0, ResultBit);
264    i.putOperand(1, Value1Bit);
265    i.putOperand(2, Value2Bit);
266    return i;
267  }
268}
269