Enum Class SubPieceOpGen

java.lang.Object
java.lang.Enum<SubPieceOpGen>
ghidra.pcode.emu.jit.gen.op.SubPieceOpGen
All Implemented Interfaces:
OpGen<JitSubPieceOp>, Serializable, Comparable<SubPieceOpGen>, Constable

public enum SubPieceOpGen extends Enum<SubPieceOpGen> implements OpGen<JitSubPieceOp>
The generator for a subpiece.

This is not quite like a normal binary operator, because the second operand is always a constant. It behaves more like a class of unary operators, if you ask me. Thus, we do not extend BinOpGen. We first emit code to load the operand. Then, because the shift amount is constant, we can deal with it at generation time. We emit code to shift right by that constant amount, accounting for bits and bytes. The masking, if required, is taken care of by the variable writing code, given the resulting type.

To avoid loading parts of the (left) operand that will just get dropped by this operator, we instead provide the subpiecing arguments (namely the offset and destination operand size) to the value-loading logic. This is done via the ValGen.subpiece(int, int) method. We can then load only those parts that are actually needed.