1 /* Intrinsics for TI C6X.
3 Copyright (C) 2011-2024 Free Software Foundation, Inc.
4 Contributed by CodeSourcery.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published
10 by the Free Software Foundation; either version 3, or (at your
11 option) any later version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
16 License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
27 #ifndef _GCC_C6X_INTRINSICS_H
28 #define _GCC_C6X_INTRINSICS_H
30 #if !defined(__TMS320C6X__)
31 # error "c6x_intrinsics.h is only supported for C6X targets"
40 /* Define vector types. */
41 typedef uint8_t __uv4qi
__attribute__((vector_size (4)));
42 typedef int16_t __v2hi
__attribute__((vector_size (4)));
43 typedef int32_t __v2si
__attribute__((vector_size (8)));
45 __extension__
static __inline
int __attribute__ ((__always_inline__
))
48 return __builtin_c6x_abs (src
);
51 __extension__
static __inline
int __attribute__ ((__always_inline__
))
54 return (int)__builtin_c6x_abs2 ((__v2hi
)src
);
57 __extension__
static __inline
int __attribute__ ((__always_inline__
))
58 _sadd (int src1
, int src2
)
60 return __builtin_c6x_sadd (src1
, src2
);
63 __extension__
static __inline
int __attribute__ ((__always_inline__
))
64 _ssub (int src1
, int src2
)
66 return __builtin_c6x_ssub (src1
, src2
);
69 __extension__
static __inline
int __attribute__ ((__always_inline__
))
70 _add2 (int src1
, int src2
)
72 return (int)__builtin_c6x_add2 ((__v2hi
)src1
, (__v2hi
)src2
);
75 __extension__
static __inline
int __attribute__ ((__always_inline__
))
76 _sub2 (int src1
, int src2
)
78 return (int)__builtin_c6x_sub2 ((__v2hi
)src1
, (__v2hi
)src2
);
81 __extension__
static __inline
int __attribute__ ((__always_inline__
))
82 _add4 (int src1
, int src2
)
84 return (int)__builtin_c6x_add4 ((__uv4qi
)src1
, (__uv4qi
)src2
);
87 __extension__
static __inline
int __attribute__ ((__always_inline__
))
88 _sub4 (int src1
, int src2
)
90 return (int)__builtin_c6x_sub4 ((__uv4qi
)src1
, (__uv4qi
)src2
);
93 __extension__
static __inline
int __attribute__ ((__always_inline__
))
94 _sadd2 (int src1
, int src2
)
96 return (int)__builtin_c6x_sadd2 ((__v2hi
)src1
, (__v2hi
)src2
);
99 __extension__
static __inline
int __attribute__ ((__always_inline__
))
100 _ssub2 (int src1
, int src2
)
102 return (int)__builtin_c6x_ssub2 ((__v2hi
)src1
, (__v2hi
)src2
);
105 __extension__
static __inline
int __attribute__ ((__always_inline__
))
106 _saddu4 (int src1
, int src2
)
108 return (int)__builtin_c6x_saddu4 ((__uv4qi
)src1
, (__uv4qi
)src2
);
111 __extension__
static __inline
int __attribute__ ((__always_inline__
))
112 _smpy (int src1
, int src2
)
114 return __builtin_c6x_smpy (src1
, src2
);
117 __extension__
static __inline
int __attribute__ ((__always_inline__
))
118 _smpylh (int src1
, int src2
)
120 return __builtin_c6x_smpylh (src1
, src2
);
123 __extension__
static __inline
int __attribute__ ((__always_inline__
))
124 _smpyhl (int src1
, int src2
)
126 return __builtin_c6x_smpyhl (src1
, src2
);
129 __extension__
static __inline
int __attribute__ ((__always_inline__
))
130 _smpyh (int src1
, int src2
)
132 return __builtin_c6x_smpyh (src1
, src2
);
135 __extension__
static __inline
long long __attribute__ ((__always_inline__
))
136 _smpy2ll (int src1
, int src2
)
138 return (long long)__builtin_c6x_smpy2 ((__v2hi
)src1
, (__v2hi
)src2
);
141 __extension__
static __inline
long long __attribute__ ((__always_inline__
))
142 _mpy2ll (int src1
, int src2
)
144 return (long long)__builtin_c6x_mpy2 ((__v2hi
)src1
, (__v2hi
)src2
);
147 __extension__
static __inline
int __attribute__ ((__always_inline__
))
148 _extr (int src1
, int src2
)
150 return __builtin_c6x_extr (src1
, src2
);
153 __extension__
static __inline
int __attribute__ ((__always_inline__
))
154 _extru (int src1
, int src2
)
156 return __builtin_c6x_extru (src1
, src2
);
159 __extension__
static __inline
int __attribute__ ((__always_inline__
))
160 _clrr (int src1
, int src2
)
162 return __builtin_c6x_clrr (src1
, src2
);
165 __extension__
static __inline
int __attribute__ ((__always_inline__
))
166 _avg2 (int src1
, int src2
)
168 return (int)__builtin_c6x_avg2 ((__v2hi
)src1
, (__v2hi
)src2
);
171 __extension__
static __inline
int __attribute__ ((__always_inline__
))
172 _avgu4 (int src1
, int src2
)
174 return (int)__builtin_c6x_avgu4 ((__uv4qi
)src1
, (__uv4qi
)src2
);
177 __extension__
static __inline
int __attribute__ ((__always_inline__
))
178 _sshl (int src1
, int src2
)
180 return __builtin_c6x_sshl (src1
, src2
);
183 __extension__
static __inline
int __attribute__ ((__always_inline__
))
184 _subc (int src1
, int src2
)
186 return __builtin_c6x_subc (src1
, src2
);