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