1 /*
2 * Copyright © 2014 Connor Abbott
3 * SPDX-License-Identifier: MIT
4 */
5
6 /*
7 * This file is split off from nir.h to allow #include'ing these defines from
8 * OpenCL code.
9 */
10
11 #ifndef NIR_DEFINES_H
12 #define NIR_DEFINES_H
13
14 /** NIR sized and unsized types
15 *
16 * The values in this enum are carefully chosen so that the sized type is
17 * just the unsized type OR the number of bits.
18 */
19 /* clang-format off */
20 typedef enum ENUM_PACKED {
21 nir_type_invalid = 0, /* Not a valid type */
22 nir_type_int = 2,
23 nir_type_uint = 4,
24 nir_type_bool = 6,
25 nir_type_float = 128,
26 nir_type_bool1 = 1 | nir_type_bool,
27 nir_type_bool8 = 8 | nir_type_bool,
28 nir_type_bool16 = 16 | nir_type_bool,
29 nir_type_bool32 = 32 | nir_type_bool,
30 nir_type_int1 = 1 | nir_type_int,
31 nir_type_int8 = 8 | nir_type_int,
32 nir_type_int16 = 16 | nir_type_int,
33 nir_type_int32 = 32 | nir_type_int,
34 nir_type_int64 = 64 | nir_type_int,
35 nir_type_uint1 = 1 | nir_type_uint,
36 nir_type_uint8 = 8 | nir_type_uint,
37 nir_type_uint16 = 16 | nir_type_uint,
38 nir_type_uint32 = 32 | nir_type_uint,
39 nir_type_uint64 = 64 | nir_type_uint,
40 nir_type_float16 = 16 | nir_type_float,
41 nir_type_float32 = 32 | nir_type_float,
42 nir_type_float64 = 64 | nir_type_float,
43 } nir_alu_type;
44 /* clang-format on */
45
46 #define NIR_ALU_TYPE_SIZE_MASK 0x79
47 #define NIR_ALU_TYPE_BASE_TYPE_MASK 0x86
48
49 static inline unsigned
nir_alu_type_get_type_size(nir_alu_type type)50 nir_alu_type_get_type_size(nir_alu_type type)
51 {
52 return type & NIR_ALU_TYPE_SIZE_MASK;
53 }
54
55 static inline nir_alu_type
nir_alu_type_get_base_type(nir_alu_type type)56 nir_alu_type_get_base_type(nir_alu_type type)
57 {
58 return (nir_alu_type)(type & NIR_ALU_TYPE_BASE_TYPE_MASK);
59 }
60
61 #endif
62