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_CondBranch2 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_CondBranch2 extends ArchInstructionFormat {
026  /**
027   * InstructionFormat identification method for MIR_CondBranch2.
028   * @param i an instruction
029   * @return <code>true</code> if the InstructionFormat of the argument
030   *         instruction is MIR_CondBranch2 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_CondBranch2.
038   * @param o an instruction
039   * @return <code>true</code> if the InstructionFormat of the argument
040   *         operator is MIR_CondBranch2 or <code>false</code>
041   *         if it is not.
042   */
043  public static boolean conforms(Operator o) {
044    return o.format == MIR_CondBranch2_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_CondBranch2");
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_CondBranch2");
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_CondBranch2");
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_CondBranch2");
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_CondBranch2");
102    return i.getOperand(0) != null;
103  }
104
105  /**
106   * Get the operand called Cond1 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 Cond1
111   */
112  public static PowerPCConditionOperand getCond1(Instruction i) {
113    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
114    return (PowerPCConditionOperand) i.getOperand(1);
115  }
116  /**
117   * Get the operand called Cond1 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 Cond1
122   */
123  public static PowerPCConditionOperand getClearCond1(Instruction i) {
124    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
125    return (PowerPCConditionOperand) i.getClearOperand(1);
126  }
127  /**
128   * Set the operand called Cond1 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 Cond1 the operand to store
134   */
135  public static void setCond1(Instruction i, PowerPCConditionOperand Cond1) {
136    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
137    i.putOperand(1, Cond1);
138  }
139  /**
140   * Return the index of the operand called Cond1
141   * in the argument instruction.
142   * @param i the instruction to access.
143   * @return the index of the operand called Cond1
144   *         in the argument instruction
145   */
146  public static int indexOfCond1(Instruction i) {
147    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
148    return 1;
149  }
150  /**
151   * Does the argument instruction have a non-null
152   * operand named Cond1?
153   * @param i the instruction to access.
154   * @return <code>true</code> if the instruction has an non-null
155   *         operand named Cond1 or <code>false</code>
156   *         if it does not.
157   */
158  public static boolean hasCond1(Instruction i) {
159    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
160    return i.getOperand(1) != null;
161  }
162
163  /**
164   * Get the operand called Target1 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 Target1
169   */
170  public static BranchOperand getTarget1(Instruction i) {
171    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
172    return (BranchOperand) i.getOperand(2);
173  }
174  /**
175   * Get the operand called Target1 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 Target1
180   */
181  public static BranchOperand getClearTarget1(Instruction i) {
182    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
183    return (BranchOperand) i.getClearOperand(2);
184  }
185  /**
186   * Set the operand called Target1 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 Target1 the operand to store
192   */
193  public static void setTarget1(Instruction i, BranchOperand Target1) {
194    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
195    i.putOperand(2, Target1);
196  }
197  /**
198   * Return the index of the operand called Target1
199   * in the argument instruction.
200   * @param i the instruction to access.
201   * @return the index of the operand called Target1
202   *         in the argument instruction
203   */
204  public static int indexOfTarget1(Instruction i) {
205    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
206    return 2;
207  }
208  /**
209   * Does the argument instruction have a non-null
210   * operand named Target1?
211   * @param i the instruction to access.
212   * @return <code>true</code> if the instruction has an non-null
213   *         operand named Target1 or <code>false</code>
214   *         if it does not.
215   */
216  public static boolean hasTarget1(Instruction i) {
217    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
218    return i.getOperand(2) != null;
219  }
220
221  /**
222   * Get the operand called BranchProfile1 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 BranchProfile1
227   */
228  public static BranchProfileOperand getBranchProfile1(Instruction i) {
229    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
230    return (BranchProfileOperand) i.getOperand(3);
231  }
232  /**
233   * Get the operand called BranchProfile1 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 BranchProfile1
238   */
239  public static BranchProfileOperand getClearBranchProfile1(Instruction i) {
240    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
241    return (BranchProfileOperand) i.getClearOperand(3);
242  }
243  /**
244   * Set the operand called BranchProfile1 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 BranchProfile1 the operand to store
250   */
251  public static void setBranchProfile1(Instruction i, BranchProfileOperand BranchProfile1) {
252    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
253    i.putOperand(3, BranchProfile1);
254  }
255  /**
256   * Return the index of the operand called BranchProfile1
257   * in the argument instruction.
258   * @param i the instruction to access.
259   * @return the index of the operand called BranchProfile1
260   *         in the argument instruction
261   */
262  public static int indexOfBranchProfile1(Instruction i) {
263    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
264    return 3;
265  }
266  /**
267   * Does the argument instruction have a non-null
268   * operand named BranchProfile1?
269   * @param i the instruction to access.
270   * @return <code>true</code> if the instruction has an non-null
271   *         operand named BranchProfile1 or <code>false</code>
272   *         if it does not.
273   */
274  public static boolean hasBranchProfile1(Instruction i) {
275    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
276    return i.getOperand(3) != null;
277  }
278
279  /**
280   * Get the operand called Cond2 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 Cond2
285   */
286  public static PowerPCConditionOperand getCond2(Instruction i) {
287    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
288    return (PowerPCConditionOperand) i.getOperand(4);
289  }
290  /**
291   * Get the operand called Cond2 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 Cond2
296   */
297  public static PowerPCConditionOperand getClearCond2(Instruction i) {
298    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
299    return (PowerPCConditionOperand) i.getClearOperand(4);
300  }
301  /**
302   * Set the operand called Cond2 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 Cond2 the operand to store
308   */
309  public static void setCond2(Instruction i, PowerPCConditionOperand Cond2) {
310    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
311    i.putOperand(4, Cond2);
312  }
313  /**
314   * Return the index of the operand called Cond2
315   * in the argument instruction.
316   * @param i the instruction to access.
317   * @return the index of the operand called Cond2
318   *         in the argument instruction
319   */
320  public static int indexOfCond2(Instruction i) {
321    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
322    return 4;
323  }
324  /**
325   * Does the argument instruction have a non-null
326   * operand named Cond2?
327   * @param i the instruction to access.
328   * @return <code>true</code> if the instruction has an non-null
329   *         operand named Cond2 or <code>false</code>
330   *         if it does not.
331   */
332  public static boolean hasCond2(Instruction i) {
333    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
334    return i.getOperand(4) != null;
335  }
336
337  /**
338   * Get the operand called Target2 from the
339   * argument instruction. Note that the returned operand
340   * will still point to its containing instruction.
341   * @param i the instruction to fetch the operand from
342   * @return the operand called Target2
343   */
344  public static BranchOperand getTarget2(Instruction i) {
345    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
346    return (BranchOperand) i.getOperand(5);
347  }
348  /**
349   * Get the operand called Target2 from the argument
350   * instruction clearing its instruction pointer. The returned
351   * operand will not point to any containing instruction.
352   * @param i the instruction to fetch the operand from
353   * @return the operand called Target2
354   */
355  public static BranchOperand getClearTarget2(Instruction i) {
356    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
357    return (BranchOperand) i.getClearOperand(5);
358  }
359  /**
360   * Set the operand called Target2 in the argument
361   * instruction to the argument operand. The operand will
362   * now point to the argument instruction as its containing
363   * instruction.
364   * @param i the instruction in which to store the operand
365   * @param Target2 the operand to store
366   */
367  public static void setTarget2(Instruction i, BranchOperand Target2) {
368    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
369    i.putOperand(5, Target2);
370  }
371  /**
372   * Return the index of the operand called Target2
373   * in the argument instruction.
374   * @param i the instruction to access.
375   * @return the index of the operand called Target2
376   *         in the argument instruction
377   */
378  public static int indexOfTarget2(Instruction i) {
379    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
380    return 5;
381  }
382  /**
383   * Does the argument instruction have a non-null
384   * operand named Target2?
385   * @param i the instruction to access.
386   * @return <code>true</code> if the instruction has an non-null
387   *         operand named Target2 or <code>false</code>
388   *         if it does not.
389   */
390  public static boolean hasTarget2(Instruction i) {
391    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
392    return i.getOperand(5) != null;
393  }
394
395  /**
396   * Get the operand called BranchProfile2 from the
397   * argument instruction. Note that the returned operand
398   * will still point to its containing instruction.
399   * @param i the instruction to fetch the operand from
400   * @return the operand called BranchProfile2
401   */
402  public static BranchProfileOperand getBranchProfile2(Instruction i) {
403    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
404    return (BranchProfileOperand) i.getOperand(6);
405  }
406  /**
407   * Get the operand called BranchProfile2 from the argument
408   * instruction clearing its instruction pointer. The returned
409   * operand will not point to any containing instruction.
410   * @param i the instruction to fetch the operand from
411   * @return the operand called BranchProfile2
412   */
413  public static BranchProfileOperand getClearBranchProfile2(Instruction i) {
414    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
415    return (BranchProfileOperand) i.getClearOperand(6);
416  }
417  /**
418   * Set the operand called BranchProfile2 in the argument
419   * instruction to the argument operand. The operand will
420   * now point to the argument instruction as its containing
421   * instruction.
422   * @param i the instruction in which to store the operand
423   * @param BranchProfile2 the operand to store
424   */
425  public static void setBranchProfile2(Instruction i, BranchProfileOperand BranchProfile2) {
426    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
427    i.putOperand(6, BranchProfile2);
428  }
429  /**
430   * Return the index of the operand called BranchProfile2
431   * in the argument instruction.
432   * @param i the instruction to access.
433   * @return the index of the operand called BranchProfile2
434   *         in the argument instruction
435   */
436  public static int indexOfBranchProfile2(Instruction i) {
437    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
438    return 6;
439  }
440  /**
441   * Does the argument instruction have a non-null
442   * operand named BranchProfile2?
443   * @param i the instruction to access.
444   * @return <code>true</code> if the instruction has an non-null
445   *         operand named BranchProfile2 or <code>false</code>
446   *         if it does not.
447   */
448  public static boolean hasBranchProfile2(Instruction i) {
449    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_CondBranch2");
450    return i.getOperand(6) != null;
451  }
452
453
454  /**
455   * Create an instruction of the MIR_CondBranch2 instruction format.
456   * @param o the instruction's operator
457   * @param Value the instruction's Value operand
458   * @param Cond1 the instruction's Cond1 operand
459   * @param Target1 the instruction's Target1 operand
460   * @param BranchProfile1 the instruction's BranchProfile1 operand
461   * @param Cond2 the instruction's Cond2 operand
462   * @param Target2 the instruction's Target2 operand
463   * @param BranchProfile2 the instruction's BranchProfile2 operand
464   * @return the newly created MIR_CondBranch2 instruction
465   */
466  public static Instruction create(Operator o
467                   , RegisterOperand Value
468                   , PowerPCConditionOperand Cond1
469                   , BranchOperand Target1
470                   , BranchProfileOperand BranchProfile1
471                   , PowerPCConditionOperand Cond2
472                   , BranchOperand Target2
473                   , BranchProfileOperand BranchProfile2
474                )
475  {
476    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_CondBranch2");
477    Instruction i = Instruction.create(o, 7);
478    i.putOperand(0, Value);
479    i.putOperand(1, Cond1);
480    i.putOperand(2, Target1);
481    i.putOperand(3, BranchProfile1);
482    i.putOperand(4, Cond2);
483    i.putOperand(5, Target2);
484    i.putOperand(6, BranchProfile2);
485    return i;
486  }
487
488  /**
489   * Mutate the argument instruction into an instruction of the
490   * MIR_CondBranch2 instruction format having the specified
491   * operator and operands.
492   * @param i the instruction to mutate
493   * @param o the instruction's operator
494   * @param Value the instruction's Value operand
495   * @param Cond1 the instruction's Cond1 operand
496   * @param Target1 the instruction's Target1 operand
497   * @param BranchProfile1 the instruction's BranchProfile1 operand
498   * @param Cond2 the instruction's Cond2 operand
499   * @param Target2 the instruction's Target2 operand
500   * @param BranchProfile2 the instruction's BranchProfile2 operand
501   * @return the mutated instruction
502   */
503  public static Instruction mutate(Instruction i, Operator o
504                   , RegisterOperand Value
505                   , PowerPCConditionOperand Cond1
506                   , BranchOperand Target1
507                   , BranchProfileOperand BranchProfile1
508                   , PowerPCConditionOperand Cond2
509                   , BranchOperand Target2
510                   , BranchProfileOperand BranchProfile2
511                )
512  {
513    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_CondBranch2");
514    i.resizeNumberOfOperands(7);
515
516    i.changeOperatorTo(o);
517    i.putOperand(0, Value);
518    i.putOperand(1, Cond1);
519    i.putOperand(2, Target1);
520    i.putOperand(3, BranchProfile1);
521    i.putOperand(4, Cond2);
522    i.putOperand(5, Target2);
523    i.putOperand(6, BranchProfile2);
524    return i;
525  }
526}
527