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
53 extern "C" {
54 #endif
55
56 #define LP_CHAN_ALL ~0u
57
58 #define LP_MAX_INSTRUCTIONS 256
59
60 struct tgsi_full_declaration;
61 struct tgsi_full_immediate;
62 struct tgsi_full_instruction;
63 struct tgsi_full_src_register;
64 struct tgsi_full_dst_register;
65 struct tgsi_opcode_info;
66 struct tgsi_token;
67 struct tgsi_shader_info;
68 struct lp_build_mask_context;
69 struct gallivm_state;
70 struct lp_derivatives;
71 struct lp_build_gs_iface;
72
73 enum 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 */
95 struct 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 */
111 struct 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
121 struct 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 */
167 struct 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 invocation_id;
175 LLVMValueRef draw_id;
176 LLVMValueRef thread_id;
177 LLVMValueRef block_id;
178 LLVMValueRef grid_size;
179 LLVMValueRef front_facing;
180 LLVMValueRef work_dim;
181 LLVMValueRef block_size;
182 LLVMValueRef tess_coord;
183 LLVMValueRef tess_outer;
184 LLVMValueRef tess_inner;
185 LLVMValueRef vertices_in;
186 LLVMValueRef sample_id;
187 LLVMValueRef sample_pos;
188 LLVMValueRef sample_mask_in;
189 };
190
191
192 /**
193 * Sampler code generation interface.
194 *
195 * Although texture sampling is a requirement for TGSI translation, it is
196 * a very different problem with several different approaches to it. This
197 * structure establishes an interface for texture sampling code generation, so
198 * that we can easily use different texture sampling strategies.
199 */
200 struct lp_build_sampler_soa
201 {
202 void
203 (*destroy)( struct lp_build_sampler_soa *sampler );
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 unsigned target, /* TGSI_TEXTURE_* */
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 (*destroy)( struct lp_build_image_soa *image );
235
236 void
237 (*emit_op)(const struct lp_build_image_soa *image,
238 struct gallivm_state *gallivm,
239 const struct lp_img_params *params);
240
241 void
242 (*emit_size_query)( const struct lp_build_image_soa *sampler,
243 struct gallivm_state *gallivm,
244 const struct lp_sampler_size_query_params *params);
245 };
246
247 struct lp_build_fs_iface;
248 struct lp_build_fs_iface {
249 LLVMValueRef (*interp_fn)(const struct lp_build_fs_iface *iface,
250 struct lp_build_context *bld,
251 unsigned attrib, unsigned chan,
252 bool centroid, bool sample,
253 LLVMValueRef indir_index, LLVMValueRef offsets[2]);
254
255 void (*fb_fetch)(const struct lp_build_fs_iface *iface,
256 struct lp_build_context *bld,
257 unsigned cbuf,
258 LLVMValueRef result[4]);
259 };
260
261 void
262 lp_build_tgsi_info(const struct tgsi_token *tokens,
263 struct lp_tgsi_info *info);
264
265
266 struct lp_build_tgsi_params {
267 struct lp_type type;
268 struct lp_build_mask_context *mask;
269 LLVMValueRef consts_ptr;
270 LLVMValueRef const_sizes_ptr;
271 const struct lp_bld_tgsi_system_values *system_values;
272 const LLVMValueRef (*inputs)[4];
273 LLVMValueRef context_ptr;
274 LLVMValueRef thread_data_ptr;
275 const struct lp_build_sampler_soa *sampler;
276 const struct tgsi_shader_info *info;
277 const struct lp_build_gs_iface *gs_iface;
278 const struct lp_build_tcs_iface *tcs_iface;
279 const struct lp_build_tes_iface *tes_iface;
280 LLVMValueRef ssbo_ptr;
281 LLVMValueRef ssbo_sizes_ptr;
282 const struct lp_build_image_soa *image;
283 LLVMValueRef shared_ptr;
284 const struct lp_build_coro_suspend_info *coro;
285 LLVMValueRef kernel_args;
286 const struct lp_build_fs_iface *fs_iface;
287 unsigned gs_vertex_streams;
288 };
289
290 void
291 lp_build_tgsi_soa(struct gallivm_state *gallivm,
292 const struct tgsi_token *tokens,
293 const struct lp_build_tgsi_params *params,
294 LLVMValueRef (*outputs)[4]);
295
296 void
297 lp_build_tgsi_aos(struct gallivm_state *gallivm,
298 const struct tgsi_token *tokens,
299 struct lp_type type,
300 const unsigned char swizzles[4],
301 LLVMValueRef consts_ptr,
302 const LLVMValueRef *inputs,
303 LLVMValueRef *outputs,
304 const struct lp_build_sampler_aos *sampler,
305 const struct tgsi_shader_info *info);
306
307
308 struct lp_build_tgsi_inst_list
309 {
310 struct tgsi_full_instruction *instructions;
311 uint max_instructions;
312 uint num_instructions;
313 };
314
315 unsigned lp_bld_tgsi_list_init(struct lp_build_tgsi_context * bld_base);
316
317
318 unsigned lp_bld_tgsi_add_instruction(
319 struct lp_build_tgsi_context * bld_base,
320 const struct tgsi_full_instruction *inst_to_add);
321
322
323 struct lp_build_tgsi_context;
324
325
326 typedef LLVMValueRef (*lp_build_emit_fetch_fn)(struct lp_build_tgsi_context *,
327 const struct tgsi_full_src_register *,
328 enum tgsi_opcode_type,
329 unsigned);
330
331 typedef void (*lp_build_emit_store_reg_fn)(struct lp_build_tgsi_context *,
332 enum tgsi_opcode_type,
333 const struct tgsi_full_dst_register *,
334 unsigned,
335 unsigned,
336 LLVMValueRef,
337 LLVMValueRef);
338
339 struct lp_build_tgsi_context
340 {
341 struct lp_build_context base;
342
343 struct lp_build_context uint_bld;
344 struct lp_build_context int_bld;
345
346 struct lp_build_context dbl_bld;
347
348 struct lp_build_context uint64_bld;
349 struct lp_build_context int64_bld;
350
351 /** This array stores functions that are used to transform TGSI opcodes to
352 * LLVM instructions.
353 */
354 struct lp_build_tgsi_action op_actions[TGSI_OPCODE_LAST];
355
356 /* TGSI_OPCODE_RSQ is defined as 1 / sqrt( abs(src0.x) ), rsq_action
357 * should compute 1 / sqrt (src0.x) */
358 struct lp_build_tgsi_action rsq_action;
359
360 struct lp_build_tgsi_action sqrt_action;
361
362 struct lp_build_tgsi_action drsq_action;
363
364 struct lp_build_tgsi_action dsqrt_action;
365 const struct tgsi_shader_info *info;
366
367 lp_build_emit_fetch_fn emit_fetch_funcs[TGSI_FILE_COUNT];
368 lp_build_emit_store_reg_fn emit_store_reg_funcs[TGSI_FILE_COUNT];
369
370 LLVMValueRef (*emit_swizzle)(struct lp_build_tgsi_context *,
371 LLVMValueRef, unsigned, unsigned, unsigned, unsigned);
372
373
374 void (*emit_debug)(struct lp_build_tgsi_context *,
375 const struct tgsi_full_instruction *,
376 const struct tgsi_opcode_info *);
377
378 void (*emit_store)(struct lp_build_tgsi_context *,
379 const struct tgsi_full_instruction *,
380 const struct tgsi_opcode_info *,
381 unsigned index,
382 LLVMValueRef dst[4]);
383
384 void (*emit_declaration)(struct lp_build_tgsi_context *,
385 const struct tgsi_full_declaration *decl);
386
387 void (*emit_immediate)(struct lp_build_tgsi_context *,
388 const struct tgsi_full_immediate *imm);
389
390
391 /* Allow the user to store data in this structure rather than passing it
392 * to every function. */
393 void * userdata;
394
395 boolean soa;
396
397 int pc;
398
399 struct tgsi_full_instruction *instructions;
400 uint max_instructions;
401 uint num_instructions;
402
403 /** This function allows the user to insert some instructions at the
404 * beginning of the program. It is optional and does not need to be
405 * implemented.
406 */
407 void (*emit_prologue)(struct lp_build_tgsi_context*);
408
409 /** This function allows the user to insert some instructions after
410 * declarations section, but before any other code.
411 * It is optional and does not need to be implemented.
412 */
413 void (*emit_prologue_post_decl)(struct lp_build_tgsi_context*);
414
415 /** This function allows the user to insert some instructions at the end of
416 * the program. This callback is intended to be used for emitting
417 * instructions to handle the export for the output registers, but it can
418 * be used for any purpose. Implementing this function is optiona, but
419 * recommended.
420 */
421 void (*emit_epilogue)(struct lp_build_tgsi_context*);
422 };
423
424 struct lp_build_gs_iface
425 {
426 LLVMValueRef (*fetch_input)(const struct lp_build_gs_iface *gs_iface,
427 struct lp_build_context * bld,
428 boolean is_vindex_indirect,
429 LLVMValueRef vertex_index,
430 boolean is_aindex_indirect,
431 LLVMValueRef attrib_index,
432 LLVMValueRef swizzle_index);
433 void (*emit_vertex)(const struct lp_build_gs_iface *gs_iface,
434 struct lp_build_context * bld,
435 LLVMValueRef (*outputs)[4],
436 LLVMValueRef emitted_vertices_vec,
437 LLVMValueRef mask_vec, LLVMValueRef stream_id);
438 void (*end_primitive)(const struct lp_build_gs_iface *gs_iface,
439 struct lp_build_context * bld,
440 LLVMValueRef total_emitted_vertices_vec,
441 LLVMValueRef verts_per_prim_vec,
442 LLVMValueRef emitted_prims_vec,
443 LLVMValueRef mask_vec, unsigned stream);
444 void (*gs_epilogue)(const struct lp_build_gs_iface *gs_iface,
445 LLVMValueRef total_emitted_vertices_vec,
446 LLVMValueRef emitted_prims_vec, unsigned stream);
447 };
448
449 struct lp_build_tcs_iface
450 {
451 void (*emit_prologue)(struct lp_build_context * bld);
452 void (*emit_epilogue)(struct lp_build_context * bld);
453 void (*emit_barrier)(struct lp_build_context *bld_base);
454
455 void (*emit_store_output)(const struct lp_build_tcs_iface *tcs_iface,
456 struct lp_build_context * bld,
457 unsigned name,
458 boolean is_vindex_indirect,
459 LLVMValueRef vertex_index,
460 boolean is_aindex_indirect,
461 LLVMValueRef attrib_index,
462 boolean is_sindex_indirect,
463 LLVMValueRef swizzle_index,
464 LLVMValueRef value,
465 LLVMValueRef mask_vec);
466
467 LLVMValueRef (*emit_fetch_input)(const struct lp_build_tcs_iface *tcs_iface,
468 struct lp_build_context * bld,
469 boolean is_vindex_indirect,
470 LLVMValueRef vertex_index,
471 boolean is_aindex_indirect,
472 LLVMValueRef attrib_index,
473 boolean is_sindex_indirect,
474 LLVMValueRef swizzle_index);
475
476 LLVMValueRef (*emit_fetch_output)(const struct lp_build_tcs_iface *tcs_iface,
477 struct lp_build_context * bld,
478 boolean is_vindex_indirect,
479 LLVMValueRef vertex_index,
480 boolean is_aindex_indirect,
481 LLVMValueRef attrib_index,
482 boolean is_sindex_indirect,
483 LLVMValueRef swizzle_index,
484 uint32_t name);
485 };
486
487 struct lp_build_tes_iface
488 {
489 LLVMValueRef (*fetch_vertex_input)(const struct lp_build_tes_iface *tes_iface,
490 struct lp_build_context * bld,
491 boolean is_vindex_indirect,
492 LLVMValueRef vertex_index,
493 boolean is_aindex_indirect,
494 LLVMValueRef attrib_index,
495 boolean is_sindex_indirect,
496 LLVMValueRef swizzle_index);
497
498 LLVMValueRef (*fetch_patch_input)(const struct lp_build_tes_iface *tes_iface,
499 struct lp_build_context * bld,
500 boolean is_aindex_indirect,
501 LLVMValueRef attrib_index,
502 LLVMValueRef swizzle_index);
503 };
504
505 struct lp_build_tgsi_soa_context
506 {
507 struct lp_build_tgsi_context bld_base;
508
509 /* Builder for scalar elements of shader's data type (float) */
510 struct lp_build_context elem_bld;
511
512 const struct lp_build_gs_iface *gs_iface;
513 const struct lp_build_tcs_iface *tcs_iface;
514 const struct lp_build_tes_iface *tes_iface;
515
516 LLVMValueRef emitted_prims_vec_ptr;
517 LLVMValueRef total_emitted_vertices_vec_ptr;
518 LLVMValueRef emitted_vertices_vec_ptr;
519 LLVMValueRef max_output_vertices_vec;
520
521 LLVMValueRef consts_ptr;
522 LLVMValueRef const_sizes_ptr;
523 LLVMValueRef consts[LP_MAX_TGSI_CONST_BUFFERS];
524 LLVMValueRef consts_sizes[LP_MAX_TGSI_CONST_BUFFERS];
525 const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS];
526 LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS];
527 LLVMValueRef context_ptr;
528 LLVMValueRef thread_data_ptr;
529
530 LLVMValueRef ssbo_ptr;
531 LLVMValueRef ssbo_sizes_ptr;
532 LLVMValueRef ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
533 LLVMValueRef ssbo_sizes[LP_MAX_TGSI_SHADER_BUFFERS];
534
535 LLVMValueRef shared_ptr;
536
537 const struct lp_build_coro_suspend_info *coro;
538
539 const struct lp_build_sampler_soa *sampler;
540 const struct lp_build_image_soa *image;
541
542 struct tgsi_declaration_sampler_view sv[PIPE_MAX_SHADER_SAMPLER_VIEWS];
543
544 LLVMValueRef immediates[LP_MAX_INLINED_IMMEDIATES][TGSI_NUM_CHANNELS];
545 LLVMValueRef temps[LP_MAX_INLINED_TEMPS][TGSI_NUM_CHANNELS];
546 LLVMValueRef addr[LP_MAX_TGSI_ADDRS][TGSI_NUM_CHANNELS];
547
548 /* We allocate/use this array of temps if (1 << TGSI_FILE_TEMPORARY) is
549 * set in the indirect_files field.
550 * The temps[] array above is unused then.
551 */
552 LLVMValueRef temps_array;
553
554 /* We allocate/use this array of output if (1 << TGSI_FILE_OUTPUT) is
555 * set in the indirect_files field.
556 * The outputs[] array above is unused then.
557 */
558 LLVMValueRef outputs_array;
559
560 /* We allocate/use this array of inputs if (1 << TGSI_FILE_INPUT) is
561 * set in the indirect_files field.
562 * The inputs[] array above is unused then.
563 */
564 LLVMValueRef inputs_array;
565
566 /* We allocate/use this array of temps if (1 << TGSI_FILE_IMMEDIATE) is
567 * set in the indirect_files field.
568 */
569 LLVMValueRef imms_array;
570
571
572 struct lp_bld_tgsi_system_values system_values;
573
574 /** bitmask indicating which register files are accessed indirectly */
575 unsigned indirect_files;
576
577 struct lp_build_mask_context *mask;
578 struct lp_exec_mask exec_mask;
579
580 uint num_immediates;
581 boolean use_immediates_array;
582 };
583
584 void
585 lp_emit_declaration_soa(
586 struct lp_build_tgsi_context *bld,
587 const struct tgsi_full_declaration *decl);
588
589 void lp_emit_immediate_soa(
590 struct lp_build_tgsi_context *bld_base,
591 const struct tgsi_full_immediate *imm);
592
593 boolean
594 lp_emit_instruction_soa(
595 struct lp_build_tgsi_soa_context *bld,
596 const struct tgsi_full_instruction *inst,
597 const struct tgsi_opcode_info *info);
598
599
600 LLVMValueRef
601 lp_get_temp_ptr_soa(
602 struct lp_build_tgsi_soa_context *bld,
603 unsigned index,
604 unsigned chan);
605
606 LLVMValueRef
607 lp_get_output_ptr(
608 struct lp_build_tgsi_soa_context *bld,
609 unsigned index,
610 unsigned chan);
611
612 struct lp_build_tgsi_aos_context
613 {
614 struct lp_build_tgsi_context bld_base;
615
616 /* Builder for integer masks and indices */
617 struct lp_build_context int_bld;
618
619 /*
620 * AoS swizzle used:
621 * - swizzles[0] = red index
622 * - swizzles[1] = green index
623 * - swizzles[2] = blue index
624 * - swizzles[3] = alpha index
625 */
626 unsigned char swizzles[4];
627 unsigned char inv_swizzles[4];
628
629 LLVMValueRef consts_ptr;
630 const LLVMValueRef *inputs;
631 LLVMValueRef *outputs;
632
633 const struct lp_build_sampler_aos *sampler;
634
635 struct tgsi_declaration_sampler_view sv[PIPE_MAX_SHADER_SAMPLER_VIEWS];
636
637 LLVMValueRef immediates[LP_MAX_INLINED_IMMEDIATES];
638 LLVMValueRef temps[LP_MAX_INLINED_TEMPS];
639 LLVMValueRef addr[LP_MAX_TGSI_ADDRS];
640
641 /* We allocate/use this array of temps if (1 << TGSI_FILE_TEMPORARY) is
642 * set in the indirect_files field.
643 * The temps[] array above is unused then.
644 */
645 LLVMValueRef temps_array;
646
647 /** bitmask indicating which register files are accessed indirectly */
648 unsigned indirect_files;
649
650 };
651
652 static inline struct lp_build_tgsi_soa_context *
lp_soa_context(struct lp_build_tgsi_context * bld_base)653 lp_soa_context(struct lp_build_tgsi_context *bld_base)
654 {
655 return (struct lp_build_tgsi_soa_context *)bld_base;
656 }
657
658 static inline struct lp_build_tgsi_aos_context *
lp_aos_context(struct lp_build_tgsi_context * bld_base)659 lp_aos_context(struct lp_build_tgsi_context *bld_base)
660 {
661 return (struct lp_build_tgsi_aos_context *)bld_base;
662 }
663
664 void
665 lp_emit_declaration_aos(
666 struct lp_build_tgsi_aos_context *bld,
667 const struct tgsi_full_declaration *decl);
668
669
670 boolean
671 lp_emit_instruction_aos(
672 struct lp_build_tgsi_aos_context *bld,
673 const struct tgsi_full_instruction *inst,
674 const struct tgsi_opcode_info *info,
675 int *pc);
676
677 void
678 lp_emit_store_aos(
679 struct lp_build_tgsi_aos_context *bld,
680 const struct tgsi_full_instruction *inst,
681 unsigned index,
682 LLVMValueRef value);
683
684 void lp_build_fetch_args(
685 struct lp_build_tgsi_context * bld_base,
686 struct lp_build_emit_data * emit_data);
687
688 LLVMValueRef
689 lp_build_tgsi_inst_llvm_aos(
690 struct lp_build_tgsi_context * bld_base,
691 const struct tgsi_full_instruction *inst);
692
693 void
694 lp_build_tgsi_intrinsic(
695 const struct lp_build_tgsi_action * action,
696 struct lp_build_tgsi_context * bld_base,
697 struct lp_build_emit_data * emit_data);
698
699 LLVMValueRef
700 lp_build_emit_llvm(
701 struct lp_build_tgsi_context *bld_base,
702 unsigned tgsi_opcode,
703 struct lp_build_emit_data * emit_data);
704
705 LLVMValueRef
706 lp_build_emit_llvm_unary(
707 struct lp_build_tgsi_context *bld_base,
708 unsigned tgsi_opcode,
709 LLVMValueRef arg0);
710
711 LLVMValueRef
712 lp_build_emit_llvm_binary(
713 struct lp_build_tgsi_context *bld_base,
714 unsigned tgsi_opcode,
715 LLVMValueRef arg0,
716 LLVMValueRef arg1);
717
718 LLVMValueRef
719 lp_build_emit_llvm_ternary(
720 struct lp_build_tgsi_context *bld_base,
721 unsigned tgsi_opcode,
722 LLVMValueRef arg0,
723 LLVMValueRef arg1,
724 LLVMValueRef arg2);
725
726 boolean
727 lp_build_tgsi_inst_llvm(
728 struct lp_build_tgsi_context * bld_base,
729 const struct tgsi_full_instruction *inst);
730
731 LLVMValueRef
732 lp_build_emit_fetch_src(
733 struct lp_build_tgsi_context *bld_base,
734 const struct tgsi_full_src_register *reg,
735 enum tgsi_opcode_type stype,
736 const unsigned chan_index);
737
738 LLVMValueRef
739 lp_build_emit_fetch(
740 struct lp_build_tgsi_context *bld_base,
741 const struct tgsi_full_instruction *inst,
742 unsigned src_op,
743 const unsigned chan_index);
744
745
746 LLVMValueRef
747 lp_build_emit_fetch_texoffset(
748 struct lp_build_tgsi_context *bld_base,
749 const struct tgsi_full_instruction *inst,
750 unsigned tex_off_op,
751 const unsigned chan_index);
752
753 boolean
754 lp_build_tgsi_llvm(
755 struct lp_build_tgsi_context * bld_base,
756 const struct tgsi_token *tokens);
757
758 #ifdef __cplusplus
759 }
760 #endif
761
762 #endif /* LP_BLD_TGSI_H */
763