Interface IntCompareBinOpGen<T extends JitIntTestOp>

Type Parameters:
T - the class of p-code op node in the use-def graph
All Superinterfaces:
BinOpGen<T>, IntPredBinOpGen<T>, OpGen<T>
All Known Implementing Classes:
IntEqualOpGen, IntLessEqualOpGen, IntLessOpGen, IntNotEqualOpGen, IntSLessEqualOpGen, IntSLessOpGen

public interface IntCompareBinOpGen<T extends JitIntTestOp> extends IntPredBinOpGen<T>
An extension for integer comparison operators
  • Method Details

    • not

      static <N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, Types.TInt>> Emitter<Emitter.Ent<N1,Types.TInt>> not(Emitter<N0> em)
      Invert the boolean on top of the stack
      Type Parameters:
      N1 - the tail of the incoming stack
      N0 - the incoming stack with the boolean 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
    • genBool

      default <N extends Emitter.Next> Emitter<Emitter.Ent<N,Types.TInt>> genBool(Lbl.LblEm<N,N> lblEmTrue)
      Assuming a conditional jump bytecode was just emitted, emit bytecode to push 0 (false) onto the stack for the fall-through case, or 1 (true) onto the stack for the taken case.
      Type Parameters:
      N - the incoming stack, i.e., that after emitting the conditional jump
      Parameters:
      lblEmTrue - the target label of the conditional jump just emitted, and the emitter typed with the incoming stack
      Returns:
      the emitter with the resulting stack, i.e., having pushed the boolean result
    • genIntViaUcmpThenIf

      default <N2 extends Emitter.Next, N1 extends Emitter.Ent<N2, Types.TInt>, N0 extends Emitter.Ent<N1, Types.TInt>> Emitter<Emitter.Ent<N2,Types.TInt>> genIntViaUcmpThenIf(Emitter<N0> em, Function<Emitter<Emitter.Ent<N2,Types.TInt>>,Lbl.LblEm<N2,N2>> opIf)
      An implementation for (unsigned) int operands that invokes Integer.compareUnsigned(int, int) and then emits the given if<cond> jump.
      Type Parameters:
      N2 - the tail of the incoming stack
      N1 - the tail of the incoming stack including the right operand
      N0 - the incoming stack with the right and left operands on top
      Parameters:
      em - the emitter typed with the incoming stack
      opIf - a method reference, e.g., to Op.ifge(Emitter, Lbl) for the conditional jump
      Returns:
      the emitter typed with the resulting stack, i.e., the tail with the result pushed
    • genIntViaIfIcmp

      default <N2 extends Emitter.Next, N1 extends Emitter.Ent<N2, Types.TInt>, N0 extends Emitter.Ent<N1, Types.TInt>> Emitter<Emitter.Ent<N2,Types.TInt>> genIntViaIfIcmp(Emitter<N0> em, Function<Emitter<N0>,Lbl.LblEm<N2,N2>> opIfIcmp)
      An implementation for (signed) int operands that simply emits the given if_icmp<cond> jump.
      Type Parameters:
      N2 - the tail of the incoming stack
      N1 - the tail of the incoming stack including the right operand
      N0 - the incoming stack with the right and left operands on top
      Parameters:
      em - the emitter typed with the incoming stack
      opIfIcmp - a method reference, e.g., to Op.if_icmpge(Emitter, Lbl) for the conditional jump
      Returns:
      the emitter typed with the resulting stack, i.e., the tail with the result pushed
    • genIntViaIf

      default <N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, Types.TInt>> Emitter<Emitter.Ent<N1,Types.TInt>> genIntViaIf(Emitter<N0> em, Function<Emitter<N0>,Lbl.LblEm<N1,N1>> opIf)
      A utility that emits the given if<cond> along with the logic that pushes the correct result depending on whether or not the jump is taken.
      Type Parameters:
      N1 - the tail of the incoming stack
      N0 - the incoming stack including the predicate, which is compared with 0
      Parameters:
      em - the emitter typed with the incoming stack
      opIf - a method reference, e.g., to Op.ifge(Emitter, Lbl) for the conditional jump
      Returns:
      the emitter typed with the resulting stack, i.e., the tail with the result pushed
    • genLongViaLcmpThenIf

      default <N2 extends Emitter.Next, N1 extends Emitter.Ent<N2, Types.TLong>, N0 extends Emitter.Ent<N1, Types.TLong>> Emitter<Emitter.Ent<N2,Types.TInt>> genLongViaLcmpThenIf(Emitter<N0> em, Function<Emitter<Emitter.Ent<N2,Types.TInt>>,Lbl.LblEm<N2,N2>> opIf)
      An implementation for (signed) long operands that emits lcmp and then emits the given if<cond> jump.
      Type Parameters:
      N2 - the tail of the incoming stack
      N1 - the tail of the incoming stack including the right operand
      N0 - the incoming stack with the right and left operands on top
      Parameters:
      em - the emitter typed with the incoming stack
      opIf - a method reference, e.g., to Op.ifge(Emitter, Lbl) for the conditional jump
      Returns:
      the emitter typed with the resulting stack, i.e., the tail with the result pushed
    • genLongViaUcmpThenIf

      default <N2 extends Emitter.Next, N1 extends Emitter.Ent<N2, Types.TLong>, N0 extends Emitter.Ent<N1, Types.TLong>> Emitter<Emitter.Ent<N2,Types.TInt>> genLongViaUcmpThenIf(Emitter<N0> em, Function<Emitter<Emitter.Ent<N2,Types.TInt>>,Lbl.LblEm<N2,N2>> opIf)
      An implementation for (unsigned) long operands that invokes Long.compareUnsigned(long, long) and then emits the given if<cond> jump.
      Type Parameters:
      N2 - the tail of the incoming stack
      N1 - the tail of the incoming stack including the right operand
      N0 - the incoming stack with the right and left operands on top
      Parameters:
      em - the emitter typed with the incoming stack
      opIf - a method reference, e.g., to Op.ifge(Emitter, Lbl) for the conditional jump
      Returns:
      the emitter typed with the resulting stack, i.e., the tail with the result pushed
    • genRunMpInt

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

      The strategy for multi-precision comparison can be applied to all comparisons: Start with the most-significant legs and compare for equality until we find the first not-equal pair. Then, apply IntPredBinOpGen.opForInt(Emitter, IntJitType) to determine the overall result. There is no need to load or compare any legs beyond the most-significant not-equal pair. If we reach the final (least-significant) pair, we need not check them for equality. Just delegate to IntPredBinOpGen.opForInt(Emitter, IntJitType).

      Specified by:
      genRunMpInt in interface IntPredBinOpGen<T extends JitIntTestOp>
      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 resulting stack, i.e., containing only the result