org.jikesrvm.compilers.opt.ir
Class Instruction

java.lang.Object
  extended by org.jikesrvm.compilers.opt.ir.Instruction
All Implemented Interfaces:
OptConstants, Operators, Constants, HeapLayoutConstants, ThinLockConstants, TIBLayoutConstants, SizeConstants

public final class Instruction
extends Object
implements Constants, Operators, OptConstants

Instructions are the basic atomic unit of the IR. An instruction contains an operator and (optionally) some operands. In addition, an instruction may (or may not) have valid bcIndex andposition fields that together encode a description of the bytecode that it came from.

Although we use a single class, Instruction, to implement all IR instructions, there are logically a number of different kinds of instructions. For example, binary operators, array loads, calls, and null_checks all have different number of operands with differing semantics. To manage this in an abstract, somewhat object-oriented, but still highly efficient fashion we have the notion of an Instruction Format. An Instruction Format is a class external to Instruction (defined in the instructionFormat package) that provides static methods to create instructions and symbolically access their operands. Every instance of Operator is assigned to exactly one Instruction Format. Thus, the instruction's operator implies which Instruction Format class can be used to access the instruction's operands.

There are some common logical operands (eg Result, Location) that appear in a large number of Instruction Formats. In addition to the basic Instruction Format classes, we provided additional classes (eg ResultCarrier, LocationCarrier) that allow manipulation of all instructions that contain a common operands.

A configuration (OptOptVIFcopyingGC) is defined in which all methods of all Instruction Format classes verify that the operator of the instruction being manipulated actually belongs to the appropriate Instruction Format. This configuration is quite slow, but is an important sanity check to make sure that Instruction Formats are being used in a consistent fashion.

The instruction's operator also has a number of traits. Methods on Instruction are provided to query these operator traits. In general, clients should use the methods of Instruction to query traits, since a particular instruction may override the operator-provided default in some cases. For example, isMove(), isBranch(), isPEI(), and isCall() are some of the trait queries.

Unfortunately, the combination of operators, operator traits, and Instruction Formats often leads to a tricky decision of which of three roughly equivalent idioms one should use when writing code that needs to manipulate instructions and their operands. For example,

 if (Call.conforms(instr)) {
    return Call.getResult(instr);
 }
 
and
 if (instr.operator() == CALL) {
    return Call.getResult(instr);
 }
 
and
 if (instr.isCall()) {
    return ResultCarrier.getResult(instr);
 }
 
