1 /**************************************************************************
2 *
3 * Copyright 2008 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef TGSI_INFO_H
29 #define TGSI_INFO_H
30
31 #include "compiler/shader_enums.h"
32 #include "util/compiler.h"
33 #include "pipe/p_shader_tokens.h"
34 #include "util/format/u_format.h"
35
36 #if defined __cplusplus
37 extern "C" {
38 #endif
39
40 /* This enum describes how an opcode calculates its result. */
41 enum tgsi_output_mode {
42 /** The opcode produces no result. */
43 TGSI_OUTPUT_NONE = 0,
44
45 /** When this opcode writes to a channel of the destination register,
46 * it takes as arguments values from the same channel of the source
47 * register(s).
48 *
49 * Example: TGSI_OPCODE_ADD
50 */
51 TGSI_OUTPUT_COMPONENTWISE = 1,
52
53 /** This opcode writes the same value to all enabled channels of the
54 * destination register.
55 *
56 * Example: TGSI_OPCODE_RSQ
57 */
58 TGSI_OUTPUT_REPLICATE = 2,
59
60 /** The operation performed by this opcode is dependent on which channel
61 * of the destination register is being written.
62 *
63 * Example: TGSI_OPCODE_LOG
64 */
65 TGSI_OUTPUT_CHAN_DEPENDENT = 3,
66
67 /**
68 * Example: TGSI_OPCODE_TEX
69 */
70 TGSI_OUTPUT_OTHER = 4
71 };
72
73 struct tgsi_opcode_info
74 {
75 unsigned num_dst:3;
76 unsigned num_src:3;
77 unsigned is_tex:1;
78 unsigned is_store:1;
79 unsigned is_branch:1;
80 unsigned pre_dedent:1;
81 unsigned post_indent:1;
82 enum tgsi_output_mode output_mode:4;
83 enum tgsi_opcode opcode:10;
84 };
85
86 const struct tgsi_opcode_info *
87 tgsi_get_opcode_info(enum tgsi_opcode opcode);
88
89 const char *
90 tgsi_get_opcode_name(enum tgsi_opcode opcode);
91
92 enum tgsi_opcode_type {
93 TGSI_TYPE_UNTYPED, /* for MOV */
94 TGSI_TYPE_VOID,
95 TGSI_TYPE_UNSIGNED,
96 TGSI_TYPE_SIGNED,
97 TGSI_TYPE_FLOAT,
98 TGSI_TYPE_DOUBLE,
99 TGSI_TYPE_UNSIGNED64,
100 TGSI_TYPE_SIGNED64,
101 };
102
tgsi_type_is_64bit(enum tgsi_opcode_type type)103 static inline bool tgsi_type_is_64bit(enum tgsi_opcode_type type)
104 {
105 if (type == TGSI_TYPE_DOUBLE || type == TGSI_TYPE_UNSIGNED64 ||
106 type == TGSI_TYPE_SIGNED64)
107 return true;
108 return false;
109 }
110
111 enum tgsi_opcode_type
112 tgsi_opcode_infer_src_type(enum tgsi_opcode opcode, unsigned src_idx);
113
114 enum tgsi_opcode_type
115 tgsi_opcode_infer_dst_type(enum tgsi_opcode opcode, unsigned dst_idx);
116
117 #if defined __cplusplus
118 }
119 #endif
120
121 #endif /* TGSI_INFO_H */
122