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.ia32; 009 010import org.jikesrvm.Configuration; 011import org.jikesrvm.compilers.opt.ir.operand.ia32.IA32ConditionOperand; 012import org.jikesrvm.compilers.opt.ir.operand.*; 013import org.jikesrvm.compilers.opt.ir.Instruction; 014import org.jikesrvm.compilers.opt.ir.Operator; 015 016/** 017 * The MIR_LowTableSwitch InstructionFormat class. 018 * 019 * The header comment for {@link Instruction} contains 020 * an explanation of the role of InstructionFormats in the 021 * opt compiler's IR. 022 */ 023@SuppressWarnings("unused") // Machine generated code is never 100% clean 024public final class MIR_LowTableSwitch extends ArchInstructionFormat { 025 /** 026 * InstructionFormat identification method for MIR_LowTableSwitch. 027 * @param i an instruction 028 * @return <code>true</code> if the InstructionFormat of the argument 029 * instruction is MIR_LowTableSwitch or <code>false</code> 030 * if it is not. 031 */ 032 public static boolean conforms(Instruction i) { 033 return conforms(i.operator()); 034 } 035 /** 036 * InstructionFormat identification method for MIR_LowTableSwitch. 037 * @param o an instruction 038 * @return <code>true</code> if the InstructionFormat of the argument 039 * operator is MIR_LowTableSwitch or <code>false</code> 040 * if it is not. 041 */ 042 public static boolean conforms(Operator o) { 043 return o.format == MIR_LowTableSwitch_format; 044 } 045 046 /** 047 * Get the operand called Index from the 048 * argument instruction. Note that the returned operand 049 * will still point to its containing instruction. 050 * @param i the instruction to fetch the operand from 051 * @return the operand called Index 052 */ 053 public static RegisterOperand getIndex(Instruction i) { 054 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 055 return (RegisterOperand) i.getOperand(0); 056 } 057 /** 058 * Get the operand called Index from the argument 059 * instruction clearing its instruction pointer. The returned 060 * operand will not point to any containing instruction. 061 * @param i the instruction to fetch the operand from 062 * @return the operand called Index 063 */ 064 public static RegisterOperand getClearIndex(Instruction i) { 065 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 066 return (RegisterOperand) i.getClearOperand(0); 067 } 068 /** 069 * Set the operand called Index 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 Index the operand to store 075 */ 076 public static void setIndex(Instruction i, RegisterOperand Index) { 077 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 078 i.putOperand(0, Index); 079 } 080 /** 081 * Return the index of the operand called Index 082 * in the argument instruction. 083 * @param i the instruction to access. 084 * @return the index of the operand called Index 085 * in the argument instruction 086 */ 087 public static int indexOfIndex(Instruction i) { 088 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 089 return 0; 090 } 091 /** 092 * Does the argument instruction have a non-null 093 * operand named Index? 094 * @param i the instruction to access. 095 * @return <code>true</code> if the instruction has an non-null 096 * operand named Index or <code>false</code> 097 * if it does not. 098 */ 099 public static boolean hasIndex(Instruction i) { 100 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 101 return i.getOperand(0) != null; 102 } 103 104 /** 105 * Get the operand called MethodStart from the 106 * argument instruction. Note that the returned operand 107 * will still point to its containing instruction. 108 * @param i the instruction to fetch the operand from 109 * @return the operand called MethodStart 110 */ 111 public static RegisterOperand getMethodStart(Instruction i) { 112 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 113 return (RegisterOperand) i.getOperand(1); 114 } 115 /** 116 * Get the operand called MethodStart from the argument 117 * instruction clearing its instruction pointer. The returned 118 * operand will not point to any containing instruction. 119 * @param i the instruction to fetch the operand from 120 * @return the operand called MethodStart 121 */ 122 public static RegisterOperand getClearMethodStart(Instruction i) { 123 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 124 return (RegisterOperand) i.getClearOperand(1); 125 } 126 /** 127 * Set the operand called MethodStart in the argument 128 * instruction to the argument operand. The operand will 129 * now point to the argument instruction as its containing 130 * instruction. 131 * @param i the instruction in which to store the operand 132 * @param MethodStart the operand to store 133 */ 134 public static void setMethodStart(Instruction i, RegisterOperand MethodStart) { 135 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 136 i.putOperand(1, MethodStart); 137 } 138 /** 139 * Return the index of the operand called MethodStart 140 * in the argument instruction. 141 * @param i the instruction to access. 142 * @return the index of the operand called MethodStart 143 * in the argument instruction 144 */ 145 public static int indexOfMethodStart(Instruction i) { 146 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 147 return 1; 148 } 149 /** 150 * Does the argument instruction have a non-null 151 * operand named MethodStart? 152 * @param i the instruction to access. 153 * @return <code>true</code> if the instruction has an non-null 154 * operand named MethodStart or <code>false</code> 155 * if it does not. 156 */ 157 public static boolean hasMethodStart(Instruction i) { 158 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 159 return i.getOperand(1) != null; 160 } 161 162 /** 163 * Get the k'th operand called Target from the 164 * argument instruction. Note that the returned operand 165 * will still point to its containing instruction. 166 * @param i the instruction to fetch the operand from 167 * @param k the index of the operand 168 * @return the k'th operand called Target 169 */ 170 public static BranchOperand getTarget(Instruction i, int k) { 171 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 172 return (BranchOperand) i.getOperand(2+k*2+0); 173 } 174 /** 175 * Get the k'th 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 * @param k the index of the operand 180 * @return the k'th operand called Target 181 */ 182 public static BranchOperand getClearTarget(Instruction i, int k) { 183 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 184 return (BranchOperand) i.getClearOperand(2+k*2+0); 185 } 186 /** 187 * Set the k'th operand called Target in the argument 188 * instruction to the argument operand. The operand will 189 * now point to the argument instruction as its containing 190 * instruction. 191 * @param i the instruction in which to store the operand 192 * @param k the index of the operand 193 * @param o the operand to store 194 */ 195 public static void setTarget(Instruction i, int k, BranchOperand o) { 196 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 197 i.putOperand(2+k*2+0, o); 198 } 199 /** 200 * Return the index of the k'th operand called Target 201 * in the argument instruction. 202 * @param i the instruction to access. 203 * @param k the index of the operand. 204 * @return the index of the k'th operand called Target 205 * in the argument instruction 206 */ 207 public static int indexOfTarget(Instruction i, int k) { 208 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 209 return 2+k*2+0; 210 } 211 /** 212 * Does the argument instruction have a non-null 213 * k'th operand named Target? 214 * @param i the instruction to access. 215 * @param k the index of the operand. 216 * @return <code>true</code> if the instruction has an non-null 217 * k'th operand named Target or <code>false</code> 218 * if it does not. 219 */ 220 public static boolean hasTarget(Instruction i, int k) { 221 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 222 return i.getOperand(2+k*2+0) != null; 223 } 224 225 /** 226 * Return the index of the first operand called Target 227 * in the argument instruction. 228 * @param i the instruction to access. 229 * @return the index of the first operand called Target 230 * in the argument instruction 231 */ 232 public static int indexOfTargets(Instruction i) 233 { 234 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 235 return 2; 236 } 237 /** 238 * Does the argument instruction have any operands 239 * named Target? 240 * @param i the instruction to access. 241 * @return <code>true</code> if the instruction has operands 242 * named Target or <code>false</code> if it does not. 243 */ 244 public static boolean hasTargets(Instruction i) 245 { 246 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 247 return i.getNumberOfOperands()-2 > 0 && i.getOperand(2) != null; 248 } 249 250 /** 251 * How many variable-length operands called Targets 252 * does the argument instruction have? 253 * @param i the instruction to access 254 * @return the number of operands called Targets the instruction has 255 */ 256 public static int getNumberOfTargets(Instruction i) 257 { 258 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 259 return (i.getNumberOfOperands()-2)/2; 260 } 261 262 /** 263 * Change the number of Targets that may be stored in 264 * the argument instruction to numVarOps. 265 * @param i the instruction to access 266 * @param numVarOps the new number of variable operands called Targets 267 * that may be stored in the instruction 268 */ 269 public static void resizeNumberOfTargets(Instruction i, int numVarOps) 270 { 271 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 272 if (2+numVarOps*2>MIN_OPERAND_ARRAY_LENGTH) 273 i.resizeNumberOfOperands(2+numVarOps*2); 274 else 275 for (int j = 2+numVarOps*2; j < MIN_OPERAND_ARRAY_LENGTH; j++) 276 i.putOperand(j, null); 277 } 278 /** 279 * Get the k'th operand called BranchProfile from the 280 * argument instruction. Note that the returned operand 281 * will still point to its containing instruction. 282 * @param i the instruction to fetch the operand from 283 * @param k the index of the operand 284 * @return the k'th operand called BranchProfile 285 */ 286 public static BranchProfileOperand getBranchProfile(Instruction i, int k) { 287 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 288 return (BranchProfileOperand) i.getOperand(2+k*2+1); 289 } 290 /** 291 * Get the k'th operand called BranchProfile 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 * @param k the index of the operand 296 * @return the k'th operand called BranchProfile 297 */ 298 public static BranchProfileOperand getClearBranchProfile(Instruction i, int k) { 299 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 300 return (BranchProfileOperand) i.getClearOperand(2+k*2+1); 301 } 302 /** 303 * Set the k'th operand called BranchProfile in the argument 304 * instruction to the argument operand. The operand will 305 * now point to the argument instruction as its containing 306 * instruction. 307 * @param i the instruction in which to store the operand 308 * @param k the index of the operand 309 * @param o the operand to store 310 */ 311 public static void setBranchProfile(Instruction i, int k, BranchProfileOperand o) { 312 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 313 i.putOperand(2+k*2+1, o); 314 } 315 /** 316 * Return the index of the k'th operand called BranchProfile 317 * in the argument instruction. 318 * @param i the instruction to access. 319 * @param k the index of the operand. 320 * @return the index of the k'th operand called BranchProfile 321 * in the argument instruction 322 */ 323 public static int indexOfBranchProfile(Instruction i, int k) { 324 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 325 return 2+k*2+1; 326 } 327 /** 328 * Does the argument instruction have a non-null 329 * k'th operand named BranchProfile? 330 * @param i the instruction to access. 331 * @param k the index of the operand. 332 * @return <code>true</code> if the instruction has an non-null 333 * k'th operand named BranchProfile or <code>false</code> 334 * if it does not. 335 */ 336 public static boolean hasBranchProfile(Instruction i, int k) { 337 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 338 return i.getOperand(2+k*2+1) != null; 339 } 340 341 /** 342 * Return the index of the first operand called BranchProfile 343 * in the argument instruction. 344 * @param i the instruction to access. 345 * @return the index of the first operand called BranchProfile 346 * in the argument instruction 347 */ 348 public static int indexOfBranchProfiles(Instruction i) 349 { 350 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 351 return 3; 352 } 353 /** 354 * Does the argument instruction have any operands 355 * named BranchProfile? 356 * @param i the instruction to access. 357 * @return <code>true</code> if the instruction has operands 358 * named BranchProfile or <code>false</code> if it does not. 359 */ 360 public static boolean hasBranchProfiles(Instruction i) 361 { 362 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 363 return i.getNumberOfOperands()-3 > 0 && i.getOperand(3) != null; 364 } 365 366 /** 367 * How many variable-length operands called BranchProfiles 368 * does the argument instruction have? 369 * @param i the instruction to access 370 * @return the number of operands called BranchProfiles the instruction has 371 */ 372 public static int getNumberOfBranchProfiles(Instruction i) 373 { 374 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 375 return (i.getNumberOfOperands()-2)/2; 376 } 377 378 /** 379 * Change the number of BranchProfiles that may be stored in 380 * the argument instruction to numVarOps. 381 * @param i the instruction to access 382 * @param numVarOps the new number of variable operands called BranchProfiles 383 * that may be stored in the instruction 384 */ 385 public static void resizeNumberOfBranchProfiles(Instruction i, int numVarOps) 386 { 387 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "MIR_LowTableSwitch"); 388 if (2+numVarOps*2>MIN_OPERAND_ARRAY_LENGTH) 389 i.resizeNumberOfOperands(2+numVarOps*2); 390 else 391 for (int j = 2+numVarOps*2; j < MIN_OPERAND_ARRAY_LENGTH; j++) 392 i.putOperand(j, null); 393 } 394 395 /** 396 * Create an instruction of the MIR_LowTableSwitch instruction format. 397 * @param o the instruction's operator 398 * @param Index the instruction's Index operand 399 * @param MethodStart the instruction's MethodStart operand 400 * @param numVarOps the number of variable length operands that 401 * will be stored in the insruction. 402 * @return the newly created MIR_LowTableSwitch instruction 403 */ 404 public static Instruction create(Operator o 405 , RegisterOperand Index 406 , RegisterOperand MethodStart 407 , int numVarOps 408 ) 409 { 410 if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_LowTableSwitch"); 411 Instruction i = Instruction.create(o, Math.max(2+numVarOps*2, MIN_OPERAND_ARRAY_LENGTH)); 412 i.putOperand(0, Index); 413 i.putOperand(1, MethodStart); 414 return i; 415 } 416 417 /** 418 * Mutate the argument instruction into an instruction of the 419 * MIR_LowTableSwitch instruction format having the specified 420 * operator and operands. 421 * @param i the instruction to mutate 422 * @param o the instruction's operator 423 * @param Index the instruction's Index operand 424 * @param MethodStart the instruction's MethodStart operand 425 * @param numVarOps the number of variable length operands that 426 * will be stored in the insruction. 427 * @return the mutated instruction 428 */ 429 public static Instruction mutate(Instruction i, Operator o 430 , RegisterOperand Index 431 , RegisterOperand MethodStart 432 , int numVarOps 433 ) 434 { 435 if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "MIR_LowTableSwitch"); 436 if (2+numVarOps*2>MIN_OPERAND_ARRAY_LENGTH) 437 i.resizeNumberOfOperands(2+numVarOps*2); 438 439 i.changeOperatorTo(o); 440 i.putOperand(0, Index); 441 i.putOperand(1, MethodStart); 442 return i; 443 } 444} 445