1 /*===---- velintrin.h - VEL intrinsics for VE ------------------------------===
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 __VEL_INTRIN_H__
10 #define __VEL_INTRIN_H__
11
12 // Vector registers
13 typedef double __vr __attribute__((__vector_size__(2048)));
14
15 // Vector mask registers
16 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
17 // For C99
18 typedef _Bool __vm __attribute__((ext_vector_type(256)));
19 typedef _Bool __vm256 __attribute__((ext_vector_type(256)));
20 typedef _Bool __vm512 __attribute__((ext_vector_type(512)));
21 #else
22 #ifdef __cplusplus
23 // For C++
24 typedef bool __vm __attribute__((ext_vector_type(256)));
25 typedef bool __vm256 __attribute__((ext_vector_type(256)));
26 typedef bool __vm512 __attribute__((ext_vector_type(512)));
27 #else
28 #error need C++ or C99 to use vector intrinsics for VE
29 #endif
30 #endif
31
32 enum VShuffleCodes {
33 VE_VSHUFFLE_YUYU = 0,
34 VE_VSHUFFLE_YUYL = 1,
35 VE_VSHUFFLE_YUZU = 2,
36 VE_VSHUFFLE_YUZL = 3,
37 VE_VSHUFFLE_YLYU = 4,
38 VE_VSHUFFLE_YLYL = 5,
39 VE_VSHUFFLE_YLZU = 6,
40 VE_VSHUFFLE_YLZL = 7,
41 VE_VSHUFFLE_ZUYU = 8,
42 VE_VSHUFFLE_ZUYL = 9,
43 VE_VSHUFFLE_ZUZU = 10,
44 VE_VSHUFFLE_ZUZL = 11,
45 VE_VSHUFFLE_ZLYU = 12,
46 VE_VSHUFFLE_ZLYL = 13,
47 VE_VSHUFFLE_ZLZU = 14,
48 VE_VSHUFFLE_ZLZL = 15,
49 };
50
51 // Use generated intrinsic name definitions
52 #include <velintrin_gen.h>
53
54 // Use helper functions
55 #include <velintrin_approx.h>
56
57 // pack
58
59 #define _vel_pack_f32p __builtin_ve_vl_pack_f32p
60 #define _vel_pack_f32a __builtin_ve_vl_pack_f32a
61
_vel_pack_i32(unsigned int a,unsigned int b)62 static inline unsigned long int _vel_pack_i32(unsigned int a, unsigned int b) {
63 return (((unsigned long int)a) << 32) | b;
64 }
65
66 #define _vel_extract_vm512u(vm) __builtin_ve_vl_extract_vm512u(vm)
67 #define _vel_extract_vm512l(vm) __builtin_ve_vl_extract_vm512l(vm)
68 #define _vel_insert_vm512u(vm512, vm) __builtin_ve_vl_insert_vm512u(vm512, vm)
69 #define _vel_insert_vm512l(vm512, vm) __builtin_ve_vl_insert_vm512l(vm512, vm)
70
71 #endif
72