xref: /aosp_15_r20/external/mesa3d/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
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 <[email protected]>
34  * @author Tom Stellard <[email protected]>
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 "util/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
53 extern "C" {
54 #endif
55 
56 #define LP_CHAN_ALL ~0u
57 
58 struct tgsi_full_declaration;
59 struct tgsi_full_immediate;
60 struct tgsi_full_instruction;
61 struct tgsi_full_src_register;
62 struct tgsi_full_dst_register;
63 struct tgsi_opcode_info;
64 struct tgsi_token;
65 struct tgsi_shader_info;
66 struct lp_build_mask_context;
67 struct gallivm_state;
68 struct lp_derivatives;
69 struct lp_build_gs_iface;
70 
71 enum lp_build_tex_modifier {
72    LP_BLD_TEX_MODIFIER_NONE = 0,
73    LP_BLD_TEX_MODIFIER_PROJECTED,
74    LP_BLD_TEX_MODIFIER_LOD_BIAS,
75    LP_BLD_TEX_MODIFIER_EXPLICIT_LOD,
76    LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV,
77    LP_BLD_TEX_MODIFIER_LOD_ZERO
78 };
79 
80 
81 /**
82  * Describe a channel of a register.
83  *
84  * The value can be a:
85  * - immediate value (i.e. derived from a IMM register)
86  * - CONST[n].x/y/z/w
87  * - IN[n].x/y/z/w
88  * - undetermined (when .file == TGSI_FILE_NULL)
89  *
90  * This is one of the analysis results, and is used to described
91  * the output color in terms of inputs.
92  */
93 struct lp_tgsi_channel_info
94 {
95    unsigned file:4; /* TGSI_FILE_* */
96    unsigned swizzle:3; /* PIPE_SWIZZLE_x */
97    union {
98       uint32_t index;
99       float value; /* for TGSI_FILE_IMMEDIATE */
100    } u;
101 };
102 
103 
104 /**
105  * Describe a texture sampler interpolator.
106  *
107  * The interpolation is described in terms of regular inputs.
108  */
109 struct lp_tgsi_texture_info
110 {
111    struct lp_tgsi_channel_info coord[4];
112    unsigned target:8; /* TGSI_TEXTURE_* */
113    unsigned sampler_unit:8;  /* Sampler unit */
114    unsigned texture_unit:8;  /* Texture unit */
115    unsigned modifier:8; /* LP_BLD_TEX_MODIFIER_* */
116 };
117 
118 
119 struct lp_tgsi_info
120 {
121    struct tgsi_shader_info base;
122 
123    /*
124     * Whether any of the texture opcodes access a register file other than
125     * TGSI_FILE_INPUT.
126     *
127     * We could also handle TGSI_FILE_CONST/IMMEDIATE here, but there is little
128     * benefit.
129     */
130    unsigned indirect_textures:1;
131 
132    /*
133     * Whether any of the texture (sample) ocpodes use different sampler
134     * and sampler view unit.
135     */
136    unsigned sampler_texture_units_different:1;
137 
138    /*
139     * Whether any immediate values are outside the range of 0 and 1
140     */
141    unsigned unclamped_immediates:1;
142 
143    /*
144     * Texture opcode description. Aimed at detecting and described direct
145     * texture opcodes.
146     */
147    unsigned num_texs;
148    struct lp_tgsi_texture_info tex[PIPE_MAX_SAMPLERS];
149 
150    /*
151     * Output description. Aimed at detecting and describing simple blit
152     * shaders.
153     */
154    struct lp_tgsi_channel_info output[PIPE_MAX_SHADER_OUTPUTS][4];
155 
156    /*
157     * Shortcut pointers into the above (for fragment shaders).
158     */
159    const struct lp_tgsi_channel_info *cbuf[PIPE_MAX_COLOR_BUFS];
160 };
161 
162 /**
163  * Reference to system values.
164  */
165 struct lp_bld_tgsi_system_values {
166    LLVMValueRef instance_id;
167    LLVMValueRef base_instance;
168    LLVMValueRef vertex_id;
169    LLVMValueRef vertex_id_nobase;
170    LLVMValueRef prim_id;
171    LLVMValueRef basevertex;
172    LLVMValueRef firstvertex;
173    LLVMValueRef invocation_id;
174    LLVMValueRef draw_id;
175    LLVMValueRef thread_id[3];
176    LLVMValueRef block_id[3];
177    LLVMValueRef grid_size[3];
178    LLVMValueRef front_facing;
179    LLVMValueRef work_dim;
180    LLVMValueRef block_size[3];
181    LLVMValueRef tess_coord;
182    LLVMValueRef tess_outer;
183    LLVMValueRef tess_inner;
184    LLVMValueRef vertices_in;
185    LLVMValueRef sample_id;
186    LLVMTypeRef sample_pos_type;
187    LLVMValueRef sample_pos;
188    LLVMValueRef sample_mask_in;
189    LLVMValueRef view_index;
190    LLVMValueRef subgroup_id;
191    LLVMValueRef num_subgroups;
192 };
193 
194 
195 /**
196  * Sampler code generation interface.
197  *
198  * Although texture sampling is a requirement for TGSI translation, it is
199  * a very different problem with several different approaches to it. This
200  * structure establishes an interface for texture sampling code generation, so
201  * that we can easily use different texture sampling strategies.
202  */
203 struct lp_build_sampler_soa
204 {
205    void
206    (*emit_tex_sample)(const struct lp_build_sampler_soa *sampler,
207                       struct gallivm_state *gallivm,
208                       const struct lp_sampler_params *params);
209 
210    void
211    (*emit_size_query)(const struct lp_build_sampler_soa *sampler,
212                       struct gallivm_state *gallivm,
213                       const struct lp_sampler_size_query_params *params);
214 };
215 
216 
217 struct lp_build_sampler_aos
218 {
219    LLVMValueRef
220    (*emit_fetch_texel)(const struct lp_build_sampler_aos *sampler,
221                        struct lp_build_context *bld,
222                        enum tgsi_texture_type target,
223                        unsigned unit,
224                        LLVMValueRef coords,
225                        const struct lp_derivatives derivs,
226                        enum lp_build_tex_modifier modifier);
227 };
228 
229 struct lp_img_params;
230 
231 struct lp_build_image_soa
232 {
233    void
234    (*emit_op)(const struct lp_build_image_soa *image,
235               struct gallivm_state *gallivm,
236               const struct lp_img_params *params);
237 
238    void
239    (*emit_size_query)(const struct lp_build_image_soa *sampler,
240                       struct gallivm_state *gallivm,
241                       const struct lp_sampler_size_query_params *params);
242 };
243 
244 struct lp_build_fs_iface;
245 struct lp_build_fs_iface {
246    LLVMValueRef (*interp_fn)(const struct lp_build_fs_iface *iface,
247                              struct lp_build_context *bld,
248                              unsigned attrib, unsigned chan,
249                              bool centroid, bool sample,
250                              LLVMValueRef indir_index, LLVMValueRef offsets[2]);
251 
252    void (*fb_fetch)(const struct lp_build_fs_iface *iface,
253                     struct lp_build_context *bld,
254                     int location,
255                     LLVMValueRef result[4]);
256 };
257 
258 void
259 lp_build_tgsi_info(const struct tgsi_token *tokens,
260                    struct lp_tgsi_info *info);
261 
262 
263 struct lp_build_tgsi_params {
264    struct lp_type type;
265    struct lp_build_mask_context *mask;
266    LLVMValueRef consts_ptr;
267    LLVMValueRef const_sizes_ptr;
268    const struct lp_bld_tgsi_system_values *system_values;
269    const LLVMValueRef (*inputs)[4];
270    int num_inputs;
271    LLVMTypeRef context_type;
272    LLVMValueRef context_ptr;
273    LLVMTypeRef resources_type;
274    LLVMValueRef resources_ptr;
275    LLVMTypeRef thread_data_type;
276    LLVMValueRef thread_data_ptr;
277    const struct lp_build_sampler_soa *sampler;
278    const struct tgsi_shader_info *info;
279    const struct lp_build_gs_iface *gs_iface;
280    const struct lp_build_tcs_iface *tcs_iface;
281    const struct lp_build_tes_iface *tes_iface;
282    const struct lp_build_mesh_iface *mesh_iface;
283    LLVMValueRef ssbo_ptr;
284    LLVMValueRef ssbo_sizes_ptr;
285    const struct lp_build_image_soa *image;
286    LLVMValueRef shared_ptr;
287    LLVMValueRef payload_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    LLVMValueRef current_func;
294    struct hash_table *fns;
295    LLVMValueRef scratch_ptr;
296    LLVMValueRef call_context_ptr;
297 };
298 
299 void
300 lp_build_tgsi_soa(struct gallivm_state *gallivm,
301                   const struct tgsi_token *tokens,
302                   const struct lp_build_tgsi_params *params,
303                   LLVMValueRef (*outputs)[4]);
304 
305 struct lp_build_tgsi_inst_list
306 {
307    struct tgsi_full_instruction *instructions;
308    unsigned max_instructions;
309    unsigned num_instructions;
310 };
311 
312 unsigned lp_bld_tgsi_list_init(struct lp_build_tgsi_context * bld_base);
313 
314 
315 unsigned lp_bld_tgsi_add_instruction(
316    struct lp_build_tgsi_context * bld_base,
317    const struct tgsi_full_instruction *inst_to_add);
318 
319 
320 struct lp_build_tgsi_context;
321 
322 
323 typedef LLVMValueRef (*lp_build_emit_fetch_fn)(struct lp_build_tgsi_context *,
324                                         const struct tgsi_full_src_register *,
325                                         enum tgsi_opcode_type,
326                                         unsigned);
327 
328 typedef void (*lp_build_emit_store_reg_fn)(struct lp_build_tgsi_context *,
329                               enum tgsi_opcode_type,
330                               const struct tgsi_full_dst_register *,
331                               unsigned,
332                               unsigned,
333                               LLVMValueRef,
334                               LLVMValueRef);
335 
336 struct lp_build_tgsi_context
337 {
338    struct lp_build_context base;
339 
340    struct lp_build_context uint_bld;
341    struct lp_build_context int_bld;
342 
343    struct lp_build_context dbl_bld;
344 
345    struct lp_build_context uint64_bld;
346    struct lp_build_context int64_bld;
347 
348    /** This array stores functions that are used to transform TGSI opcodes to
349      * LLVM instructions.
350      */
351    struct lp_build_tgsi_action op_actions[TGSI_OPCODE_LAST];
352 
353    /* TGSI_OPCODE_RSQ is defined as 1 / sqrt( abs(src0.x) ), rsq_action
354     * should compute 1 / sqrt (src0.x) */
355    struct lp_build_tgsi_action rsq_action;
356 
357    struct lp_build_tgsi_action sqrt_action;
358 
359    struct lp_build_tgsi_action drsq_action;
360 
361    struct lp_build_tgsi_action dsqrt_action;
362    const struct tgsi_shader_info *info;
363 
364    lp_build_emit_fetch_fn emit_fetch_funcs[TGSI_FILE_COUNT];
365    lp_build_emit_store_reg_fn emit_store_reg_funcs[TGSI_FILE_COUNT];
366 
367    LLVMValueRef (*emit_swizzle)(struct lp_build_tgsi_context *,
368                          LLVMValueRef, unsigned, unsigned, unsigned, unsigned);
369 
370 
371    void (*emit_debug)(struct lp_build_tgsi_context *,
372                       const struct tgsi_full_instruction *,
373                       const struct tgsi_opcode_info *);
374 
375    void (*emit_store)(struct lp_build_tgsi_context *,
376                       const struct tgsi_full_instruction *,
377                       const struct tgsi_opcode_info *,
378                       unsigned index,
379                       LLVMValueRef dst[4]);
380 
381    void (*emit_declaration)(struct lp_build_tgsi_context *,
382                              const struct tgsi_full_declaration *decl);
383 
384    void (*emit_immediate)(struct lp_build_tgsi_context *,
385                           const struct tgsi_full_immediate *imm);
386 
387 
388    /* Allow the user to store data in this structure rather than passing it
389     * to every function. */
390    void * userdata;
391 
392    bool soa;
393 
394    int pc;
395 
396    struct tgsi_full_instruction *instructions;
397    unsigned max_instructions;
398    unsigned num_instructions;
399 
400    /** This function allows the user to insert some instructions at the
401      * beginning of the program.  It is optional and does not need to be
402      * implemented.
403      */
404    void (*emit_prologue)(struct lp_build_tgsi_context*);
405 
406    /** This function allows the user to insert some instructions after
407      * declarations section, but before any other code.
408      * It is optional and does not need to be implemented.
409      */
410    void (*emit_prologue_post_decl)(struct lp_build_tgsi_context*);
411 
412    /** This function allows the user to insert some instructions at the end of
413      * the program.  This callback is intended to be used for emitting
414      * instructions to handle the export for the output registers, but it can
415      * be used for any purpose.  Implementing this function is optiona, but
416      * recommended.
417      */
418    void (*emit_epilogue)(struct lp_build_tgsi_context*);
419 };
420 
421 struct lp_build_gs_iface
422 {
423    LLVMValueRef (*fetch_input)(const struct lp_build_gs_iface *gs_iface,
424                                struct lp_build_context * bld,
425                                bool is_vindex_indirect,
426                                LLVMValueRef vertex_index,
427                                bool is_aindex_indirect,
428                                LLVMValueRef attrib_index,
429                                LLVMValueRef swizzle_index);
430    void (*emit_vertex)(const struct lp_build_gs_iface *gs_iface,
431                        struct lp_build_context * bld,
432                        LLVMValueRef (*outputs)[4],
433                        LLVMValueRef emitted_vertices_vec,
434                        LLVMValueRef mask_vec, LLVMValueRef stream_id);
435    void (*end_primitive)(const struct lp_build_gs_iface *gs_iface,
436                          struct lp_build_context * bld,
437                          LLVMValueRef total_emitted_vertices_vec,
438                          LLVMValueRef verts_per_prim_vec,
439                          LLVMValueRef emitted_prims_vec,
440                          LLVMValueRef mask_vec, unsigned stream);
441    void (*gs_epilogue)(const struct lp_build_gs_iface *gs_iface,
442                        LLVMValueRef total_emitted_vertices_vec,
443                        LLVMValueRef emitted_prims_vec, unsigned stream);
444 };
445 
446 struct lp_build_tcs_iface
447 {
448    void (*emit_prologue)(struct lp_build_context * bld);
449    void (*emit_epilogue)(struct lp_build_context * bld);
450    void (*emit_barrier)(struct lp_build_context *bld_base);
451 
452    void (*emit_store_output)(const struct lp_build_tcs_iface *tcs_iface,
453                              struct lp_build_context * bld,
454                              unsigned name,
455                              bool is_vindex_indirect,
456                              LLVMValueRef vertex_index,
457                              bool is_aindex_indirect,
458                              LLVMValueRef attrib_index,
459                              bool is_sindex_indirect,
460                              LLVMValueRef swizzle_index,
461                              LLVMValueRef value,
462                              LLVMValueRef mask_vec);
463 
464    LLVMValueRef (*emit_fetch_input)(const struct lp_build_tcs_iface *tcs_iface,
465                                     struct lp_build_context * bld,
466                                     bool is_vindex_indirect,
467                                     LLVMValueRef vertex_index,
468                                     bool is_aindex_indirect,
469                                     LLVMValueRef attrib_index,
470                                     bool is_sindex_indirect,
471                                     LLVMValueRef swizzle_index);
472 
473    LLVMValueRef (*emit_fetch_output)(const struct lp_build_tcs_iface *tcs_iface,
474                                     struct lp_build_context * bld,
475                                     bool is_vindex_indirect,
476                                     LLVMValueRef vertex_index,
477                                     bool is_aindex_indirect,
478                                     LLVMValueRef attrib_index,
479                                     bool is_sindex_indirect,
480                                     LLVMValueRef swizzle_index,
481                                     uint32_t name);
482 };
483 
484 struct lp_build_tes_iface
485 {
486    LLVMValueRef (*fetch_vertex_input)(const struct lp_build_tes_iface *tes_iface,
487                                       struct lp_build_context * bld,
488                                       bool is_vindex_indirect,
489                                       LLVMValueRef vertex_index,
490                                       bool is_aindex_indirect,
491                                       LLVMValueRef attrib_index,
492                                       bool is_sindex_indirect,
493                                       LLVMValueRef swizzle_index);
494 
495    LLVMValueRef (*fetch_patch_input)(const struct lp_build_tes_iface *tes_iface,
496                                      struct lp_build_context * bld,
497                                      bool is_aindex_indirect,
498                                      LLVMValueRef attrib_index,
499                                      LLVMValueRef swizzle_index);
500 };
501 
502 struct lp_build_mesh_iface
503 {
504    void (*emit_store_output)(const struct lp_build_mesh_iface *mesh_iface,
505                              struct lp_build_context * bld,
506                              unsigned name,
507                              bool is_vindex_indirect,
508                              LLVMValueRef vertex_index,
509                              bool is_aindex_indirect,
510                              LLVMValueRef attrib_index,
511                              bool is_sindex_indirect,
512                              LLVMValueRef swizzle_index,
513                              LLVMValueRef value,
514                              LLVMValueRef mask_vec);
515    void (*emit_vertex_and_primitive_count)(const struct lp_build_mesh_iface *mesh_iface,
516                                            struct lp_build_context *bld,
517                                            LLVMValueRef vertices_count,
518                                            LLVMValueRef primitives_count);
519 };
520 
521 struct lp_build_tgsi_soa_context
522 {
523    struct lp_build_tgsi_context bld_base;
524 
525    /* Builder for scalar elements of shader's data type (float) */
526    struct lp_build_context elem_bld;
527 
528    const struct lp_build_gs_iface *gs_iface;
529    const struct lp_build_tcs_iface *tcs_iface;
530    const struct lp_build_tes_iface *tes_iface;
531 
532    LLVMValueRef emitted_prims_vec_ptr;
533    LLVMValueRef total_emitted_vertices_vec_ptr;
534    LLVMValueRef emitted_vertices_vec_ptr;
535    LLVMValueRef max_output_vertices_vec;
536 
537    LLVMValueRef consts_ptr;
538    LLVMValueRef consts[LP_MAX_TGSI_CONST_BUFFERS];
539    LLVMValueRef consts_sizes[LP_MAX_TGSI_CONST_BUFFERS];
540    const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS];
541    LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS];
542    LLVMTypeRef context_type;
543    LLVMValueRef context_ptr;
544    LLVMTypeRef resources_type;
545    LLVMValueRef resources_ptr;
546    LLVMTypeRef thread_data_type;
547    LLVMValueRef thread_data_ptr;
548 
549    LLVMValueRef ssbo_ptr;
550    LLVMValueRef ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
551    LLVMValueRef ssbo_sizes[LP_MAX_TGSI_SHADER_BUFFERS];
552 
553    LLVMValueRef shared_ptr;
554 
555    const struct lp_build_coro_suspend_info *coro;
556 
557    const struct lp_build_sampler_soa *sampler;
558    const struct lp_build_image_soa *image;
559 
560    struct tgsi_declaration_sampler_view sv[PIPE_MAX_SHADER_SAMPLER_VIEWS];
561 
562    LLVMValueRef immediates[LP_MAX_INLINED_IMMEDIATES][TGSI_NUM_CHANNELS];
563    LLVMValueRef temps[LP_MAX_INLINED_TEMPS][TGSI_NUM_CHANNELS];
564    LLVMValueRef addr[LP_MAX_TGSI_ADDRS][TGSI_NUM_CHANNELS];
565 
566    /* We allocate/use this array of temps if (1 << TGSI_FILE_TEMPORARY) is
567     * set in the indirect_files field.
568     * The temps[] array above is unused then.
569     */
570    LLVMTypeRef temps_array_type;
571    LLVMValueRef temps_array;
572 
573    /* We allocate/use this array of output if (1 << TGSI_FILE_OUTPUT) is
574     * set in the indirect_files field.
575     * The outputs[] array above is unused then.
576     */
577    LLVMTypeRef outputs_array_type;
578    LLVMValueRef outputs_array;
579 
580    /* We allocate/use this array of inputs if (1 << TGSI_FILE_INPUT) is
581     * set in the indirect_files field.
582     * The inputs[] array above is unused then.
583     */
584    LLVMValueRef inputs_array;
585 
586    /* We allocate/use this array of temps if (1 << TGSI_FILE_IMMEDIATE) is
587     * set in the indirect_files field.
588     */
589    LLVMValueRef imms_array;
590 
591 
592    struct lp_bld_tgsi_system_values system_values;
593 
594    /** bitmask indicating which register files are accessed indirectly */
595    unsigned indirect_files;
596 
597    struct lp_build_mask_context *mask;
598    struct lp_exec_mask exec_mask;
599 
600    unsigned num_immediates;
601    bool use_immediates_array;
602 };
603 
604 void
605 lp_emit_declaration_soa(
606    struct lp_build_tgsi_context *bld,
607    const struct tgsi_full_declaration *decl);
608 
609 void lp_emit_immediate_soa(
610    struct lp_build_tgsi_context *bld_base,
611    const struct tgsi_full_immediate *imm);
612 
613 bool
614 lp_emit_instruction_soa(
615    struct lp_build_tgsi_soa_context *bld,
616    const struct tgsi_full_instruction *inst,
617    const struct tgsi_opcode_info *info);
618 
619 
620 LLVMValueRef
621 lp_get_temp_ptr_soa(
622    struct lp_build_tgsi_soa_context *bld,
623    unsigned index,
624    unsigned chan);
625 
626 LLVMValueRef
627 lp_get_output_ptr(
628    struct lp_build_tgsi_soa_context *bld,
629    unsigned index,
630    unsigned chan);
631 
632 static inline struct lp_build_tgsi_soa_context *
lp_soa_context(struct lp_build_tgsi_context * bld_base)633 lp_soa_context(struct lp_build_tgsi_context *bld_base)
634 {
635    return (struct lp_build_tgsi_soa_context *)bld_base;
636 }
637 
638 void lp_build_fetch_args(
639    struct lp_build_tgsi_context * bld_base,
640    struct lp_build_emit_data * emit_data);
641 
642 void
643 lp_build_tgsi_intrinsic(
644  const struct lp_build_tgsi_action * action,
645  struct lp_build_tgsi_context * bld_base,
646  struct lp_build_emit_data * emit_data);
647 
648 LLVMValueRef
649 lp_build_emit_llvm(
650    struct lp_build_tgsi_context *bld_base,
651    unsigned tgsi_opcode,
652    struct lp_build_emit_data * emit_data);
653 
654 LLVMValueRef
655 lp_build_emit_llvm_unary(
656    struct lp_build_tgsi_context *bld_base,
657    unsigned tgsi_opcode,
658    LLVMValueRef arg0);
659 
660 LLVMValueRef
661 lp_build_emit_llvm_binary(
662    struct lp_build_tgsi_context *bld_base,
663    unsigned tgsi_opcode,
664    LLVMValueRef arg0,
665    LLVMValueRef arg1);
666 
667 LLVMValueRef
668 lp_build_emit_llvm_ternary(
669    struct lp_build_tgsi_context *bld_base,
670    unsigned tgsi_opcode,
671    LLVMValueRef arg0,
672    LLVMValueRef arg1,
673    LLVMValueRef arg2);
674 
675 bool
676 lp_build_tgsi_inst_llvm(
677    struct lp_build_tgsi_context * bld_base,
678    const struct tgsi_full_instruction *inst);
679 
680 LLVMValueRef
681 lp_build_emit_fetch_src(
682    struct lp_build_tgsi_context *bld_base,
683    const struct tgsi_full_src_register *reg,
684    enum tgsi_opcode_type stype,
685    const unsigned chan_index);
686 
687 LLVMValueRef
688 lp_build_emit_fetch(
689    struct lp_build_tgsi_context *bld_base,
690    const struct tgsi_full_instruction *inst,
691    unsigned src_op,
692    const unsigned chan_index);
693 
694 
695 LLVMValueRef
696 lp_build_emit_fetch_texoffset(
697    struct lp_build_tgsi_context *bld_base,
698    const struct tgsi_full_instruction *inst,
699    unsigned tex_off_op,
700    const unsigned chan_index);
701 
702 bool
703 lp_build_tgsi_llvm(
704    struct lp_build_tgsi_context * bld_base,
705    const struct tgsi_token *tokens);
706 
707 #ifdef __cplusplus
708 }
709 #endif
710 
711 #endif /* LP_BLD_TGSI_H */
712