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_Branch 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_Branch extends ArchInstructionFormat {
026  /**
027   * InstructionFormat identification method for MIR_Branch.
028   * @param i an instruction
029   * @return <code>true</code> if the InstructionFormat of the argument
030   *         instruction is MIR_Branch 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_Branch.
038   * @param o an instruction
039   * @return <code>true</code> if the InstructionFormat of the argument
040   *         operator is MIR_Branch or <code>false</code>
041   *         if it is not.
042   */
043  public static boolean conforms(Operator o) {
044    return o.format == MIR_Branch_format;
045  }
046
047  /**
048   * Get the operand called Target 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 Target
053   */
054  public static BranchOperand getTarget(Instruction i) {
055    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Branch");
056    return (BranchOperand) i.getOperand(0);
057  }
058  /**
059   * Get the operand called Target 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 Target
064   */
065  public static BranchOperand getClearTarget(Instruction i) {
066    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Branch");
067    return (BranchOperand) i.getClearOperand(0);
068  }
069  /**
070   * Set the operand called Target 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 Target the operand to store
076   */
077  public static void setTarget(Instruction i, BranchOperand Target) {
078    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Branch");
079    i.putOperand(0, Target);
080  }
081  /**
082   * Return the index of the operand called Target
083   * in the argument instruction.
084   * @param i the instruction to access.
085   * @return the index of the operand called Target
086   *         in the argument instruction
087   */
088  public static int indexOfTarget(Instruction i) {
089    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Branch");
090    return 0;
091  }
092  /**
093   * Does the argument instruction have a non-null
094   * operand named Target?
095   * @param i the instruction to access.
096   * @return <code>true</code> if the instruction has an non-null
097   *         operand named Target or <code>false</code>
098   *         if it does not.
099   */
100  public static boolean hasTarget(Instruction i) {
101    if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_Branch");
102    return i.getOperand(0) != null;
103  }
104
105
106  /**
107   * Create an instruction of the MIR_Branch instruction format.
108   * @param o the instruction's operator
109   * @param Target the instruction's Target operand
110   * @return the newly created MIR_Branch instruction
111   */
112  public static Instruction create(Operator o
113                   , BranchOperand Target
114                )
115  {
116    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_Branch");
117    Instruction i = Instruction.create(o, 5);
118    i.putOperand(0, Target);
119    return i;
120  }
121
122  /**
123   * Mutate the argument instruction into an instruction of the
124   * MIR_Branch instruction format having the specified
125   * operator and operands.
126   * @param i the instruction to mutate
127   * @param o the instruction's operator
128   * @param Target the instruction's Target operand
129   * @return the mutated instruction
130   */
131  public static Instruction mutate(Instruction i, Operator o
132                   , BranchOperand Target
133                )
134  {
135    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_Branch");
136    i.changeOperatorTo(o);
137    i.putOperand(0, Target);
138    return i;
139  }
140  /**
141   * Create an instruction of the MIR_Branch instruction format.
142   * @param o the instruction's operator
143   * @return the newly created MIR_Branch instruction
144   */
145  public static Instruction create(Operator o
146                )
147  {
148    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_Branch");
149    Instruction i = Instruction.create(o, 5);
150    return i;
151  }
152
153  /**
154   * Mutate the argument instruction into an instruction of the
155   * MIR_Branch instruction format having the specified
156   * operator and operands.
157   * @param i the instruction to mutate
158   * @param o the instruction's operator
159   * @return the mutated instruction
160   */
161  public static Instruction mutate(Instruction i, Operator o
162                )
163  {
164    if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_Branch");
165    i.changeOperatorTo(o);
166    i.putOperand(0, null);
167    return i;
168  }
169}
170