Merge commit 'origin/master' into i965g-restart
[mesa.git] / src / gallium / auxiliary / tgsi / tgsi_parse.h
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
34 extern "C" {
35 #endif
36
37 struct tgsi_full_header
38 {
39 struct tgsi_header Header;
40 struct tgsi_processor Processor;
41 };
42
43 struct tgsi_full_dst_register
44 {
45 struct tgsi_dst_register Register;
46 struct tgsi_src_register Indirect;
47 };
48
49 struct tgsi_full_src_register
50 {
51 struct tgsi_src_register Register;
52 struct tgsi_src_register Indirect;
53 struct tgsi_dimension Dimension;
54 struct tgsi_src_register DimIndirect;
55 };
56
57 struct tgsi_full_declaration
58 {
59 struct tgsi_declaration Declaration;
60 struct tgsi_declaration_range Range;
61 struct tgsi_declaration_semantic Semantic;
62 };
63
64 struct tgsi_full_immediate
65 {
66 struct tgsi_immediate Immediate;
67 union tgsi_immediate_data u[4];
68 };
69
70 #define TGSI_FULL_MAX_DST_REGISTERS 2
71 #define TGSI_FULL_MAX_SRC_REGISTERS 4 /* TXD has 4 */
72
73 struct tgsi_full_instruction
74 {
75 struct tgsi_instruction Instruction;
76 struct tgsi_instruction_predicate Predicate;
77 struct tgsi_instruction_label Label;
78 struct tgsi_instruction_texture Texture;
79 struct tgsi_full_dst_register Dst[TGSI_FULL_MAX_DST_REGISTERS];
80 struct tgsi_full_src_register Src[TGSI_FULL_MAX_SRC_REGISTERS];
81 };
82
83 union tgsi_full_token
84 {
85 struct tgsi_token Token;
86 struct tgsi_full_declaration FullDeclaration;
87 struct tgsi_full_immediate FullImmediate;
88 struct tgsi_full_instruction FullInstruction;
89 };
90
91 struct tgsi_parse_context
92 {
93 const struct tgsi_token *Tokens;
94 unsigned Position;
95 struct tgsi_full_header FullHeader;
96 union tgsi_full_token FullToken;
97 };
98
99 #define TGSI_PARSE_OK 0
100 #define TGSI_PARSE_ERROR 1
101
102 unsigned
103 tgsi_parse_init(
104 struct tgsi_parse_context *ctx,
105 const struct tgsi_token *tokens );
106
107 void
108 tgsi_parse_free(
109 struct tgsi_parse_context *ctx );
110
111 boolean
112 tgsi_parse_end_of_tokens(
113 struct tgsi_parse_context *ctx );
114
115 void
116 tgsi_parse_token(
117 struct tgsi_parse_context *ctx );
118
119 unsigned
120 tgsi_num_tokens(const struct tgsi_token *tokens);
121
122 struct tgsi_token *
123 tgsi_dup_tokens(const struct tgsi_token *tokens);
124
125 #if defined __cplusplus
126 }
127 #endif
128
129 #endif /* TGSI_PARSE_H */
130