tgsi_parse.h revision 101f792a2af9c9a19a050afba8b60caa689466a5
1/**************************************************************************
2 *
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
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 TUNGSTEN GRAPHICS 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_PARSE_H
29#define TGSI_PARSE_H
30
31#include "pipe/p_shader_tokens.h"
32
33#if defined __cplusplus
34extern "C" {
35#endif
36
37struct tgsi_full_header
38{
39   struct tgsi_header      Header;
40   struct tgsi_processor   Processor;
41};
42
43struct tgsi_full_dst_register
44{
45   struct tgsi_dst_register               Register;
46   struct tgsi_src_register               Indirect;
47   struct tgsi_dimension                  Dimension;
48   struct tgsi_src_register               DimIndirect;
49};
50
51struct tgsi_full_src_register
52{
53   struct tgsi_src_register         Register;
54   struct tgsi_src_register         Indirect;
55   struct tgsi_dimension            Dimension;
56   struct tgsi_src_register         DimIndirect;
57};
58
59struct tgsi_immediate_array_data
60{
61   union tgsi_immediate_data *u;
62};
63
64struct tgsi_full_declaration
65{
66   struct tgsi_declaration Declaration;
67   struct tgsi_declaration_range Range;
68   struct tgsi_declaration_dimension Dim;
69   struct tgsi_declaration_semantic Semantic;
70   struct tgsi_immediate_array_data ImmediateData;
71};
72
73struct tgsi_full_immediate
74{
75   struct tgsi_immediate   Immediate;
76   union tgsi_immediate_data u[4];
77};
78
79struct tgsi_full_property
80{
81   struct tgsi_property   Property;
82   struct tgsi_property_data u[8];
83};
84
85#define TGSI_FULL_MAX_DST_REGISTERS 2
86#define TGSI_FULL_MAX_SRC_REGISTERS 4 /* TXD has 4 */
87
88struct tgsi_full_instruction
89{
90   struct tgsi_instruction             Instruction;
91   struct tgsi_instruction_predicate   Predicate;
92   struct tgsi_instruction_label       Label;
93   struct tgsi_instruction_texture     Texture;
94   struct tgsi_full_dst_register       Dst[TGSI_FULL_MAX_DST_REGISTERS];
95   struct tgsi_full_src_register       Src[TGSI_FULL_MAX_SRC_REGISTERS];
96};
97
98union tgsi_full_token
99{
100   struct tgsi_token             Token;
101   struct tgsi_full_declaration  FullDeclaration;
102   struct tgsi_full_immediate    FullImmediate;
103   struct tgsi_full_instruction  FullInstruction;
104   struct tgsi_full_property     FullProperty;
105};
106
107struct tgsi_parse_context
108{
109   const struct tgsi_token    *Tokens;
110   unsigned                   Position;
111   struct tgsi_full_header    FullHeader;
112   union tgsi_full_token      FullToken;
113};
114
115#define TGSI_PARSE_OK      0
116#define TGSI_PARSE_ERROR   1
117
118unsigned
119tgsi_parse_init(
120   struct tgsi_parse_context *ctx,
121   const struct tgsi_token *tokens );
122
123void
124tgsi_parse_free(
125   struct tgsi_parse_context *ctx );
126
127boolean
128tgsi_parse_end_of_tokens(
129   struct tgsi_parse_context *ctx );
130
131void
132tgsi_parse_token(
133   struct tgsi_parse_context *ctx );
134
135unsigned
136tgsi_num_tokens(const struct tgsi_token *tokens);
137
138struct tgsi_token *
139tgsi_dup_tokens(const struct tgsi_token *tokens);
140
141struct tgsi_token *
142tgsi_alloc_tokens(unsigned num_tokens);
143
144
145#if defined __cplusplus
146}
147#endif
148
149#endif /* TGSI_PARSE_H */
150
151