|
| 1 | +/*===---- riscv_corev_alu.h - CORE-V ALU intrinsics ------------------------=== |
| 2 | + * |
| 3 | + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | + * See https://llvm.org/LICENSE.txt for license information. |
| 5 | + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | + * |
| 7 | + *===-----------------------------------------------------------------------=== |
| 8 | + */ |
| 9 | + |
| 10 | +#ifndef __RISCV_COREV_ALU_H |
| 11 | +#define __RISCV_COREV_ALU_H |
| 12 | + |
| 13 | +#include <stdint.h> |
| 14 | + |
| 15 | +#if defined(__cplusplus) |
| 16 | +extern "C" { |
| 17 | +#endif |
| 18 | + |
| 19 | +#if defined(__riscv_xcvalu) |
| 20 | + |
| 21 | +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__)) |
| 22 | + |
| 23 | +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_abs(long a) { |
| 24 | + return __builtin_abs(a); |
| 25 | +} |
| 26 | + |
| 27 | +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_slet(long a, long b) { |
| 28 | + return __builtin_riscv_cv_alu_slet(a, b); |
| 29 | +} |
| 30 | + |
| 31 | +static __inline__ long __DEFAULT_FN_ATTRS |
| 32 | +__riscv_cv_alu_sletu(unsigned long a, unsigned long b) { |
| 33 | + return __builtin_riscv_cv_alu_sletu(a, b); |
| 34 | +} |
| 35 | + |
| 36 | +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_min(long a, long b) { |
| 37 | + return __builtin_elementwise_min(a, b); |
| 38 | +} |
| 39 | + |
| 40 | +static __inline__ unsigned long __DEFAULT_FN_ATTRS |
| 41 | +__riscv_cv_alu_minu(unsigned long a, unsigned long b) { |
| 42 | + return __builtin_elementwise_min(a, b); |
| 43 | +} |
| 44 | + |
| 45 | +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_max(long a, long b) { |
| 46 | + return __builtin_elementwise_max(a, b); |
| 47 | +} |
| 48 | + |
| 49 | +static __inline__ unsigned long __DEFAULT_FN_ATTRS |
| 50 | +__riscv_cv_alu_maxu(unsigned long a, unsigned long b) { |
| 51 | + return __builtin_elementwise_max(a, b); |
| 52 | +} |
| 53 | + |
| 54 | +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_exths(int16_t a) { |
| 55 | + return __builtin_riscv_cv_alu_exths(a); |
| 56 | +} |
| 57 | + |
| 58 | +static __inline__ unsigned long __DEFAULT_FN_ATTRS |
| 59 | +__riscv_cv_alu_exthz(uint16_t a) { |
| 60 | + return __builtin_riscv_cv_alu_exthz(a); |
| 61 | +} |
| 62 | + |
| 63 | +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_extbs(int8_t a) { |
| 64 | + return __builtin_riscv_cv_alu_extbs(a); |
| 65 | +} |
| 66 | + |
| 67 | +static __inline__ unsigned long __DEFAULT_FN_ATTRS |
| 68 | +__riscv_cv_alu_extbz(uint8_t a) { |
| 69 | + return __builtin_riscv_cv_alu_extbz(a); |
| 70 | +} |
| 71 | + |
| 72 | +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_clip(long a, |
| 73 | + unsigned long b) { |
| 74 | + return __builtin_riscv_cv_alu_clip(a, b); |
| 75 | +} |
| 76 | + |
| 77 | +static __inline__ unsigned long __DEFAULT_FN_ATTRS |
| 78 | +__riscv_cv_alu_clipu(unsigned long a, unsigned long b) { |
| 79 | + return __builtin_riscv_cv_alu_clipu(a, b); |
| 80 | +} |
| 81 | + |
| 82 | +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_addN(long a, long b, |
| 83 | + uint8_t shft) { |
| 84 | + return __builtin_riscv_cv_alu_addN(a, b, shft); |
| 85 | +} |
| 86 | + |
| 87 | +static __inline__ unsigned long __DEFAULT_FN_ATTRS |
| 88 | +__riscv_cv_alu_adduN(unsigned long a, unsigned long b, uint8_t shft) { |
| 89 | + return __builtin_riscv_cv_alu_adduN(a, b, shft); |
| 90 | +} |
| 91 | + |
| 92 | +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_addRN(long a, long b, |
| 93 | + uint8_t shft) { |
| 94 | + return __builtin_riscv_cv_alu_addRN(a, b, shft); |
| 95 | +} |
| 96 | + |
| 97 | +static __inline__ unsigned long __DEFAULT_FN_ATTRS |
| 98 | +__riscv_cv_alu_adduRN(unsigned long a, unsigned long b, uint8_t shft) { |
| 99 | + return __builtin_riscv_cv_alu_adduRN(a, b, shft); |
| 100 | +} |
| 101 | + |
| 102 | +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_subN(long a, long b, |
| 103 | + uint8_t shft) { |
| 104 | + return __builtin_riscv_cv_alu_subN(a, b, shft); |
| 105 | +} |
| 106 | + |
| 107 | +static __inline__ unsigned long __DEFAULT_FN_ATTRS |
| 108 | +__riscv_cv_alu_subuN(unsigned long a, unsigned long b, uint8_t shft) { |
| 109 | + return __builtin_riscv_cv_alu_subuN(a, b, shft); |
| 110 | +} |
| 111 | + |
| 112 | +static __inline__ long __DEFAULT_FN_ATTRS __riscv_cv_alu_subRN(long a, long b, |
| 113 | + uint8_t shft) { |
| 114 | + return __builtin_riscv_cv_alu_subRN(a, b, shft); |
| 115 | +} |
| 116 | + |
| 117 | +static __inline__ unsigned long __DEFAULT_FN_ATTRS |
| 118 | +__riscv_cv_alu_subuRN(unsigned long a, unsigned long b, uint8_t shft) { |
| 119 | + return __builtin_riscv_cv_alu_subuRN(a, b, shft); |
| 120 | +} |
| 121 | + |
| 122 | +#endif // defined(__riscv_xcvalu) |
| 123 | + |
| 124 | +#if defined(__cplusplus) |
| 125 | +} |
| 126 | +#endif |
| 127 | + |
| 128 | +#endif // define __RISCV_COREV_ALU_H |
0 commit comments