1 /*
2   Copyright (c) 2019-2021, Intel Corporation
3   All rights reserved.
4 
5   Redistribution and use in source and binary forms, with or without
6   modification, are permitted provided that the following conditions are
7   met:
8 
9     * Redistributions of source code must retain the above copyright
10       notice, this list of conditions and the following disclaimer.
11 
12     * Redistributions in binary form must reproduce the above copyright
13       notice, this list of conditions and the following disclaimer in the
14       documentation and/or other materials provided with the distribution.
15 
16     * Neither the name of Intel Corporation nor the names of its
17       contributors may be used to endorse or promote products derived from
18       this software without specific prior written permission.
19 
20 
21    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22    IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23    TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
25    OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 
34 /** @file target_enums.h
35     @brief Define enums describing target platform.
36 */
37 
38 #pragma once
39 
40 #include <string>
41 #include <vector>
42 
43 namespace ispc {
44 
45 enum class CallingConv { uninitialized, defaultcall, x86_vectorcall };
46 
47 enum class TargetOS { windows, linux, custom_linux, freebsd, dragonfly, macos, android, ios, ps4, web, error };
48 
49 TargetOS ParseOS(std::string os);
50 std::string OSToString(TargetOS os);
51 std::string OSToLowerString(TargetOS os);
52 TargetOS GetHostOS();
53 
54 enum class Arch { none, x86, x86_64, arm, aarch64, wasm32, genx32, genx64, error };
55 
56 Arch ParseArch(std::string arch);
57 std::string ArchToString(Arch arch);
58 
59 enum class ISPCTarget {
60     none,
61     host,
62     sse2_i32x4,
63     sse2_i32x8,
64     sse4_i8x16,
65     sse4_i16x8,
66     sse4_i32x4,
67     sse4_i32x8,
68     avx1_i32x4,
69     avx1_i32x8,
70     avx1_i32x16,
71     avx1_i64x4,
72     avx2_i8x32,
73     avx2_i16x16,
74     avx2_i32x4,
75     avx2_i32x8,
76     avx2_i32x16,
77     avx2_i64x4,
78     avx512knl_i32x16,
79     avx512skx_i32x8,
80     avx512skx_i32x16,
81     avx512skx_i8x64,
82     avx512skx_i16x32,
83     neon_i8x16,
84     neon_i16x8,
85     neon_i32x4,
86     neon_i32x8,
87     wasm_i32x4,
88     genx_x8,
89     genx_x16,
90     error
91 };
92 
93 ISPCTarget ParseISPCTarget(std::string target);
94 std::pair<std::vector<ISPCTarget>, std::string> ParseISPCTargets(const char *target);
95 std::string ISPCTargetToString(ISPCTarget target);
96 bool ISPCTargetIsX86(ISPCTarget target);
97 bool ISPCTargetIsNeon(ISPCTarget target);
98 bool ISPCTargetIsWasm(ISPCTarget target);
99 bool ISPCTargetIsGen(ISPCTarget target);
100 } // namespace ispc
101