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; 009 010import org.jikesrvm.Configuration; 011import org.jikesrvm.compilers.opt.ir.operand.*; 012 013/** 014 * The Prologue InstructionFormat class. 015 * 016 * The header comment for {@link Instruction} contains 017 * an explanation of the role of InstructionFormats in the 018 * opt compiler's IR. 019 */ 020@SuppressWarnings("unused") // Machine generated code is never 100% clean 021public final class Prologue extends InstructionFormat { 022 /** 023 * InstructionFormat identification method for Prologue. 024 * @param i an instruction 025 * @return <code>true</code> if the InstructionFormat of the argument 026 * instruction is Prologue or <code>false</code> 027 * if it is not. 028 */ 029 public static boolean conforms(Instruction i) { 030 return conforms(i.operator()); 031 } 032 /** 033 * InstructionFormat identification method for Prologue. 034 * @param o an instruction 035 * @return <code>true</code> if the InstructionFormat of the argument 036 * operator is Prologue or <code>false</code> 037 * if it is not. 038 */ 039 public static boolean conforms(Operator o) { 040 return o.format == Prologue_format; 041 } 042 043 /** 044 * Get the k'th operand called Formal from the 045 * argument instruction. Note that the returned operand 046 * will still point to its containing instruction. 047 * @param i the instruction to fetch the operand from 048 * @param k the index of the operand 049 * @return the k'th operand called Formal 050 */ 051 public static RegisterOperand getFormal(Instruction i, int k) { 052 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Prologue"); 053 return (RegisterOperand) i.getOperand(0+k); 054 } 055 /** 056 * Get the k'th operand called Formal from the argument 057 * instruction clearing its instruction pointer. The returned 058 * operand will not point to any containing instruction. 059 * @param i the instruction to fetch the operand from 060 * @param k the index of the operand 061 * @return the k'th operand called Formal 062 */ 063 public static RegisterOperand getClearFormal(Instruction i, int k) { 064 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Prologue"); 065 return (RegisterOperand) i.getClearOperand(0+k); 066 } 067 /** 068 * Set the k'th operand called Formal in the argument 069 * instruction to the argument operand. The operand will 070 * now point to the argument instruction as its containing 071 * instruction. 072 * @param i the instruction in which to store the operand 073 * @param k the index of the operand 074 * @param o the operand to store 075 */ 076 public static void setFormal(Instruction i, int k, RegisterOperand o) { 077 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Prologue"); 078 i.putOperand(0+k, o); 079 } 080 /** 081 * Return the index of the k'th operand called Formal 082 * in the argument instruction. 083 * @param i the instruction to access. 084 * @param k the index of the operand. 085 * @return the index of the k'th operand called Formal 086 * in the argument instruction 087 */ 088 public static int indexOfFormal(Instruction i, int k) { 089 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Prologue"); 090 return 0+k; 091 } 092 /** 093 * Does the argument instruction have a non-null 094 * k'th operand named Formal? 095 * @param i the instruction to access. 096 * @param k the index of the operand. 097 * @return <code>true</code> if the instruction has an non-null 098 * k'th operand named Formal or <code>false</code> 099 * if it does not. 100 */ 101 public static boolean hasFormal(Instruction i, int k) { 102 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Prologue"); 103 return i.getOperand(0+k) != null; 104 } 105 106 /** 107 * Return the index of the first operand called Formal 108 * in the argument instruction. 109 * @param i the instruction to access. 110 * @return the index of the first operand called Formal 111 * in the argument instruction 112 */ 113 public static int indexOfFormals(Instruction i) 114 { 115 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Prologue"); 116 return 0; 117 } 118 /** 119 * Does the argument instruction have any operands 120 * named Formal? 121 * @param i the instruction to access. 122 * @return <code>true</code> if the instruction has operands 123 * named Formal or <code>false</code> if it does not. 124 */ 125 public static boolean hasFormals(Instruction i) 126 { 127 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Prologue"); 128 return i.getNumberOfOperands()-0 > 0 && i.getOperand(0) != null; 129 } 130 131 /** 132 * How many variable-length operands called Formals 133 * does the argument instruction have? 134 * @param i the instruction to access 135 * @return the number of operands called Formals the instruction has 136 */ 137 public static int getNumberOfFormals(Instruction i) 138 { 139 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Prologue"); 140 return i.getNumberOfOperands()-0; 141 } 142 143 /** 144 * Change the number of Formals that may be stored in 145 * the argument instruction to numVarOps. 146 * @param i the instruction to access 147 * @param numVarOps the new number of variable operands called Formals 148 * that may be stored in the instruction 149 */ 150 public static void resizeNumberOfFormals(Instruction i, int numVarOps) 151 { 152 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Prologue"); 153 if (0+numVarOps>MIN_OPERAND_ARRAY_LENGTH) 154 i.resizeNumberOfOperands(0+numVarOps); 155 else 156 for (int j = 0+numVarOps; j < MIN_OPERAND_ARRAY_LENGTH; j++) 157 i.putOperand(j, null); 158 } 159 160 /** 161 * Create an instruction of the Prologue instruction format. 162 * @param o the instruction's operator 163 * @param numVarOps the number of variable length operands that 164 * will be stored in the insruction. 165 * @return the newly created Prologue instruction 166 */ 167 public static Instruction create(Operator o 168 , int numVarOps 169 ) 170 { 171 if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "Prologue"); 172 Instruction i = Instruction.create(o, Math.max(0+numVarOps, MIN_OPERAND_ARRAY_LENGTH)); 173 return i; 174 } 175 176 /** 177 * Mutate the argument instruction into an instruction of the 178 * Prologue instruction format having the specified 179 * operator and operands. 180 * @param i the instruction to mutate 181 * @param o the instruction's operator 182 * @param numVarOps the number of variable length operands that 183 * will be stored in the instruction. 184 * @return the mutated instruction 185 */ 186 public static Instruction mutate(Instruction i, Operator o 187 , int numVarOps 188 ) 189 { 190 if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "Prologue"); 191 if (0+numVarOps>MIN_OPERAND_ARRAY_LENGTH) 192 i.resizeNumberOfOperands(0+numVarOps); 193 194 i.changeOperatorTo(o); 195 return i; 196 } 197} 198