/*
 * Copyright 2023 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SOFTRVV_VMFLE_H
#define SOFTRVV_VMFLE_H

#include <stddef.h>

namespace softrvv {

// The type of dest is defined as int32_t instead of float
// to use "set_bit_in_dest_mask", which has bitwise operations in it.
void vmfle_vf(int32_t *dest, float *src2, const float *src1, int32_t avl) {
  for (int32_t idx = 0; idx < avl; idx++) {
    set_bit_in_dest_mask<int32_t>(idx, dest, src2[idx] <= *src1);
  }
}

// The type of dest is defined as int32_t instead of float
// to use "set_bit_in_dest_mask", which has bitwise operations in it.
void vmfle_vv(int32_t *dest, float *src2, float *src1, int32_t avl) {
  for (int32_t idx = 0; idx < avl; idx++) {
    set_bit_in_dest_mask<int32_t>(idx, dest, src2[idx] <= src1[idx]);
  }
}

}  // namespace softrvv

#endif  // SOFTRVV_VMFLE_H
