1848b8605Smrg/************************************************************************** 2848b8605Smrg * 3848b8605Smrg * Copyright 2007 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_PARSE_H 29848b8605Smrg#define TGSI_PARSE_H 30848b8605Smrg 31848b8605Smrg#include "pipe/p_compiler.h" 32848b8605Smrg#include "pipe/p_shader_tokens.h" 33848b8605Smrg 34848b8605Smrg#if defined __cplusplus 35848b8605Smrgextern "C" { 36848b8605Smrg#endif 37848b8605Smrg 38848b8605Smrgstruct tgsi_full_header 39848b8605Smrg{ 40848b8605Smrg struct tgsi_header Header; 41848b8605Smrg struct tgsi_processor Processor; 42848b8605Smrg}; 43848b8605Smrg 44848b8605Smrgstruct tgsi_full_dst_register 45848b8605Smrg{ 46848b8605Smrg struct tgsi_dst_register Register; 47848b8605Smrg struct tgsi_ind_register Indirect; 48848b8605Smrg struct tgsi_dimension Dimension; 49848b8605Smrg struct tgsi_ind_register DimIndirect; 50848b8605Smrg}; 51848b8605Smrg 52848b8605Smrgstruct tgsi_full_src_register 53848b8605Smrg{ 54848b8605Smrg struct tgsi_src_register Register; 55848b8605Smrg struct tgsi_ind_register Indirect; 56848b8605Smrg struct tgsi_dimension Dimension; 57848b8605Smrg struct tgsi_ind_register DimIndirect; 58848b8605Smrg}; 59848b8605Smrg 60848b8605Smrgstruct tgsi_full_declaration 61848b8605Smrg{ 62848b8605Smrg struct tgsi_declaration Declaration; 63848b8605Smrg struct tgsi_declaration_range Range; 64848b8605Smrg struct tgsi_declaration_dimension Dim; 65848b8605Smrg struct tgsi_declaration_interp Interp; 66848b8605Smrg struct tgsi_declaration_semantic Semantic; 67b8e80941Smrg struct tgsi_declaration_image Image; 68848b8605Smrg struct tgsi_declaration_sampler_view SamplerView; 69848b8605Smrg struct tgsi_declaration_array Array; 70848b8605Smrg}; 71848b8605Smrg 72848b8605Smrgstruct tgsi_full_immediate 73848b8605Smrg{ 74848b8605Smrg struct tgsi_immediate Immediate; 75848b8605Smrg union tgsi_immediate_data u[4]; 76848b8605Smrg}; 77848b8605Smrg 78848b8605Smrgstruct tgsi_full_property 79848b8605Smrg{ 80848b8605Smrg struct tgsi_property Property; 81848b8605Smrg struct tgsi_property_data u[8]; 82848b8605Smrg}; 83848b8605Smrg 84848b8605Smrg#define TGSI_FULL_MAX_DST_REGISTERS 2 85848b8605Smrg#define TGSI_FULL_MAX_SRC_REGISTERS 5 /* SAMPLE_D has 5 */ 86848b8605Smrg#define TGSI_FULL_MAX_TEX_OFFSETS 4 87848b8605Smrg 88848b8605Smrgstruct tgsi_full_instruction 89848b8605Smrg{ 90848b8605Smrg struct tgsi_instruction Instruction; 91848b8605Smrg struct tgsi_instruction_label Label; 92848b8605Smrg struct tgsi_instruction_texture Texture; 93b8e80941Smrg struct tgsi_instruction_memory Memory; 94848b8605Smrg struct tgsi_full_dst_register Dst[TGSI_FULL_MAX_DST_REGISTERS]; 95848b8605Smrg struct tgsi_full_src_register Src[TGSI_FULL_MAX_SRC_REGISTERS]; 96848b8605Smrg struct tgsi_texture_offset TexOffsets[TGSI_FULL_MAX_TEX_OFFSETS]; 97848b8605Smrg}; 98848b8605Smrg 99848b8605Smrgunion tgsi_full_token 100848b8605Smrg{ 101848b8605Smrg struct tgsi_token Token; 102848b8605Smrg struct tgsi_full_declaration FullDeclaration; 103848b8605Smrg struct tgsi_full_immediate FullImmediate; 104848b8605Smrg struct tgsi_full_instruction FullInstruction; 105848b8605Smrg struct tgsi_full_property FullProperty; 106848b8605Smrg}; 107848b8605Smrg 108848b8605Smrgstruct tgsi_parse_context 109848b8605Smrg{ 110848b8605Smrg const struct tgsi_token *Tokens; 111848b8605Smrg unsigned Position; 112848b8605Smrg struct tgsi_full_header FullHeader; 113848b8605Smrg union tgsi_full_token FullToken; 114848b8605Smrg}; 115848b8605Smrg 116848b8605Smrg#define TGSI_PARSE_OK 0 117848b8605Smrg#define TGSI_PARSE_ERROR 1 118848b8605Smrg 119848b8605Smrgunsigned 120848b8605Smrgtgsi_parse_init( 121848b8605Smrg struct tgsi_parse_context *ctx, 122848b8605Smrg const struct tgsi_token *tokens ); 123848b8605Smrg 124848b8605Smrgvoid 125848b8605Smrgtgsi_parse_free( 126848b8605Smrg struct tgsi_parse_context *ctx ); 127848b8605Smrg 128848b8605Smrgboolean 129848b8605Smrgtgsi_parse_end_of_tokens( 130848b8605Smrg struct tgsi_parse_context *ctx ); 131848b8605Smrg 132848b8605Smrgvoid 133848b8605Smrgtgsi_parse_token( 134848b8605Smrg struct tgsi_parse_context *ctx ); 135848b8605Smrg 136b8e80941Smrgstatic inline unsigned 137848b8605Smrgtgsi_num_tokens(const struct tgsi_token *tokens) 138848b8605Smrg{ 139848b8605Smrg struct tgsi_header header; 140848b8605Smrg memcpy(&header, tokens, sizeof(header)); 141848b8605Smrg return header.HeaderSize + header.BodySize; 142848b8605Smrg} 143848b8605Smrg 144848b8605Smrgvoid 145848b8605Smrgtgsi_dump_tokens(const struct tgsi_token *tokens); 146848b8605Smrg 147848b8605Smrgstruct tgsi_token * 148848b8605Smrgtgsi_dup_tokens(const struct tgsi_token *tokens); 149848b8605Smrg 150848b8605Smrgstruct tgsi_token * 151848b8605Smrgtgsi_alloc_tokens(unsigned num_tokens); 152848b8605Smrg 153b8e80941Smrgvoid 154b8e80941Smrgtgsi_free_tokens(const struct tgsi_token *tokens); 155b8e80941Smrg 156b8e80941Smrgunsigned 157b8e80941Smrgtgsi_get_processor_type(const struct tgsi_token *tokens); 158848b8605Smrg 159848b8605Smrg#if defined __cplusplus 160848b8605Smrg} 161848b8605Smrg#endif 162848b8605Smrg 163848b8605Smrg#endif /* TGSI_PARSE_H */ 164848b8605Smrg 165