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