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 TableSwitch 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 TableSwitch extends InstructionFormat { 023 /** 024 * InstructionFormat identification method for TableSwitch. 025 * @param i an instruction 026 * @return <code>true</code> if the InstructionFormat of the argument 027 * instruction is TableSwitch 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 TableSwitch. 035 * @param o an instruction 036 * @return <code>true</code> if the InstructionFormat of the argument 037 * operator is TableSwitch or <code>false</code> 038 * if it is not. 039 */ 040 public static boolean conforms(Operator o) { 041 return o.format == TableSwitch_format; 042 } 043 044 /** 045 * Get the operand called Value 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 * @return the operand called Value 050 */ 051 public static Operand getValue(Instruction i) { 052 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 053 return (Operand) i.getOperand(0); 054 } 055 /** 056 * Get the operand called Value 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 * @return the operand called Value 061 */ 062 public static Operand getClearValue(Instruction i) { 063 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 064 return (Operand) i.getClearOperand(0); 065 } 066 /** 067 * Set the operand called Value in the argument 068 * instruction to the argument operand. The operand will 069 * now point to the argument instruction as its containing 070 * instruction. 071 * @param i the instruction in which to store the operand 072 * @param Value the operand to store 073 */ 074 public static void setValue(Instruction i, Operand Value) { 075 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 076 i.putOperand(0, Value); 077 } 078 /** 079 * Return the index of the operand called Value 080 * in the argument instruction. 081 * @param i the instruction to access. 082 * @return the index of the operand called Value 083 * in the argument instruction 084 */ 085 public static int indexOfValue(Instruction i) { 086 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 087 return 0; 088 } 089 /** 090 * Does the argument instruction have a non-null 091 * operand named Value? 092 * @param i the instruction to access. 093 * @return <code>true</code> if the instruction has an non-null 094 * operand named Value or <code>false</code> 095 * if it does not. 096 */ 097 public static boolean hasValue(Instruction i) { 098 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 099 return i.getOperand(0) != null; 100 } 101 102 /** 103 * Get the operand called Unknown1 from the 104 * argument instruction. Note that the returned operand 105 * will still point to its containing instruction. 106 * @param i the instruction to fetch the operand from 107 * @return the operand called Unknown1 108 */ 109 public static Operand getUnknown1(Instruction i) { 110 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 111 return (Operand) i.getOperand(1); 112 } 113 /** 114 * Get the operand called Unknown1 from the argument 115 * instruction clearing its instruction pointer. The returned 116 * operand will not point to any containing instruction. 117 * @param i the instruction to fetch the operand from 118 * @return the operand called Unknown1 119 */ 120 public static Operand getClearUnknown1(Instruction i) { 121 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 122 return (Operand) i.getClearOperand(1); 123 } 124 /** 125 * Set the operand called Unknown1 in the argument 126 * instruction to the argument operand. The operand will 127 * now point to the argument instruction as its containing 128 * instruction. 129 * @param i the instruction in which to store the operand 130 * @param Unknown1 the operand to store 131 */ 132 public static void setUnknown1(Instruction i, Operand Unknown1) { 133 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 134 i.putOperand(1, Unknown1); 135 } 136 /** 137 * Return the index of the operand called Unknown1 138 * in the argument instruction. 139 * @param i the instruction to access. 140 * @return the index of the operand called Unknown1 141 * in the argument instruction 142 */ 143 public static int indexOfUnknown1(Instruction i) { 144 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 145 return 1; 146 } 147 /** 148 * Does the argument instruction have a non-null 149 * operand named Unknown1? 150 * @param i the instruction to access. 151 * @return <code>true</code> if the instruction has an non-null 152 * operand named Unknown1 or <code>false</code> 153 * if it does not. 154 */ 155 public static boolean hasUnknown1(Instruction i) { 156 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 157 return i.getOperand(1) != null; 158 } 159 160 /** 161 * Get the operand called Unknown2 from the 162 * argument instruction. Note that the returned operand 163 * will still point to its containing instruction. 164 * @param i the instruction to fetch the operand from 165 * @return the operand called Unknown2 166 */ 167 public static Operand getUnknown2(Instruction i) { 168 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 169 return (Operand) i.getOperand(2); 170 } 171 /** 172 * Get the operand called Unknown2 from the argument 173 * instruction clearing its instruction pointer. The returned 174 * operand will not point to any containing instruction. 175 * @param i the instruction to fetch the operand from 176 * @return the operand called Unknown2 177 */ 178 public static Operand getClearUnknown2(Instruction i) { 179 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 180 return (Operand) i.getClearOperand(2); 181 } 182 /** 183 * Set the operand called Unknown2 in the argument 184 * instruction to the argument operand. The operand will 185 * now point to the argument instruction as its containing 186 * instruction. 187 * @param i the instruction in which to store the operand 188 * @param Unknown2 the operand to store 189 */ 190 public static void setUnknown2(Instruction i, Operand Unknown2) { 191 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 192 i.putOperand(2, Unknown2); 193 } 194 /** 195 * Return the index of the operand called Unknown2 196 * in the argument instruction. 197 * @param i the instruction to access. 198 * @return the index of the operand called Unknown2 199 * in the argument instruction 200 */ 201 public static int indexOfUnknown2(Instruction i) { 202 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 203 return 2; 204 } 205 /** 206 * Does the argument instruction have a non-null 207 * operand named Unknown2? 208 * @param i the instruction to access. 209 * @return <code>true</code> if the instruction has an non-null 210 * operand named Unknown2 or <code>false</code> 211 * if it does not. 212 */ 213 public static boolean hasUnknown2(Instruction i) { 214 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 215 return i.getOperand(2) != null; 216 } 217 218 /** 219 * Get the operand called Low from the 220 * argument instruction. Note that the returned operand 221 * will still point to its containing instruction. 222 * @param i the instruction to fetch the operand from 223 * @return the operand called Low 224 */ 225 public static IntConstantOperand getLow(Instruction i) { 226 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 227 return (IntConstantOperand) i.getOperand(3); 228 } 229 /** 230 * Get the operand called Low from the argument 231 * instruction clearing its instruction pointer. The returned 232 * operand will not point to any containing instruction. 233 * @param i the instruction to fetch the operand from 234 * @return the operand called Low 235 */ 236 public static IntConstantOperand getClearLow(Instruction i) { 237 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 238 return (IntConstantOperand) i.getClearOperand(3); 239 } 240 /** 241 * Set the operand called Low in the argument 242 * instruction to the argument operand. The operand will 243 * now point to the argument instruction as its containing 244 * instruction. 245 * @param i the instruction in which to store the operand 246 * @param Low the operand to store 247 */ 248 public static void setLow(Instruction i, IntConstantOperand Low) { 249 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 250 i.putOperand(3, Low); 251 } 252 /** 253 * Return the index of the operand called Low 254 * in the argument instruction. 255 * @param i the instruction to access. 256 * @return the index of the operand called Low 257 * in the argument instruction 258 */ 259 public static int indexOfLow(Instruction i) { 260 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 261 return 3; 262 } 263 /** 264 * Does the argument instruction have a non-null 265 * operand named Low? 266 * @param i the instruction to access. 267 * @return <code>true</code> if the instruction has an non-null 268 * operand named Low or <code>false</code> 269 * if it does not. 270 */ 271 public static boolean hasLow(Instruction i) { 272 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 273 return i.getOperand(3) != null; 274 } 275 276 /** 277 * Get the operand called High from the 278 * argument instruction. Note that the returned operand 279 * will still point to its containing instruction. 280 * @param i the instruction to fetch the operand from 281 * @return the operand called High 282 */ 283 public static IntConstantOperand getHigh(Instruction i) { 284 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 285 return (IntConstantOperand) i.getOperand(4); 286 } 287 /** 288 * Get the operand called High from the argument 289 * instruction clearing its instruction pointer. The returned 290 * operand will not point to any containing instruction. 291 * @param i the instruction to fetch the operand from 292 * @return the operand called High 293 */ 294 public static IntConstantOperand getClearHigh(Instruction i) { 295 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 296 return (IntConstantOperand) i.getClearOperand(4); 297 } 298 /** 299 * Set the operand called High in the argument 300 * instruction to the argument operand. The operand will 301 * now point to the argument instruction as its containing 302 * instruction. 303 * @param i the instruction in which to store the operand 304 * @param High the operand to store 305 */ 306 public static void setHigh(Instruction i, IntConstantOperand High) { 307 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 308 i.putOperand(4, High); 309 } 310 /** 311 * Return the index of the operand called High 312 * in the argument instruction. 313 * @param i the instruction to access. 314 * @return the index of the operand called High 315 * in the argument instruction 316 */ 317 public static int indexOfHigh(Instruction i) { 318 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 319 return 4; 320 } 321 /** 322 * Does the argument instruction have a non-null 323 * operand named High? 324 * @param i the instruction to access. 325 * @return <code>true</code> if the instruction has an non-null 326 * operand named High or <code>false</code> 327 * if it does not. 328 */ 329 public static boolean hasHigh(Instruction i) { 330 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 331 return i.getOperand(4) != null; 332 } 333 334 /** 335 * Get the operand called Default from the 336 * argument instruction. Note that the returned operand 337 * will still point to its containing instruction. 338 * @param i the instruction to fetch the operand from 339 * @return the operand called Default 340 */ 341 public static BranchOperand getDefault(Instruction i) { 342 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 343 return (BranchOperand) i.getOperand(5); 344 } 345 /** 346 * Get the operand called Default from the argument 347 * instruction clearing its instruction pointer. The returned 348 * operand will not point to any containing instruction. 349 * @param i the instruction to fetch the operand from 350 * @return the operand called Default 351 */ 352 public static BranchOperand getClearDefault(Instruction i) { 353 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 354 return (BranchOperand) i.getClearOperand(5); 355 } 356 /** 357 * Set the operand called Default in the argument 358 * instruction to the argument operand. The operand will 359 * now point to the argument instruction as its containing 360 * instruction. 361 * @param i the instruction in which to store the operand 362 * @param Default the operand to store 363 */ 364 public static void setDefault(Instruction i, BranchOperand Default) { 365 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 366 i.putOperand(5, Default); 367 } 368 /** 369 * Return the index of the operand called Default 370 * in the argument instruction. 371 * @param i the instruction to access. 372 * @return the index of the operand called Default 373 * in the argument instruction 374 */ 375 public static int indexOfDefault(Instruction i) { 376 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 377 return 5; 378 } 379 /** 380 * Does the argument instruction have a non-null 381 * operand named Default? 382 * @param i the instruction to access. 383 * @return <code>true</code> if the instruction has an non-null 384 * operand named Default or <code>false</code> 385 * if it does not. 386 */ 387 public static boolean hasDefault(Instruction i) { 388 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 389 return i.getOperand(5) != null; 390 } 391 392 /** 393 * Get the operand called DefaultBranchProfile from the 394 * argument instruction. Note that the returned operand 395 * will still point to its containing instruction. 396 * @param i the instruction to fetch the operand from 397 * @return the operand called DefaultBranchProfile 398 */ 399 public static BranchProfileOperand getDefaultBranchProfile(Instruction i) { 400 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 401 return (BranchProfileOperand) i.getOperand(6); 402 } 403 /** 404 * Get the operand called DefaultBranchProfile from the argument 405 * instruction clearing its instruction pointer. The returned 406 * operand will not point to any containing instruction. 407 * @param i the instruction to fetch the operand from 408 * @return the operand called DefaultBranchProfile 409 */ 410 public static BranchProfileOperand getClearDefaultBranchProfile(Instruction i) { 411 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 412 return (BranchProfileOperand) i.getClearOperand(6); 413 } 414 /** 415 * Set the operand called DefaultBranchProfile in the argument 416 * instruction to the argument operand. The operand will 417 * now point to the argument instruction as its containing 418 * instruction. 419 * @param i the instruction in which to store the operand 420 * @param DefaultBranchProfile the operand to store 421 */ 422 public static void setDefaultBranchProfile(Instruction i, BranchProfileOperand DefaultBranchProfile) { 423 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 424 i.putOperand(6, DefaultBranchProfile); 425 } 426 /** 427 * Return the index of the operand called DefaultBranchProfile 428 * in the argument instruction. 429 * @param i the instruction to access. 430 * @return the index of the operand called DefaultBranchProfile 431 * in the argument instruction 432 */ 433 public static int indexOfDefaultBranchProfile(Instruction i) { 434 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 435 return 6; 436 } 437 /** 438 * Does the argument instruction have a non-null 439 * operand named DefaultBranchProfile? 440 * @param i the instruction to access. 441 * @return <code>true</code> if the instruction has an non-null 442 * operand named DefaultBranchProfile or <code>false</code> 443 * if it does not. 444 */ 445 public static boolean hasDefaultBranchProfile(Instruction i) { 446 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 447 return i.getOperand(6) != null; 448 } 449 450 /** 451 * Get the k'th operand called Target from the 452 * argument instruction. Note that the returned operand 453 * will still point to its containing instruction. 454 * @param i the instruction to fetch the operand from 455 * @param k the index of the operand 456 * @return the k'th operand called Target 457 */ 458 public static BranchOperand getTarget(Instruction i, int k) { 459 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 460 return (BranchOperand) i.getOperand(7+k*2+0); 461 } 462 /** 463 * Get the k'th operand called Target from the argument 464 * instruction clearing its instruction pointer. The returned 465 * operand will not point to any containing instruction. 466 * @param i the instruction to fetch the operand from 467 * @param k the index of the operand 468 * @return the k'th operand called Target 469 */ 470 public static BranchOperand getClearTarget(Instruction i, int k) { 471 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 472 return (BranchOperand) i.getClearOperand(7+k*2+0); 473 } 474 /** 475 * Set the k'th operand called Target in the argument 476 * instruction to the argument operand. The operand will 477 * now point to the argument instruction as its containing 478 * instruction. 479 * @param i the instruction in which to store the operand 480 * @param k the index of the operand 481 * @param o the operand to store 482 */ 483 public static void setTarget(Instruction i, int k, BranchOperand o) { 484 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 485 i.putOperand(7+k*2+0, o); 486 } 487 /** 488 * Return the index of the k'th operand called Target 489 * in the argument instruction. 490 * @param i the instruction to access. 491 * @param k the index of the operand. 492 * @return the index of the k'th operand called Target 493 * in the argument instruction 494 */ 495 public static int indexOfTarget(Instruction i, int k) { 496 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 497 return 7+k*2+0; 498 } 499 /** 500 * Does the argument instruction have a non-null 501 * k'th operand named Target? 502 * @param i the instruction to access. 503 * @param k the index of the operand. 504 * @return <code>true</code> if the instruction has an non-null 505 * k'th operand named Target or <code>false</code> 506 * if it does not. 507 */ 508 public static boolean hasTarget(Instruction i, int k) { 509 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 510 return i.getOperand(7+k*2+0) != null; 511 } 512 513 /** 514 * Return the index of the first operand called Target 515 * in the argument instruction. 516 * @param i the instruction to access. 517 * @return the index of the first operand called Target 518 * in the argument instruction 519 */ 520 public static int indexOfTargets(Instruction i) 521 { 522 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 523 return 7; 524 } 525 /** 526 * Does the argument instruction have any operands 527 * named Target? 528 * @param i the instruction to access. 529 * @return <code>true</code> if the instruction has operands 530 * named Target or <code>false</code> if it does not. 531 */ 532 public static boolean hasTargets(Instruction i) 533 { 534 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 535 return i.getNumberOfOperands()-7 > 0 && i.getOperand(7) != null; 536 } 537 538 /** 539 * How many variable-length operands called Targets 540 * does the argument instruction have? 541 * @param i the instruction to access 542 * @return the number of operands called Targets the instruction has 543 */ 544 public static int getNumberOfTargets(Instruction i) 545 { 546 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 547 return (i.getNumberOfOperands()-7)/2; 548 } 549 550 /** 551 * Change the number of Targets that may be stored in 552 * the argument instruction to numVarOps. 553 * @param i the instruction to access 554 * @param numVarOps the new number of variable operands called Targets 555 * that may be stored in the instruction 556 */ 557 public static void resizeNumberOfTargets(Instruction i, int numVarOps) 558 { 559 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 560 if (7+numVarOps*2>MIN_OPERAND_ARRAY_LENGTH) 561 i.resizeNumberOfOperands(7+numVarOps*2); 562 else 563 for (int j = 7+numVarOps*2; j < MIN_OPERAND_ARRAY_LENGTH; j++) 564 i.putOperand(j, null); 565 } 566 /** 567 * Get the k'th operand called BranchProfile from the 568 * argument instruction. Note that the returned operand 569 * will still point to its containing instruction. 570 * @param i the instruction to fetch the operand from 571 * @param k the index of the operand 572 * @return the k'th operand called BranchProfile 573 */ 574 public static BranchProfileOperand getBranchProfile(Instruction i, int k) { 575 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 576 return (BranchProfileOperand) i.getOperand(7+k*2+1); 577 } 578 /** 579 * Get the k'th operand called BranchProfile from the argument 580 * instruction clearing its instruction pointer. The returned 581 * operand will not point to any containing instruction. 582 * @param i the instruction to fetch the operand from 583 * @param k the index of the operand 584 * @return the k'th operand called BranchProfile 585 */ 586 public static BranchProfileOperand getClearBranchProfile(Instruction i, int k) { 587 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 588 return (BranchProfileOperand) i.getClearOperand(7+k*2+1); 589 } 590 /** 591 * Set the k'th operand called BranchProfile in the argument 592 * instruction to the argument operand. The operand will 593 * now point to the argument instruction as its containing 594 * instruction. 595 * @param i the instruction in which to store the operand 596 * @param k the index of the operand 597 * @param o the operand to store 598 */ 599 public static void setBranchProfile(Instruction i, int k, BranchProfileOperand o) { 600 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 601 i.putOperand(7+k*2+1, o); 602 } 603 /** 604 * Return the index of the k'th operand called BranchProfile 605 * in the argument instruction. 606 * @param i the instruction to access. 607 * @param k the index of the operand. 608 * @return the index of the k'th operand called BranchProfile 609 * in the argument instruction 610 */ 611 public static int indexOfBranchProfile(Instruction i, int k) { 612 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 613 return 7+k*2+1; 614 } 615 /** 616 * Does the argument instruction have a non-null 617 * k'th operand named BranchProfile? 618 * @param i the instruction to access. 619 * @param k the index of the operand. 620 * @return <code>true</code> if the instruction has an non-null 621 * k'th operand named BranchProfile or <code>false</code> 622 * if it does not. 623 */ 624 public static boolean hasBranchProfile(Instruction i, int k) { 625 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 626 return i.getOperand(7+k*2+1) != null; 627 } 628 629 /** 630 * Return the index of the first operand called BranchProfile 631 * in the argument instruction. 632 * @param i the instruction to access. 633 * @return the index of the first operand called BranchProfile 634 * in the argument instruction 635 */ 636 public static int indexOfBranchProfiles(Instruction i) 637 { 638 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 639 return 8; 640 } 641 /** 642 * Does the argument instruction have any operands 643 * named BranchProfile? 644 * @param i the instruction to access. 645 * @return <code>true</code> if the instruction has operands 646 * named BranchProfile or <code>false</code> if it does not. 647 */ 648 public static boolean hasBranchProfiles(Instruction i) 649 { 650 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 651 return i.getNumberOfOperands()-8 > 0 && i.getOperand(8) != null; 652 } 653 654 /** 655 * How many variable-length operands called BranchProfiles 656 * does the argument instruction have? 657 * @param i the instruction to access 658 * @return the number of operands called BranchProfiles the instruction has 659 */ 660 public static int getNumberOfBranchProfiles(Instruction i) 661 { 662 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 663 return (i.getNumberOfOperands()-7)/2; 664 } 665 666 /** 667 * Change the number of BranchProfiles that may be stored in 668 * the argument instruction to numVarOps. 669 * @param i the instruction to access 670 * @param numVarOps the new number of variable operands called BranchProfiles 671 * that may be stored in the instruction 672 */ 673 public static void resizeNumberOfBranchProfiles(Instruction i, int numVarOps) 674 { 675 if (Configuration.ExtremeAssertions && !conforms(i)) fail(i, "TableSwitch"); 676 if (7+numVarOps*2>MIN_OPERAND_ARRAY_LENGTH) 677 i.resizeNumberOfOperands(7+numVarOps*2); 678 else 679 for (int j = 7+numVarOps*2; j < MIN_OPERAND_ARRAY_LENGTH; j++) 680 i.putOperand(j, null); 681 } 682 683 /** 684 * Create an instruction of the TableSwitch instruction format. 685 * @param o the instruction's operator 686 * @param Value the instruction's Value operand 687 * @param Unknown1 the instruction's Unknown1 operand 688 * @param Unknown2 the instruction's Unknown2 operand 689 * @param Low the instruction's Low operand 690 * @param High the instruction's High operand 691 * @param Default the instruction's Default operand 692 * @param DefaultBranchProfile the instruction's DefaultBranchProfile operand 693 * @param numVarOps the number of variable length operands that 694 * will be stored in the insruction. 695 * @return the newly created TableSwitch instruction 696 */ 697 public static Instruction create(Operator o 698 , Operand Value 699 , Operand Unknown1 700 , Operand Unknown2 701 , IntConstantOperand Low 702 , IntConstantOperand High 703 , BranchOperand Default 704 , BranchProfileOperand DefaultBranchProfile 705 , int numVarOps 706 ) 707 { 708 if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "TableSwitch"); 709 Instruction i = new Instruction(o, Math.max(7+numVarOps*2, MIN_OPERAND_ARRAY_LENGTH)); 710 i.putOperand(0, Value); 711 i.putOperand(1, Unknown1); 712 i.putOperand(2, Unknown2); 713 i.putOperand(3, Low); 714 i.putOperand(4, High); 715 i.putOperand(5, Default); 716 i.putOperand(6, DefaultBranchProfile); 717 return i; 718 } 719 720 /** 721 * Mutate the argument instruction into an instruction of the 722 * TableSwitch instruction format having the specified 723 * operator and operands. 724 * @param i the instruction to mutate 725 * @param o the instruction's operator 726 * @param Value the instruction's Value operand 727 * @param Unknown1 the instruction's Unknown1 operand 728 * @param Unknown2 the instruction's Unknown2 operand 729 * @param Low the instruction's Low operand 730 * @param High the instruction's High operand 731 * @param Default the instruction's Default operand 732 * @param DefaultBranchProfile the instruction's DefaultBranchProfile operand 733 * @param numVarOps the number of variable length operands that 734 * will be stored in the insruction. 735 * @return the mutated instruction 736 */ 737 public static Instruction mutate(Instruction i, Operator o 738 , Operand Value 739 , Operand Unknown1 740 , Operand Unknown2 741 , IntConstantOperand Low 742 , IntConstantOperand High 743 , BranchOperand Default 744 , BranchProfileOperand DefaultBranchProfile 745 , int numVarOps 746 ) 747 { 748 if (Configuration.ExtremeAssertions && !conforms(o)) fail(o, "TableSwitch"); 749 if (7+numVarOps*2>MIN_OPERAND_ARRAY_LENGTH) 750 i.resizeNumberOfOperands(7+numVarOps*2); 751 752 i.operator = o; 753 i.putOperand(0, Value); 754 i.putOperand(1, Unknown1); 755 i.putOperand(2, Unknown2); 756 i.putOperand(3, Low); 757 i.putOperand(4, High); 758 i.putOperand(5, Default); 759 i.putOperand(6, DefaultBranchProfile); 760 return i; 761 } 762 } 763