1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
30 * Zack Rusin zack@tungstengraphics.com
37 LLVM representation consists of two stages - layout independent
38 intermediate representation gallivm_ir and driver specific
39 gallivm_prog. TGSI is first being translated into gallivm_ir
40 after that driver can set number of options on gallivm_ir and
41 have it compiled into gallivm_prog. gallivm_prog can be either
42 executed (assuming there's LLVM JIT backend for the current
43 target) or machine code generation can be done (assuming there's
44 a LLVM code generator for thecurrent target)
46 #if defined __cplusplus
50 #include "pipe/p_state.h"
58 struct gallivm_cpu_engine
;
59 struct tgsi_interp_coef
;
61 struct tgsi_exec_vector
;
63 enum gallivm_shader_type
{
68 enum gallivm_vector_layout
{
73 struct gallivm_ir
*gallivm_ir_new(enum gallivm_shader_type type
);
74 void gallivm_ir_set_layout(struct gallivm_ir
*ir
,
75 enum gallivm_vector_layout layout
);
76 void gallivm_ir_set_components(struct gallivm_ir
*ir
, int num
);
77 void gallivm_ir_fill_from_tgsi(struct gallivm_ir
*ir
,
78 const struct tgsi_token
*tokens
);
79 void gallivm_ir_delete(struct gallivm_ir
*ir
);
82 struct gallivm_prog
*gallivm_ir_compile(struct gallivm_ir
*ir
);
84 void gallivm_prog_inputs_interpolate(struct gallivm_prog
*prog
,
85 float (*inputs
)[PIPE_MAX_SHADER_INPUTS
][4],
86 const struct tgsi_interp_coef
*coefs
);
87 void gallivm_prog_dump(struct gallivm_prog
*prog
, const char *file_prefix
);
90 struct gallivm_cpu_engine
*gallivm_cpu_engine_create(struct gallivm_prog
*prog
);
91 struct gallivm_cpu_engine
*gallivm_global_cpu_engine();
92 int gallivm_cpu_vs_exec(struct gallivm_prog
*prog
,
93 struct tgsi_exec_machine
*machine
,
94 const float (*input
)[4],
98 const float (*constants
)[4],
100 unsigned input_stride
,
101 unsigned output_stride
);
102 int gallivm_cpu_fs_exec(struct gallivm_prog
*prog
,
104 float (*dests
)[PIPE_MAX_SHADER_INPUTS
][4],
105 float (*inputs
)[PIPE_MAX_SHADER_INPUTS
][4],
107 struct tgsi_sampler
*samplers
);
108 void gallivm_cpu_jit_compile(struct gallivm_cpu_engine
*ee
, struct gallivm_prog
*prog
);
109 void gallivm_cpu_engine_delete(struct gallivm_cpu_engine
*ee
);
112 #endif /* MESA_LLVM */
114 #if defined __cplusplus