1/************************************************************************** 2 * 3 * Copyright 2011-2012 Advanced Micro Devices, Inc. 4 * Copyright 2009 VMware, Inc. 5 * All Rights Reserved. 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a 8 * copy of this software and associated documentation files (the 9 * "Software"), to deal in the Software without restriction, including 10 * without limitation the rights to use, copy, modify, merge, publish, 11 * distribute, sub license, and/or sell copies of the Software, and to 12 * permit persons to whom the Software is furnished to do so, subject to 13 * the following conditions: 14 * 15 * The above copyright notice and this permission notice (including the 16 * next paragraph) shall be included in all copies or substantial portions 17 * of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 22 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 * 27 **************************************************************************/ 28 29/** 30 * @file 31 * TGSI to LLVM IR translation. 32 * 33 * @author Jose Fonseca <jfonseca@vmware.com> 34 * @author Tom Stellard <thomas.stellard@amd.com> 35 */ 36 37#ifndef LP_BLD_TGSI_H 38#define LP_BLD_TGSI_H 39 40#include "gallivm/lp_bld.h" 41#include "gallivm/lp_bld_tgsi_action.h" 42#include "gallivm/lp_bld_limits.h" 43#include "gallivm/lp_bld_sample.h" 44#include "gallivm/lp_bld_ir_common.h" 45#include "lp_bld_type.h" 46#include "pipe/p_compiler.h" 47#include "pipe/p_state.h" 48#include "tgsi/tgsi_exec.h" 49#include "tgsi/tgsi_scan.h" 50#include "tgsi/tgsi_info.h" 51 52#ifdef __cplusplus 53extern "C" { 54#endif 55 56#define LP_CHAN_ALL ~0u 57 58#define LP_MAX_INSTRUCTIONS 256 59 60struct tgsi_full_declaration; 61struct tgsi_full_immediate; 62struct tgsi_full_instruction; 63struct tgsi_full_src_register; 64struct tgsi_full_dst_register; 65struct tgsi_opcode_info; 66struct tgsi_token; 67struct tgsi_shader_info; 68struct lp_build_mask_context; 69struct gallivm_state; 70struct lp_derivatives; 71struct lp_build_gs_iface; 72 73enum lp_build_tex_modifier { 74 LP_BLD_TEX_MODIFIER_NONE = 0, 75 LP_BLD_TEX_MODIFIER_PROJECTED, 76 LP_BLD_TEX_MODIFIER_LOD_BIAS, 77 LP_BLD_TEX_MODIFIER_EXPLICIT_LOD, 78 LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV, 79 LP_BLD_TEX_MODIFIER_LOD_ZERO 80}; 81 82 83/** 84 * Describe a channel of a register. 85 * 86 * The value can be a: 87 * - immediate value (i.e. derived from a IMM register) 88 * - CONST[n].x/y/z/w 89 * - IN[n].x/y/z/w 90 * - undetermined (when .file == TGSI_FILE_NULL) 91 * 92 * This is one of the analysis results, and is used to described 93 * the output color in terms of inputs. 94 */ 95struct lp_tgsi_channel_info 96{ 97 unsigned file:4; /* TGSI_FILE_* */ 98 unsigned swizzle:3; /* PIPE_SWIZZLE_x */ 99 union { 100 uint32_t index; 101 float value; /* for TGSI_FILE_IMMEDIATE */ 102 } u; 103}; 104 105 106/** 107 * Describe a texture sampler interpolator. 108 * 109 * The interpolation is described in terms of regular inputs. 110 */ 111struct lp_tgsi_texture_info 112{ 113 struct lp_tgsi_channel_info coord[4]; 114 unsigned target:8; /* TGSI_TEXTURE_* */ 115 unsigned sampler_unit:8; /* Sampler unit */ 116 unsigned texture_unit:8; /* Texture unit */ 117 unsigned modifier:8; /* LP_BLD_TEX_MODIFIER_* */ 118}; 119 120 121struct lp_tgsi_info 122{ 123 struct tgsi_shader_info base; 124 125 /* 126 * Whether any of the texture opcodes access a register file other than 127 * TGSI_FILE_INPUT. 128 * 129 * We could also handle TGSI_FILE_CONST/IMMEDIATE here, but there is little 130 * benefit. 131 */ 132 unsigned indirect_textures:1; 133 134 /* 135 * Whether any of the texture (sample) ocpodes use different sampler 136 * and sampler view unit. 137 */ 138 unsigned sampler_texture_units_different:1; 139 140 /* 141 * Whether any immediate values are outside the range of 0 and 1 142 */ 143 unsigned unclamped_immediates:1; 144 145 /* 146 * Texture opcode description. Aimed at detecting and described direct 147 * texture opcodes. 148 */ 149 unsigned num_texs; 150 struct lp_tgsi_texture_info tex[PIPE_MAX_SAMPLERS]; 151 152 /* 153 * Output description. Aimed at detecting and describing simple blit 154 * shaders. 155 */ 156 struct lp_tgsi_channel_info output[PIPE_MAX_SHADER_OUTPUTS][4]; 157 158 /* 159 * Shortcut pointers into the above (for fragment shaders). 160 */ 161 const struct lp_tgsi_channel_info *cbuf[PIPE_MAX_COLOR_BUFS]; 162}; 163 164/** 165 * Reference to system values. 166 */ 167struct lp_bld_tgsi_system_values { 168 LLVMValueRef instance_id; 169 LLVMValueRef base_instance; 170 LLVMValueRef vertex_id; 171 LLVMValueRef vertex_id_nobase; 172 LLVMValueRef prim_id; 173 LLVMValueRef basevertex; 174 LLVMValueRef firstvertex; 175 LLVMValueRef invocation_id; 176 LLVMValueRef draw_id; 177 LLVMValueRef thread_id; 178 LLVMValueRef block_id; 179 LLVMValueRef grid_size; 180 LLVMValueRef front_facing; 181 LLVMValueRef work_dim; 182 LLVMValueRef block_size; 183 LLVMValueRef tess_coord; 184 LLVMValueRef tess_outer; 185 LLVMValueRef tess_inner; 186 LLVMValueRef vertices_in; 187 LLVMValueRef sample_id; 188 LLVMValueRef sample_pos; 189 LLVMValueRef sample_mask_in; 190 LLVMValueRef view_index; 191 LLVMValueRef subgroup_id; 192 LLVMValueRef num_subgroups; 193}; 194 195 196/** 197 * Sampler code generation interface. 198 * 199 * Although texture sampling is a requirement for TGSI translation, it is 200 * a very different problem with several different approaches to it. This 201 * structure establishes an interface for texture sampling code generation, so 202 * that we can easily use different texture sampling strategies. 203 */ 204struct lp_build_sampler_soa 205{ 206 void 207 (*destroy)( struct lp_build_sampler_soa *sampler ); 208 209 void 210 (*emit_tex_sample)(const struct lp_build_sampler_soa *sampler, 211 struct gallivm_state *gallivm, 212 const struct lp_sampler_params *params); 213 214 void 215 (*emit_size_query)( const struct lp_build_sampler_soa *sampler, 216 struct gallivm_state *gallivm, 217 const struct lp_sampler_size_query_params *params); 218}; 219 220 221struct lp_build_sampler_aos 222{ 223 LLVMValueRef 224 (*emit_fetch_texel)( const struct lp_build_sampler_aos *sampler, 225 struct lp_build_context *bld, 226 unsigned target, /* TGSI_TEXTURE_* */ 227 unsigned unit, 228 LLVMValueRef coords, 229 const struct lp_derivatives derivs, 230 enum lp_build_tex_modifier modifier); 231}; 232 233struct lp_img_params; 234 235struct lp_build_image_soa 236{ 237 void 238 (*destroy)( struct lp_build_image_soa *image ); 239 240 void 241 (*emit_op)(const struct lp_build_image_soa *image, 242 struct gallivm_state *gallivm, 243 const struct lp_img_params *params); 244 245 void 246 (*emit_size_query)( const struct lp_build_image_soa *sampler, 247 struct gallivm_state *gallivm, 248 const struct lp_sampler_size_query_params *params); 249}; 250 251struct lp_build_fs_iface; 252struct lp_build_fs_iface { 253 LLVMValueRef (*interp_fn)(const struct lp_build_fs_iface *iface, 254 struct lp_build_context *bld, 255 unsigned attrib, unsigned chan, 256 bool centroid, bool sample, 257 LLVMValueRef indir_index, LLVMValueRef offsets[2]); 258 259 void (*fb_fetch)(const struct lp_build_fs_iface *iface, 260 struct lp_build_context *bld, 261 int location, 262 LLVMValueRef result[4]); 263}; 264 265void 266lp_build_tgsi_info(const struct tgsi_token *tokens, 267 struct lp_tgsi_info *info); 268 269 270struct lp_build_tgsi_params { 271 struct lp_type type; 272 struct lp_build_mask_context *mask; 273 LLVMValueRef consts_ptr; 274 LLVMValueRef const_sizes_ptr; 275 const struct lp_bld_tgsi_system_values *system_values; 276 const LLVMValueRef (*inputs)[4]; 277 LLVMValueRef context_ptr; 278 LLVMValueRef thread_data_ptr; 279 const struct lp_build_sampler_soa *sampler; 280 const struct tgsi_shader_info *info; 281 const struct lp_build_gs_iface *gs_iface; 282 const struct lp_build_tcs_iface *tcs_iface; 283 const struct lp_build_tes_iface *tes_iface; 284 LLVMValueRef ssbo_ptr; 285 LLVMValueRef ssbo_sizes_ptr; 286 const struct lp_build_image_soa *image; 287 LLVMValueRef shared_ptr; 288 const struct lp_build_coro_suspend_info *coro; 289 LLVMValueRef kernel_args; 290 const struct lp_build_fs_iface *fs_iface; 291 unsigned gs_vertex_streams; 292 LLVMValueRef aniso_filter_table; 293}; 294 295void 296lp_build_tgsi_soa(struct gallivm_state *gallivm, 297 const struct tgsi_token *tokens, 298 const struct lp_build_tgsi_params *params, 299 LLVMValueRef (*outputs)[4]); 300 301void 302lp_build_tgsi_aos(struct gallivm_state *gallivm, 303 const struct tgsi_token *tokens, 304 struct lp_type type, 305 const unsigned char swizzles[4], 306 LLVMValueRef consts_ptr, 307 const LLVMValueRef *inputs, 308 LLVMValueRef *outputs, 309 const struct lp_build_sampler_aos *sampler, 310 const struct tgsi_shader_info *info); 311 312 313struct lp_build_tgsi_inst_list 314{ 315 struct tgsi_full_instruction *instructions; 316 uint max_instructions; 317 uint num_instructions; 318}; 319 320unsigned lp_bld_tgsi_list_init(struct lp_build_tgsi_context * bld_base); 321 322 323unsigned lp_bld_tgsi_add_instruction( 324 struct lp_build_tgsi_context * bld_base, 325 const struct tgsi_full_instruction *inst_to_add); 326 327 328struct lp_build_tgsi_context; 329 330 331typedef LLVMValueRef (*lp_build_emit_fetch_fn)(struct lp_build_tgsi_context *, 332 const struct tgsi_full_src_register *, 333 enum tgsi_opcode_type, 334 unsigned); 335 336typedef void (*lp_build_emit_store_reg_fn)(struct lp_build_tgsi_context *, 337 enum tgsi_opcode_type, 338 const struct tgsi_full_dst_register *, 339 unsigned, 340 unsigned, 341 LLVMValueRef, 342 LLVMValueRef); 343 344struct lp_build_tgsi_context 345{ 346 struct lp_build_context base; 347 348 struct lp_build_context uint_bld; 349 struct lp_build_context int_bld; 350 351 struct lp_build_context dbl_bld; 352 353 struct lp_build_context uint64_bld; 354 struct lp_build_context int64_bld; 355 356 /** This array stores functions that are used to transform TGSI opcodes to 357 * LLVM instructions. 358 */ 359 struct lp_build_tgsi_action op_actions[TGSI_OPCODE_LAST]; 360 361 /* TGSI_OPCODE_RSQ is defined as 1 / sqrt( abs(src0.x) ), rsq_action 362 * should compute 1 / sqrt (src0.x) */ 363 struct lp_build_tgsi_action rsq_action; 364 365 struct lp_build_tgsi_action sqrt_action; 366 367 struct lp_build_tgsi_action drsq_action; 368 369 struct lp_build_tgsi_action dsqrt_action; 370 const struct tgsi_shader_info *info; 371 372 lp_build_emit_fetch_fn emit_fetch_funcs[TGSI_FILE_COUNT]; 373 lp_build_emit_store_reg_fn emit_store_reg_funcs[TGSI_FILE_COUNT]; 374 375 LLVMValueRef (*emit_swizzle)(struct lp_build_tgsi_context *, 376 LLVMValueRef, unsigned, unsigned, unsigned, unsigned); 377 378 379 void (*emit_debug)(struct lp_build_tgsi_context *, 380 const struct tgsi_full_instruction *, 381 const struct tgsi_opcode_info *); 382 383 void (*emit_store)(struct lp_build_tgsi_context *, 384 const struct tgsi_full_instruction *, 385 const struct tgsi_opcode_info *, 386 unsigned index, 387 LLVMValueRef dst[4]); 388 389 void (*emit_declaration)(struct lp_build_tgsi_context *, 390 const struct tgsi_full_declaration *decl); 391 392 void (*emit_immediate)(struct lp_build_tgsi_context *, 393 const struct tgsi_full_immediate *imm); 394 395 396 /* Allow the user to store data in this structure rather than passing it 397 * to every function. */ 398 void * userdata; 399 400 boolean soa; 401 402 int pc; 403 404 struct tgsi_full_instruction *instructions; 405 uint max_instructions; 406 uint num_instructions; 407 408 /** This function allows the user to insert some instructions at the 409 * beginning of the program. It is optional and does not need to be 410 * implemented. 411 */ 412 void (*emit_prologue)(struct lp_build_tgsi_context*); 413 414 /** This function allows the user to insert some instructions after 415 * declarations section, but before any other code. 416 * It is optional and does not need to be implemented. 417 */ 418 void (*emit_prologue_post_decl)(struct lp_build_tgsi_context*); 419 420 /** This function allows the user to insert some instructions at the end of 421 * the program. This callback is intended to be used for emitting 422 * instructions to handle the export for the output registers, but it can 423 * be used for any purpose. Implementing this function is optiona, but 424 * recommended. 425 */ 426 void (*emit_epilogue)(struct lp_build_tgsi_context*); 427}; 428 429struct lp_build_gs_iface 430{ 431 LLVMValueRef (*fetch_input)(const struct lp_build_gs_iface *gs_iface, 432 struct lp_build_context * bld, 433 boolean is_vindex_indirect, 434 LLVMValueRef vertex_index, 435 boolean is_aindex_indirect, 436 LLVMValueRef attrib_index, 437 LLVMValueRef swizzle_index); 438 void (*emit_vertex)(const struct lp_build_gs_iface *gs_iface, 439 struct lp_build_context * bld, 440 LLVMValueRef (*outputs)[4], 441 LLVMValueRef emitted_vertices_vec, 442 LLVMValueRef mask_vec, LLVMValueRef stream_id); 443 void (*end_primitive)(const struct lp_build_gs_iface *gs_iface, 444 struct lp_build_context * bld, 445 LLVMValueRef total_emitted_vertices_vec, 446 LLVMValueRef verts_per_prim_vec, 447 LLVMValueRef emitted_prims_vec, 448 LLVMValueRef mask_vec, unsigned stream); 449 void (*gs_epilogue)(const struct lp_build_gs_iface *gs_iface, 450 LLVMValueRef total_emitted_vertices_vec, 451 LLVMValueRef emitted_prims_vec, unsigned stream); 452}; 453 454struct lp_build_tcs_iface 455{ 456 void (*emit_prologue)(struct lp_build_context * bld); 457 void (*emit_epilogue)(struct lp_build_context * bld); 458 void (*emit_barrier)(struct lp_build_context *bld_base); 459 460 void (*emit_store_output)(const struct lp_build_tcs_iface *tcs_iface, 461 struct lp_build_context * bld, 462 unsigned name, 463 boolean is_vindex_indirect, 464 LLVMValueRef vertex_index, 465 boolean is_aindex_indirect, 466 LLVMValueRef attrib_index, 467 boolean is_sindex_indirect, 468 LLVMValueRef swizzle_index, 469 LLVMValueRef value, 470 LLVMValueRef mask_vec); 471 472 LLVMValueRef (*emit_fetch_input)(const struct lp_build_tcs_iface *tcs_iface, 473 struct lp_build_context * bld, 474 boolean is_vindex_indirect, 475 LLVMValueRef vertex_index, 476 boolean is_aindex_indirect, 477 LLVMValueRef attrib_index, 478 boolean is_sindex_indirect, 479 LLVMValueRef swizzle_index); 480 481 LLVMValueRef (*emit_fetch_output)(const struct lp_build_tcs_iface *tcs_iface, 482 struct lp_build_context * bld, 483 boolean is_vindex_indirect, 484 LLVMValueRef vertex_index, 485 boolean is_aindex_indirect, 486 LLVMValueRef attrib_index, 487 boolean is_sindex_indirect, 488 LLVMValueRef swizzle_index, 489 uint32_t name); 490}; 491 492struct lp_build_tes_iface 493{ 494 LLVMValueRef (*fetch_vertex_input)(const struct lp_build_tes_iface *tes_iface, 495 struct lp_build_context * bld, 496 boolean is_vindex_indirect, 497 LLVMValueRef vertex_index, 498 boolean is_aindex_indirect, 499 LLVMValueRef attrib_index, 500 boolean is_sindex_indirect, 501 LLVMValueRef swizzle_index); 502 503 LLVMValueRef (*fetch_patch_input)(const struct lp_build_tes_iface *tes_iface, 504 struct lp_build_context * bld, 505 boolean is_aindex_indirect, 506 LLVMValueRef attrib_index, 507 LLVMValueRef swizzle_index); 508}; 509 510struct lp_build_tgsi_soa_context 511{ 512 struct lp_build_tgsi_context bld_base; 513 514 /* Builder for scalar elements of shader's data type (float) */ 515 struct lp_build_context elem_bld; 516 517 const struct lp_build_gs_iface *gs_iface; 518 const struct lp_build_tcs_iface *tcs_iface; 519 const struct lp_build_tes_iface *tes_iface; 520 521 LLVMValueRef emitted_prims_vec_ptr; 522 LLVMValueRef total_emitted_vertices_vec_ptr; 523 LLVMValueRef emitted_vertices_vec_ptr; 524 LLVMValueRef max_output_vertices_vec; 525 526 LLVMValueRef consts_ptr; 527 LLVMValueRef const_sizes_ptr; 528 LLVMValueRef consts[LP_MAX_TGSI_CONST_BUFFERS]; 529 LLVMValueRef consts_sizes[LP_MAX_TGSI_CONST_BUFFERS]; 530 const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS]; 531 LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS]; 532 LLVMValueRef context_ptr; 533 LLVMValueRef thread_data_ptr; 534 535 LLVMValueRef ssbo_ptr; 536 LLVMValueRef ssbo_sizes_ptr; 537 LLVMValueRef ssbos[LP_MAX_TGSI_SHADER_BUFFERS]; 538 LLVMValueRef ssbo_sizes[LP_MAX_TGSI_SHADER_BUFFERS]; 539 540 LLVMValueRef shared_ptr; 541 542 const struct lp_build_coro_suspend_info *coro; 543 544 const struct lp_build_sampler_soa *sampler; 545 const struct lp_build_image_soa *image; 546 547 struct tgsi_declaration_sampler_view sv[PIPE_MAX_SHADER_SAMPLER_VIEWS]; 548 549 LLVMValueRef immediates[LP_MAX_INLINED_IMMEDIATES][TGSI_NUM_CHANNELS]; 550 LLVMValueRef temps[LP_MAX_INLINED_TEMPS][TGSI_NUM_CHANNELS]; 551 LLVMValueRef addr[LP_MAX_TGSI_ADDRS][TGSI_NUM_CHANNELS]; 552 553 /* We allocate/use this array of temps if (1 << TGSI_FILE_TEMPORARY) is 554 * set in the indirect_files field. 555 * The temps[] array above is unused then. 556 */ 557 LLVMValueRef temps_array; 558 559 /* We allocate/use this array of output if (1 << TGSI_FILE_OUTPUT) is 560 * set in the indirect_files field. 561 * The outputs[] array above is unused then. 562 */ 563 LLVMValueRef outputs_array; 564 565 /* We allocate/use this array of inputs if (1 << TGSI_FILE_INPUT) is 566 * set in the indirect_files field. 567 * The inputs[] array above is unused then. 568 */ 569 LLVMValueRef inputs_array; 570 571 /* We allocate/use this array of temps if (1 << TGSI_FILE_IMMEDIATE) is 572 * set in the indirect_files field. 573 */ 574 LLVMValueRef imms_array; 575 576 577 struct lp_bld_tgsi_system_values system_values; 578 579 /** bitmask indicating which register files are accessed indirectly */ 580 unsigned indirect_files; 581 582 struct lp_build_mask_context *mask; 583 struct lp_exec_mask exec_mask; 584 585 uint num_immediates; 586 boolean use_immediates_array; 587}; 588 589void 590lp_emit_declaration_soa( 591 struct lp_build_tgsi_context *bld, 592 const struct tgsi_full_declaration *decl); 593 594void lp_emit_immediate_soa( 595 struct lp_build_tgsi_context *bld_base, 596 const struct tgsi_full_immediate *imm); 597 598boolean 599lp_emit_instruction_soa( 600 struct lp_build_tgsi_soa_context *bld, 601 const struct tgsi_full_instruction *inst, 602 const struct tgsi_opcode_info *info); 603 604 605LLVMValueRef 606lp_get_temp_ptr_soa( 607 struct lp_build_tgsi_soa_context *bld, 608 unsigned index, 609 unsigned chan); 610 611LLVMValueRef 612lp_get_output_ptr( 613 struct lp_build_tgsi_soa_context *bld, 614 unsigned index, 615 unsigned chan); 616 617struct lp_build_tgsi_aos_context 618{ 619 struct lp_build_tgsi_context bld_base; 620 621 /* Builder for integer masks and indices */ 622 struct lp_build_context int_bld; 623 624 /* 625 * AoS swizzle used: 626 * - swizzles[0] = red index 627 * - swizzles[1] = green index 628 * - swizzles[2] = blue index 629 * - swizzles[3] = alpha index 630 */ 631 unsigned char swizzles[4]; 632 unsigned char inv_swizzles[4]; 633 634 LLVMValueRef consts_ptr; 635 const LLVMValueRef *inputs; 636 LLVMValueRef *outputs; 637 638 const struct lp_build_sampler_aos *sampler; 639 640 struct tgsi_declaration_sampler_view sv[PIPE_MAX_SHADER_SAMPLER_VIEWS]; 641 642 LLVMValueRef immediates[LP_MAX_INLINED_IMMEDIATES]; 643 LLVMValueRef temps[LP_MAX_INLINED_TEMPS]; 644 LLVMValueRef addr[LP_MAX_TGSI_ADDRS]; 645 646 /* We allocate/use this array of temps if (1 << TGSI_FILE_TEMPORARY) is 647 * set in the indirect_files field. 648 * The temps[] array above is unused then. 649 */ 650 LLVMValueRef temps_array; 651 652 /** bitmask indicating which register files are accessed indirectly */ 653 unsigned indirect_files; 654 655}; 656 657static inline struct lp_build_tgsi_soa_context * 658lp_soa_context(struct lp_build_tgsi_context *bld_base) 659{ 660 return (struct lp_build_tgsi_soa_context *)bld_base; 661} 662 663static inline struct lp_build_tgsi_aos_context * 664lp_aos_context(struct lp_build_tgsi_context *bld_base) 665{ 666 return (struct lp_build_tgsi_aos_context *)bld_base; 667} 668 669void 670lp_emit_declaration_aos( 671 struct lp_build_tgsi_aos_context *bld, 672 const struct tgsi_full_declaration *decl); 673 674 675boolean 676lp_emit_instruction_aos( 677 struct lp_build_tgsi_aos_context *bld, 678 const struct tgsi_full_instruction *inst, 679 const struct tgsi_opcode_info *info, 680 int *pc); 681 682void 683lp_emit_store_aos( 684 struct lp_build_tgsi_aos_context *bld, 685 const struct tgsi_full_instruction *inst, 686 unsigned index, 687 LLVMValueRef value); 688 689void lp_build_fetch_args( 690 struct lp_build_tgsi_context * bld_base, 691 struct lp_build_emit_data * emit_data); 692 693LLVMValueRef 694lp_build_tgsi_inst_llvm_aos( 695 struct lp_build_tgsi_context * bld_base, 696 const struct tgsi_full_instruction *inst); 697 698void 699lp_build_tgsi_intrinsic( 700 const struct lp_build_tgsi_action * action, 701 struct lp_build_tgsi_context * bld_base, 702 struct lp_build_emit_data * emit_data); 703 704LLVMValueRef 705lp_build_emit_llvm( 706 struct lp_build_tgsi_context *bld_base, 707 unsigned tgsi_opcode, 708 struct lp_build_emit_data * emit_data); 709 710LLVMValueRef 711lp_build_emit_llvm_unary( 712 struct lp_build_tgsi_context *bld_base, 713 unsigned tgsi_opcode, 714 LLVMValueRef arg0); 715 716LLVMValueRef 717lp_build_emit_llvm_binary( 718 struct lp_build_tgsi_context *bld_base, 719 unsigned tgsi_opcode, 720 LLVMValueRef arg0, 721 LLVMValueRef arg1); 722 723LLVMValueRef 724lp_build_emit_llvm_ternary( 725 struct lp_build_tgsi_context *bld_base, 726 unsigned tgsi_opcode, 727 LLVMValueRef arg0, 728 LLVMValueRef arg1, 729 LLVMValueRef arg2); 730 731boolean 732lp_build_tgsi_inst_llvm( 733 struct lp_build_tgsi_context * bld_base, 734 const struct tgsi_full_instruction *inst); 735 736LLVMValueRef 737lp_build_emit_fetch_src( 738 struct lp_build_tgsi_context *bld_base, 739 const struct tgsi_full_src_register *reg, 740 enum tgsi_opcode_type stype, 741 const unsigned chan_index); 742 743LLVMValueRef 744lp_build_emit_fetch( 745 struct lp_build_tgsi_context *bld_base, 746 const struct tgsi_full_instruction *inst, 747 unsigned src_op, 748 const unsigned chan_index); 749 750 751LLVMValueRef 752lp_build_emit_fetch_texoffset( 753 struct lp_build_tgsi_context *bld_base, 754 const struct tgsi_full_instruction *inst, 755 unsigned tex_off_op, 756 const unsigned chan_index); 757 758boolean 759lp_build_tgsi_llvm( 760 struct lp_build_tgsi_context * bld_base, 761 const struct tgsi_token *tokens); 762 763#ifdef __cplusplus 764} 765#endif 766 767#endif /* LP_BLD_TGSI_H */ 768