Enum Class FloatRoundOpGen

java.lang.Object
java.lang.Enum<FloatRoundOpGen>
ghidra.pcode.emu.jit.gen.op.FloatRoundOpGen
All Implemented Interfaces:
FloatOpUnOpGen<JitFloatRoundOp>, OpGen<JitFloatRoundOp>, UnOpGen<JitFloatRoundOp>, Serializable, Comparable<FloatRoundOpGen>, Constable

public enum FloatRoundOpGen extends Enum<FloatRoundOpGen> implements FloatOpUnOpGen<JitFloatRoundOp>
The generator for a float_round.

The JVM does provide a Math.round(float) method, however it returns an int. (It has similar for doubles with the same problem.) That would be suitable if a type conversion were also desired, but that is not the case. Thus, we construct a rounding function without conversion: round(x) = floor(x + 0.5). This uses the unary operator generator and emits the bytecode to implement that definition, applying type conversions as needed.

  • Enum Constant Details

  • Method Details

    • values

      public static FloatRoundOpGen[] 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 FloatRoundOpGen 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
    • opForFloat

      public <N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, Types.TFloat>> Emitter<Emitter.Ent<N1,Types.TFloat>> opForFloat(Emitter<N0> em)
      Description copied from interface: FloatOpUnOpGen
      Emit the JVM bytecode to perform the operator with float operands on the stack.
      Specified by:
      opForFloat in interface FloatOpUnOpGen<JitFloatRoundOp>
      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
    • opForDouble

      public <N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, Types.TDouble>> Emitter<Emitter.Ent<N1,Types.TDouble>> opForDouble(Emitter<N0> em)
      Description copied from interface: FloatOpUnOpGen
      Emit the JVM bytecode to perform the operator with double operands on the stack.
      Specified by:
      opForDouble in interface FloatOpUnOpGen<JitFloatRoundOp>
      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