Enum Class Int2CompOpGen

java.lang.Object
java.lang.Enum<Int2CompOpGen>
ghidra.pcode.emu.jit.gen.op.Int2CompOpGen
All Implemented Interfaces:
IntOpUnOpGen<JitInt2CompOp>, OpGen<JitInt2CompOp>, UnOpGen<JitInt2CompOp>, Serializable, Comparable<Int2CompOpGen>, Constable

public enum Int2CompOpGen extends Enum<Int2CompOpGen> implements IntOpUnOpGen<JitInt2CompOp>
The generator for a int_2comp.

This uses the unary operator generator and emits ineg or lneg, depending on type.

The multi-precision logic is similar to IntAddOpGen. We follow the process "flip the bits and add 1", so for each leg, we consider that it may have a carry in. We then invert all the bits using ^-1 and then add that carry in. The least significant leg is assumed to have a carry in, effecting the +1.

  • Enum Constant Details

    • GEN

      public static final Int2CompOpGen GEN
      The generator singleton
  • Method Details

    • values

      public static Int2CompOpGen[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Int2CompOpGen valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • isSigned

      public boolean isSigned()
      Description copied from interface: UnOpGen
      Whether this operator is signed

      In many cases, the operator itself is not affected by the signedness of the operands; however, if size adjustments to the operands are needed, this can determine how those operands are extended.

      Specified by:
      isSigned in interface UnOpGen<JitInt2CompOp>
      Returns:
      true for signed, false if not
    • opForInt

      public <N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, Types.TInt>> Emitter<Emitter.Ent<N1,Types.TInt>> opForInt(Emitter<N0> em)
      Description copied from interface: IntOpUnOpGen
      Emit the JVM bytecode to perform the operator with int operands on the stack.
      Specified by:
      opForInt in interface IntOpUnOpGen<JitInt2CompOp>
      Type Parameters:
      N1 - the tail of the incoming stack
      N0 - the incoming stack with the input operand on top
      Parameters:
      em - the emitter typed with the incoming stack
      Returns:
      the emitter typed with the resulting stack, i.e., the tail with the result pushed
    • opForLong

      public <N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, Types.TLong>> Emitter<Emitter.Ent<N1,Types.TLong>> opForLong(Emitter<N0> em)
      Description copied from interface: IntOpUnOpGen
      Emit the JVM bytecode to perform the operator with long operands on the stack.
      Specified by:
      opForLong in interface IntOpUnOpGen<JitInt2CompOp>
      Type Parameters:
      N1 - the tail of the incoming stack
      N0 - the incoming stack with the input operand on top
      Parameters:
      em - the emitter typed with the incoming stack
      Returns:
      the emitter typed with the resulting stack, i.e., the tail with the result pushed
    • genRunMpInt

      public <THIS extends JitCompiledPassage> Emitter<Emitter.Bot> genRunMpInt(Emitter<Emitter.Bot> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JitInt2CompOp op, JitType.MpIntJitType type, Scope scope)
      Emit the JVM bytecode to perform the operator with multi-precision operands.

      The strategy here follows after IntAddOpGen.genRunMpInt(Emitter, Local, JitCodeGenerator, ghidra.pcode.emu.jit.op.JitIntAddOp, MpIntJitType, Scope). We no longer need to assert a minimum length, since we provide a "carry in" of 1 for the initial leg. We initialize the complement by loading that 1 onto the stack and invoking genMpIntLeg2CmpTakesAndGivesCarry(Emitter, SimpleOpnd, boolean, Scope) with shiftCarry cleared. We terminate the operation with genMpIntLeg2CmpTakesCarry(Emitter, SimpleOpnd, boolean, Scope). We use genMpIntLeg2CmpTakesAndGivesCarry(Emitter, SimpleOpnd, boolean, Scope) with shiftCarry set for each middle leg. The resulting legs are all appended to form the final multi-precision output.

      Specified by:
      genRunMpInt in interface IntOpUnOpGen<JitInt2CompOp>
      Type Parameters:
      THIS - the type of the generated passage
      Parameters:
      em - the emitter typed with the empty stack
      localThis - a handle to the local holding the this reference
      gen - the code generator
      op - the p-code op
      type - the p-code type of the operands
      scope - a scope for generating temporary local storage
      Returns:
      the emitter typed with the empty stack