gallium: point rast coord tweak
[mesa.git] / src / gallium / auxiliary / rtasm / rtasm_ppc_spe.h
1 /*
2 * (C) Copyright IBM Corporation 2008
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 /**
26 * \file
27 * Real-time assembly generation interface for Cell B.E. SPEs.
28 *
29 * \author Ian Romanick <idr@us.ibm.com>
30 */
31
32 #ifndef RTASM_PPC_SPE_H
33 #define RTASM_PPC_SPE_H
34
35 struct spe_function {
36 /**
37 *
38 */
39 uint32_t *store;
40 uint32_t *csr;
41 const char *fn;
42 };
43
44 extern void spe_init_func(struct spe_function *p, unsigned code_size);
45 extern void spe_release_func(struct spe_function *p);
46
47 #endif /* RTASM_PPC_SPE_H */
48
49 #ifndef EMIT_
50 #define EMIT_(name, _op) \
51 extern void _name (struct spe_function *p, unsigned rT)
52 #define EMIT_R(_name, _op) \
53 extern void _name (struct spe_function *p, unsigned rT, unsigned rA)
54 #define EMIT_RR(_name, _op) \
55 extern void _name (struct spe_function *p, unsigned rT, unsigned rA, \
56 unsigned rB)
57 #define EMIT_RRR(_name, _op) \
58 extern void _name (struct spe_function *p, unsigned rT, unsigned rA, \
59 unsigned rB, unsigned rC)
60 #define EMIT_RI7(_name, _op) \
61 extern void _name (struct spe_function *p, unsigned rT, unsigned rA, \
62 int imm)
63 #define EMIT_RI8(_name, _op) \
64 extern void _name (struct spe_function *p, unsigned rT, unsigned rA, \
65 int imm)
66 #define EMIT_RI10(_name, _op) \
67 extern void _name (struct spe_function *p, unsigned rT, unsigned rA, \
68 int imm)
69 #define EMIT_RI16(_name, _op) \
70 extern void _name (struct spe_function *p, unsigned rT, int imm)
71 #define EMIT_RI18(_name, _op) \
72 extern void _name (struct spe_function *p, unsigned rT, int imm)
73 #define EMIT_I16(_name, _op) \
74 extern void _name (struct spe_function *p, int imm)
75 #define UNDEF_EMIT_MACROS
76 #endif /* EMIT_ */
77
78
79 /* Memory load / store instructions
80 */
81 EMIT_RI10(spe_lqd, 0x034);
82 EMIT_RR (spe_lqx, 0x1c4);
83 EMIT_RI16(spe_lqa, 0x061);
84 EMIT_RI16(spe_lqr, 0x067);
85 EMIT_RI10(spe_stqd, 0x024);
86 EMIT_RR (spe_stqx, 0x144);
87 EMIT_RI16(spe_stqa, 0x041);
88 EMIT_RI16(spe_stqr, 0x047);
89 EMIT_RI7 (spe_cbd, 0x1f4);
90 EMIT_RR (spe_cbx, 0x1d4);
91 EMIT_RI7 (spe_chd, 0x1f5);
92 EMIT_RI7 (spe_chx, 0x1d5);
93 EMIT_RI7 (spe_cwd, 0x1f6);
94 EMIT_RI7 (spe_cwx, 0x1d6);
95 EMIT_RI7 (spe_cdd, 0x1f7);
96 EMIT_RI7 (spe_cdx, 0x1d7);
97
98
99 /* Constant formation instructions
100 */
101 EMIT_RI16(spe_ilh, 0x083);
102 EMIT_RI16(spe_ilhu, 0x082);
103 EMIT_RI16(spe_il, 0x081);
104 EMIT_RI18(spe_ila, 0x021);
105 EMIT_RI16(spe_iohl, 0x0c1);
106 EMIT_RI16(spe_fsmbi, 0x0c5);
107
108
109 /* Integer and logical instructions
110 */
111 EMIT_RR (spe_ah, 0x0c8);
112 EMIT_RI10(spe_ahi, 0x01d);
113 EMIT_RR (spe_a, 0x0c0);
114 EMIT_RI10(spe_ai, 0x01c);
115 EMIT_RR (spe_sfh, 0x048);
116 EMIT_RI10(spe_sfhi, 0x00d);
117 EMIT_RR (spe_sf, 0x040);
118 EMIT_RI10(spe_sfi, 0x00c);
119 EMIT_RR (spe_addx, 0x340);
120 EMIT_RR (spe_cg, 0x0c2);
121 EMIT_RR (spe_cgx, 0x342);
122 EMIT_RR (spe_sfx, 0x341);
123 EMIT_RR (spe_bg, 0x042);
124 EMIT_RR (spe_bgx, 0x343);
125 EMIT_RR (spe_mpy, 0x3c4);
126 EMIT_RR (spe_mpyu, 0x3cc);
127 EMIT_RI10(spe_mpyi, 0x074);
128 EMIT_RI10(spe_mpyui, 0x075);
129 EMIT_RRR (spe_mpya, 0x00c);
130 EMIT_RR (spe_mpyh, 0x3c5);
131 EMIT_RR (spe_mpys, 0x3c7);
132 EMIT_RR (spe_mpyhh, 0x3c6);
133 EMIT_RR (spe_mpyhha, 0x346);
134 EMIT_RR (spe_mpyhhu, 0x3ce);
135 EMIT_RR (spe_mpyhhau, 0x34e);
136 EMIT_R (spe_clz, 0x2a5);
137 EMIT_R (spe_cntb, 0x2b4);
138 EMIT_R (spe_fsmb, 0x1b6);
139 EMIT_R (spe_fsmh, 0x1b5);
140 EMIT_R (spe_fsm, 0x1b4);
141 EMIT_R (spe_gbb, 0x1b2);
142 EMIT_R (spe_gbh, 0x1b1);
143 EMIT_R (spe_gb, 0x1b0);
144 EMIT_RR (spe_avgb, 0x0d3);
145 EMIT_RR (spe_absdb, 0x053);
146 EMIT_RR (spe_sumb, 0x253);
147 EMIT_R (spe_xsbh, 0x2b6);
148 EMIT_R (spe_xshw, 0x2ae);
149 EMIT_R (spe_xswd, 0x2a6);
150 EMIT_RR (spe_and, 0x0c1);
151 EMIT_RR (spe_andc, 0x2c1);
152 EMIT_RI10(spe_andbi, 0x016);
153 EMIT_RI10(spe_andhi, 0x015);
154 EMIT_RI10(spe_andi, 0x014);
155 EMIT_RR (spe_or, 0x041);
156 EMIT_RR (spe_orc, 0x2c9);
157 EMIT_RI10(spe_orbi, 0x006);
158 EMIT_RI10(spe_orhi, 0x005);
159 EMIT_RI10(spe_ori, 0x004);
160 EMIT_R (spe_orx, 0x1f0);
161 EMIT_RR (spe_xor, 0x241);
162 EMIT_RI10(spe_xorbi, 0x026);
163 EMIT_RI10(spe_xorhi, 0x025);
164 EMIT_RI10(spe_xori, 0x024);
165 EMIT_RR (spe_nand, 0x0c9);
166 EMIT_RR (spe_nor, 0x049);
167 EMIT_RR (spe_eqv, 0x249);
168 EMIT_RRR (spe_selb, 0x008);
169 EMIT_RRR (spe_shufb, 0x00b);
170
171
172 /* Shift and rotate instructions
173 */
174 EMIT_RR (spe_shlh, 0x05f);
175 EMIT_RI7 (spe_shlhi, 0x07f);
176 EMIT_RR (spe_shl, 0x05b);
177 EMIT_RI7 (spe_shli, 0x07b);
178 EMIT_RR (spe_shlqbi, 0x1db);
179 EMIT_RI7 (spe_shlqbii, 0x1fb);
180 EMIT_RR (spe_shlqby, 0x1df);
181 EMIT_RI7 (spe_shlqbyi, 0x1ff);
182 EMIT_RR (spe_shlqbybi, 0x1cf);
183 EMIT_RR (spe_roth, 0x05c);
184 EMIT_RI7 (spe_rothi, 0x07c);
185 EMIT_RR (spe_rot, 0x058);
186 EMIT_RI7 (spe_roti, 0x078);
187 EMIT_RR (spe_rotqby, 0x1dc);
188 EMIT_RI7 (spe_rotqbyi, 0x1fc);
189 EMIT_RR (spe_rotqbybi, 0x1cc);
190 EMIT_RR (spe_rotqbi, 0x1d8);
191 EMIT_RI7 (spe_rotqbii, 0x1f8);
192 EMIT_RR (spe_rothm, 0x05d);
193 EMIT_RI7 (spe_rothmi, 0x07d);
194 EMIT_RR (spe_rotm, 0x059);
195 EMIT_RI7 (spe_rotmi, 0x079);
196 EMIT_RR (spe_rotqmby, 0x1dd);
197 EMIT_RI7 (spe_rotqmbyi, 0x1fd);
198 EMIT_RR (spe_rotqmbybi, 0x1cd);
199 EMIT_RR (spe_rotqmbi, 0x1c9);
200 EMIT_RI7 (spe_rotqmbii, 0x1f9);
201 EMIT_RR (spe_rotmah, 0x05e);
202 EMIT_RI7 (spe_rotmahi, 0x07e);
203 EMIT_RR (spe_rotma, 0x05a);
204 EMIT_RI7 (spe_rotmai, 0x07a);
205
206
207 /* Compare, branch, and halt instructions
208 */
209 EMIT_RR (spe_heq, 0x3d8);
210 EMIT_RI10(spe_heqi, 0x07f);
211 EMIT_RR (spe_hgt, 0x258);
212 EMIT_RI10(spe_hgti, 0x04f);
213 EMIT_RR (spe_hlgt, 0x2d8);
214 EMIT_RI10(spe_hlgti, 0x05f);
215 EMIT_RR (spe_ceqb, 0x3d0);
216 EMIT_RI10(spe_ceqbi, 0x07e);
217 EMIT_RR (spe_ceqh, 0x3c8);
218 EMIT_RI10(spe_ceqhi, 0x07d);
219 EMIT_RR (spe_ceq, 0x3c0);
220 EMIT_RI10(spe_ceqi, 0x07c);
221 EMIT_RR (spe_cgtb, 0x250);
222 EMIT_RI10(spe_cgtbi, 0x04e);
223 EMIT_RR (spe_cgth, 0x248);
224 EMIT_RI10(spe_cgthi, 0x04d);
225 EMIT_RR (spe_cgt, 0x240);
226 EMIT_RI10(spe_cgti, 0x04c);
227 EMIT_RR (spe_clgtb, 0x2d0);
228 EMIT_RI10(spe_clgtbi, 0x05e);
229 EMIT_RR (spe_clgth, 0x2c8);
230 EMIT_RI10(spe_clgthi, 0x05d);
231 EMIT_RR (spe_clgt, 0x2c0);
232 EMIT_RI10(spe_clgti, 0x05c);
233 EMIT_I16 (spe_br, 0x064);
234 EMIT_I16 (spe_bra, 0x060);
235 EMIT_RI16(spe_brsl, 0x066);
236 EMIT_RI16(spe_brasl, 0x062);
237 EMIT_RI16(spe_brnz, 0x042);
238 EMIT_RI16(spe_brz, 0x040);
239 EMIT_RI16(spe_brhnz, 0x046);
240 EMIT_RI16(spe_brhz, 0x044);
241
242 extern void spe_bi(struct spe_function *p, unsigned rA, int d, int e);
243 extern void spe_iret(struct spe_function *p, unsigned rA, int d, int e);
244 extern void spe_bisled(struct spe_function *p, unsigned rT, unsigned rA,
245 int d, int e);
246 extern void spe_bisl(struct spe_function *p, unsigned rT, unsigned rA,
247 int d, int e);
248 extern void spe_biz(struct spe_function *p, unsigned rT, unsigned rA,
249 int d, int e);
250 extern void spe_binz(struct spe_function *p, unsigned rT, unsigned rA,
251 int d, int e);
252 extern void spe_bihz(struct spe_function *p, unsigned rT, unsigned rA,
253 int d, int e);
254 extern void spe_bihnz(struct spe_function *p, unsigned rT, unsigned rA,
255 int d, int e);
256
257
258 /* Floating-point instructions
259 */
260 EMIT_RR (spe_fa, 0x2c4);
261 EMIT_RR (spe_dfa, 0x2cc);
262 EMIT_RR (spe_fs, 0x2c5);
263 EMIT_RR (spe_dfs, 0x2cd);
264 EMIT_RR (spe_fm, 0x2c6);
265 EMIT_RR (spe_dfm, 0x2ce);
266 EMIT_RRR (spe_fma, 0x00e);
267 EMIT_RR (spe_dfma, 0x35c);
268 EMIT_RRR (spe_fnms, 0x00d);
269 EMIT_RR (spe_dfnms, 0x35e);
270 EMIT_RRR (spe_fms, 0x00f);
271 EMIT_RR (spe_dfms, 0x35d);
272 EMIT_RR (spe_dfnma, 0x35f);
273 EMIT_R (spe_frest, 0x1b8);
274 EMIT_R (spe_frsqest, 0x1b9);
275 EMIT_RR (spe_fi, 0x3d4);
276 EMIT_RI8 (spe_csflt, 0x1da);
277 EMIT_RI8 (spe_cflts, 0x1d8);
278 EMIT_RI8 (spe_cuflt, 0x1db);
279 EMIT_RI8 (spe_cfltu, 0x1d9);
280 EMIT_R (spe_frds, 0x3b9);
281 EMIT_R (spe_fesd, 0x3b8);
282 EMIT_RR (spe_dfceq, 0x3c3);
283 EMIT_RR (spe_dfcmeq, 0x3cb);
284 EMIT_RR (spe_dfcgt, 0x2c3);
285 EMIT_RR (spe_dfcmgt, 0x2cb);
286 EMIT_RI7 (spe_dftsv, 0x3bf);
287 EMIT_RR (spe_fceq, 0x3c2);
288 EMIT_RR (spe_fcmeq, 0x3ca);
289 EMIT_RR (spe_fcgt, 0x2c2);
290 EMIT_RR (spe_fcmgt, 0x2ca);
291 EMIT_R (spe_fscrwr, 0x3ba);
292 EMIT_ (spe_fscrrd, 0x398);
293
294
295 /* Channel instructions
296 */
297 EMIT_R (spe_rdch, 0x00d);
298 EMIT_R (spe_rdchcnt, 0x00f);
299 EMIT_R (spe_wrch, 0x10d);
300
301
302 #ifdef UNDEF_EMIT_MACROS
303 #undef EMIT_
304 #undef EMIT_R
305 #undef EMIT_RR
306 #undef EMIT_RRR
307 #undef EMIT_RI7
308 #undef EMIT_RI8
309 #undef EMIT_RI10
310 #undef EMIT_RI16
311 #undef EMIT_RI18
312 #undef EMIT_I16
313 #undef UNDEF_EMIT_MACROS
314 #endif /* EMIT_ */