1848b8605Smrg/**************************************************************************
2848b8605Smrg *
3848b8605Smrg * Copyright 2008 VMware, Inc.
4848b8605Smrg * All Rights Reserved.
5848b8605Smrg *
6848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a
7848b8605Smrg * copy of this software and associated documentation files (the
8848b8605Smrg * "Software"), to deal in the Software without restriction, including
9848b8605Smrg * without limitation the rights to use, copy, modify, merge, publish,
10848b8605Smrg * distribute, sub license, and/or sell copies of the Software, and to
11848b8605Smrg * permit persons to whom the Software is furnished to do so, subject to
12848b8605Smrg * the following conditions:
13848b8605Smrg *
14848b8605Smrg * The above copyright notice and this permission notice (including the
15848b8605Smrg * next paragraph) shall be included in all copies or substantial portions
16848b8605Smrg * of the Software.
17848b8605Smrg *
18848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19848b8605Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20848b8605Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21848b8605Smrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22848b8605Smrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23848b8605Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24848b8605Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25848b8605Smrg *
26848b8605Smrg **************************************************************************/
27848b8605Smrg
28848b8605Smrg#ifndef TGSI_INFO_H
29848b8605Smrg#define TGSI_INFO_H
30848b8605Smrg
31848b8605Smrg#include "pipe/p_compiler.h"
32848b8605Smrg#include "pipe/p_shader_tokens.h"
33848b8605Smrg#include "util/u_format.h"
34848b8605Smrg
35848b8605Smrg#if defined __cplusplus
36848b8605Smrgextern "C" {
37848b8605Smrg#endif
38848b8605Smrg
39848b8605Smrg/* This enum describes how an opcode calculates its result. */
40848b8605Smrgenum tgsi_output_mode {
41848b8605Smrg   /** The opcode produces no result. */
42848b8605Smrg   TGSI_OUTPUT_NONE            = 0,
43848b8605Smrg
44848b8605Smrg   /** When this opcode writes to a channel of the destination register,
45848b8605Smrg    *  it takes as arguments values from the same channel of the source
46848b8605Smrg    *  register(s).
47848b8605Smrg    *
48848b8605Smrg    *  Example: TGSI_OPCODE_ADD
49848b8605Smrg    */
50848b8605Smrg   TGSI_OUTPUT_COMPONENTWISE   = 1,
51848b8605Smrg
52848b8605Smrg   /** This opcode writes the same value to all enabled channels of the
53848b8605Smrg    * destination register.
54848b8605Smrg    *
55848b8605Smrg    *  Example: TGSI_OPCODE_RSQ
56848b8605Smrg    */
57848b8605Smrg   TGSI_OUTPUT_REPLICATE       = 2,
58848b8605Smrg
59848b8605Smrg   /** The operation performed by this opcode is dependent on which channel
60848b8605Smrg    *  of the destination register is being written.
61848b8605Smrg    *
62848b8605Smrg    *  Example: TGSI_OPCODE_LOG
63848b8605Smrg    */
64848b8605Smrg   TGSI_OUTPUT_CHAN_DEPENDENT  = 3,
65848b8605Smrg
66848b8605Smrg   /**
67848b8605Smrg    * Example: TGSI_OPCODE_TEX
68848b8605Smrg    */
69848b8605Smrg   TGSI_OUTPUT_OTHER           = 4
70848b8605Smrg};
71848b8605Smrg
72848b8605Smrgstruct tgsi_opcode_info
73848b8605Smrg{
74848b8605Smrg   unsigned num_dst:3;
75848b8605Smrg   unsigned num_src:3;
76848b8605Smrg   unsigned is_tex:1;
77b8e80941Smrg   unsigned is_store:1;
78848b8605Smrg   unsigned is_branch:1;
79b8e80941Smrg   unsigned pre_dedent:1;
80b8e80941Smrg   unsigned post_indent:1;
81b8e80941Smrg   enum tgsi_output_mode output_mode:4;
82b8e80941Smrg   enum tgsi_opcode opcode:10;
83848b8605Smrg};
84848b8605Smrg
85848b8605Smrgconst struct tgsi_opcode_info *
86b8e80941Smrgtgsi_get_opcode_info(enum tgsi_opcode opcode);
87848b8605Smrg
88848b8605Smrgconst char *
89b8e80941Smrgtgsi_get_opcode_name(enum tgsi_opcode opcode);
90848b8605Smrg
91848b8605Smrgconst char *
92b8e80941Smrgtgsi_get_processor_name(enum pipe_shader_type processor);
93848b8605Smrg
94848b8605Smrgenum tgsi_opcode_type {
95848b8605Smrg   TGSI_TYPE_UNTYPED, /* for MOV */
96848b8605Smrg   TGSI_TYPE_VOID,
97848b8605Smrg   TGSI_TYPE_UNSIGNED,
98848b8605Smrg   TGSI_TYPE_SIGNED,
99848b8605Smrg   TGSI_TYPE_FLOAT,
100b8e80941Smrg   TGSI_TYPE_DOUBLE,
101b8e80941Smrg   TGSI_TYPE_UNSIGNED64,
102b8e80941Smrg   TGSI_TYPE_SIGNED64,
103848b8605Smrg};
104848b8605Smrg
105b8e80941Smrgstatic inline bool tgsi_type_is_64bit(enum tgsi_opcode_type type)
106b8e80941Smrg{
107b8e80941Smrg   if (type == TGSI_TYPE_DOUBLE || type == TGSI_TYPE_UNSIGNED64 ||
108b8e80941Smrg       type == TGSI_TYPE_SIGNED64)
109b8e80941Smrg      return true;
110b8e80941Smrg   return false;
111b8e80941Smrg}
112b8e80941Smrg
113848b8605Smrgenum tgsi_opcode_type
114b8e80941Smrgtgsi_opcode_infer_src_type(enum tgsi_opcode opcode, uint src_idx);
115848b8605Smrg
116848b8605Smrgenum tgsi_opcode_type
117b8e80941Smrgtgsi_opcode_infer_dst_type(enum tgsi_opcode opcode, uint dst_idx);
118848b8605Smrg
119848b8605Smrg#if defined __cplusplus
120848b8605Smrg}
121848b8605Smrg#endif
122848b8605Smrg
123848b8605Smrg#endif /* TGSI_INFO_H */
124