List of High-Level IR opcodes used in Jitrino.OPT compiler:
Use this link for details on type system used in Jitrino.OPT compiler
Arithmetic:
Op_Add - Adds src1 and src2 operands and stores the result to dst. Modifiers: OverflowModifier, ExceptionModifier
Op_Mul - Multiplies src1 and src2 operands and stores the result to dst. Modifiers: OverflowModifier, ExceptionModifier
Op_Sub - Substracts src2 from src1 operands and stores the result to dst. Modifiers: OverflowModifier, ExceptionModifier
Op_TauDiv - Divides src1 by src2 and stores the results to dst. Uses tau operand to ensure that that 0/overflow cases were checked before. Modifiers: SignedModifier
Op_TauRem - Computes residue of division of src1 by src2 and stores the results to dst. Uses tau operand to ensure that that 0/overflow cases were checked before. Modifiers: SignedModifier
Op_Neg - Negates the src1 operands and stores the result to dst. Modifiers: SignedModifier
Op_MulHi - Gets high part of multiply.
Op_Min - Compares src1 and src2 and stores minimal value to dst. Modifiers: none
Op_Max - Compares src1 and src2 and stores maximal value to dst. Modifiers: none
Op_Abs - Stores absolute value of src1 to dst. Modifiers: none
Bitwise:
Op_And - A bitwise AND takes src1 and src2 operands of equal size and performs the logical AND operation on each pair of corresponding bits storing the result to dst. In each pair, the result is 1 if the first bit is 1 AND the second bit is 1. Otherwise, the result is 0. Modifiers: none
Op_Or - A bitwise OR takes src1 and src2 operands of equal size and performs the logical OR operation on each pair of corresponding bits storing the result to dst. In each pair, the result is 1 if the first bit is 1 OR the second bit is 1 OR both the first and the second bits are 1. Otherwise, the result is 0. Modifiers: none
Op_Xor - A bitwise XOR takes src1 and src2 operands of equal size and performs the logical XOR operation on each pair of corresponding bits storing the result to dst. In each pair, the result is 1 if the two bits are different, and 0 if they are the same. Modifiers: none
Op_Not - A bitwise NOT takes src1 and performs the logical NOT operation storing the result to dst. For each bit that was 0 the result is 1. For each bit that was 1 the results is 0. Modifiers: none
Selection:
Op_Select - Selects a value: (src1 ? src2 : src3).
Conversion:
Op_Conv - Converts src1 to dst using type information provided as a parameter. Must not be used for conversion of managed pointers to Unmanaged Pointers and via versa. Modifiers: OverflowModifier, ExceptionModifier
Op_ConvZE - Converts src1 to dst using type information provided as a parameter. If the size of dst of greater that the size of src1 all extra bits are filled with 0. Must not be used for conversion of managed pointers to Unmanaged Pointers and via versa. Modifiers: OverflowModifier, ExceptionModifier
Op_ConvUnmanaged - Converts src1 from managed memory pointer type to unmanaged memory pointer type or via versa and stores the result of conversion to dst. Modifiers: none.
Shift:
Op_Shladd - Shifts 'src1' by src2 bits left, adds src3 to the result of the shift and stores the result to dst. The src2 must be an LdConstant result. Modifiers: none
Op_Shl - Shifts 'src1' left by src2 bits left and stores the result in 'dst'. Modifiers: ShiftMaskModifier
Op_Shr - Shifts 'src1' left by src2 bits right and stores the result in 'dst'. Modifiers: ShiftMaskModifier
Comparison:
Op_Cmp - Compares src1 and src2 and stores the result of comparison to dst. The result of comparision is 32-bit signed integer. Modifiers: ComparisonModifier
Op_Cmp3 - 3-way compare, e.g.: ((s0>s1)?1:((s1>s0)?-1:0)). For floats, exactly 1 of the two comparisons is unordered. Modifiers: ComparisonModifier. The modifier in the instruction applies to the first test.
Control flow:
Op_Branch - There are two types of instructions with this opcode. For the first if the src1 is not 0 the branch pointed by label operand is taken. The second version of the instruction combines both Op_Cmp and the first version of this operation. It takes two src1 and src2 operands, compares them and jumps to the label block if comparison condition is 'true'. Modifiers: ComparisonModifier
Op_Jump - Unconditional jump to a node pointer by the label operand. Modifiers: none.
Op_Switch - Takes src1, labels[] and defaultLabel operands and jumps to the label with the index stored in src0. If the src1 is out of the labels[] range, a jump to the defaultLabel is used.
Op_DirectCall - A direct call to a Java method. Takes the list of method's parameters and two tau operands to ensure that this is not null and all parameter types are checked. Stores the result of the call to dst operand. Modifiers: ExceptionModifier
Op_TauVirtualCall - - A virtual call to a Java method. Takes the list of method's parameters and two tau operands to ensure that this is not null and all parameter types are checked. Stores the result of the call to dst operand. Modifiers: ExceptionModifier
Op_IndirectCall - An indirect call to an arbitrary native method. Takes the address of the call as src1 operand, the list of method's parameters and two tau operands to ensure that the first operand is not null and types for operands are checked. Stores the result of the call to dst operand. Modifiers: ExceptionModifier
Op_IndirectMemoryCall - Works the same as Op_IndirectCall. TODO: one of this instructions must be removed or its use clarified.
Op_JitHelperCall - A call of an internal JIT helper referenced by JitHelperCallId parameter. Modifiers: ExceptionModifier
Op_VMHelperCall - A call of an runtime VM helper referenced by VM_RT_SUPPORT parameter. Modifiers: ExceptionModifier
Op_Return - A result of the current method. Uses 1 or no operands as return operands. Modifiers: none.
Exception processing:
Op_Catch - Stores exception object to dst operand. Usually this is the first inst (except label and phi insts) in a catch block. Modifiers: none.
Op_Throw - Throws the exception object located in src1 operand. Modifiers: ThrowModifier
Op_PseudoThrow - A pseudo instruction to break infinte loops. Modifiers: ExceptionModifier
Op_ThrowSystemException - A throw with a predefined object thrown. Takes a CompilationInterface::SystemExceptionId parameter. Modifiers: ThrowModifier
Op_ThrowLinkingException - A throw with a predefined object thrown. Generate a call to Helper_Throw_LinkingException. Modifiers: ThrowModifier
Op_JSR - An unconditional branch to a subroutine. Modifiers: none.
Op_Ret - A return from a subroutine called with Op_JSR instruction. Modifiers: none.
Op_SaveRet - Prepares an operand for saving result of subroutine. Modifiers: none.
Move instruction:
Op_Copy - Creates a copy of an operand. No conversion is applied. Modifiers: none.
Op_DefArg - Defines an argument of the current method. Usually one the first instructions in entry node. Modifiers: DefArgModifier
Load instructions:
Op_LdConstant - Load constant provided as a ConstInst::ConstValue into dst operand.
Op_LdRef - Loads constant String or reference address. The index of the contant in a method's metadata structure (constant pool index in case of Java) and the type of the resulted value are provided as parameters.
Op_LdVar - Loads temporary src1 operand into var operand
Op_LdVarAddr - Loads address of a var operand into dst operand. The type of the result is a managed pointer to source var operand's type.
Op_TauLdInd - Gets address of a value as src1 operand and 2 taus to ensure that address is in valid range and this pointer for the loaded field is not null. Loads the value referenced by src0 operand and returns it as a result.
Op_TauLdField - The same as Op_TauLdInd but instead of the address of the field a field handle is provided.
Op_LdStatic - Loads a value of a static field into dst operand. No null check is needed.
Op_TauLdElem - Loads a value stored in array operand of array type located by the index parameter value. Uses 2 tau operandsto ensure that array is not null and the index is not out of bounds.
Op_LdFieldAddr - For the provided base and field_handle operands returns the address of a field.
Op_LdStaticAddr - For the field_handle operand of the static field returns the address of a field.
Op_LdElemAddr - Loads an address of array element referenced by array and index parameters
Op_TauLdVTableAddr - Returns an address of VTable structure for the provided base operand of object type.
Op_TauLdIntfcVTableAddr - Returns an address of interface VTable structure for the provided base operand of object type. The interface type is provided as a second type parameter.
Op_TauLdVirtFunAddr - For the given VTable address and method handle loads the address of the method. Uses 1 tau parameter to ensure that VTable does really have a pointer to the method.
Op_TauLdVirtFunAddrSlot -For the given VTable address and method handle loads the offset of the method in VTable. Uses 1 tau parameter to ensure that VTable does really have a pointer to the method.
Op_LdFunAddr - Loads address of the memory location that contains function address.
Op_LdFunAddrSlot - This opcode is processed the same ways as Op_LdFunAddr today. TODO: remove it or make it other meaning.
Op_GetVTableAddr - Obtains the address of the VTable for a particular object type provided as a parameter.
Array manipulation:
Op_TauArrayLen - Gets arrays pointer as a parameter and returns a length of the array. Uses 2 tau parameters to ensure that pointed object type is array and that it's not null.
Op_LdArrayBaseAddr - Load the base (zero'th element) address of array.
Op_AddScaledIndex - Add a scaled index to an array element address
Store instructions:
Op_StVar - Stores var operand into temporary dst operand.
Op_TauStInd - Stores the src operand into memory area referenced by ptr operand. Uses 3 tau operands to ensure that that object pointed by ptr is not null, the type of src operand matches the type of the field pointed by ptr operand and that address pointer by ptr operand is in valid range. Modifiers: StoreModifier
Op_TauStField - The same as Op_TauStInd but uses field_handle instead of ptr operand. Modifiers: StoreModifier
Op_TauStElem - Stores src value as index element of array parameter. Uses 3 tau operands to ensure that array is not null, src type is checked to match the element type and index is not is out of bounds. Modifiers: StoreModifier
Op_TauStStatic - Stores src value into static field referenced by field_handle parameter.
Op_TauStRef - A high-level version of TauStInd that also has a pointer to an dst object referenced by ptr operand and can be used for a mode with write barriers support, when the addresses of both src and dstobjects must be reported.
Runtime exception check instructions:
// all of these take ExceptionModifier
Op_TauCheckBounds - Takes index and array length arguments, the overflow modifier == none indicates that 0<=idx*element_size<2^31
Op_TauCheckLowerBound - Throws ArrayOfBoundException unless src0 <= src1
Op_TauCheckUpperBound - Throws ArrayOfBoundException unless src0 < src1
Op_TauCheckNull - Throws NullPointerException if src operand is null
Op_TauCheckZero - Throws DivideByZero exceptions. The resulted tauoperand is used in Op_TauDiv and Op_TauRem instructions.
Op_TauCheckDivOpnds - Was used for signed divide overflow in CLI (div/rem of MAXNEGINT, -1): generates an ArithmeticException. TODO: remove as unused.
Op_TauCheckElemType - Checks array element type. The resulted tau operand is used in Op_TauStElem instruction.
Op_TauCheckFinite - Throws ArithmeticException if src operand is NaN or +- infinity
Allocation:
Op_NewObj - Allocates an object instance of the specified type. Throws OutOfMemoryException.
Op_NewArray - Allocates an array instance of the specified size and element type. Throws OutOfMemoryException, NegativeArraySizeException
Op_NewMultiArray - Allocates a multiarray instance. Gets number of dimension, sizes for each of the dimensions and element type as parameters. Throws OutOfMemoryException, NegativeArraySizeException
Synchronization:
Op_TauMonitorEnter - Locks monitor for the given object. The object must not be null.
// this could take an ExceptionModifier
Op_TauMonitorExit - Unlocks monitor for the given object. The object must not be null. Throws IllegalMonitorStateException
Op_TypeMonitorEnter - Locks monitor for the given class (type) object.
Op_TypeMonitorExit - Unlocks monitor for the given class (type) object.Throws IllegalMonitorStateException
Type checking:
// cast takes an ExceptionModifier
Op_TauStaticCast - Compile-time assertion. Asserts that cast is legal.
Op_TauCast - Casts the argument to the specified type. Succeeds if argument is null, returns casted object. throws CastException if cast is illegal.
Op_TauAsType - Returns casted object if argument is an instance of, or return null otherwise.
Op_TauInstanceOf - Returns true if argument is a non-null instance of type T
Op_TauCheckCast - Returns tau that the cast is safe if argument is an instance of, or throws ClassCastException otherwise.
Op_TauHasType- Returns tau that the cast is safe.
Op_TauHasExactType - The same as Op_TauHasType but ensures that argument has exact type.
Op_TauIsNonNull - Returns tau that can be used to prove that argument is not null
Type initialization:
Op_InitType - Initialize type before static method invocation or field access. For Java language it means that <clinit> will be called for an uninitialized class. Nothing happened if a class is already initialized.
Labels & markers:
Op_Label - A special label instructions for branch labels, finally, catch blocks. Every node in HIR must start with this instruction.
Op_MethodEntry - Method entry label. Used to mark inlined methods boundaries.
Op_MethodEnd - Method end label. Used to mark inlined methods boundaries.
Profile instrumentation instructions:
Op_IncCounter - Increment edge profile profile counter by 1. The counter's key provided as an argument is used to derive the address of a counter. If the key == 0, entry counter address is used.
Op_Prefetch - Prefetches a given memory location.
Compressed Pointer instructions:
Op_UncompressRef - Performs uncompress operation for compressed_ref, e.g. uncompressed_ref = (compressed_ref<<s) + heapbase
Op_CompressRef - Performs compress operation, which is reverse operation for Op_UncompressRef.
Op_LdFieldOffset - Loads field offset from the start of the object.
Op_LdFieldOffsetPlusHeapbase - Loads field offset and adds heapbase to it.
Op_LdArrayBaseOffset - Loads the offset of array base.
Op_LdArrayBaseOffsetPlusHeapbase - Offset of array base plus heap base.
Op_LdArrayLenOffset - Returns offset of array length field.
Op_LdArrayLenOffsetPlusHeapbase - Returns offset of array length field plus heap base.
Op_AddOffset - Adds offset to uncompressed reference.
Op_AddOffsetPlusHeapbase - Uncompresses compressed reference and adds field offsets to result.