Skip to content

Commit e22c1ad

Browse files
maciej-czekajgerekon
authored andcommitted
[Xtensa] Add HIFI3 C types and intrinsics
1 parent b0e6831 commit e22c1ad

File tree

3 files changed

+6974
-1
lines changed

3 files changed

+6974
-1
lines changed

clang/lib/Headers/CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ set(x86_files
234234
cpuid.h
235235
)
236236

237+
set(xtensa_files
238+
xtensa_defs.h
239+
xtensa_protos.h
240+
)
241+
237242
set(windows_only_files
238243
intrin.h
239244
vadefs.h
@@ -261,6 +266,7 @@ set(files
261266
${systemz_files}
262267
${ve_files}
263268
${x86_files}
269+
${xtensa_files}
264270
${webassembly_files}
265271
${windows_only_files}
266272
${utility_files}
@@ -463,6 +469,7 @@ add_header_target("systemz-resource-headers" "${systemz_files}")
463469
add_header_target("ve-resource-headers" "${ve_files}")
464470
add_header_target("webassembly-resource-headers" "${webassembly_files}")
465471
add_header_target("x86-resource-headers" "${x86_files}")
472+
add_header_target("xtensa-resource-headers" "${xtensa_files}")
466473

467474
# Other header groupings
468475
add_header_target("hlsl-resource-headers" ${hlsl_files})
@@ -633,7 +640,13 @@ if(NOT CLANG_ENABLE_HLSL)
633640
endif()
634641

635642
install(
636-
FILES ${hlsl_h}
643+
FILES ${xtensa_files}
644+
DESTINATION ${header_install_dir}
645+
EXCLUDE_FROM_ALL
646+
COMPONENT xtensa-resource-headers)
647+
648+
install(
649+
FILES ${hlsl_files}
637650
DESTINATION ${header_install_dir}
638651
${EXCLUDE_HLSL}
639652
COMPONENT hlsl-resource-headers)

clang/lib/Headers/xtensa_defs.h

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*===---- xtensa_defs.h - Xtensa definitions -------------------------------===
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+
#ifndef __XTENSAHIFI3_H
10+
#define __XTENSAHIFI3_H
11+
12+
typedef __attribute__((ext_vector_type(1))) _Bool xtbool;
13+
typedef __attribute__((ext_vector_type(2))) _Bool xtbool2;
14+
typedef __attribute__((ext_vector_type(4))) _Bool xtbool4;
15+
16+
typedef int ae_int32 __attribute__((vector_size(4)));
17+
typedef int ae_int32x2 __attribute__((vector_size(8)));
18+
typedef short ae_int16 __attribute__((vector_size(2)));
19+
typedef short ae_int16x2 __attribute__((vector_size(4)));
20+
typedef short ae_int16x4 __attribute__((vector_size(8)));
21+
typedef long long ae_int64 __attribute__((vector_size(8)));
22+
typedef unsigned char ae_valign __attribute__((vector_size(8)));
23+
typedef ae_int16x4 ae_f16x4;
24+
typedef ae_int32x2 ae_f32x2;
25+
typedef ae_int32 ae_f32;
26+
typedef ae_int64 ae_f64;
27+
typedef ae_int32 ae_f24;
28+
typedef ae_int32x2 ae_f24x2;
29+
typedef ae_int16 ae_f16;
30+
31+
#include <xtensa_protos.h>
32+
33+
#define AE_SETCBEGIN0(x) WUR_AE_CBEGIN0(x)
34+
#define AE_SETCEND0(x) WUR_AE_CEND0(x)
35+
#define AE_ZERO64(x) AE_MOVI(0)
36+
#define AE_ZERO24(x) AE_MOVI(0)
37+
#define AE_ZERO32(x) AE_MOVI(0)
38+
#define AE_ZERO16(x) AE_MOVI(0)
39+
#define AE_ZEROQ56(x) AE_ZERO64(x)
40+
41+
#define AE_SEL32_L(a) \
42+
({ \
43+
ae_int32x2 _a = a; \
44+
__builtin_shufflevector(_a, _a, 0); \
45+
})
46+
47+
#define AE_INT32(a) __builtin_xtensa_ae_int32(a);
48+
#define AE_INT32X2(a) __builtin_xtensa_ae_int32x2(a);
49+
50+
#define AE_F32X2 AE_INT32X2
51+
#define AE_F32 AE_INT32
52+
53+
#define AE_MOVINT16X4_FROMINT32X2(a) ((ae_int32x2)(a))
54+
55+
#define AE_F32_ADDS_F32(s1, s2) \
56+
AE_F32(AE_ADD32S(AE_INT32X2(s1), AE_INT32X2(s2)))
57+
58+
typedef float xtfloat;
59+
60+
#define XT_xtfloat_storeip(x, a, i) ({ a = __builtin_xtensa_xt_ssip(x, a, i); })
61+
#define XT_xtfloat_loadip(x, a, i) \
62+
({ x = __builtin_xtensa_xt_lsip((xtfloat **)&a, i); })
63+
#define XT_xtfloat_loadxp(x, a, i) \
64+
({ x = __builtin_xtensa_xt_lsxp((xtfloat **)&a, i); })
65+
66+
#endif /* __XTENSAHIFI3_H */

0 commit comments

Comments
 (0)