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