def METHOD_NAME(rewriter: PatternRewriter) -> list[SSAValue]:
    """
    Add cast operations just before the targeted operation
    if the operands were not already int registers
    """
    new_ops = list[Operation]()
    new_operands = list[SSAValue]()
    for operand in rewriter.current_operation.operands:
        if not isinstance(
            operand.type, riscv.IntRegisterType | riscv.FloatRegisterType
        ):
            new_type = register_type_for_type(operand.type)
            cast_op = builtin.UnrealizedConversionCastOp.get(
                (operand,), (new_type.unallocated(),)
            )
            new_ops.append(cast_op)
            operand = cast_op.results[0]
        new_operands.append(operand)
    rewriter.insert_op_before_matched_op(new_ops)
    return new_operands