Vxsort (#37159)
[platform/upstream/dotnet/runtime.git] / src / coreclr / src / gc / vxsort / machine_traits.h
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3
4 //
5 // Created by dans on 6/1/20.
6 //
7
8 #ifndef VXSORT_MACHINE_TRAITS_H
9 #define VXSORT_MACHINE_TRAITS_H
10
11 //#include <cstdint>
12
13 namespace vxsort {
14
15 enum vector_machine {
16     NONE,
17     AVX2,
18     AVX512,
19     SVE,
20 };
21
22 template <typename T, vector_machine M>
23 struct vxsort_machine_traits {
24    public:
25     typedef int TV;
26     typedef int TMASK;
27
28     static constexpr bool supports_compress_writes();
29
30     static TV load_vec(TV* ptr);
31     static void store_vec(TV* ptr, TV v);
32     static void store_compress_vec(TV* ptr, TV v, TMASK mask);
33     static TV partition_vector(TV v, int mask);
34     static TV broadcast(T pivot);
35     static TMASK get_cmpgt_mask(TV a, TV b);
36
37     static TV shift_right(TV v, int i);
38     static TV shift_left(TV v, int i);
39
40     static TV add(TV a, TV b);
41     static TV sub(TV a, TV b);
42
43     static TV pack_ordered(TV a, TV b);
44     static TV pack_unordered(TV a, TV b);
45
46     static void unpack_ordered_signed(TV p, TV& u1, TV& u2);
47     static void unpack_ordered_unsigned(TV p, TV& u1, TV& u2);
48
49
50 };
51 }
52
53 #endif  // VXSORT_MACHINE_TRAITS_H