Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
[mesa.git] / src / gallium / auxiliary / tgsi / util / 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_version
38 {
39 struct tgsi_version Version;
40 };
41
42 struct tgsi_full_header
43 {
44 struct tgsi_header Header;
45 struct tgsi_processor Processor;
46 };
47
48 struct tgsi_full_dst_register
49 {
50 struct tgsi_dst_register DstRegister;
51 struct tgsi_dst_register_ext_concode DstRegisterExtConcode;
52 struct tgsi_dst_register_ext_modulate DstRegisterExtModulate;
53 };
54
55 struct tgsi_full_src_register
56 {
57 struct tgsi_src_register SrcRegister;
58 struct tgsi_src_register_ext_swz SrcRegisterExtSwz;
59 struct tgsi_src_register_ext_mod SrcRegisterExtMod;
60 struct tgsi_src_register SrcRegisterInd;
61 struct tgsi_dimension SrcRegisterDim;
62 struct tgsi_src_register SrcRegisterDimInd;
63 };
64
65 struct tgsi_full_declaration
66 {
67 struct tgsi_declaration Declaration;
68 union
69 {
70 struct tgsi_declaration_range DeclarationRange;
71 struct tgsi_declaration_mask DeclarationMask;
72 } u;
73 struct tgsi_declaration_interpolation Interpolation;
74 struct tgsi_declaration_semantic Semantic;
75 };
76
77 struct tgsi_full_immediate
78 {
79 struct tgsi_immediate Immediate;
80 union
81 {
82 const void *Pointer;
83 const struct tgsi_immediate_float32 *ImmediateFloat32;
84 } u;
85 };
86
87 #define TGSI_FULL_MAX_DST_REGISTERS 2
88 #define TGSI_FULL_MAX_SRC_REGISTERS 4 /* TXD has 4 */
89
90 struct tgsi_full_instruction
91 {
92 struct tgsi_instruction Instruction;
93 struct tgsi_instruction_ext_nv InstructionExtNv;
94 struct tgsi_instruction_ext_label InstructionExtLabel;
95 struct tgsi_instruction_ext_texture InstructionExtTexture;
96 struct tgsi_full_dst_register FullDstRegisters[TGSI_FULL_MAX_DST_REGISTERS];
97 struct tgsi_full_src_register FullSrcRegisters[TGSI_FULL_MAX_SRC_REGISTERS];
98 };
99
100 union tgsi_full_token
101 {
102 struct tgsi_token Token;
103 struct tgsi_full_declaration FullDeclaration;
104 struct tgsi_full_immediate FullImmediate;
105 struct tgsi_full_instruction FullInstruction;
106 };
107
108 void
109 tgsi_full_token_init(
110 union tgsi_full_token *full_token );
111
112 void
113 tgsi_full_token_free(
114 union tgsi_full_token *full_token );
115
116 struct tgsi_parse_context
117 {
118 const struct tgsi_token *Tokens;
119 unsigned Position;
120 struct tgsi_full_version FullVersion;
121 struct tgsi_full_header FullHeader;
122 union tgsi_full_token FullToken;
123 };
124
125 #define TGSI_PARSE_OK 0
126 #define TGSI_PARSE_ERROR 1
127
128 unsigned
129 tgsi_parse_init(
130 struct tgsi_parse_context *ctx,
131 const struct tgsi_token *tokens );
132
133 void
134 tgsi_parse_free(
135 struct tgsi_parse_context *ctx );
136
137 boolean
138 tgsi_parse_end_of_tokens(
139 struct tgsi_parse_context *ctx );
140
141 void
142 tgsi_parse_token(
143 struct tgsi_parse_context *ctx );
144
145 unsigned
146 tgsi_num_tokens(const struct tgsi_token *tokens);
147
148 struct tgsi_token *
149 tgsi_dup_tokens(const struct tgsi_token *tokens);
150
151 #if defined __cplusplus
152 }
153 #endif
154
155 #endif /* TGSI_PARSE_H */
156