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