are more or less the same. In some cases, picking an idiom is simply a matter of taste, but in others making the wrong choice can lead to code that is less robust or maintainable as operators and/or instruction formats are added and removed from the IR. One should always think carefully about which idiom is the most concise, maintainable, robust and efficient means of accomplishing a given task. Some general rules of thumb (or at least one person's opinion):

See Also:
Operator, Operand, BasicBlock

Nested Class Summary
private static class Instruction.BASE_OE
          Shared functionality for operand enumerations
private static class Instruction.MOE
          Enumerate the memory operands of an instruction
private static class Instruction.OE
          enumerate leaf operands in the given ranges
private static class Instruction.OEDefsOnly
          Enumerate the def operands of an instruction (ignores memory operands, since the contained operands of a MO are uses).
private static class Instruction.ROE
          Enumerate the root operands of an instruction
 
Field Summary
 int bcIndex
          The index of the bytecode that this instruction came from.
private static byte MARK1
          BITFIELD used to encode operatorInfo.
private static byte MARK2
          BITFIELD used to encode operatorInfo.
private  Instruction next
          The next instruction in the intra-basic-block list of instructions, will be null if no such instruction exists.
private static byte OI_GC
          BITFIELD used to encode operatorInfo.
private static byte OI_GC_VALID
          BITFIELD used to encode operatorInfo.
private static byte OI_INVALID
          BITFIELD used to encode operatorInfo.
private static byte OI_PEI
          BITFIELD used to encode operatorInfo.
private static byte OI_PEI_VALID
          BITFIELD used to encode operatorInfo.
 Operator operator
          The operator for this instruction.
private  byte operatorInfo
          Override and refine the operator-based trait (characteristic) information.
private  Operand[] ops
          The operands of this instruction.
 InlineSequence position
          A description of the tree of inlined methods that contains the bytecode that this instruction came from.
private  Instruction prev
          The previous instruction in the intra-basic-block list of instructions, will be null if no such instruction exists.
 int scratch
          A scratch word to be used as needed by analyses/optimizations to store information during an optimization.
 Object scratchObject
          A scratch object to be used as needed by analyses/optimizations to store information during an optimization.
 
Fields inherited from interface org.jikesrvm.Constants
NOT_REACHED, REFLECTION_FPRS_BITS, REFLECTION_FPRS_MASK, REFLECTION_GPRS_BITS, REFLECTION_GPRS_MASK
 
Fields inherited from interface org.jikesrvm.objectmodel.ThinLockConstants
TL_DEDICATED_U16_OFFSET, TL_DEDICATED_U16_SHIFT, TL_LOCK_COUNT_MASK, TL_LOCK_COUNT_SHIFT, TL_LOCK_COUNT_UNIT, TL_LOCK_ID_MASK, TL_LOCK_ID_SHIFT, TL_NUM_BITS_RC, TL_NUM_BITS_STAT, TL_NUM_BITS_TID, TL_STAT_BIASABLE, TL_STAT_FAT, TL_STAT_MASK, TL_STAT_SHIFT, TL_STAT_THIN, TL_THREAD_ID_MASK, TL_THREAD_ID_SHIFT, TL_UNLOCK_MASK
 
Fields inherited from interface org.jikesrvm.SizeConstants
BITS_IN_ADDRESS, BITS_IN_BOOLEAN, BITS_IN_BYTE, BITS_IN_CHAR, BITS_IN_DOUBLE, BITS_IN_EXTENT, BITS_IN_FLOAT, BITS_IN_INT, BITS_IN_LONG, BITS_IN_OFFSET, BITS_IN_PAGE, BITS_IN_SHORT, BITS_IN_WORD, BYTES_IN_ADDRESS, BYTES_IN_BOOLEAN, BYTES_IN_BYTE, BYTES_IN_CHAR, BYTES_IN_DOUBLE, BYTES_IN_EXTENT, BYTES_IN_FLOAT, BYTES_IN_INT, BYTES_IN_LONG, BYTES_IN_OFFSET, BYTES_IN_PAGE, BYTES_IN_SHORT, BYTES_IN_WORD, LOG_BITS_IN_ADDRESS, LOG_BITS_IN_BOOLEAN, LOG_BITS_IN_BYTE, LOG_BITS_IN_CHAR, LOG_BITS_IN_DOUBLE, LOG_BITS_IN_EXTENT, LOG_BITS_IN_FLOAT, LOG_BITS_IN_INT, LOG_BITS_IN_LONG, LOG_BITS_IN_OFFSET, LOG_BITS_IN_PAGE, LOG_BITS_IN_SHORT, LOG_BITS_IN_WORD, LOG_BYTES_IN_ADDRESS, LOG_BYTES_IN_BOOLEAN, LOG_BYTES_IN_BYTE, LOG_BYTES_IN_CHAR, LOG_BYTES_IN_DOUBLE, LOG_BYTES_IN_EXTENT, LOG_BYTES_IN_FLOAT, LOG_BYTES_IN_INT, LOG_BYTES_IN_LONG, LOG_BYTES_IN_OFFSET, LOG_BYTES_IN_PAGE, LOG_BYTES_IN_SHORT, LOG_BYTES_IN_WORD
 
Fields inherited from interface org.jikesrvm.objectmodel.TIBLayoutConstants
IMT_METHOD_SLOTS, NEEDS_DYNAMIC_LINK, TIB_ARRAY_ELEMENT_TIB_INDEX, TIB_DOES_IMPLEMENT_INDEX, TIB_FIRST_SPECIALIZED_METHOD_INDEX, TIB_FIRST_VIRTUAL_METHOD_INDEX, TIB_INTERFACE_DISPATCH_TABLE_INDEX, TIB_SUPERCLASS_IDS_INDEX, TIB_TYPE_INDEX
 
Fields inherited from interface org.jikesrvm.HeapLayoutConstants
BAD_MAP_COMPRESSION, BOOT_IMAGE_CODE_END, BOOT_IMAGE_CODE_SIZE, BOOT_IMAGE_CODE_START, BOOT_IMAGE_DATA_END, BOOT_IMAGE_DATA_SIZE, BOOT_IMAGE_DATA_START, BOOT_IMAGE_END, BOOT_IMAGE_RMAP_END, BOOT_IMAGE_RMAP_START, MAX_BOOT_IMAGE_RMAP_SIZE, MAXIMUM_MAPPABLE
 
Fields inherited from interface org.jikesrvm.compilers.opt.ir.Operators
ADDR_2INT, ADDR_2INT_opcode, ADDR_2LONG, ADDR_2LONG_opcode, ADDRESS_CONSTANT, ADDRESS_CONSTANT_opcode, ADVISE_ESP, ADVISE_ESP_opcode, ARCH_INDEPENDENT_END_opcode, ARRAYLENGTH, ARRAYLENGTH_opcode, ATHROW, ATHROW_opcode, ATTEMPT_ADDR, ATTEMPT_ADDR_opcode, ATTEMPT_INT, ATTEMPT_INT_opcode, ATTEMPT_LONG, ATTEMPT_LONG_opcode, BBEND, BBEND_opcode, BOOLEAN_CMP_ADDR, BOOLEAN_CMP_ADDR_opcode, BOOLEAN_CMP_DOUBLE, BOOLEAN_CMP_DOUBLE_opcode, BOOLEAN_CMP_FLOAT, BOOLEAN_CMP_FLOAT_opcode, BOOLEAN_CMP_INT, BOOLEAN_CMP_INT_opcode, BOOLEAN_CMP_LONG, BOOLEAN_CMP_LONG_opcode, BOOLEAN_NOT, BOOLEAN_NOT_opcode, BOUNDS_CHECK, BOUNDS_CHECK_opcode, BRANCH_TARGET, BRANCH_TARGET_opcode, BYTE_ALOAD, BYTE_ALOAD_opcode, BYTE_ASTORE, BYTE_ASTORE_opcode, BYTE_LOAD, BYTE_LOAD_opcode, BYTE_STORE, BYTE_STORE_opcode, CALL, CALL_opcode, CALL_SAVE_VOLATILE, CALL_SAVE_VOLATILE_opcode, CHECKCAST, CHECKCAST_NOTNULL, CHECKCAST_NOTNULL_opcode, CHECKCAST_opcode, CHECKCAST_UNRESOLVED, CHECKCAST_UNRESOLVED_opcode, CLEAR_FLOATING_POINT_STATE, CLEAR_FLOATING_POINT_STATE_opcode, CMP_CMOV, CMP_CMOV_opcode, CMP_FCMOV, CMP_FCMOV_opcode, DOUBLE_2FLOAT, DOUBLE_2FLOAT_opcode, DOUBLE_2INT, DOUBLE_2INT_opcode, DOUBLE_2LONG, DOUBLE_2LONG_opcode, DOUBLE_ADD, DOUBLE_ADD_opcode, DOUBLE_ALOAD, DOUBLE_ALOAD_opcode, DOUBLE_AS_LONG_BITS, DOUBLE_AS_LONG_BITS_opcode, DOUBLE_ASTORE, DOUBLE_ASTORE_opcode, DOUBLE_CMPG, DOUBLE_CMPG_opcode, DOUBLE_CMPL, DOUBLE_CMPL_opcode, DOUBLE_COND_MOVE, DOUBLE_COND_MOVE_opcode, DOUBLE_DIV, DOUBLE_DIV_opcode, DOUBLE_IFCMP, DOUBLE_IFCMP_opcode, DOUBLE_LOAD, DOUBLE_LOAD_opcode, DOUBLE_MOVE, DOUBLE_MOVE_opcode, DOUBLE_MUL, DOUBLE_MUL_opcode, DOUBLE_NEG, DOUBLE_NEG_opcode, DOUBLE_REM, DOUBLE_REM_opcode, DOUBLE_SQRT, DOUBLE_SQRT_opcode, DOUBLE_STORE, DOUBLE_STORE_opcode, DOUBLE_SUB, DOUBLE_SUB_opcode, DUMMY_DEF, DUMMY_DEF_opcode, DUMMY_USE, DUMMY_USE_opcode, FCMP_CMOV, FCMP_CMOV_opcode, FCMP_FCMOV, FCMP_FCMOV_opcode, FENCE, FENCE_opcode, FLOAT_2DOUBLE, FLOAT_2DOUBLE_opcode, FLOAT_2INT, FLOAT_2INT_opcode, FLOAT_2LONG, FLOAT_2LONG_opcode, FLOAT_ADD, FLOAT_ADD_opcode, FLOAT_ALOAD, FLOAT_ALOAD_opcode, FLOAT_AS_INT_BITS, FLOAT_AS_INT_BITS_opcode, FLOAT_ASTORE, FLOAT_ASTORE_opcode, FLOAT_CMPG, FLOAT_CMPG_opcode, FLOAT_CMPL, FLOAT_CMPL_opcode, FLOAT_COND_MOVE, FLOAT_COND_MOVE_opcode, FLOAT_DIV, FLOAT_DIV_opcode, FLOAT_IFCMP, FLOAT_IFCMP_opcode, FLOAT_LOAD, FLOAT_LOAD_opcode, FLOAT_MOVE, FLOAT_MOVE_opcode, FLOAT_MUL, FLOAT_MUL_opcode, FLOAT_NEG, FLOAT_NEG_opcode, FLOAT_REM, FLOAT_REM_opcode, FLOAT_SQRT, FLOAT_SQRT_opcode, FLOAT_STORE, FLOAT_STORE_opcode, FLOAT_SUB, FLOAT_SUB_opcode, FP_ADD, FP_ADD_opcode, FP_DIV, FP_DIV_opcode, FP_MUL, FP_MUL_opcode, FP_NEG, FP_NEG_opcode, FP_REM, FP_REM_opcode, FP_SUB, FP_SUB_opcode, GET_ARRAY_ELEMENT_TIB_FROM_TIB, GET_ARRAY_ELEMENT_TIB_FROM_TIB_opcode, GET_CAUGHT_EXCEPTION, GET_CAUGHT_EXCEPTION_opcode, GET_CLASS_TIB, GET_CLASS_TIB_opcode, GET_CURRENT_PROCESSOR, GET_CURRENT_PROCESSOR_opcode, GET_DOES_IMPLEMENT_FROM_TIB, GET_DOES_IMPLEMENT_FROM_TIB_opcode, GET_OBJ_TIB, GET_OBJ_TIB_opcode, GET_SUPERCLASS_IDS_FROM_TIB, GET_SUPERCLASS_IDS_FROM_TIB_opcode, GET_TIME_BASE, GET_TIME_BASE_opcode, GET_TYPE_FROM_TIB, GET_TYPE_FROM_TIB_opcode, GETFIELD, GETFIELD_opcode, GETSTATIC, GETSTATIC_opcode, GOTO, GOTO_opcode, GUARD_COMBINE, GUARD_COMBINE_opcode, GUARD_COND_MOVE, GUARD_COND_MOVE_opcode, GUARD_MOVE, GUARD_MOVE_opcode, helper, IA32_ADC, IA32_ADC_opcode, IA32_ADD, IA32_ADD_opcode, IA32_ADDSD, IA32_ADDSD_opcode, IA32_ADDSS, IA32_ADDSS_opcode, IA32_AND, IA32_AND_opcode, IA32_ANDNPD, IA32_ANDNPD_opcode, IA32_ANDNPS, IA32_ANDNPS_opcode, IA32_ANDPD, IA32_ANDPD_opcode, IA32_ANDPS, IA32_ANDPS_opcode, IA32_BSWAP, IA32_BSWAP_opcode, IA32_BT, IA32_BT_opcode, IA32_BTC, IA32_BTC_opcode, IA32_BTR, IA32_BTR_opcode, IA32_BTS, IA32_BTS_opcode, IA32_CALL, IA32_CALL_opcode, IA32_CDO, IA32_CDO_opcode, IA32_CDQ, IA32_CDQ_opcode, IA32_CDQE, IA32_CDQE_opcode, IA32_CMOV, IA32_CMOV_opcode, IA32_CMP, IA32_CMP_opcode, IA32_CMPEQSD, IA32_CMPEQSD_opcode, IA32_CMPEQSS, IA32_CMPEQSS_opcode, IA32_CMPLESD, IA32_CMPLESD_opcode, IA32_CMPLESS, IA32_CMPLESS_opcode, IA32_CMPLTSD, IA32_CMPLTSD_opcode, IA32_CMPLTSS, IA32_CMPLTSS_opcode, IA32_CMPNESD, IA32_CMPNESD_opcode, IA32_CMPNESS, IA32_CMPNESS_opcode, IA32_CMPNLESD, IA32_CMPNLESD_opcode, IA32_CMPNLESS, IA32_CMPNLESS_opcode, IA32_CMPNLTSD, IA32_CMPNLTSD_opcode, IA32_CMPNLTSS, IA32_CMPNLTSS_opcode, IA32_CMPORDSD, IA32_CMPORDSD_opcode, IA32_CMPORDSS, IA32_CMPORDSS_opcode, IA32_CMPUNORDSD, IA32_CMPUNORDSD_opcode, IA32_CMPUNORDSS, IA32_CMPUNORDSS_opcode, IA32_CMPXCHG, IA32_CMPXCHG_opcode, IA32_CMPXCHG8B, IA32_CMPXCHG8B_opcode, IA32_CVTSD2SI, IA32_CVTSD2SI_opcode, IA32_CVTSD2SIQ, IA32_CVTSD2SIQ_opcode, IA32_CVTSD2SS, IA32_CVTSD2SS_opcode, IA32_CVTSI2SD, IA32_CVTSI2SD_opcode, IA32_CVTSI2SDQ, IA32_CVTSI2SDQ_opcode, IA32_CVTSI2SS, IA32_CVTSI2SS_opcode, IA32_CVTSS2SD, IA32_CVTSS2SD_opcode, IA32_CVTSS2SI, IA32_CVTSS2SI_opcode, IA32_CVTTSD2SI, IA32_CVTTSD2SI_opcode, IA32_CVTTSD2SIQ, IA32_CVTTSD2SIQ_opcode, IA32_CVTTSS2SI, IA32_CVTTSS2SI_opcode, IA32_DEC, IA32_DEC_opcode, IA32_DIV, IA32_DIV_opcode, IA32_DIVSD, IA32_DIVSD_opcode, IA32_DIVSS, IA32_DIVSS_opcode, IA32_FADD, IA32_FADD_opcode, IA32_FADDP, IA32_FADDP_opcode, IA32_FCHS, IA32_FCHS_opcode, IA32_FCLEAR, IA32_FCLEAR_opcode, IA32_FCMOV, IA32_FCMOV_opcode, IA32_FCOMI, IA32_FCOMI_opcode, IA32_FCOMIP, IA32_FCOMIP_opcode, IA32_FDIV, IA32_FDIV_opcode, IA32_FDIVP, IA32_FDIVP_opcode, IA32_FDIVR, IA32_FDIVR_opcode, IA32_FDIVRP, IA32_FDIVRP_opcode, IA32_FEXAM, IA32_FEXAM_opcode, IA32_FFREE, IA32_FFREE_opcode, IA32_FIADD, IA32_FIADD_opcode, IA32_FIDIV, IA32_FIDIV_opcode, IA32_FIDIVR, IA32_FIDIVR_opcode, IA32_FILD, IA32_FILD_opcode, IA32_FIMUL, IA32_FIMUL_opcode, IA32_FINIT, IA32_FINIT_opcode, IA32_FIST, IA32_FIST_opcode, IA32_FISTP, IA32_FISTP_opcode, IA32_FISUB, IA32_FISUB_opcode, IA32_FISUBR, IA32_FISUBR_opcode, IA32_FLD, IA32_FLD_opcode, IA32_FLD1, IA32_FLD1_opcode, IA32_FLDCW, IA32_FLDCW_opcode, IA32_FLDL2E, IA32_FLDL2E_opcode, IA32_FLDL2T, IA32_FLDL2T_opcode, IA32_FLDLG2, IA32_FLDLG2_opcode, IA32_FLDLN2, IA32_FLDLN2_opcode, IA32_FLDPI, IA32_FLDPI_opcode, IA32_FLDZ, IA32_FLDZ_opcode, IA32_FMOV, IA32_FMOV_ENDING_LIVE_RANGE, IA32_FMOV_ENDING_LIVE_RANGE_opcode, IA32_FMOV_opcode, IA32_FMUL, IA32_FMUL_opcode, IA32_FMULP, IA32_FMULP_opcode, IA32_FNINIT, IA32_FNINIT_opcode, IA32_FNSAVE, IA32_FNSAVE_opcode, IA32_FNSTCW, IA32_FNSTCW_opcode, IA32_FPREM, IA32_FPREM_opcode, IA32_FRSTOR, IA32_FRSTOR_opcode, IA32_FST, IA32_FST_opcode, IA32_FSTCW, IA32_FSTCW_opcode, IA32_FSTP, IA32_FSTP_opcode, IA32_FSUB, IA32_FSUB_opcode, IA32_FSUBP, IA32_FSUBP_opcode, IA32_FSUBR, IA32_FSUBR_opcode, IA32_FSUBRP, IA32_FSUBRP_opcode, IA32_FUCOMI, IA32_FUCOMI_opcode, IA32_FUCOMIP, IA32_FUCOMIP_opcode, IA32_FXCH, IA32_FXCH_opcode, IA32_IDIV, IA32_IDIV_opcode, IA32_IMUL1, IA32_IMUL1_opcode, IA32_IMUL2, IA32_IMUL2_opcode, IA32_INC, IA32_INC_opcode, IA32_INT, IA32_INT_opcode, IA32_JCC, IA32_JCC_opcode, IA32_JCC2, IA32_JCC2_opcode, IA32_JMP, IA32_JMP_opcode, IA32_LEA, IA32_LEA_opcode, IA32_LOCK, IA32_LOCK_CMPXCHG, IA32_LOCK_CMPXCHG_opcode, IA32_LOCK_CMPXCHG8B, IA32_LOCK_CMPXCHG8B_opcode, IA32_LOCK_opcode, IA32_METHODSTART, IA32_METHODSTART_opcode, IA32_MFENCE, IA32_MFENCE_opcode, IA32_MOV, IA32_MOV_opcode, IA32_MOVD, IA32_MOVD_opcode, IA32_MOVLPD, IA32_MOVLPD_opcode, IA32_MOVLPS, IA32_MOVLPS_opcode, IA32_MOVQ, IA32_MOVQ_opcode, IA32_MOVSD, IA32_MOVSD_opcode, IA32_MOVSS, IA32_MOVSS_opcode, IA32_MOVSX__B, IA32_MOVSX__B_opcode, IA32_MOVSX__W, IA32_MOVSX__W_opcode, IA32_MOVSXQ__B, IA32_MOVSXQ__B_opcode, IA32_MOVSXQ__W, IA32_MOVSXQ__W_opcode, IA32_MOVZX__B, IA32_MOVZX__B_opcode, IA32_MOVZX__W, IA32_MOVZX__W_opcode, IA32_MOVZXQ__B, IA32_MOVZXQ__B_opcode, IA32_MOVZXQ__W, IA32_MOVZXQ__W_opcode, IA32_MUL, IA32_MUL_opcode, IA32_MULSD, IA32_MULSD_opcode, IA32_MULSS, IA32_MULSS_opcode, IA32_NEG, IA32_NEG_opcode, IA32_NOT, IA32_NOT_opcode, IA32_OFFSET, IA32_OFFSET_opcode, IA32_OR, IA32_OR_opcode, IA32_ORPD, IA32_ORPD_opcode, IA32_ORPS, IA32_ORPS_opcode, IA32_PAUSE, IA32_PAUSE_opcode, IA32_POP, IA32_POP_opcode, IA32_PREFETCHNTA, IA32_PREFETCHNTA_opcode, IA32_PSLLQ, IA32_PSLLQ_opcode, IA32_PSRLQ, IA32_PSRLQ_opcode, IA32_PUSH, IA32_PUSH_opcode, IA32_RCL, IA32_RCL_opcode, IA32_RCR, IA32_RCR_opcode, IA32_RDTSC, IA32_RDTSC_opcode, IA32_RET, IA32_RET_opcode, IA32_ROL, IA32_ROL_opcode, IA32_ROR, IA32_ROR_opcode, IA32_SAL, IA32_SAL_opcode, IA32_SAR, IA32_SAR_opcode, IA32_SBB, IA32_SBB_opcode, IA32_SET__B, IA32_SET__B_opcode, IA32_SHL, IA32_SHL_opcode, IA32_SHLD, IA32_SHLD_opcode, IA32_SHR, IA32_SHR_opcode, IA32_SHRD, IA32_SHRD_opcode, IA32_SQRTSD, IA32_SQRTSD_opcode, IA32_SQRTSS, IA32_SQRTSS_opcode, IA32_SUB, IA32_SUB_opcode, IA32_SUBSD, IA32_SUBSD_opcode, IA32_SUBSS, IA32_SUBSS_opcode, IA32_SYSCALL, IA32_SYSCALL_opcode, IA32_TEST, IA32_TEST_opcode, IA32_TRAPIF, IA32_TRAPIF_opcode, IA32_UCOMISD, IA32_UCOMISD_opcode, IA32_UCOMISS, IA32_UCOMISS_opcode, IA32_XOR, IA32_XOR_opcode, IA32_XORPD, IA32_XORPD_opcode, IA32_XORPS, IA32_XORPS_opcode, IG_CLASS_TEST, IG_CLASS_TEST_opcode, IG_METHOD_TEST, IG_METHOD_TEST_opcode, IG_PATCH_POINT, IG_PATCH_POINT_opcode, INSTANCEOF, INSTANCEOF_NOTNULL, INSTANCEOF_NOTNULL_opcode, INSTANCEOF_opcode, INSTANCEOF_UNRESOLVED, INSTANCEOF_UNRESOLVED_opcode, INSTRUMENTED_EVENT_COUNTER, INSTRUMENTED_EVENT_COUNTER_opcode, INT_2ADDRSigExt, INT_2ADDRSigExt_opcode, INT_2ADDRZerExt, INT_2ADDRZerExt_opcode, INT_2BYTE, INT_2BYTE_opcode, INT_2DOUBLE, INT_2DOUBLE_opcode, INT_2FLOAT, INT_2FLOAT_opcode, INT_2FP, INT_2FP_opcode, INT_2LONG, INT_2LONG_opcode, INT_2SHORT, INT_2SHORT_opcode, INT_2USHORT, INT_2USHORT_opcode, INT_ADD, INT_ADD_opcode, INT_ALOAD, INT_ALOAD_opcode, INT_AND, INT_AND_opcode, INT_ASTORE, INT_ASTORE_opcode, INT_BITS_AS_FLOAT, INT_BITS_AS_FLOAT_opcode, INT_COND_MOVE, INT_COND_MOVE_opcode, INT_CONSTANT, INT_CONSTANT_opcode, INT_DIV, INT_DIV_opcode, INT_IFCMP, INT_IFCMP_opcode, INT_IFCMP2, INT_IFCMP2_opcode, INT_LOAD, INT_LOAD_opcode, INT_MOVE, INT_MOVE_opcode, INT_MUL, INT_MUL_opcode, INT_NEG, INT_NEG_opcode, INT_NOT, INT_NOT_opcode, INT_OR, INT_OR_opcode, INT_REM, INT_REM_opcode, INT_SHL, INT_SHL_opcode, INT_SHR, INT_SHR_opcode, INT_STORE, INT_STORE_opcode, INT_SUB, INT_SUB_opcode, INT_USHR, INT_USHR_opcode, INT_XOR, INT_XOR_opcode, INT_ZERO_CHECK, INT_ZERO_CHECK_opcode, IR_PROLOGUE, IR_PROLOGUE_opcode, LABEL, LABEL_opcode, LCMP_CMOV, LCMP_CMOV_opcode, LONG_2ADDR, LONG_2ADDR_opcode, LONG_2DOUBLE, LONG_2DOUBLE_opcode, LONG_2FLOAT, LONG_2FLOAT_opcode, LONG_2FP, LONG_2FP_opcode, LONG_2INT, LONG_2INT_opcode, LONG_ADD, LONG_ADD_opcode, LONG_ALOAD, LONG_ALOAD_opcode, LONG_AND, LONG_AND_opcode, LONG_ASTORE, LONG_ASTORE_opcode, LONG_BITS_AS_DOUBLE, LONG_BITS_AS_DOUBLE_opcode, LONG_CMP, LONG_CMP_opcode, LONG_COND_MOVE, LONG_COND_MOVE_opcode, LONG_CONSTANT, LONG_CONSTANT_opcode, LONG_DIV, LONG_DIV_opcode, LONG_IFCMP, LONG_IFCMP_opcode, LONG_LOAD, LONG_LOAD_opcode, LONG_MOVE, LONG_MOVE_opcode, LONG_MUL, LONG_MUL_opcode, LONG_NEG, LONG_NEG_opcode, LONG_NOT, LONG_NOT_opcode, LONG_OR, LONG_OR_opcode, LONG_REM, LONG_REM_opcode, LONG_SHL, LONG_SHL_opcode, LONG_SHR, LONG_SHR_opcode, LONG_STORE, LONG_STORE_opcode, LONG_SUB, LONG_SUB_opcode, LONG_USHR, LONG_USHR_opcode, LONG_XOR, LONG_XOR_opcode, LONG_ZERO_CHECK, LONG_ZERO_CHECK_opcode, LOOKUPSWITCH, LOOKUPSWITCH_opcode, LOWTABLESWITCH, LOWTABLESWITCH_opcode, MATERIALIZE_FP_CONSTANT, MATERIALIZE_FP_CONSTANT_opcode, MIR_END, MIR_END_opcode, MIR_LOWTABLESWITCH, MIR_LOWTABLESWITCH_opcode, MIR_START, MIR_START_opcode, MONITORENTER, MONITORENTER_opcode, MONITOREXIT, MONITOREXIT_opcode, MUST_IMPLEMENT_INTERFACE, MUST_IMPLEMENT_INTERFACE_opcode, NEW, NEW_opcode, NEW_UNRESOLVED, NEW_UNRESOLVED_opcode, NEWARRAY, NEWARRAY_opcode, NEWARRAY_UNRESOLVED, NEWARRAY_UNRESOLVED_opcode, NEWOBJMULTIARRAY, NEWOBJMULTIARRAY_opcode, NOP, NOP_opcode, NULL, NULL_CHECK, NULL_CHECK_opcode, NULL_opcode, OBJARRAY_STORE_CHECK, OBJARRAY_STORE_CHECK_NOTNULL, OBJARRAY_STORE_CHECK_NOTNULL_opcode, OBJARRAY_STORE_CHECK_opcode, OSR_BARRIER, OSR_BARRIER_opcode, OTHER_OPERAND, OTHER_OPERAND_opcode, PAUSE, PAUSE_opcode, PHI, PHI_opcode, PI, PI_opcode, PREFETCH, PREFETCH_opcode, PREPARE_ADDR, PREPARE_ADDR_opcode, PREPARE_INT, PREPARE_INT_opcode, PREPARE_LONG, PREPARE_LONG_opcode, PUTFIELD, PUTFIELD_opcode, PUTSTATIC, PUTSTATIC_opcode, READ_CEILING, READ_CEILING_opcode, REF_ADD, REF_ADD_opcode, REF_ALOAD, REF_ALOAD_opcode, REF_AND, REF_AND_opcode, REF_ASTORE, REF_ASTORE_opcode, REF_COND_MOVE, REF_COND_MOVE_opcode, REF_IFCMP, REF_IFCMP_opcode, REF_LOAD, REF_LOAD_opcode, REF_MOVE, REF_MOVE_opcode, REF_NEG, REF_NEG_opcode, REF_NOT, REF_NOT_opcode, REF_OR, REF_OR_opcode, REF_SHL, REF_SHL_opcode, REF_SHR, REF_SHR_opcode, REF_STORE, REF_STORE_opcode, REF_SUB, REF_SUB_opcode, REF_USHR, REF_USHR_opcode, REF_XOR, REF_XOR_opcode, REGISTER, REGISTER_opcode, REQUIRE_ESP, REQUIRE_ESP_opcode, RESOLVE, RESOLVE_MEMBER, RESOLVE_MEMBER_opcode, RESOLVE_opcode, RETURN, RETURN_opcode, ROUND_TO_ZERO, ROUND_TO_ZERO_opcode, SET_CAUGHT_EXCEPTION, SET_CAUGHT_EXCEPTION_opcode, SHORT_ALOAD, SHORT_ALOAD_opcode, SHORT_ASTORE, SHORT_ASTORE_opcode, SHORT_LOAD, SHORT_LOAD_opcode, SHORT_STORE, SHORT_STORE_opcode, SPLIT, SPLIT_opcode, SYSCALL, SYSCALL_opcode, TABLESWITCH, TABLESWITCH_opcode, TRAP, TRAP_IF, TRAP_IF_opcode, TRAP_opcode, UBYTE_ALOAD, UBYTE_ALOAD_opcode, UBYTE_LOAD, UBYTE_LOAD_opcode, UNINT_BEGIN, UNINT_BEGIN_opcode, UNINT_END, UNINT_END_opcode, USHORT_ALOAD, USHORT_ALOAD_opcode, USHORT_LOAD, USHORT_LOAD_opcode, WRITE_FLOOR, WRITE_FLOOR_opcode, YIELDPOINT_BACKEDGE, YIELDPOINT_BACKEDGE_opcode, YIELDPOINT_EPILOGUE, YIELDPOINT_EPILOGUE_opcode, YIELDPOINT_OSR, YIELDPOINT_OSR_opcode, YIELDPOINT_PROLOGUE, YIELDPOINT_PROLOGUE_opcode
 
Fields inherited from interface org.jikesrvm.compilers.opt.driver.OptConstants
EPILOGUE_BCI, EPILOGUE_BLOCK_BCI, EXTANT_ANALYSIS_BCI, INSTRUMENTATION_BCI, MAYBE, METHOD_COUNTER_BCI, NO, OSR_PROLOGUE, PROLOGUE_BCI, PROLOGUE_BLOCK_BCI, RECTIFY_BCI, RUNTIME_SERVICES_BCI, SSA_SYNTH_BCI, SYNCHRONIZED_MONITORENTER_BCI, SYNCHRONIZED_MONITOREXIT_BCI, SYNTH_CATCH_BCI, SYNTH_LOOP_VERSIONING_BCI, UNKNOWN_BCI, YES
 
Constructor Summary
Instruction(Operator op, int size)
          INTERNAL IR USE ONLY: create a new instruction with the specified number of operands.
 
Method Summary
 void BURS_backdoor_linkWithNext(Instruction other)
          Allow BURS a back door into linkWithNext.
(package private)  void clearLinks()
          For IR internal use only; general clients should always use higer level mutation functions.
(package private)  void clearMark1()
          Clear the first mark bit of the instruction.
(package private)  void clearMark2()
          Clear the second mark bit of the instruction.
 void copyPosition(Instruction source)
          Set the source position description (bcIndex, position) for this instruction to be the same as the source instruction's source position description.
 Instruction copyWithoutLinks()
          Create a copy of this instruction.
 void flipBranchProbability()
          Invert the probabilty of this branch being taken.
 BasicBlock getBasicBlock()
          Get the basic block that contains this instruction.
 float getBranchProbability()
          Return the probability (in the range 0.0 - 1.0) that this two-way branch instruction is taken (as opposed to falling through).
 BasicBlock getBranchTarget()
          Returns the basic block jumped to by this BRANCH instruction.
 Enumeration<BasicBlock> getBranchTargets()
          Return an enumeration of the basic blocks that are targets of this branch instruction.
 int getBytecodeIndex()
          Get the bytecode index of the instruction.
 Operand getClearOperand(int i)
          NOTE: It is incorrect to use getClearOperand with a constant argument outside of the automatically generated code in Operators.
 Enumeration<Operand> getDefs()
          Enumerate all defs (both pure defs and def/uses) of an instruction.
 Enumeration<Operand> getDefUses()
          Enumerate all the def/uses of an instruction.
 int getmcOffset()
          Get the offset into the machine code array (in bytes) that corresponds to the first byte after this instruction.
 Enumeration<Operand> getMemoryOperands()
          Enumerate all memory operands of an instruction
(package private)  Instruction getNext()
          For IR internal use only; general clients should use nextInstructionInCodeOrder().
 int getNumberOfDefs()
          Returns the number of operands that are defs (either pure defs or combined def/uses).
 int getNumberOfOperands()
          Get the number of operands in this instruction.
private  int getNumberOfOperandsVarUsesOrDefs()
           
 int getNumberOfPureDefs()
          Returns the number of operands that are pure defs.
 int getNumberOfPureUses()
          Returns the number of operands that are pure uses.
 int getNumberOfUses()
          Returns the number of operands that are uses (either combined def/uses or pure uses).
 char getOpcode()
          Return the opcode of the instruction's operator (a unique id suitable for use in switches); see Operator.opcode.
 Operand getOperand(int i)
          NOTE: It is incorrect to use getOperand with a constant argument outside of the automatically generated code in Operators.
 Enumeration<Operand> getOperands()
          Enumerate all "leaf" operands of an instruction.
(package private)  Instruction getPrev()
          For IR internal use only; General clients should use prevInstructionInCodeOrder().
 Enumeration<Operand> getPureDefs()
          Enumerate all the pure defs (ie not including def/uses) of an instruction.
 Enumeration<Operand> getPureUses()
          Enumerate all the pure uses (ie not including def/uses) of an instruction.
 Enumeration<Operand> getRootOperands()
          Enumerate all the root operands of an instruction (DOES NOT ENUMERATE CONTAINED OPERANDS OF MEMORY OPERANDS).
 Enumeration<Operand> getRootUses()
          Enumerate all root uses of an instruction.
 Enumeration<Operand> getUses()
          Enumerate all uses of an instruction (includes def/use).
 boolean hasMemoryOperand()
          Does this instruction hold any memory or stack location operands?
 boolean hasPrev()
           
 void insertAfter(Instruction newInstr)
          Insertion: Insert newInstr immediately after this in the instruction stream.
 void insertBefore(Instruction newInstr)
          Insertion: Insert newInstr immediately before this in the instruction stream.
 boolean isAcquire()
          Is the instruction an acquire (monitorenter/lock)?
 boolean isAllocation()
          Is the instruction an actual memory allocation instruction (NEW, NEWARRAY, etc)?
private  void isBackwardLinked()
           
 boolean isBbFirst()
          Return true if this instruction is the first instruction in a basic block.
 boolean isBbInside()
          Mainly intended for assertion checking; returns true if the instruction is expected to appear on the "inside" of a basic block, false otherwise.
 boolean isBbLast()
          Return true if this instruction is the last instruction in a basic block.
 boolean isBranch()
          Is the instruction an intraprocedural branch?
 boolean isCall()
          Is the instruction a call (one kind of interprocedural branch)?
 boolean isCompare()
          Is the instruction a compare (val,val) => condition?
 boolean isConditionalBranch()
          Is the instruction a conditional intraprocedural branch?
 boolean isConditionalCall()
          Is the instruction a conditional call?
 boolean isDirectBranch()
          Is the instruction a direct intraprocedural branch?
 boolean isDirectCalll()
          Is the instruction a direct call?
 boolean isDynamicLinkingPoint()
          Could the instruction either directly or indirectly cause dynamic class loading?
 boolean isExplicitLoad()
          Is the instruction an explicit load of a finite set of values from a finite set of memory locations (load, load multiple, _not_ call)?
 boolean isExplicitStore()
          Is the instruction an explicit store of a finite set of values to a finite set of memory locations (store, store multiple, _not_ call)?
private  void isForwardLinked()
           
 boolean isGCPoint()
          Is the instruction a potential GC point?
 boolean isImplicitLoad()
          Should the instruction be treated as a load from some unknown location(s) for the purposes of scheduling and/or modeling the memory subsystem?
 boolean isImplicitStore()
          Should the instruction be treated as a store to some unknown location(s) for the purposes of scheduling and/or modeling the memory subsystem?
 boolean isIndirectBranch()
          Is the instruction an indirect intraprocedural branch?
 boolean isIndirectCall()
          Is the instruction an indirect call?
private  void isLinked()
           
(package private)  boolean isMarked1()
          Is the first mark bit of the instruction set?
(package private)  boolean isMarked2()
          Is the second mark bit of the instruction set?
 boolean isMarkedAsPEI()
          Has the instruction been explictly marked as a a PEI (Potentially Excepting Instruction)?
 boolean isMove()
          Does the instruction represent a simple move (the value is unchanged) from one "register" location to another "register" location?
 boolean isNonPureCall()
          Is the instruction a call but not a pure call (one kind of interprocedural branch)?
private  void isNotLinked()
           
 boolean isPEI()
          Is the instruction a PEI (Potentially Excepting Instruction)?
 boolean isPureCall()
          Is the instruction a pure call (one kind of interprocedural branch)?
 boolean isRelease()
          Is the instruction a release (monitorexit/unlock)?
 boolean isReturn()
          Is the instruction a return (interprocedural branch)?
 boolean isThrow()
          Is the instruction a throw of a Java exception?
 boolean isTSPoint()
          Is the instruction a potential thread switch point?
 boolean isTwoWayBranch()
          Is this instruction a branch that has that has only two possible successors?
 boolean isUnconditionalBranch()
          Is the instruction an unconditional intraprocedural branch?
 boolean isUnconditionalCall()
          Is the instruction an unconditional call?
 boolean isYieldPoint()
          Is the instruction a yield point?
(package private)  void linkWithNext(Instruction other)
          For IR internal use only; general clients should always use higer level mutation functions.
 void markAsGCPoint()
          NOTE: ONLY FOR USE ON MIR INSTRUCTIONS!!!!
 void markAsNonGCPoint()
          NOTE: ONLY FOR USE ON MIR INSTRUCTIONS!!!!
 void markAsNonPEI()
          Record that this instruction is not a PEI.
 void markAsNonPEINonGCPoint()
          NOTE: ONLY FOR USE ON MIR INSTRUCTIONS!!!!
 void markAsPEI()
          NOTE: ONLY FOR USE ON MIR INSTRUCTIONS!!!!
 boolean mayBeVolatileFieldLoad()
          Might this instruction be a load from a field that is declared to be volatile?
 Instruction nextInstructionInCodeOrder()
          Return the next instruction with respect to the current code linearization order.
 Operator operator()
          Return the instruction's operator.
private  Operand outOfLineCopy(Operand op)
           
 Instruction prevInstructionInCodeOrder()
          Return the previous instruction with respect to the current code linearization order.
 void putOperand(int i, Operand op)
          NOTE: It is incorrect to use putOperand with a constant argument outside of the automatically generated code in Operators.
 Instruction remove()
          Removal: Remove this from the instruction stream.
 void replace(Instruction newInstr)
          Replacement: Replace this with newInstr.
 void replaceOperand(Operand oldOp, Operand newOp)
          Replace all occurances of the first operand with the second.
 void replaceRegister(Register r, Register n)
          Replace all occurances of register r with register n
 void replaceSimilarOperands(Operand oldOp, Operand newOp)
          Replace any operands that are similar to the first operand with a copy of the second operand.
(package private)  void resizeNumberOfOperands(int newSize)
          Enlarge the number of operands in this instruction, if necessary.
 void setBranchProbability(float takenProbability)
          Record the probability (in the range 0.0 - 1.0) that this two-way branch instruction is taken (as opposed to falling through).
 void setBytecodeIndex(int bci)
          Set the bytecode index of the instruction.
(package private)  void setMark1()
          Set the first mark bit of the instruction.
(package private)  void setMark2()
          Set the second mark bit of the instruction.
 void setmcOffset(int mcOffset)
          Only for use by AssemblerBase.generateCode(org.jikesrvm.compilers.opt.ir.IR, boolean); sets the machine code offset of the instruction as described in getmcOffset().
(package private)  void setNext(Instruction n)
          For IR internal use only; general clients should always use higer level mutation functions.
(package private)  void setPrev(Instruction p)
          For IR internal use only; general clients should always use higer level mutation functions.
 boolean similar(Instruction similarInstr)
          Are two instructions similar, i.e. having the same operator and the same number of similar operands?
 String toString()
          Returns the string representation of this instruction (mainly intended for use when printing the IR).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OI_INVALID

private static final byte OI_INVALID
BITFIELD used to encode operatorInfo. NB: OI_INVALID must be default value!

See Also:
Constant Field Values

OI_PEI_VALID

private static final byte OI_PEI_VALID
BITFIELD used to encode operatorInfo.

See Also:
Constant Field Values

OI_PEI

private static final byte OI_PEI
BITFIELD used to encode operatorInfo.

See Also:
Constant Field Values

OI_GC_VALID

private static final byte OI_GC_VALID
BITFIELD used to encode operatorInfo.

See Also:
Constant Field Values

OI_GC

private static final byte OI_GC
BITFIELD used to encode operatorInfo.

See Also:
Constant Field Values

MARK1

private static final byte MARK1
BITFIELD used to encode operatorInfo.

See Also:
Constant Field Values

MARK2

private static final byte MARK2
BITFIELD used to encode operatorInfo.

See Also:
Constant Field Values

bcIndex

public int bcIndex
The index of the bytecode that this instruction came from. In combination with the position, the bcIndex field uniquely identifies the source position of the bytecode that this instruction came from.


position

public InlineSequence position
A description of the tree of inlined methods that contains the bytecode that this instruction came from.

In combination with the bcIndex, the position field uniquely identifies the source position of the bytecode that this instruction came from.

A single position operator can be shared by many instruction objects.

See Also:
InlineSequence, OptEncodedCallSiteTree

scratch

public int scratch
A scratch word to be used as needed by analyses/optimizations to store information during an optimization.

Cannot be used to communicate information between compiler phases since any phase is allowed to mutate it.

Cannot safely be assumed to have a particular value at the start of a phase.

Typical uses:


scratchObject

public Object scratchObject
A scratch object to be used as needed by analyses/optimizations to store information during an optimization.

Cannot be used to communicate information between compiler phases since any phase is allowed to mutate it.

Cannot safely be assumed to have a particular value at the start of a phase.

To be used when more than one word of information is needed and lookaside arrays are not desirable.

Typical uses: attribute objects or links to shared data


operator

public Operator operator
The operator for this instruction.

The preferred idiom is to use the operator() accessor method instead of accessing this field directly, but we are still in the process of updating old code.

The same operator object can be shared by many instruction objects.

TODO: finish conversion and make this field private.


next

private Instruction next
The next instruction in the intra-basic-block list of instructions, will be null if no such instruction exists.


prev

private Instruction prev
The previous instruction in the intra-basic-block list of instructions, will be null if no such instruction exists.


operatorInfo

private byte operatorInfo
Override and refine the operator-based trait (characteristic) information.

See Also:
Operator

ops

private Operand[] ops
The operands of this instruction.

Constructor Detail

Instruction

Instruction(Operator op,
            int size)
INTERNAL IR USE ONLY: create a new instruction with the specified number of operands.

For internal use only -- general clients must use the appropriate InstructionFormat class's create and mutate methods to create instruction objects!!!

Parameters:
op - operator
size - number of operands
Method Detail

copyWithoutLinks

public Instruction copyWithoutLinks()
Create a copy of this instruction. The copy has the same operator and operands, but is not linked into an instruction list.

Returns:
the copy

toString

public String toString()
Returns the string representation of this instruction (mainly intended for use when printing the IR).

Overrides:
toString in class Object
Returns:
string representation of this instruction.

nextInstructionInCodeOrder

public Instruction nextInstructionInCodeOrder()
Return the next instruction with respect to the current code linearization order.

Returns:
the next instruction in the code order or null if no such instruction exists

prevInstructionInCodeOrder

public Instruction prevInstructionInCodeOrder()
Return the previous instruction with respect to the current code linearization order.

Returns:
the previous instruction in the code order or null if no such instruction exists

hasPrev

public boolean hasPrev()
Returns:
has this instruction been linked with a previous instruction? ie will calls to insertBefore succeed?

getBasicBlock

public BasicBlock getBasicBlock()
Get the basic block that contains this instruction. Note: this instruction takes O(1) time for LABEL and BBEND instructions, but will take O(# of instrs in the block) for all other instructions. Therefore, although it can be used on any instruction, care must be taken when using it to avoid doing silly O(N^2) work for what could be done in O(N) work.


copyPosition

public void copyPosition(Instruction source)
Set the source position description (bcIndex, position) for this instruction to be the same as the source instruction's source position description.

Parameters:
source - the instruction to copy the source position from

getBytecodeIndex

public int getBytecodeIndex()
Get the bytecode index of the instruction.

Returns:
the bytecode index of the instruction

setBytecodeIndex

public void setBytecodeIndex(int bci)
Set the bytecode index of the instruction.

Parameters:
bci - the new bytecode index

getmcOffset

public int getmcOffset()
Get the offset into the machine code array (in bytes) that corresponds to the first byte after this instruction.

This method only returns a valid value after it has been set as a side-effect of final assembly.

To get the offset in INSTRUCTIONs you must shift by LG_INSTURUCTION_SIZE.

Returns:
the offset (in bytes) of the machinecode instruction generated for this IR instruction in the final machinecode

setmcOffset

public void setmcOffset(int mcOffset)
Only for use by AssemblerBase.generateCode(org.jikesrvm.compilers.opt.ir.IR, boolean); sets the machine code offset of the instruction as described in getmcOffset().

Parameters:
mcOffset - the offset (in bytes) for this instruction.

operator

public Operator operator()
Return the instruction's operator.

Returns:
the operator

getOpcode

public char getOpcode()
Return the opcode of the instruction's operator (a unique id suitable for use in switches); see Operator.opcode.

Returns:
the operator's opcode

getNumberOfOperands

public int getNumberOfOperands()
Get the number of operands in this instruction.

Returns:
number of operands

getNumberOfOperandsVarUsesOrDefs

private int getNumberOfOperandsVarUsesOrDefs()

getNumberOfDefs

public int getNumberOfDefs()
Returns the number of operands that are defs (either pure defs or combined def/uses).

By convention, operands are ordered in instructions such that all defs are first, followed by all combined defs/uses, followed by all pure uses. Note that this may change in the future.

Returns:
number of operands that are defs

getNumberOfPureDefs

public int getNumberOfPureDefs()
Returns the number of operands that are pure defs.

By convention, operands are ordered in instructions such that all defs are first, followed by all combined defs/uses, followed by all pure uses. Note that this may change in the future.

Returns:
number of operands that are defs

getNumberOfPureUses

public int getNumberOfPureUses()
Returns the number of operands that are pure uses.

By convention, operands are ordered in instructions such that all defs are first, followed by all combined defs/uses, followed by all pure uses. Note that this may change in the future.

Returns:
number of operands that are defs

getNumberOfUses

public int getNumberOfUses()
Returns the number of operands that are uses (either combined def/uses or pure uses).

By convention, operands are ordered in instructions such that all defs are first, followed by all combined defs/uses, followed by all pure uses. Note that this may change in the future.

Returns:
how many operands are uses

replaceOperand

public void replaceOperand(Operand oldOp,
                           Operand newOp)
Replace all occurances of the first operand with the second.

Parameters:
oldOp - The operand to replace
newOp - The new one to replace it with

replaceSimilarOperands

public void replaceSimilarOperands(Operand oldOp,
                                   Operand newOp)
Replace any operands that are similar to the first operand with a copy of the second operand.

Parameters:
oldOp - The operand whose similar operands should be replaced
newOp - The new one to replace it with

replaceRegister

public void replaceRegister(Register r,
                            Register n)
Replace all occurances of register r with register n

Parameters:
r - the old register
n - the new register

hasMemoryOperand

public boolean hasMemoryOperand()
Does this instruction hold any memory or stack location operands?


getOperands

public Enumeration<Operand> getOperands()
Enumerate all "leaf" operands of an instruction.

NOTE: DOES NOT RETURN MEMORY OPERANDS, ONLY THEIR CONTAINED OPERANDS!!!!!

Returns:
an enumeration of the instruction's operands.

getMemoryOperands

public Enumeration<Operand> getMemoryOperands()
Enumerate all memory operands of an instruction

Returns:
an enumeration of the instruction's operands.

getRootOperands

public Enumeration<Operand> getRootOperands()
Enumerate all the root operands of an instruction (DOES NOT ENUMERATE CONTAINED OPERANDS OF MEMORY OPERANDS).

Returns:
an enumeration of the instruction's operands.

getDefs

public Enumeration<Operand> getDefs()
Enumerate all defs (both pure defs and def/uses) of an instruction.

Returns:
an enumeration of the instruction's defs.

getPureDefs

public Enumeration<Operand> getPureDefs()
Enumerate all the pure defs (ie not including def/uses) of an instruction.

Returns:
an enumeration of the instruction's pure defs.

getPureUses

public Enumeration<Operand> getPureUses()
Enumerate all the pure uses (ie not including def/uses) of an instruction.

Returns:
an enumeration of the instruction's pure defs.

getDefUses

public Enumeration<Operand> getDefUses()
Enumerate all the def/uses of an instruction.

Returns:
an enumeration of the instruction's def/uses.

getUses

public Enumeration<Operand> getUses()
Enumerate all uses of an instruction (includes def/use).

Returns:
an enumeration of the instruction's uses.

getRootUses

public Enumeration<Operand> getRootUses()
Enumerate all root uses of an instruction.

Returns:
an enumeration of the instruction's uses.

isMove

public boolean isMove()
Does the instruction represent a simple move (the value is unchanged) from one "register" location to another "register" location?

Returns:
true if the instruction is a simple move or false if it is not.

isBranch

public boolean isBranch()
Is the instruction an intraprocedural branch?

Returns:
true if the instruction is am intraprocedural branch or false if it is not.

isConditionalBranch

public boolean isConditionalBranch()
Is the instruction a conditional intraprocedural branch?

Returns:
true if the instruction is a conditional intraprocedural branch or false if it is not.

isTwoWayBranch

public boolean isTwoWayBranch()
Is this instruction a branch that has that has only two possible successors?

Returns:
true if the instruction is an interprocedural conditional branch with only two possible outcomes (taken or not taken).

isUnconditionalBranch

public boolean isUnconditionalBranch()
Is the instruction an unconditional intraprocedural branch? We consider various forms of switches to be unconditional intraprocedural branches, even though they are multi-way branches and we may not no exactly which target will be taken. This turns out to be the right thing to do, since some arm of the switch will always be taken (unlike conditional branches).

Returns:
true if the instruction is an unconditional intraprocedural branch or false if it is not.

isDirectBranch

public boolean isDirectBranch()
Is the instruction a direct intraprocedural branch? In the HIR and LIR we consider switches to be direct branches, because their targets are known precisely.

Returns:
true if the instruction is a direct intraprocedural branch or false if it is not.

isIndirectBranch

public boolean isIndirectBranch()
Is the instruction an indirect intraprocedural branch?

Returns:
true if the instruction is an indirect interprocedural branch or false if it is not.

isCall

public boolean isCall()
Is the instruction a call (one kind of interprocedural branch)?

Returns:
true if the instruction is a call or false if it is not.

isPureCall

public boolean isPureCall()
Is the instruction a pure call (one kind of interprocedural branch)?

Returns:
true if the instruction is a pure call or false if it is not.

isNonPureCall

public boolean isNonPureCall()
Is the instruction a call but not a pure call (one kind of interprocedural branch)?

Returns:
true if the instruction is a nonpure call or false if it is not.

isConditionalCall

public boolean isConditionalCall()
Is the instruction a conditional call? We only allow conditional calls in the MIR, since they tend to only be directly implementable on some architecutres.

Returns:
true if the instruction is a conditional call or false if it is not.

isUnconditionalCall

public boolean isUnconditionalCall()
Is the instruction an unconditional call? Really only an interesting question in the MIR, since it is by definition true for all HIR and LIR calls.

Returns:
true if the instruction is an unconditional call or false if it is not.

isDirectCalll

public boolean isDirectCalll()
Is the instruction a direct call? Only interesting on the MIR. In the HIR and LIR we pretend that all calls are "direct" even though most of them aren't.

Returns:
true if the instruction is a direct call or false if it is not.

isIndirectCall

public boolean isIndirectCall()
Is the instruction an indirect call? Only interesting on the MIR. In the HIR and LIR we pretend that all calls are "direct" even though most of them aren't.

Returns:
true if the instruction is an indirect call or false if it is not.

isExplicitLoad

public boolean isExplicitLoad()
Is the instruction an explicit load of a finite set of values from a finite set of memory locations (load, load multiple, _not_ call)?

Returns:
true if the instruction is an explicit load or false if it is not.

isImplicitLoad

public boolean isImplicitLoad()
Should the instruction be treated as a load from some unknown location(s) for the purposes of scheduling and/or modeling the memory subsystem?

Returns:
true if the instruction is an implicit load or false if it is not.

isExplicitStore

public boolean isExplicitStore()
Is the instruction an explicit store of a finite set of values to a finite set of memory locations (store, store multiple, _not_ call)?

Returns:
true if the instruction is an explicit store or false if it is not.

isImplicitStore

public boolean isImplicitStore()
Should the instruction be treated as a store to some unknown location(s) for the purposes of scheduling and/or modeling the memory subsystem?

Returns:
true if the instruction is an implicit store or false if it is not.

isThrow

public boolean isThrow()
Is the instruction a throw of a Java exception?

Returns:
true if the instruction is a throw or false if it is not.

isPEI

public boolean isPEI()
Is the instruction a PEI (Potentially Excepting Instruction)?

Returns:
true if the instruction is a PEI or false if it is not.

isMarkedAsPEI

public boolean isMarkedAsPEI()
Has the instruction been explictly marked as a a PEI (Potentially Excepting Instruction)?

Returns:
true if the instruction is explicitly marked as a PEI or false if it is not.

isGCPoint

public boolean isGCPoint()
Is the instruction a potential GC point?

Returns:
true if the instruction is a potential GC point or false if it is not.

isTSPoint

public boolean isTSPoint()
Is the instruction a potential thread switch point?

Returns:
true if the instruction is a potential thread switch point or false if it is not.

isCompare

public boolean isCompare()
Is the instruction a compare (val,val) => condition?

Returns:
true if the instruction is a compare or false if it is not.

isAllocation

public boolean isAllocation()
Is the instruction an actual memory allocation instruction (NEW, NEWARRAY, etc)?

Returns:
true if the instruction is an allocation or false if it is not.

isReturn

public boolean isReturn()
Is the instruction a return (interprocedural branch)?

Returns:
true if the instruction is a return or false if it is not.

isAcquire

public boolean isAcquire()
Is the instruction an acquire (monitorenter/lock)?

Returns:
true if the instruction is an acquire or false if it is not.

isRelease

public boolean isRelease()
Is the instruction a release (monitorexit/unlock)?

Returns:
true if the instruction is a release or false if it is not.

isDynamicLinkingPoint

public boolean isDynamicLinkingPoint()
Could the instruction either directly or indirectly cause dynamic class loading?

Returns:
true if the instruction is a dynamic linking point or false if it is not.

isYieldPoint

public boolean isYieldPoint()
Is the instruction a yield point?

Returns:
true if the instruction is a yield point or false if it is not.

markAsNonPEI

public void markAsNonPEI()
Record that this instruction is not a PEI. Leave GCPoint status (if any) unchanged.


markAsPEI

public void markAsPEI()
NOTE: ONLY FOR USE ON MIR INSTRUCTIONS!!!! Record that this instruction is a PEI. Note that marking as a PEI implies marking as GCpoint.


markAsNonGCPoint

public void markAsNonGCPoint()
NOTE: ONLY FOR USE ON MIR INSTRUCTIONS!!!! Record that this instruction does not represent a potential GC point. Leave exception state (if any) unchanged.


markAsGCPoint

public void markAsGCPoint()
NOTE: ONLY FOR USE ON MIR INSTRUCTIONS!!!! Record that this instruction is a potential GC point. Leave PEI status (if any) unchanged.


markAsNonPEINonGCPoint

public void markAsNonPEINonGCPoint()
NOTE: ONLY FOR USE ON MIR INSTRUCTIONS!!!! Mark this instruction as being neither an exception or GC point.


isMarked1

boolean isMarked1()
Is the first mark bit of the instruction set?

Returns:
true if the first mark bit is set or false if it is not.

isMarked2

boolean isMarked2()
Is the second mark bit of the instruction set?

Returns:
true if the first mark bit is set or false if it is not.

setMark1

void setMark1()
Set the first mark bit of the instruction.


setMark2

void setMark2()
Set the second mark bit of the instruction.


clearMark1

void clearMark1()
Clear the first mark bit of the instruction.


clearMark2

void clearMark2()
Clear the second mark bit of the instruction.


getBranchProbability

public float getBranchProbability()
Return the probability (in the range 0.0 - 1.0) that this two-way branch instruction is taken (as opposed to falling through).

Returns:
The probability that the branch is taken.

setBranchProbability

public void setBranchProbability(float takenProbability)
Record the probability (in the range 0.0 - 1.0) that this two-way branch instruction is taken (as opposed to falling through).

Parameters:
takenProbability - The probability that the branch is taken.

flipBranchProbability

public void flipBranchProbability()
Invert the probabilty of this branch being taken. This method should be called on a branch instruction when its condition is reversed using flipCode().


getBranchTarget

public BasicBlock getBranchTarget()
Returns the basic block jumped to by this BRANCH instruction. TODO: Not all types of branches supported yet.

Returns:
the target of this branch instruction

getBranchTargets

public Enumeration<BasicBlock> getBranchTargets()
Return an enumeration of the basic blocks that are targets of this branch instruction.

Returns:
the targets of this branch instruction

isBbFirst

public boolean isBbFirst()
Return true if this instruction is the first instruction in a basic block. By convention (construction) every basic block starts with a label instruction and a label instruction only appears at the start of a basic block

Returns:
true if the instruction is the first instruction in its basic block or false if it is not.

isBbLast

public boolean isBbLast()
Return true if this instruction is the last instruction in a basic block. By convention (construction) every basic block ends with a BBEND instruction and a BBEND instruction only appears at the end of a basic block

Returns:
true if the instruction is the last instruction in its basic block or false if it is not.

isBbInside

public boolean isBbInside()
Mainly intended for assertion checking; returns true if the instruction is expected to appear on the "inside" of a basic block, false otherwise.

Returns:
true if the instruction is expected to appear on the inside (not first or last) of its basic block or false if it is expected to be a first/last instruction.

insertAfter

public void insertAfter(Instruction newInstr)
Insertion: Insert newInstr immediately after this in the instruction stream. Can't insert after a BBEND instruction, since it must be the last instruction in its basic block.

Parameters:
newInstr - the instruction to insert, must not be in an instruction list already.

insertBefore

public void insertBefore(Instruction newInstr)
Insertion: Insert newInstr immediately before this in the instruction stream. Can't insert before a LABEL instruction, since it must be the last instruction in its basic block.

Parameters:
newInstr - the instruction to insert, must not be in an instruction list already.

replace

public void replace(Instruction newInstr)
Replacement: Replace this with newInstr. We could allow replacement of first & last instrs in the basic block, but it would be a fair amount of work to update everything, and probably isn't useful, so we'll simply disallow it for now.

Parameters:
newInstr - the replacement instruction must not be in an instruction list already and must not be a LABEL or BBEND instruction.

remove

public Instruction remove()
Removal: Remove this from the instruction stream. We currently forbid the removal of LABEL instructions to avoid problems updating branch instructions that reference the label. We also outlaw removal of BBEND instructions.

NOTE: We allow the removal of branch instructions, but don't update the CFG data structure.....right now we just assume the caller knows what they are doing and takes care of it.

NB: execution of this method nulls out the prev & next fields of this

Returns:
the previous instruction in the instruction stream

isLinked

private void isLinked()

isBackwardLinked

private void isBackwardLinked()

isForwardLinked

private void isForwardLinked()

isNotLinked

private void isNotLinked()

getOperand

public Operand getOperand(int i)
NOTE: It is incorrect to use getOperand with a constant argument outside of the automatically generated code in Operators. The only approved direct use of getOperand is in a loop over some subset of an instructions operands (all of them, all uses, all defs).

Parameters:
i - which operand to return
Returns:
the ith operand

getClearOperand

public Operand getClearOperand(int i)
NOTE: It is incorrect to use getClearOperand with a constant argument outside of the automatically generated code in Operators. The only approved direct use of getOperand is in a loop over some subset of an instructions operands (all of them, all uses, all defs).

Parameters:
i - which operand to return
Returns:
the ith operand detatching it from the instruction

putOperand

public void putOperand(int i,
                       Operand op)
NOTE: It is incorrect to use putOperand with a constant argument outside of the automatically generated code in Operators. The only approved direct use of getOperand is in a loop over some subset of an instruction's operands (all of them, all uses, all defs).

Parameters:
i - which operand to set
op - the operand to set it to

outOfLineCopy

private Operand outOfLineCopy(Operand op)

resizeNumberOfOperands

void resizeNumberOfOperands(int newSize)
Enlarge the number of operands in this instruction, if necessary. Only meant to be used by InstructionFormat classes.

Parameters:
newSize - the new minimum number of operands.

getNext

Instruction getNext()
For IR internal use only; general clients should use nextInstructionInCodeOrder().

Returns:
the contents of next

setNext

void setNext(Instruction n)
For IR internal use only; general clients should always use higer level mutation functions. Set the next field of the instruction.

Parameters:
n - the new value for next

getPrev

Instruction getPrev()
For IR internal use only; General clients should use prevInstructionInCodeOrder().

Returns:
the contents of prev

setPrev

void setPrev(Instruction p)
For IR internal use only; general clients should always use higer level mutation functions. Set the prev field of the instruction.

Parameters:
p - the new value for prev

clearLinks

void clearLinks()
For IR internal use only; general clients should always use higer level mutation functions. Clear the prev and next fields of the instruction.


similar

public boolean similar(Instruction similarInstr)
Are two instructions similar, i.e. having the same operator and the same number of similar operands?

Parameters:
similarInstr - instruction to compare against
Returns:
true if they are similar

linkWithNext

void linkWithNext(Instruction other)
For IR internal use only; general clients should always use higer level mutation functions. Link this and other together by setting this's next field to point to other and other's prev field to point to this.

Parameters:
other - the instruction to link with.

BURS_backdoor_linkWithNext

public void BURS_backdoor_linkWithNext(Instruction other)
Allow BURS a back door into linkWithNext. This method should only be called within BURS.


mayBeVolatileFieldLoad

public boolean mayBeVolatileFieldLoad()
Might this instruction be a load from a field that is declared to be volatile?

Returns:
true if the instruction might be a load from a volatile field or false if it cannot be a load from a volatile field