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.ia32;
009
010import org.jikesrvm.Configuration;
011import org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand;
012import org.jikesrvm.compilers.opt.ir.operand.*;
013import org.jikesrvm.compilers.opt.ir.Instruction;
014import org.jikesrvm.compilers.opt.ir.Operator;
015
016/**
017 * The MIR_CondBranch InstructionFormat class.
018 *
019 * The header comment for {@link Instruction} contains
020 * an explanation of the role of InstructionFormats in the
021 * opt compiler's IR.
022 */
023@SuppressWarnings("unused")  // Machine generated code is never 100% clean
024public final class MIR_CondBranch extends ArchInstructionFormat {
025  /**
026   * InstructionFormat identification method for MIR_CondBranch.
027   * @param i an instruction
028   * @return <code>true</code> if the InstructionFormat of the argument
029   *         instruction is MIR_CondBranch or <code>false</code>
030   *         if it is not.
031   */
032  public static boolean conforms(Instruction i) {
033    return conforms(i.operator());
034  }
035  /**
036   * InstructionFormat identification method for MIR_CondBranch.
037   * @param o an instruction
038   * @return <code>true</code> if the InstructionFormat of the argument
039   *         operator is MIR_CondBranch or <code>false</code>
040   *         if it is not.
041   */
042  public static boolean conforms(Operator o) {
043    return o.format == MIR_CondBranch_format;
044  }
045
046  /**
047   * Get the operand called Cond from the
048   * argument instruction. Note that the returned operand
049   * will still point to its containing instruction.
050   * @param i the instruction to fetch the operand from
051   * @return the operand called Cond
052   */
053  public static IA32ConditionOperand getCond(Instruction i) {
054    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
055    return (IA32ConditionOperand) i.getOperand(0);
056  }
057  /**
058   * Get the operand called Cond from the argument
059   * instruction clearing its instruction pointer. The returned
060   * operand will not point to any containing instruction.
061   * @param i the instruction to fetch the operand from
062   * @return the operand called Cond
063   */
064  public static IA32ConditionOperand getClearCond(Instruction i) {
065    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
066    return (IA32ConditionOperand) i.getClearOperand(0);
067  }
068  /**
069   * Set the operand called Cond in the argument
070   * instruction to the argument operand. The operand will
071   * now point to the argument instruction as its containing
072   * instruction.
073   * @param i the instruction in which to store the operand
074   * @param Cond the operand to store
075   */
076  public static void setCond(Instruction i, IA32ConditionOperand Cond) {
077    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
078    i.putOperand(0, Cond);
079  }
080  /**
081   * Return the index of the operand called Cond
082   * in the argument instruction.
083   * @param i the instruction to access.
084   * @return the index of the operand called Cond
085   *         in the argument instruction
086   */
087  public static int indexOfCond(Instruction i) {
088    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
089    return 0;
090  }
091  /**
092   * Does the argument instruction have a non-null
093   * operand named Cond?
094   * @param i the instruction to access.
095   * @return <code>true</code> if the instruction has an non-null
096   *         operand named Cond or <code>false</code>
097   *         if it does not.
098   */
099  public static boolean hasCond(Instruction i) {
100    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
101    return i.getOperand(0) != null;
102  }
103
104  /**
105   * Get the operand called Target from the
106   * argument instruction. Note that the returned operand
107   * will still point to its containing instruction.
108   * @param i the instruction to fetch the operand from
109   * @return the operand called Target
110   */
111  public static BranchOperand getTarget(Instruction i) {
112    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
113    return (BranchOperand) i.getOperand(1);
114  }
115  /**
116   * Get the operand called Target from the argument
117   * instruction clearing its instruction pointer. The returned
118   * operand will not point to any containing instruction.
119   * @param i the instruction to fetch the operand from
120   * @return the operand called Target
121   */
122  public static BranchOperand getClearTarget(Instruction i) {
123    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
124    return (BranchOperand) i.getClearOperand(1);
125  }
126  /**
127   * Set the operand called Target in the argument
128   * instruction to the argument operand. The operand will
129   * now point to the argument instruction as its containing
130   * instruction.
131   * @param i the instruction in which to store the operand
132   * @param Target the operand to store
133   */
134  public static void setTarget(Instruction i, BranchOperand Target) {
135    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
136    i.putOperand(1, Target);
137  }
138  /**
139   * Return the index of the operand called Target
140   * in the argument instruction.
141   * @param i the instruction to access.
142   * @return the index of the operand called Target
143   *         in the argument instruction
144   */
145  public static int indexOfTarget(Instruction i) {
146    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
147    return 1;
148  }
149  /**
150   * Does the argument instruction have a non-null
151   * operand named Target?
152   * @param i the instruction to access.
153   * @return <code>true</code> if the instruction has an non-null
154   *         operand named Target or <code>false</code>
155   *         if it does not.
156   */
157  public static boolean hasTarget(Instruction i) {
158    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
159    return i.getOperand(1) != null;
160  }
161
162  /**
163   * Get the operand called BranchProfile from the
164   * argument instruction. Note that the returned operand
165   * will still point to its containing instruction.
166   * @param i the instruction to fetch the operand from
167   * @return the operand called BranchProfile
168   */
169  public static BranchProfileOperand getBranchProfile(Instruction i) {
170    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
171    return (BranchProfileOperand) i.getOperand(2);
172  }
173  /**
174   * Get the operand called BranchProfile from the argument
175   * instruction clearing its instruction pointer. The returned
176   * operand will not point to any containing instruction.
177   * @param i the instruction to fetch the operand from
178   * @return the operand called BranchProfile
179   */
180  public static BranchProfileOperand getClearBranchProfile(Instruction i) {
181    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
182    return (BranchProfileOperand) i.getClearOperand(2);
183  }
184  /**
185   * Set the operand called BranchProfile 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 BranchProfile the operand to store
191   */
192  public static void setBranchProfile(Instruction i, BranchProfileOperand BranchProfile) {
193    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
194    i.putOperand(2, BranchProfile);
195  }
196  /**
197   * Return the index of the operand called BranchProfile
198   * in the argument instruction.
199   * @param i the instruction to access.
200   * @return the index of the operand called BranchProfile
201   *         in the argument instruction
202   */
203  public static int indexOfBranchProfile(Instruction i) {
204    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
205    return 2;
206  }
207  /**
208   * Does the argument instruction have a non-null
209   * operand named BranchProfile?
210   * @param i the instruction to access.
211   * @return <code>true</code> if the instruction has an non-null
212   *         operand named BranchProfile or <code>false</code>
213   *         if it does not.
214   */
215  public static boolean hasBranchProfile(Instruction i) {
216    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
217    return i.getOperand(2) != null;
218  }
219
220
221  /**
222   * Create an instruction of the MIR_CondBranch instruction format.
223   * @param o the instruction's operator
224   * @param Cond the instruction's Cond operand
225   * @param Target the instruction's Target operand
226   * @param BranchProfile the instruction's BranchProfile operand
227   * @return the newly created MIR_CondBranch instruction
228   */
229  public static Instruction create(Operator o
230                   , IA32ConditionOperand Cond
231                   , BranchOperand Target
232                   , BranchProfileOperand BranchProfile
233                )
234  {
235    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_CondBranch");
236    Instruction i = Instruction.create(o, 5);
237    i.putOperand(0, Cond);
238    i.putOperand(1, Target);
239    i.putOperand(2, BranchProfile);
240    return i;
241  }
242
243  /**
244   * Mutate the argument instruction into an instruction of the
245   * MIR_CondBranch instruction format having the specified
246   * operator and operands.
247   * @param i the instruction to mutate
248   * @param o the instruction's operator
249   * @param Cond the instruction's Cond operand
250   * @param Target the instruction's Target operand
251   * @param BranchProfile the instruction's BranchProfile operand
252   * @return the mutated instruction
253   */
254  public static Instruction mutate(Instruction i, Operator o
255                   , IA32ConditionOperand Cond
256                   , BranchOperand Target
257                   , BranchProfileOperand BranchProfile
258                )
259  {
260    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_CondBranch");
261    i.changeOperatorTo(o);
262    i.putOperand(0, Cond);
263    i.putOperand(1, Target);
264    i.putOperand(2, BranchProfile);
265    return i;
266  }
267  /**
268   * Create an instruction of the MIR_CondBranch instruction format.
269   * @param o the instruction's operator
270   * @param Cond the instruction's Cond operand
271   * @param BranchProfile the instruction's BranchProfile operand
272   * @return the newly created MIR_CondBranch instruction
273   */
274  public static Instruction create(Operator o
275                   , IA32ConditionOperand Cond
276                   , BranchProfileOperand BranchProfile
277                )
278  {
279    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_CondBranch");
280    Instruction i = Instruction.create(o, 5);
281    i.putOperand(0, Cond);
282    i.putOperand(2, BranchProfile);
283    return i;
284  }
285
286  /**
287   * Mutate the argument instruction into an instruction of the
288   * MIR_CondBranch instruction format having the specified
289   * operator and operands.
290   * @param i the instruction to mutate
291   * @param o the instruction's operator
292   * @param Cond the instruction's Cond operand
293   * @param BranchProfile the instruction's BranchProfile operand
294   * @return the mutated instruction
295   */
296  public static Instruction mutate(Instruction i, Operator o
297                   , IA32ConditionOperand Cond
298                   , BranchProfileOperand BranchProfile
299                )
300  {
301    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_CondBranch");
302    i.changeOperatorTo(o);
303    i.putOperand(0, Cond);
304    i.putOperand(1, null);
305    i.putOperand(2, BranchProfile);
306    return i;
307  }
308}
309