| /* |
| * 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_VSEXT_VZEXT_H |
| #define SOFTRVV_VSEXT_VZEXT_H |
| |
| #include <stddef.h> |
| |
| namespace softrvv { |
| |
| // Cast a vector from T2 to T1 |
| // vsext is the vector signed extention instruction |
| template <typename T1, typename T2> |
| void vsext_v(T1 *dest, const T2 *src1, int32_t avl) { |
| for (int32_t idx = 0; idx < avl; idx++) { |
| dest[idx] = static_cast<T1>(src1[idx]); |
| } |
| } |
| |
| // Cast a vector from T2 to T1 |
| // vzext is the vector zero extention instruction |
| // Function is identical to vsext as compiler |
| // does the right thing when T1,T2 are unsigned |
| template <typename T1, typename T2> |
| void vzext_v(T1 *dest, const T2 *src1, int32_t avl) { |
| vsext_v<T1, T2>(dest, src1, avl); |
| } |
| |
| } // namespace softrvv |
| |
| #endif // SOFTRVV_VSEXT_VZEXT_H |