2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
28 struct r600_vertex_element
;
31 struct r600_bytecode_alu_src
{
41 struct r600_bytecode_alu_dst
{
49 struct r600_bytecode_alu
{
50 struct list_head list
;
51 struct r600_bytecode_alu_src src
[3];
52 struct r600_bytecode_alu_dst dst
;
57 unsigned bank_swizzle
;
58 unsigned bank_swizzle_force
;
63 struct r600_bytecode_tex
{
64 struct list_head list
;
76 unsigned coord_type_x
;
77 unsigned coord_type_y
;
78 unsigned coord_type_z
;
79 unsigned coord_type_w
;
90 struct r600_bytecode_vtx
{
91 struct list_head list
;
97 unsigned mega_fetch_count
;
103 unsigned use_const_fields
;
104 unsigned data_format
;
105 unsigned num_format_all
;
106 unsigned format_comp_all
;
107 unsigned srf_mode_all
;
112 struct r600_bytecode_output
{
117 unsigned end_of_program
;
119 /* CF_INST. This is already bit-shifted and only needs to be or'd for bytecode. */
128 unsigned burst_count
;
132 struct r600_bytecode_kcache
{
138 /* A value of CF_NATIVE in r600_bytecode_cf::inst means that this instruction
139 * has already been encoded, and the encoding has been stored in
140 * r600_bytecode::isa. This is used by the LLVM backend to emit CF instructions
141 * e.g. RAT_WRITE_* that can't be properly represented by struct
146 struct r600_bytecode_cf
{
147 struct list_head list
;
149 /* CF_INST. This is already bit-shifted and only needs to be or'd for bytecode. */
157 unsigned cf_addr
; /* control flow addr */
158 struct r600_bytecode_kcache kcache
[4];
159 unsigned r6xx_uses_waterfall
;
160 unsigned eg_alu_extended
;
161 struct list_head alu
;
162 struct list_head tex
;
163 struct list_head vtx
;
164 struct r600_bytecode_output output
;
165 struct r600_bytecode_alu
*curr_bs_head
;
166 struct r600_bytecode_alu
*prev_bs_head
;
167 struct r600_bytecode_alu
*prev2_bs_head
;
175 #define FC_PUSH_VPM 4
176 #define FC_PUSH_WQM 5
178 struct r600_cf_stack_entry
{
180 struct r600_bytecode_cf
*start
;
181 struct r600_bytecode_cf
**mid
; /* used to store the else point */
185 #define SQ_MAX_CALL_DEPTH 0x00000020
186 struct r600_cf_callstack
{
187 unsigned fc_sp_before_entry
;
193 #define AR_HANDLE_NORMAL 0
194 #define AR_HANDLE_RV6XX 1 /* except RV670 */
197 struct r600_bytecode
{
198 enum chip_class chip_class
;
201 struct r600_bytecode_cf
*cf_last
;
207 unsigned force_add_cf
;
210 struct r600_cf_stack_entry fc_stack
[32];
212 struct r600_cf_callstack callstack
[SQ_MAX_CALL_DEPTH
];
215 unsigned ar_handling
;
216 unsigned r6xx_nop_after_rel_dst
;
220 int eg_bytecode_cf_build(struct r600_bytecode
*bc
, struct r600_bytecode_cf
*cf
);
223 void r600_bytecode_init(struct r600_bytecode
*bc
, enum chip_class chip_class
, enum radeon_family family
);
224 void r600_bytecode_clear(struct r600_bytecode
*bc
);
225 int r600_bytecode_add_alu(struct r600_bytecode
*bc
, const struct r600_bytecode_alu
*alu
);
226 int r600_bytecode_add_vtx(struct r600_bytecode
*bc
, const struct r600_bytecode_vtx
*vtx
);
227 int r600_bytecode_add_tex(struct r600_bytecode
*bc
, const struct r600_bytecode_tex
*tex
);
228 int r600_bytecode_add_output(struct r600_bytecode
*bc
, const struct r600_bytecode_output
*output
);
229 int r600_bytecode_build(struct r600_bytecode
*bc
);
230 int r600_bytecode_add_cfinst(struct r600_bytecode
*bc
, int inst
);
231 int r600_bytecode_add_alu_type(struct r600_bytecode
*bc
, const struct r600_bytecode_alu
*alu
, int type
);
232 void r600_bytecode_special_constants(uint32_t value
, unsigned *sel
, unsigned *neg
);
233 void r600_bytecode_dump(struct r600_bytecode
*bc
);
235 int cm_bytecode_add_cf_end(struct r600_bytecode
*bc
);
237 int r600_vertex_elements_build_fetch_shader(struct r600_context
*rctx
, struct r600_vertex_element
*ve
);
240 void r700_bytecode_cf_vtx_build(uint32_t *bytecode
, const struct r600_bytecode_cf
*cf
);
241 int r700_bytecode_alu_build(struct r600_bytecode
*bc
, struct r600_bytecode_alu
*alu
, unsigned id
);