Merge remote branch 'origin/master' into nv50-compiler
[mesa.git] / src / gallium / drivers / r600 / r600_asm.h
1 /*
2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
3 *
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:
10 *
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
13 * Software.
14 *
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.
22 */
23 #ifndef R600_ASM_H
24 #define R600_ASM_H
25
26 #include "radeon.h"
27 #include "util/u_double_list.h"
28
29 struct r600_bc_alu_src {
30 unsigned sel;
31 unsigned chan;
32 unsigned neg;
33 unsigned abs;
34 unsigned rel;
35 };
36
37 struct r600_bc_alu_dst {
38 unsigned sel;
39 unsigned chan;
40 unsigned clamp;
41 unsigned write;
42 unsigned rel;
43 };
44
45 struct r600_bc_alu {
46 struct list_head list;
47 struct r600_bc_alu_src src[3];
48 struct r600_bc_alu_dst dst;
49 unsigned inst;
50 unsigned last;
51 unsigned is_op3;
52 unsigned predicate;
53 unsigned nliteral;
54 unsigned literal_added;
55 u32 value[4];
56 };
57
58 struct r600_bc_tex {
59 struct list_head list;
60 unsigned inst;
61 unsigned resource_id;
62 unsigned src_gpr;
63 unsigned src_rel;
64 unsigned dst_gpr;
65 unsigned dst_rel;
66 unsigned dst_sel_x;
67 unsigned dst_sel_y;
68 unsigned dst_sel_z;
69 unsigned dst_sel_w;
70 unsigned lod_bias;
71 unsigned coord_type_x;
72 unsigned coord_type_y;
73 unsigned coord_type_z;
74 unsigned coord_type_w;
75 unsigned offset_x;
76 unsigned offset_y;
77 unsigned offset_z;
78 unsigned sampler_id;
79 unsigned src_sel_x;
80 unsigned src_sel_y;
81 unsigned src_sel_z;
82 unsigned src_sel_w;
83 };
84
85 struct r600_bc_vtx {
86 struct list_head list;
87 unsigned inst;
88 unsigned fetch_type;
89 unsigned buffer_id;
90 unsigned src_gpr;
91 unsigned src_sel_x;
92 unsigned mega_fetch_count;
93 unsigned dst_gpr;
94 unsigned dst_sel_x;
95 unsigned dst_sel_y;
96 unsigned dst_sel_z;
97 unsigned dst_sel_w;
98 };
99
100 struct r600_bc_output {
101 unsigned array_base;
102 unsigned type;
103 unsigned end_of_program;
104 unsigned inst;
105 unsigned elem_size;
106 unsigned gpr;
107 unsigned swizzle_x;
108 unsigned swizzle_y;
109 unsigned swizzle_z;
110 unsigned swizzle_w;
111 unsigned barrier;
112 };
113
114 struct r600_bc_cf {
115 struct list_head list;
116 unsigned inst;
117 unsigned addr;
118 unsigned ndw;
119 unsigned id;
120 unsigned cond;
121 unsigned pop_count;
122 unsigned cf_addr; /* control flow addr */
123 struct list_head alu;
124 struct list_head tex;
125 struct list_head vtx;
126 struct r600_bc_output output;
127 };
128
129 #define FC_NONE 0
130 #define FC_IF 1
131 #define FC_LOOP 2
132 #define FC_REP 3
133 #define FC_PUSH_VPM 4
134 #define FC_PUSH_WQM 5
135
136 struct r600_cf_stack_entry {
137 int type;
138 struct r600_bc_cf *start;
139 struct r600_bc_cf **mid; /* used to store the else point */
140 int num_mid;
141 };
142
143 #define SQ_MAX_CALL_DEPTH 0x00000020
144 struct r600_cf_callstack {
145 unsigned fc_sp_before_entry;
146 int sub_desc_index;
147 int current;
148 int max;
149 };
150
151 struct r600_bc {
152 enum radeon_family family;
153 int chiprev; /* 0 - r600, 1 - r700, 2 - evergreen */
154 struct list_head cf;
155 struct r600_bc_cf *cf_last;
156 unsigned ndw;
157 unsigned ncf;
158 unsigned ngpr;
159 unsigned nstack;
160 unsigned nresource;
161 unsigned force_add_cf;
162 u32 *bytecode;
163
164 u32 fc_sp;
165 struct r600_cf_stack_entry fc_stack[32];
166
167 unsigned call_sp;
168 struct r600_cf_callstack callstack[SQ_MAX_CALL_DEPTH];
169 };
170
171 int r600_bc_init(struct r600_bc *bc, enum radeon_family family);
172 int r600_bc_add_alu(struct r600_bc *bc, const struct r600_bc_alu *alu);
173 int r600_bc_add_literal(struct r600_bc *bc, const u32 *value);
174 int r600_bc_add_vtx(struct r600_bc *bc, const struct r600_bc_vtx *vtx);
175 int r600_bc_add_tex(struct r600_bc *bc, const struct r600_bc_tex *tex);
176 int r600_bc_add_output(struct r600_bc *bc, const struct r600_bc_output *output);
177 int r600_bc_build(struct r600_bc *bc);
178 int r600_bc_add_cfinst(struct r600_bc *bc, int inst);
179 int r600_bc_add_alu_type(struct r600_bc *bc, const struct r600_bc_alu *alu, int type);
180 #endif