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_CondBranch 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_CondBranch extends ArchInstructionFormat {
026  /**
027   * InstructionFormat identification method for MIR_CondBranch.
028   * @param i an instruction
029   * @return <code>true</code> if the InstructionFormat of the argument
030   *         instruction is MIR_CondBranch 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_CondBranch.
038   * @param o an instruction
039   * @return <code>true</code> if the InstructionFormat of the argument
040   *         operator is MIR_CondBranch or <code>false</code>
041   *         if it is not.
042   */
043  public static boolean conforms(Operator o) {
044    return o.format == MIR_CondBranch_format;
045  }
046
047  /**
048   * Get the operand called Value 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 Value
053   */
054  public static RegisterOperand getValue(Instruction i) {
055    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
056    return (RegisterOperand) i.getOperand(0);
057  }
058  /**
059   * Get the operand called Value 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 Value
064   */
065  public static RegisterOperand getClearValue(Instruction i) {
066    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
067    return (RegisterOperand) i.getClearOperand(0);
068  }
069  /**
070   * Set the operand called Value 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 Value the operand to store
076   */
077  public static void setValue(Instruction i, RegisterOperand Value) {
078    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
079    i.putOperand(0, Value);
080  }
081  /**
082   * Return the index of the operand called Value
083   * in the argument instruction.
084   * @param i the instruction to access.
085   * @return the index of the operand called Value
086   *         in the argument instruction
087   */
088  public static int indexOfValue(Instruction i) {
089    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
090    return 0;
091  }
092  /**
093   * Does the argument instruction have a non-null
094   * operand named Value?
095   * @param i the instruction to access.
096   * @return <code>true</code> if the instruction has an non-null
097   *         operand named Value or <code>false</code>
098   *         if it does not.
099   */
100  public static boolean hasValue(Instruction i) {
101    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
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 PowerPCConditionOperand getCond(Instruction i) {
113    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
114    return (PowerPCConditionOperand) 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 PowerPCConditionOperand getClearCond(Instruction i) {
124    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
125    return (PowerPCConditionOperand) 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, PowerPCConditionOperand Cond) {
136    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
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_CondBranch");
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_CondBranch");
160    return i.getOperand(1) != null;
161  }
162
163  /**
164   * Get the operand called Target 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 Target
169   */
170  public static BranchOperand getTarget(Instruction i) {
171    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
172    return (BranchOperand) i.getOperand(2);
173  }
174  /**
175   * Get the operand called Target 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 Target
180   */
181  public static BranchOperand getClearTarget(Instruction i) {
182    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
183    return (BranchOperand) i.getClearOperand(2);
184  }
185  /**
186   * Set the operand called Target 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 Target the operand to store
192   */
193  public static void setTarget(Instruction i, BranchOperand Target) {
194    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
195    i.putOperand(2, Target);
196  }
197  /**
198   * Return the index of the operand called Target
199   * in the argument instruction.
200   * @param i the instruction to access.
201   * @return the index of the operand called Target
202   *         in the argument instruction
203   */
204  public static int indexOfTarget(Instruction i) {
205    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
206    return 2;
207  }
208  /**
209   * Does the argument instruction have a non-null
210   * operand named Target?
211   * @param i the instruction to access.
212   * @return <code>true</code> if the instruction has an non-null
213   *         operand named Target or <code>false</code>
214   *         if it does not.
215   */
216  public static boolean hasTarget(Instruction i) {
217    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
218    return i.getOperand(2) != null;
219  }
220
221  /**
222   * Get the operand called BranchProfile 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 BranchProfile
227   */
228  public static BranchProfileOperand getBranchProfile(Instruction i) {
229    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
230    return (BranchProfileOperand) i.getOperand(3);
231  }
232  /**
233   * Get the operand called BranchProfile 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 BranchProfile
238   */
239  public static BranchProfileOperand getClearBranchProfile(Instruction i) {
240    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
241    return (BranchProfileOperand) i.getClearOperand(3);
242  }
243  /**
244   * Set the operand called BranchProfile 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 BranchProfile the operand to store
250   */
251  public static void setBranchProfile(Instruction i, BranchProfileOperand BranchProfile) {
252    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
253    i.putOperand(3, BranchProfile);
254  }
255  /**
256   * Return the index of the operand called BranchProfile
257   * in the argument instruction.
258   * @param i the instruction to access.
259   * @return the index of the operand called BranchProfile
260   *         in the argument instruction
261   */
262  public static int indexOfBranchProfile(Instruction i) {
263    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
264    return 3;
265  }
266  /**
267   * Does the argument instruction have a non-null
268   * operand named BranchProfile?
269   * @param i the instruction to access.
270   * @return <code>true</code> if the instruction has an non-null
271   *         operand named BranchProfile or <code>false</code>
272   *         if it does not.
273   */
274  public static boolean hasBranchProfile(Instruction i) {
275    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch");
276    return i.getOperand(3) != null;
277  }
278
279
280  /**
281   * Create an instruction of the MIR_CondBranch instruction format.
282   * @param o the instruction's operator
283   * @param Value the instruction's Value operand
284   * @param Cond the instruction's Cond operand
285   * @param Target the instruction's Target operand
286   * @param BranchProfile the instruction's BranchProfile operand
287   * @return the newly created MIR_CondBranch instruction
288   */
289  public static Instruction create(Operator o
290                   , RegisterOperand Value
291                   , PowerPCConditionOperand Cond
292                   , BranchOperand Target
293                   , BranchProfileOperand BranchProfile
294                )
295  {
296    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_CondBranch");
297    Instruction i = Instruction.create(o, 5);
298    i.putOperand(0, Value);
299    i.putOperand(1, Cond);
300    i.putOperand(2, Target);
301    i.putOperand(3, BranchProfile);
302    return i;
303  }
304
305  /**
306   * Mutate the argument instruction into an instruction of the
307   * MIR_CondBranch instruction format having the specified
308   * operator and operands.
309   * @param i the instruction to mutate
310   * @param o the instruction's operator
311   * @param Value the instruction's Value operand
312   * @param Cond the instruction's Cond operand
313   * @param Target the instruction's Target operand
314   * @param BranchProfile the instruction's BranchProfile operand
315   * @return the mutated instruction
316   */
317  public static Instruction mutate(Instruction i, Operator o
318                   , RegisterOperand Value
319                   , PowerPCConditionOperand Cond
320                   , BranchOperand Target
321                   , BranchProfileOperand BranchProfile
322                )
323  {
324    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_CondBranch");
325    i.changeOperatorTo(o);
326    i.putOperand(0, Value);
327    i.putOperand(1, Cond);
328    i.putOperand(2, Target);
329    i.putOperand(3, BranchProfile);
330    return i;
331  }
332  /**
333   * Create an instruction of the MIR_CondBranch instruction format.
334   * @param o the instruction's operator
335   * @param Value the instruction's Value operand
336   * @param Cond the instruction's Cond operand
337   * @param BranchProfile the instruction's BranchProfile operand
338   * @return the newly created MIR_CondBranch instruction
339   */
340  public static Instruction create(Operator o
341                   , RegisterOperand Value
342                   , PowerPCConditionOperand Cond
343                   , BranchProfileOperand BranchProfile
344                )
345  {
346    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_CondBranch");
347    Instruction i = Instruction.create(o, 5);
348    i.putOperand(0, Value);
349    i.putOperand(1, Cond);
350    i.putOperand(3, BranchProfile);
351    return i;
352  }
353
354  /**
355   * Mutate the argument instruction into an instruction of the
356   * MIR_CondBranch instruction format having the specified
357   * operator and operands.
358   * @param i the instruction to mutate
359   * @param o the instruction's operator
360   * @param Value the instruction's Value operand
361   * @param Cond the instruction's Cond operand
362   * @param BranchProfile the instruction's BranchProfile operand
363   * @return the mutated instruction
364   */
365  public static Instruction mutate(Instruction i, Operator o
366                   , RegisterOperand Value
367                   , PowerPCConditionOperand Cond
368                   , BranchProfileOperand BranchProfile
369                )
370  {
371    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_CondBranch");
372    i.changeOperatorTo(o);
373    i.putOperand(0, Value);
374    i.putOperand(1, Cond);
375    i.putOperand(2, null);
376    i.putOperand(3, BranchProfile);
377    return i;
378  }
379}
380