/* * Copyright (C) 2019 ETH Zurich, University of Bologna * * 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 __HAL_RISCV_BUILTINS_V2_H__ #define __HAL_RISCV_BUILTINS_V2_H__ #ifdef ARCHI_CORE_HAS_PULPV2 /* ARITHMETIC SECTION */ typedef signed short v2s __attribute__((vector_size (4))); typedef unsigned short v2u __attribute__((vector_size (4))); typedef signed char v4s __attribute__((vector_size (4))); typedef unsigned char v4u __attribute__((vector_size (4))); #ifdef __EMUL__ typedef void * rt_pointerT; #else typedef unsigned int rt_pointerT; #endif /* Packing of scalars into vectors */ #define __PACK2(x, y) __builtin_pulp_pack2((signed short) (x), (signed short) (y)) #define __PACKU2(x, y) __builtin_pulp_pack2((unsigned short) (x), (unsigned short) (y)) #define __PACK4(x, y, z, t) __builtin_pulp_pack4((signed char) (x), (signed char) (y), (signed char) (z), (signed char) (t)) #define __PACKU4(x, y, z, t) __builtin_pulp_pack4((unsigned char) (x), (unsigned char) (y), (unsigned char) (z), (unsigned char) (t)) /* Max */ #define __MAX(a, b) __builtin_pulp_maxsi((a), (b)) #define __MAX2(x, y) __builtin_pulp_max2((x), (y)) #define __MAX4(x, y) __builtin_pulp_max4((x), (y)) #define __MAXU2(x, y) __builtin_pulp_maxu2((x), (y)) #define __MAXU4(x, y) __builtin_pulp_maxu4((x), (y)) /* Min */ #define __MIN2(x, y) __builtin_pulp_min2((x), (y)) #define __MIN4(x, y) __builtin_pulp_min4((x), (y)) #define __MINU2(x, y) __builtin_pulp_minu2((x), (y)) #define __MINU4(x, y) __builtin_pulp_minu4((x), (y)) /* Clip */ #define __CLIP(x, precision) __builtin_pulp_clip((x), -(1<<(precision)), (1<