1bf215546Sopenharmony_ci/************************************************************************** 2bf215546Sopenharmony_ci * 3bf215546Sopenharmony_ci * Copyright 2007 VMware, Inc. 4bf215546Sopenharmony_ci * All Rights Reserved. 5bf215546Sopenharmony_ci * 6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the 8bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 9bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 10bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to 11bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 12bf215546Sopenharmony_ci * the following conditions: 13bf215546Sopenharmony_ci * 14bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the 15bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 16bf215546Sopenharmony_ci * of the Software. 17bf215546Sopenharmony_ci * 18bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21bf215546Sopenharmony_ci * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25bf215546Sopenharmony_ci * 26bf215546Sopenharmony_ci **************************************************************************/ 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ci#ifndef TGSI_PARSE_H 29bf215546Sopenharmony_ci#define TGSI_PARSE_H 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci#include "pipe/p_compiler.h" 32bf215546Sopenharmony_ci#include "pipe/p_shader_tokens.h" 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci#if defined __cplusplus 35bf215546Sopenharmony_ciextern "C" { 36bf215546Sopenharmony_ci#endif 37bf215546Sopenharmony_ci 38bf215546Sopenharmony_cistruct tgsi_full_header 39bf215546Sopenharmony_ci{ 40bf215546Sopenharmony_ci struct tgsi_header Header; 41bf215546Sopenharmony_ci struct tgsi_processor Processor; 42bf215546Sopenharmony_ci}; 43bf215546Sopenharmony_ci 44bf215546Sopenharmony_cistruct tgsi_full_dst_register 45bf215546Sopenharmony_ci{ 46bf215546Sopenharmony_ci struct tgsi_dst_register Register; 47bf215546Sopenharmony_ci struct tgsi_ind_register Indirect; 48bf215546Sopenharmony_ci struct tgsi_dimension Dimension; 49bf215546Sopenharmony_ci struct tgsi_ind_register DimIndirect; 50bf215546Sopenharmony_ci}; 51bf215546Sopenharmony_ci 52bf215546Sopenharmony_cistruct tgsi_full_src_register 53bf215546Sopenharmony_ci{ 54bf215546Sopenharmony_ci struct tgsi_src_register Register; 55bf215546Sopenharmony_ci struct tgsi_ind_register Indirect; 56bf215546Sopenharmony_ci struct tgsi_dimension Dimension; 57bf215546Sopenharmony_ci struct tgsi_ind_register DimIndirect; 58bf215546Sopenharmony_ci}; 59bf215546Sopenharmony_ci 60bf215546Sopenharmony_cistruct tgsi_full_declaration 61bf215546Sopenharmony_ci{ 62bf215546Sopenharmony_ci struct tgsi_declaration Declaration; 63bf215546Sopenharmony_ci struct tgsi_declaration_range Range; 64bf215546Sopenharmony_ci struct tgsi_declaration_dimension Dim; 65bf215546Sopenharmony_ci struct tgsi_declaration_interp Interp; 66bf215546Sopenharmony_ci struct tgsi_declaration_semantic Semantic; 67bf215546Sopenharmony_ci struct tgsi_declaration_image Image; 68bf215546Sopenharmony_ci struct tgsi_declaration_sampler_view SamplerView; 69bf215546Sopenharmony_ci struct tgsi_declaration_array Array; 70bf215546Sopenharmony_ci}; 71bf215546Sopenharmony_ci 72bf215546Sopenharmony_cistruct tgsi_full_immediate 73bf215546Sopenharmony_ci{ 74bf215546Sopenharmony_ci struct tgsi_immediate Immediate; 75bf215546Sopenharmony_ci union tgsi_immediate_data u[4]; 76bf215546Sopenharmony_ci}; 77bf215546Sopenharmony_ci 78bf215546Sopenharmony_cistruct tgsi_full_property 79bf215546Sopenharmony_ci{ 80bf215546Sopenharmony_ci struct tgsi_property Property; 81bf215546Sopenharmony_ci struct tgsi_property_data u[8]; 82bf215546Sopenharmony_ci}; 83bf215546Sopenharmony_ci 84bf215546Sopenharmony_ci#define TGSI_FULL_MAX_DST_REGISTERS 2 85bf215546Sopenharmony_ci#define TGSI_FULL_MAX_SRC_REGISTERS 5 /* SAMPLE_D has 5 */ 86bf215546Sopenharmony_ci#define TGSI_FULL_MAX_TEX_OFFSETS 4 87bf215546Sopenharmony_ci 88bf215546Sopenharmony_cistruct tgsi_full_instruction 89bf215546Sopenharmony_ci{ 90bf215546Sopenharmony_ci struct tgsi_instruction Instruction; 91bf215546Sopenharmony_ci struct tgsi_instruction_label Label; 92bf215546Sopenharmony_ci struct tgsi_instruction_texture Texture; 93bf215546Sopenharmony_ci struct tgsi_instruction_memory Memory; 94bf215546Sopenharmony_ci struct tgsi_full_dst_register Dst[TGSI_FULL_MAX_DST_REGISTERS]; 95bf215546Sopenharmony_ci struct tgsi_full_src_register Src[TGSI_FULL_MAX_SRC_REGISTERS]; 96bf215546Sopenharmony_ci struct tgsi_texture_offset TexOffsets[TGSI_FULL_MAX_TEX_OFFSETS]; 97bf215546Sopenharmony_ci}; 98bf215546Sopenharmony_ci 99bf215546Sopenharmony_ciunion tgsi_full_token 100bf215546Sopenharmony_ci{ 101bf215546Sopenharmony_ci struct tgsi_token Token; 102bf215546Sopenharmony_ci struct tgsi_full_declaration FullDeclaration; 103bf215546Sopenharmony_ci struct tgsi_full_immediate FullImmediate; 104bf215546Sopenharmony_ci struct tgsi_full_instruction FullInstruction; 105bf215546Sopenharmony_ci struct tgsi_full_property FullProperty; 106bf215546Sopenharmony_ci}; 107bf215546Sopenharmony_ci 108bf215546Sopenharmony_cistruct tgsi_parse_context 109bf215546Sopenharmony_ci{ 110bf215546Sopenharmony_ci const struct tgsi_token *Tokens; 111bf215546Sopenharmony_ci unsigned Position; 112bf215546Sopenharmony_ci struct tgsi_full_header FullHeader; 113bf215546Sopenharmony_ci union tgsi_full_token FullToken; 114bf215546Sopenharmony_ci}; 115bf215546Sopenharmony_ci 116bf215546Sopenharmony_ci#define TGSI_PARSE_OK 0 117bf215546Sopenharmony_ci#define TGSI_PARSE_ERROR 1 118bf215546Sopenharmony_ci 119bf215546Sopenharmony_ciunsigned 120bf215546Sopenharmony_citgsi_parse_init( 121bf215546Sopenharmony_ci struct tgsi_parse_context *ctx, 122bf215546Sopenharmony_ci const struct tgsi_token *tokens ); 123bf215546Sopenharmony_ci 124bf215546Sopenharmony_civoid 125bf215546Sopenharmony_citgsi_parse_free( 126bf215546Sopenharmony_ci struct tgsi_parse_context *ctx ); 127bf215546Sopenharmony_ci 128bf215546Sopenharmony_ciboolean 129bf215546Sopenharmony_citgsi_parse_end_of_tokens( 130bf215546Sopenharmony_ci struct tgsi_parse_context *ctx ); 131bf215546Sopenharmony_ci 132bf215546Sopenharmony_civoid 133bf215546Sopenharmony_citgsi_parse_token( 134bf215546Sopenharmony_ci struct tgsi_parse_context *ctx ); 135bf215546Sopenharmony_ci 136bf215546Sopenharmony_cistatic inline unsigned 137bf215546Sopenharmony_citgsi_num_tokens(const struct tgsi_token *tokens) 138bf215546Sopenharmony_ci{ 139bf215546Sopenharmony_ci struct tgsi_header header; 140bf215546Sopenharmony_ci memcpy(&header, tokens, sizeof(header)); 141bf215546Sopenharmony_ci return header.HeaderSize + header.BodySize; 142bf215546Sopenharmony_ci} 143bf215546Sopenharmony_ci 144bf215546Sopenharmony_civoid 145bf215546Sopenharmony_citgsi_dump_tokens(const struct tgsi_token *tokens); 146bf215546Sopenharmony_ci 147bf215546Sopenharmony_cistruct tgsi_token * 148bf215546Sopenharmony_citgsi_dup_tokens(const struct tgsi_token *tokens); 149bf215546Sopenharmony_ci 150bf215546Sopenharmony_cistruct tgsi_token * 151bf215546Sopenharmony_citgsi_alloc_tokens(unsigned num_tokens); 152bf215546Sopenharmony_ci 153bf215546Sopenharmony_civoid 154bf215546Sopenharmony_citgsi_free_tokens(const struct tgsi_token *tokens); 155bf215546Sopenharmony_ci 156bf215546Sopenharmony_ciunsigned 157bf215546Sopenharmony_citgsi_get_processor_type(const struct tgsi_token *tokens); 158bf215546Sopenharmony_ci 159bf215546Sopenharmony_ci#if defined __cplusplus 160bf215546Sopenharmony_ci} 161bf215546Sopenharmony_ci#endif 162bf215546Sopenharmony_ci 163bf215546Sopenharmony_ci#endif /* TGSI_PARSE_H */ 164bf215546Sopenharmony_ci 165