added PSIZE
[mesa.git] / src / mesa / pipe / tgsi / exec / tgsi_sse2.c
1 #include "tgsi_platform.h"
2 #include "tgsi_core.h"
3 #include "x86/rtasm/x86sse.h"
4
5 #if defined(USE_X86_ASM) || defined(SLANG_X86)
6
7 #define FOR_EACH_CHANNEL( CHAN )\
8 for( CHAN = 0; CHAN < 4; CHAN++ )
9
10 #define IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
11 ((INST).FullDstRegisters[0].DstRegister.WriteMask & (1 << (CHAN)))
12
13 #define IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
14 if( IS_DST0_CHANNEL_ENABLED( INST, CHAN ))
15
16 #define FOR_EACH_DST0_ENABLED_CHANNEL( INST, CHAN )\
17 FOR_EACH_CHANNEL( CHAN )\
18 IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )
19
20 #define CHAN_X 0
21 #define CHAN_Y 1
22 #define CHAN_Z 2
23 #define CHAN_W 3
24
25 #define ALIGN16( ADDR ) (((ADDR) + 15) & ~15)
26
27 static struct x86_reg
28 get_argument(
29 unsigned index )
30 {
31 return x86_make_disp(
32 x86_make_reg( file_REG32, reg_SP ),
33 (index + 1) * 4 );
34 }
35
36 static struct x86_reg
37 make_xmm(
38 unsigned xmm )
39 {
40 return x86_make_reg(
41 file_XMM,
42 (enum x86_reg_name) xmm );
43 }
44
45 static struct x86_reg
46 get_const_base( void )
47 {
48 return x86_make_reg(
49 file_REG32,
50 reg_CX );
51 }
52
53 static struct x86_reg
54 get_const(
55 unsigned vec,
56 unsigned chan )
57 {
58 return x86_make_disp(
59 get_const_base(),
60 (vec * 4 + chan) * 4 );
61 }
62
63 static struct x86_reg
64 get_input_base( void )
65 {
66 return x86_make_reg(
67 file_REG32,
68 reg_AX );
69 }
70
71 static struct x86_reg
72 get_input(
73 unsigned vec,
74 unsigned chan )
75 {
76 return x86_make_disp(
77 get_input_base(),
78 (vec * 4 + chan) * 16 );
79 }
80
81 static struct x86_reg
82 get_output_base( void )
83 {
84 return x86_make_reg(
85 file_REG32,
86 reg_DX );
87 }
88
89 static struct x86_reg
90 get_output(
91 unsigned vec,
92 unsigned chan )
93 {
94 return x86_make_disp(
95 get_output_base(),
96 (vec * 4 + chan) * 16 );
97 }
98
99 static struct x86_reg
100 get_temp_base( void )
101 {
102 return x86_make_reg(
103 file_REG32,
104 reg_BX );
105 }
106
107 static struct x86_reg
108 get_temp(
109 unsigned vec,
110 unsigned chan )
111 {
112 return x86_make_disp(
113 get_temp_base(),
114 (vec * 4 + chan) * 16 );
115 }
116
117 static struct x86_reg
118 get_addr(
119 unsigned vec,
120 unsigned chan )
121 {
122 return get_temp(
123 vec + TGSI_EXEC_NUM_TEMPS,
124 chan );
125 }
126
127 static void
128 emit_const(
129 struct x86_function *func,
130 unsigned xmm,
131 unsigned vec,
132 unsigned chan )
133 {
134 sse_movss(
135 func,
136 make_xmm( xmm ),
137 get_const( vec, chan ) );
138 sse_shufps(
139 func,
140 make_xmm( xmm ),
141 make_xmm( xmm ),
142 SHUF( 0, 0, 0, 0 ) );
143 }
144
145 static void
146 emit_input(
147 struct x86_function *func,
148 unsigned xmm,
149 unsigned vec,
150 unsigned chan )
151 {
152 sse_movups(
153 func,
154 make_xmm( xmm ),
155 get_input( vec, chan ) );
156 }
157
158 static void
159 emit_output(
160 struct x86_function *func,
161 unsigned xmm,
162 unsigned vec,
163 unsigned chan )
164 {
165 sse_movups(
166 func,
167 get_output( vec, chan ),
168 make_xmm( xmm ) );
169 }
170
171 static void
172 emit_tempf(
173 struct x86_function *func,
174 unsigned xmm,
175 unsigned vec,
176 unsigned chan )
177 {
178 sse_movaps(
179 func,
180 make_xmm( xmm ),
181 get_temp( vec, chan ) );
182 }
183
184 static void
185 emit_temps (
186 struct x86_function *func,
187 unsigned xmm,
188 unsigned vec,
189 unsigned chan )
190 {
191 sse_movaps(
192 func,
193 get_temp( vec, chan ),
194 make_xmm( xmm ) );
195 }
196
197 static void
198 emit_addrf(
199 struct x86_function *func,
200 unsigned xmm,
201 unsigned vec,
202 unsigned chan )
203 {
204 emit_tempf(
205 func,
206 xmm,
207 vec + TGSI_EXEC_NUM_TEMPS,
208 chan );
209 }
210
211 static void
212 emit_addrs(
213 struct x86_function *func,
214 unsigned xmm,
215 unsigned vec,
216 unsigned chan )
217 {
218 emit_temps(
219 func,
220 xmm,
221 vec + TGSI_EXEC_NUM_TEMPS,
222 chan );
223 }
224
225 static void
226 emit_abs(
227 struct x86_function *func,
228 unsigned xmm )
229 {
230 sse_andps(
231 func,
232 make_xmm( xmm ),
233 get_temp(
234 TGSI_EXEC_TEMP_7FFFFFFF_I,
235 TGSI_EXEC_TEMP_7FFFFFFF_C ) );
236 }
237
238 static void
239 emit_neg(
240 struct x86_function *func,
241 unsigned xmm )
242 {
243 sse_xorps(
244 func,
245 make_xmm( xmm ),
246 get_temp(
247 TGSI_EXEC_TEMP_80000000_I,
248 TGSI_EXEC_TEMP_80000000_C ) );
249 }
250
251 static void
252 emit_setsign(
253 struct x86_function *func,
254 unsigned xmm )
255 {
256 sse_orps(
257 func,
258 make_xmm( xmm ),
259 get_temp(
260 TGSI_EXEC_TEMP_80000000_I,
261 TGSI_EXEC_TEMP_80000000_C ) );
262 }
263
264 static void
265 emit_add(
266 struct x86_function *func,
267 unsigned xmm_dst,
268 unsigned xmm_src )
269 {
270 sse_addps(
271 func,
272 make_xmm( xmm_dst ),
273 make_xmm( xmm_src ) );
274 }
275
276 static void
277 emit_push_abcd(
278 struct x86_function *func )
279 {
280 x86_push(
281 func,
282 x86_make_reg( file_REG32, reg_AX ) );
283 x86_push(
284 func,
285 x86_make_reg( file_REG32, reg_BX ) );
286 x86_push(
287 func,
288 x86_make_reg( file_REG32, reg_CX ) );
289 x86_push(
290 func,
291 x86_make_reg( file_REG32, reg_DX ) );
292 }
293
294 static void
295 emit_pop_dcba(
296 struct x86_function *func )
297 {
298 x86_pop(
299 func,
300 x86_make_reg( file_REG32, reg_DX ) );
301 x86_pop(
302 func,
303 x86_make_reg( file_REG32, reg_CX ) );
304 x86_pop(
305 func,
306 x86_make_reg( file_REG32, reg_BX ) );
307 x86_pop(
308 func,
309 x86_make_reg( file_REG32, reg_AX ) );
310 }
311
312 static void
313 emit_func_call1(
314 struct x86_function *func,
315 unsigned xmm_dst,
316 unsigned storage,
317 unsigned char *code )
318 {
319 x86_push(
320 func,
321 x86_make_reg( file_REG32, reg_AX ) );
322 x86_mov_reg_imm(
323 func,
324 x86_make_reg( file_REG32, reg_AX ),
325 storage );
326 sse_movaps(
327 func,
328 x86_deref( x86_make_reg( file_REG32, reg_AX ) ),
329 make_xmm( xmm_dst ) );
330 emit_push_abcd(
331 func );
332 x86_call(
333 func,
334 code );
335 emit_pop_dcba(
336 func );
337 sse_movaps(
338 func,
339 make_xmm( xmm_dst ),
340 x86_deref( x86_make_reg( file_REG32, reg_AX ) ) );
341 x86_pop(
342 func,
343 x86_make_reg( file_REG32, reg_AX ) );
344 }
345
346 static void
347 emit_func_call2(
348 struct x86_function *func,
349 unsigned xmm_dst,
350 unsigned xmm_src,
351 unsigned storage,
352 unsigned char *code )
353 {
354 x86_push(
355 func,
356 x86_make_reg( file_REG32, reg_AX ) );
357 x86_mov_reg_imm(
358 func,
359 x86_make_reg( file_REG32, reg_AX ),
360 storage );
361 sse_movaps(
362 func,
363 x86_deref( x86_make_reg( file_REG32, reg_AX ) ),
364 make_xmm( xmm_dst ) );
365 sse_movaps(
366 func,
367 x86_make_disp( x86_make_reg( file_REG32, reg_AX ), 16 ),
368 make_xmm( xmm_src ) );
369 emit_push_abcd(
370 func );
371 x86_call(
372 func,
373 code );
374 emit_pop_dcba(
375 func );
376 sse_movaps(
377 func,
378 make_xmm( xmm_dst ),
379 x86_deref( x86_make_reg( file_REG32, reg_AX ) ) );
380 x86_pop(
381 func,
382 x86_make_reg( file_REG32, reg_AX ) );
383 }
384
385 /* XXX: move into machine context */
386 static float g_cos_storage[4 + 3];
387
388 static void
389 cos4f( void )
390 {
391 float *store = (float *) ALIGN16( (unsigned) g_cos_storage );
392
393 #ifdef WIN32
394 store[0] = (float) cos( (double) store[0] );
395 store[1] = (float) cos( (double) store[1] );
396 store[2] = (float) cos( (double) store[2] );
397 store[3] = (float) cos( (double) store[3] );
398 #else
399 store[0] = cosf( store[0] );
400 store[1] = cosf( store[1] );
401 store[2] = cosf( store[2] );
402 store[3] = cosf( store[3] );
403 #endif
404 }
405
406 static void
407 emit_cos(
408 struct x86_function *func,
409 unsigned xmm_dst )
410 {
411 emit_func_call1(
412 func,
413 xmm_dst,
414 ALIGN16( (unsigned) g_cos_storage ),
415 (unsigned char *) cos4f );
416 }
417
418 /* XXX: move into machine context */
419 static float g_sin_storage[4 + 3];
420
421 static void
422 sin4f( void )
423 {
424 float *store = (float *) ALIGN16( (unsigned) g_sin_storage );
425
426 #ifdef WIN32
427 store[0] = (float) sin( (double) store[0] );
428 store[1] = (float) sin( (double) store[1] );
429 store[2] = (float) sin( (double) store[2] );
430 store[3] = (float) sin( (double) store[3] );
431 #else
432 store[0] = sinf( store[0] );
433 store[1] = sinf( store[1] );
434 store[2] = sinf( store[2] );
435 store[3] = sinf( store[3] );
436 #endif
437 }
438
439 static void
440 emit_sin (struct x86_function *func,
441 unsigned xmm_dst)
442 {
443 emit_func_call1(
444 func,
445 xmm_dst,
446 ALIGN16( (unsigned) g_sin_storage ),
447 (unsigned char *) sin4f );
448 }
449
450 static void
451 emit_mov(
452 struct x86_function *func,
453 unsigned xmm_dst,
454 unsigned xmm_src )
455 {
456 sse_movups(
457 func,
458 make_xmm( xmm_dst ),
459 make_xmm( xmm_src ) );
460 }
461
462 static void
463 emit_mul (struct x86_function *func,
464 unsigned xmm_dst,
465 unsigned xmm_src)
466 {
467 sse_mulps(
468 func,
469 make_xmm( xmm_dst ),
470 make_xmm( xmm_src ) );
471 }
472
473 /* XXX: move into machine context */
474 static float g_pow_storage[4 + 4 + 3];
475
476 static void
477 pow4f( void )
478 {
479 float *store = (float *) ALIGN16( (unsigned) g_pow_storage );
480
481 #ifdef WIN32
482 store[0] = (float) pow( (double) store[0], (double) store[4] );
483 store[1] = (float) pow( (double) store[1], (double) store[5] );
484 store[2] = (float) pow( (double) store[2], (double) store[6] );
485 store[3] = (float) pow( (double) store[3], (double) store[7] );
486 #else
487 store[0] = powf( store[0], store[4] );
488 store[1] = powf( store[1], store[5] );
489 store[2] = powf( store[2], store[6] );
490 store[3] = powf( store[3], store[7] );
491 #endif
492 }
493
494 static void
495 emit_pow(
496 struct x86_function *func,
497 unsigned xmm_dst,
498 unsigned xmm_src )
499 {
500 emit_func_call2(
501 func,
502 xmm_dst,
503 xmm_src,
504 ALIGN16( (unsigned) g_pow_storage ),
505 (unsigned char *) pow4f );
506 }
507
508 /* XXX: move into machine context */
509 static float g_ex2_storage[4 + 3];
510
511 static void
512 ex24f( void )
513 {
514 float *store = (float *) ALIGN16( (unsigned) g_ex2_storage );
515
516 #ifdef WIN32
517 store[0] = (float) pow( 2.0, (double) store[0] );
518 store[1] = (float) pow( 2.0, (double) store[1] );
519 store[2] = (float) pow( 2.0, (double) store[2] );
520 store[3] = (float) pow( 2.0, (double) store[3] );
521 #else
522 store[0] = powf( 2.0f, store[0] );
523 store[1] = powf( 2.0f, store[1] );
524 store[2] = powf( 2.0f, store[2] );
525 store[3] = powf( 2.0f, store[3] );
526 #endif
527 }
528
529 static void
530 emit_ex2(
531 struct x86_function *func,
532 unsigned xmm_dst )
533 {
534 emit_func_call1(
535 func,
536 xmm_dst,
537 ALIGN16( (unsigned) g_ex2_storage ),
538 (unsigned char *) ex24f );
539 }
540
541 /* XXX: move into machine context */
542 static float g_lg2_storage[4 + 3];
543
544 static void
545 lg24f( void )
546 {
547 float *store = (float *) ALIGN16( (unsigned) g_lg2_storage );
548
549 store[0] = LOG2( store[0] );
550 store[1] = LOG2( store[1] );
551 store[2] = LOG2( store[2] );
552 store[3] = LOG2( store[3] );
553 }
554
555 static void
556 emit_lg2(
557 struct x86_function *func,
558 unsigned xmm_dst )
559 {
560 emit_func_call1(
561 func,
562 xmm_dst,
563 ALIGN16( (unsigned) g_lg2_storage ),
564 (unsigned char *) lg24f );
565 }
566
567 /* XXX: move into machine context */
568 static float g_flr_storage[4 + 3];
569
570 static void
571 flr4f( void )
572 {
573 float *store = (float *) ALIGN16( (unsigned) g_flr_storage );
574
575 store[0] = (float) floor( (double) store[0] );
576 store[1] = (float) floor( (double) store[1] );
577 store[2] = (float) floor( (double) store[2] );
578 store[3] = (float) floor( (double) store[3] );
579 }
580
581 static void
582 emit_flr(
583 struct x86_function *func,
584 unsigned xmm_dst )
585 {
586 emit_func_call1(
587 func,
588 xmm_dst,
589 ALIGN16( (unsigned) g_flr_storage ),
590 (unsigned char *) flr4f );
591 }
592
593 /* XXX: move into machine context */
594 static float g_frc_storage[4 + 3];
595
596 static void
597 frc4f( void )
598 {
599 float *store = (float *) ALIGN16( (unsigned) g_frc_storage );
600
601 store[0] -= (float) floor( (double) store[0] );
602 store[1] -= (float) floor( (double) store[1] );
603 store[2] -= (float) floor( (double) store[2] );
604 store[3] -= (float) floor( (double) store[3] );
605 }
606
607 static void
608 emit_frc(
609 struct x86_function *func,
610 unsigned xmm_dst )
611 {
612 emit_func_call1(
613 func,
614 xmm_dst,
615 ALIGN16( (unsigned) g_frc_storage ),
616 (unsigned char *) frc4f );
617 }
618
619 static void
620 emit_rcp (
621 struct x86_function *func,
622 unsigned xmm_dst,
623 unsigned xmm_src )
624 {
625 sse2_rcpps(
626 func,
627 make_xmm( xmm_dst ),
628 make_xmm( xmm_src ) );
629 }
630
631 static void
632 emit_rsqrt(
633 struct x86_function *func,
634 unsigned xmm_dst,
635 unsigned xmm_src )
636 {
637 sse_rsqrtps(
638 func,
639 make_xmm( xmm_dst ),
640 make_xmm( xmm_src ) );
641 }
642
643 static void
644 emit_sub(
645 struct x86_function *func,
646 unsigned xmm_dst,
647 unsigned xmm_src )
648 {
649 sse_subps(
650 func,
651 make_xmm( xmm_dst ),
652 make_xmm( xmm_src ) );
653 }
654
655 static void
656 emit_fetch(
657 struct x86_function *func,
658 unsigned xmm,
659 const struct tgsi_full_src_register *reg,
660 const unsigned chan_index )
661 {
662 unsigned swizzle = tgsi_util_get_full_src_register_extswizzle( reg, chan_index );
663
664 switch( swizzle ) {
665 case TGSI_EXTSWIZZLE_X:
666 case TGSI_EXTSWIZZLE_Y:
667 case TGSI_EXTSWIZZLE_Z:
668 case TGSI_EXTSWIZZLE_W:
669 switch( reg->SrcRegister.File ) {
670 case TGSI_FILE_CONSTANT:
671 emit_const(
672 func,
673 xmm,
674 reg->SrcRegister.Index,
675 swizzle );
676 break;
677
678 case TGSI_FILE_INPUT:
679 emit_input(
680 func,
681 xmm,
682 reg->SrcRegister.Index,
683 swizzle );
684 break;
685
686 case TGSI_FILE_TEMPORARY:
687 emit_tempf(
688 func,
689 xmm,
690 reg->SrcRegister.Index,
691 swizzle );
692 break;
693
694 default:
695 assert( 0 );
696 }
697 break;
698
699 case TGSI_EXTSWIZZLE_ZERO:
700 emit_tempf(
701 func,
702 xmm,
703 TGSI_EXEC_TEMP_00000000_I,
704 TGSI_EXEC_TEMP_00000000_C );
705 break;
706
707 case TGSI_EXTSWIZZLE_ONE:
708 emit_tempf(
709 func,
710 xmm,
711 TGSI_EXEC_TEMP_ONE_I,
712 TGSI_EXEC_TEMP_ONE_C );
713 break;
714
715 default:
716 assert( 0 );
717 }
718
719 switch( tgsi_util_get_full_src_register_sign_mode( reg, chan_index ) ) {
720 case TGSI_UTIL_SIGN_CLEAR:
721 emit_abs( func, xmm );
722 break;
723
724 case TGSI_UTIL_SIGN_SET:
725 emit_setsign( func, xmm );
726 break;
727
728 case TGSI_UTIL_SIGN_TOGGLE:
729 emit_neg( func, xmm );
730 break;
731
732 case TGSI_UTIL_SIGN_KEEP:
733 break;
734 }
735 }
736
737 static void
738 emit_store(
739 struct x86_function *func,
740 unsigned xmm,
741 const struct tgsi_full_dst_register *reg,
742 const struct tgsi_full_instruction *inst,
743 unsigned chan_index )
744 {
745 switch( reg->DstRegister.File ) {
746 case TGSI_FILE_OUTPUT:
747 emit_output(
748 func,
749 xmm,
750 reg->DstRegister.Index,
751 chan_index );
752 break;
753
754 case TGSI_FILE_TEMPORARY:
755 emit_temps(
756 func,
757 xmm,
758 reg->DstRegister.Index,
759 chan_index );
760 break;
761
762 case TGSI_FILE_ADDRESS:
763 emit_addrs(
764 func,
765 xmm,
766 reg->DstRegister.Index,
767 chan_index );
768 break;
769
770 default:
771 assert( 0 );
772 }
773
774 switch( inst->Instruction.Saturate ) {
775 case TGSI_SAT_NONE:
776 break;
777
778 case TGSI_SAT_ZERO_ONE:
779 // assert( 0 );
780 break;
781
782 case TGSI_SAT_MINUS_PLUS_ONE:
783 assert( 0 );
784 break;
785 }
786 }
787
788 static void
789 emit_kil(
790 struct x86_function *func,
791 const struct tgsi_full_src_register *reg )
792 {
793 unsigned uniquemask;
794 unsigned registers[4];
795 unsigned nextregister = 0;
796 unsigned firstchan = ~0;
797 unsigned chan_index;
798
799 /* This mask stores component bits that were already tested. Note that
800 * we test if the value is less than zero, so 1.0 and 0.0 need not to be
801 * tested. */
802 uniquemask = (1 << TGSI_EXTSWIZZLE_ZERO) | (1 << TGSI_EXTSWIZZLE_ONE);
803
804 FOR_EACH_CHANNEL( chan_index ) {
805 unsigned swizzle;
806
807 /* unswizzle channel */
808 swizzle = tgsi_util_get_full_src_register_extswizzle(
809 reg,
810 chan_index );
811
812 /* check if the component has not been already tested */
813 if( !(uniquemask & (1 << swizzle)) ) {
814 uniquemask |= 1 << swizzle;
815
816 /* allocate register */
817 registers[chan_index] = nextregister;
818 emit_fetch(
819 func,
820 nextregister,
821 reg,
822 chan_index );
823 nextregister++;
824
825 /* mark the first channel used */
826 if( firstchan == ~0 ) {
827 firstchan = chan_index;
828 }
829 }
830 }
831
832 x86_push(
833 func,
834 x86_make_reg( file_REG32, reg_AX ) );
835 x86_push(
836 func,
837 x86_make_reg( file_REG32, reg_DX ) );
838
839 FOR_EACH_CHANNEL( chan_index ) {
840 if( uniquemask & (1 << chan_index) ) {
841 sse_cmpps(
842 func,
843 make_xmm( registers[chan_index] ),
844 get_temp(
845 TGSI_EXEC_TEMP_00000000_I,
846 TGSI_EXEC_TEMP_00000000_C ),
847 cc_LessThan );
848
849 if( chan_index == firstchan ) {
850 sse_pmovmskb(
851 func,
852 x86_make_reg( file_REG32, reg_AX ),
853 make_xmm( registers[chan_index] ) );
854 }
855 else {
856 sse_pmovmskb(
857 func,
858 x86_make_reg( file_REG32, reg_DX ),
859 make_xmm( registers[chan_index] ) );
860 x86_or(
861 func,
862 x86_make_reg( file_REG32, reg_AX ),
863 x86_make_reg( file_REG32, reg_DX ) );
864 }
865 }
866 }
867
868 x86_or(
869 func,
870 get_temp(
871 TGSI_EXEC_TEMP_KILMASK_I,
872 TGSI_EXEC_TEMP_KILMASK_C ),
873 x86_make_reg( file_REG32, reg_AX ) );
874
875 x86_pop(
876 func,
877 x86_make_reg( file_REG32, reg_DX ) );
878 x86_pop(
879 func,
880 x86_make_reg( file_REG32, reg_AX ) );
881 }
882
883 #define FETCH( FUNC, INST, XMM, INDEX, CHAN )\
884 emit_fetch( FUNC, XMM, &(INST).FullSrcRegisters[INDEX], CHAN )
885
886 #define STORE( FUNC, INST, XMM, INDEX, CHAN )\
887 emit_store( FUNC, XMM, &(INST).FullDstRegisters[INDEX], &(INST), CHAN )
888
889 static void
890 emit_setcc(
891 struct x86_function *func,
892 struct tgsi_full_instruction *inst,
893 enum sse_cc cc )
894 {
895 unsigned chan_index;
896
897 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
898 FETCH( func, *inst, 0, 0, chan_index );
899 FETCH( func, *inst, 1, 1, chan_index );
900 sse_cmpps(
901 func,
902 make_xmm( 0 ),
903 make_xmm( 1 ),
904 cc );
905 sse_andps(
906 func,
907 make_xmm( 0 ),
908 get_temp(
909 TGSI_EXEC_TEMP_ONE_I,
910 TGSI_EXEC_TEMP_ONE_C ) );
911 STORE( func, *inst, 0, 0, chan_index );
912 }
913 }
914
915 static void
916 emit_cmp(
917 struct x86_function *func,
918 struct tgsi_full_instruction *inst )
919 {
920 unsigned chan_index;
921
922 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
923 FETCH( func, *inst, 0, 0, chan_index );
924 FETCH( func, *inst, 1, 1, chan_index );
925 FETCH( func, *inst, 2, 2, chan_index );
926 sse_cmpps(
927 func,
928 make_xmm( 0 ),
929 get_temp(
930 TGSI_EXEC_TEMP_00000000_I,
931 TGSI_EXEC_TEMP_00000000_C ),
932 cc_LessThan );
933 sse_andps(
934 func,
935 make_xmm( 1 ),
936 make_xmm( 0 ) );
937 sse_andnps(
938 func,
939 make_xmm( 0 ),
940 make_xmm( 2 ) );
941 sse_orps(
942 func,
943 make_xmm( 0 ),
944 make_xmm( 1 ) );
945 STORE( func, *inst, 0, 0, chan_index );
946 }
947 }
948
949 static void
950 emit_f2it(
951 struct x86_function *func,
952 unsigned xmm )
953 {
954 sse2_cvttps2dq(
955 func,
956 make_xmm( xmm ),
957 make_xmm( xmm ) );
958 }
959
960 static void
961 emit_instruction(
962 struct x86_function *func,
963 struct tgsi_full_instruction *inst )
964 {
965 unsigned chan_index;
966
967 switch( inst->Instruction.Opcode ) {
968 case TGSI_OPCODE_ARL:
969 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
970 FETCH( func, *inst, 0, 0, chan_index );
971 emit_f2it( func, 0 );
972 STORE( func, *inst, 0, 0, chan_index );
973 }
974 break;
975
976 case TGSI_OPCODE_MOV:
977 /* TGSI_OPCODE_SWZ */
978 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
979 FETCH( func, *inst, 0, 0, chan_index );
980 STORE( func, *inst, 0, 0, chan_index );
981 }
982 break;
983
984 case TGSI_OPCODE_LIT:
985 if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) ||
986 IS_DST0_CHANNEL_ENABLED( *inst, CHAN_W ) ) {
987 emit_tempf(
988 func,
989 0,
990 TGSI_EXEC_TEMP_ONE_I,
991 TGSI_EXEC_TEMP_ONE_C);
992 if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) ) {
993 STORE( func, *inst, 0, 0, CHAN_X );
994 }
995 if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_W ) ) {
996 STORE( func, *inst, 0, 0, CHAN_W );
997 }
998 }
999 if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) ||
1000 IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z ) ) {
1001 if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) ) {
1002 FETCH( func, *inst, 0, 0, CHAN_X );
1003 sse_maxps(
1004 func,
1005 make_xmm( 0 ),
1006 get_temp(
1007 TGSI_EXEC_TEMP_00000000_I,
1008 TGSI_EXEC_TEMP_00000000_C ) );
1009 STORE( func, *inst, 0, 0, CHAN_Y );
1010 }
1011 if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z ) ) {
1012 FETCH( func, *inst, 1, 0, CHAN_Y );
1013 sse_maxps(
1014 func,
1015 make_xmm( 1 ),
1016 get_temp(
1017 TGSI_EXEC_TEMP_00000000_I,
1018 TGSI_EXEC_TEMP_00000000_C ) );
1019 FETCH( func, *inst, 2, 0, CHAN_W );
1020 sse_minps(
1021 func,
1022 make_xmm( 2 ),
1023 get_temp(
1024 TGSI_EXEC_TEMP_128_I,
1025 TGSI_EXEC_TEMP_128_C ) );
1026 sse_maxps(
1027 func,
1028 make_xmm( 2 ),
1029 get_temp(
1030 TGSI_EXEC_TEMP_MINUS_128_I,
1031 TGSI_EXEC_TEMP_MINUS_128_C ) );
1032 emit_pow( func, 1, 2 );
1033 FETCH( func, *inst, 0, 0, CHAN_X );
1034 sse_xorps(
1035 func,
1036 make_xmm( 2 ),
1037 make_xmm( 2 ) );
1038 sse_cmpps(
1039 func,
1040 make_xmm( 2 ),
1041 make_xmm( 0 ),
1042 cc_LessThanEqual );
1043 sse_andps(
1044 func,
1045 make_xmm( 2 ),
1046 make_xmm( 1 ) );
1047 STORE( func, *inst, 2, 0, CHAN_Z );
1048 }
1049 }
1050 break;
1051
1052 case TGSI_OPCODE_RCP:
1053 /* TGSI_OPCODE_RECIP */
1054 FETCH( func, *inst, 0, 0, CHAN_X );
1055 emit_rcp( func, 0, 0 );
1056 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1057 STORE( func, *inst, 0, 0, chan_index );
1058 }
1059 break;
1060
1061 case TGSI_OPCODE_RSQ:
1062 /* TGSI_OPCODE_RECIPSQRT */
1063 FETCH( func, *inst, 0, 0, CHAN_X );
1064 emit_rsqrt( func, 0, 0 );
1065 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1066 STORE( func, *inst, 0, 0, chan_index );
1067 }
1068 break;
1069
1070 case TGSI_OPCODE_EXP:
1071 assert( 0 );
1072 break;
1073
1074 case TGSI_OPCODE_LOG:
1075 assert( 0 );
1076 break;
1077
1078 case TGSI_OPCODE_MUL:
1079 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1080 FETCH( func, *inst, 0, 0, chan_index );
1081 FETCH( func, *inst, 1, 1, chan_index );
1082 emit_mul( func, 0, 1 );
1083 STORE( func, *inst, 0, 0, chan_index );
1084 }
1085 break;
1086
1087 case TGSI_OPCODE_ADD:
1088 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1089 FETCH( func, *inst, 0, 0, chan_index );
1090 FETCH( func, *inst, 1, 1, chan_index );
1091 emit_add( func, 0, 1 );
1092 STORE( func, *inst, 0, 0, chan_index );
1093 }
1094 break;
1095
1096 case TGSI_OPCODE_DP3:
1097 /* TGSI_OPCODE_DOT3 */
1098 FETCH( func, *inst, 0, 0, CHAN_X );
1099 FETCH( func, *inst, 1, 1, CHAN_X );
1100 emit_mul( func, 0, 1 );
1101 FETCH( func, *inst, 1, 0, CHAN_Y );
1102 FETCH( func, *inst, 2, 1, CHAN_Y );
1103 emit_mul( func, 1, 2 );
1104 emit_add( func, 0, 1 );
1105 FETCH( func, *inst, 1, 0, CHAN_Z );
1106 FETCH( func, *inst, 2, 1, CHAN_Z );
1107 emit_mul( func, 1, 2 );
1108 emit_add( func, 0, 1 );
1109 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1110 STORE( func, *inst, 0, 0, chan_index );
1111 }
1112 break;
1113
1114 case TGSI_OPCODE_DP4:
1115 /* TGSI_OPCODE_DOT4 */
1116 FETCH( func, *inst, 0, 0, CHAN_X );
1117 FETCH( func, *inst, 1, 1, CHAN_X );
1118 emit_mul( func, 0, 1 );
1119 FETCH( func, *inst, 1, 0, CHAN_Y );
1120 FETCH( func, *inst, 2, 1, CHAN_Y );
1121 emit_mul( func, 1, 2 );
1122 emit_add( func, 0, 1 );
1123 FETCH( func, *inst, 1, 0, CHAN_Z );
1124 FETCH( func, *inst, 2, 1, CHAN_Z );
1125 emit_mul(func, 1, 2 );
1126 emit_add(func, 0, 1 );
1127 FETCH( func, *inst, 1, 0, CHAN_W );
1128 FETCH( func, *inst, 2, 1, CHAN_W );
1129 emit_mul( func, 1, 2 );
1130 emit_add( func, 0, 1 );
1131 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1132 STORE( func, *inst, 0, 0, chan_index );
1133 }
1134 break;
1135
1136 case TGSI_OPCODE_DST:
1137 IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) {
1138 emit_tempf(
1139 func,
1140 0,
1141 TGSI_EXEC_TEMP_ONE_I,
1142 TGSI_EXEC_TEMP_ONE_C );
1143 STORE( func, *inst, 0, 0, CHAN_X );
1144 }
1145 IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) {
1146 FETCH( func, *inst, 0, 0, CHAN_Y );
1147 FETCH( func, *inst, 1, 1, CHAN_Y );
1148 emit_mul( func, 0, 1 );
1149 STORE( func, *inst, 0, 0, CHAN_Y );
1150 }
1151 IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z ) {
1152 FETCH( func, *inst, 0, 0, CHAN_Z );
1153 STORE( func, *inst, 0, 0, CHAN_Z );
1154 }
1155 IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_W ) {
1156 FETCH( func, *inst, 0, 1, CHAN_W );
1157 STORE( func, *inst, 0, 0, CHAN_W );
1158 }
1159 break;
1160
1161 case TGSI_OPCODE_MIN:
1162 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1163 FETCH( func, *inst, 0, 0, chan_index );
1164 FETCH( func, *inst, 1, 1, chan_index );
1165 sse_minps(
1166 func,
1167 make_xmm( 0 ),
1168 make_xmm( 1 ) );
1169 STORE( func, *inst, 0, 0, chan_index );
1170 }
1171 break;
1172
1173 case TGSI_OPCODE_MAX:
1174 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1175 FETCH( func, *inst, 0, 0, chan_index );
1176 FETCH( func, *inst, 1, 1, chan_index );
1177 sse_maxps(
1178 func,
1179 make_xmm( 0 ),
1180 make_xmm( 1 ) );
1181 STORE( func, *inst, 0, 0, chan_index );
1182 }
1183 break;
1184
1185 case TGSI_OPCODE_SLT:
1186 /* TGSI_OPCODE_SETLT */
1187 emit_setcc( func, inst, cc_LessThan );
1188 break;
1189
1190 case TGSI_OPCODE_SGE:
1191 /* TGSI_OPCODE_SETGE */
1192 emit_setcc( func, inst, cc_NotLessThan );
1193 break;
1194
1195 case TGSI_OPCODE_MAD:
1196 /* TGSI_OPCODE_MADD */
1197 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1198 FETCH( func, *inst, 0, 0, chan_index );
1199 FETCH( func, *inst, 1, 1, chan_index );
1200 FETCH( func, *inst, 2, 2, chan_index );
1201 emit_mul( func, 0, 1 );
1202 emit_add( func, 0, 2 );
1203 STORE( func, *inst, 0, 0, chan_index );
1204 }
1205 break;
1206
1207 case TGSI_OPCODE_SUB:
1208 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1209 FETCH( func, *inst, 0, 0, chan_index );
1210 FETCH( func, *inst, 1, 1, chan_index );
1211 emit_sub( func, 0, 1 );
1212 STORE( func, *inst, 0, 0, chan_index );
1213 }
1214 break;
1215
1216 case TGSI_OPCODE_LERP:
1217 /* TGSI_OPCODE_LRP */
1218 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1219 FETCH( func, *inst, 0, 0, chan_index );
1220 FETCH( func, *inst, 1, 1, chan_index );
1221 FETCH( func, *inst, 2, 2, chan_index );
1222 emit_sub( func, 1, 2 );
1223 emit_mul( func, 0, 1 );
1224 emit_add( func, 0, 2 );
1225 STORE( func, *inst, 0, 0, chan_index );
1226 }
1227 break;
1228
1229 case TGSI_OPCODE_CND:
1230 assert( 0 );
1231 break;
1232
1233 case TGSI_OPCODE_CND0:
1234 assert( 0 );
1235 break;
1236
1237 case TGSI_OPCODE_DOT2ADD:
1238 /* TGSI_OPCODE_DP2A */
1239 assert( 0 );
1240 break;
1241
1242 case TGSI_OPCODE_INDEX:
1243 assert( 0 );
1244 break;
1245
1246 case TGSI_OPCODE_NEGATE:
1247 assert( 0 );
1248 break;
1249
1250 case TGSI_OPCODE_FRAC:
1251 /* TGSI_OPCODE_FRC */
1252 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1253 FETCH( func, *inst, 0, 0, chan_index );
1254 emit_frc( func, 0 );
1255 STORE( func, *inst, 0, 0, chan_index );
1256 }
1257 break;
1258
1259 case TGSI_OPCODE_CLAMP:
1260 assert( 0 );
1261 break;
1262
1263 case TGSI_OPCODE_FLOOR:
1264 /* TGSI_OPCODE_FLR */
1265 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1266 FETCH( func, *inst, 0, 0, chan_index );
1267 emit_flr( func, 0 );
1268 STORE( func, *inst, 0, 0, chan_index );
1269 }
1270 break;
1271
1272 case TGSI_OPCODE_ROUND:
1273 assert( 0 );
1274 break;
1275
1276 case TGSI_OPCODE_EXPBASE2:
1277 /* TGSI_OPCODE_EX2 */
1278 FETCH( func, *inst, 0, 0, CHAN_X );
1279 emit_ex2( func, 0 );
1280 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1281 STORE( func, *inst, 0, 0, chan_index );
1282 }
1283 break;
1284
1285 case TGSI_OPCODE_LOGBASE2:
1286 /* TGSI_OPCODE_LG2 */
1287 FETCH( func, *inst, 0, 0, CHAN_X );
1288 emit_lg2( func, 0 );
1289 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1290 STORE( func, *inst, 0, 0, chan_index );
1291 }
1292 break;
1293
1294 case TGSI_OPCODE_POWER:
1295 /* TGSI_OPCODE_POW */
1296 FETCH( func, *inst, 0, 0, CHAN_X );
1297 FETCH( func, *inst, 1, 1, CHAN_X );
1298 emit_pow( func, 0, 1 );
1299 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1300 STORE( func, *inst, 0, 0, chan_index );
1301 }
1302 break;
1303
1304 case TGSI_OPCODE_CROSSPRODUCT:
1305 /* TGSI_OPCODE_XPD */
1306 if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) ||
1307 IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) ) {
1308 FETCH( func, *inst, 1, 1, CHAN_Z );
1309 FETCH( func, *inst, 3, 0, CHAN_Z );
1310 }
1311 if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) ||
1312 IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z ) ) {
1313 FETCH( func, *inst, 0, 0, CHAN_Y );
1314 FETCH( func, *inst, 4, 1, CHAN_Y );
1315 }
1316 IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) {
1317 emit_mov( func, 2, 0 );
1318 emit_mul( func, 2, 1 );
1319 emit_mov( func, 5, 3 );
1320 emit_mul( func, 5, 4 );
1321 emit_sub( func, 2, 5 );
1322 STORE( func, *inst, 2, 0, CHAN_X );
1323 }
1324 if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) ||
1325 IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z ) ) {
1326 FETCH( func, *inst, 2, 1, CHAN_X );
1327 FETCH( func, *inst, 5, 0, CHAN_X );
1328 }
1329 IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) {
1330 emit_mul( func, 3, 2 );
1331 emit_mul( func, 1, 5 );
1332 emit_sub( func, 3, 1 );
1333 STORE( func, *inst, 3, 0, CHAN_Y );
1334 }
1335 IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z ) {
1336 emit_mul( func, 5, 4 );
1337 emit_mul( func, 0, 2 );
1338 emit_sub( func, 5, 0 );
1339 STORE( func, *inst, 5, 0, CHAN_Z );
1340 }
1341 IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_W ) {
1342 FETCH( func, *inst, 0, TGSI_EXEC_TEMP_ONE_I, TGSI_EXEC_TEMP_ONE_C );
1343 STORE( func, *inst, 0, 0, CHAN_W );
1344 }
1345 break;
1346
1347 case TGSI_OPCODE_MULTIPLYMATRIX:
1348 assert( 0 );
1349 break;
1350
1351 case TGSI_OPCODE_ABS:
1352 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1353 FETCH( func, *inst, 0, 0, chan_index );
1354 emit_abs( func, 0) ;
1355
1356 STORE( func, *inst, 0, 0, chan_index );
1357 }
1358 break;
1359
1360 case TGSI_OPCODE_RCC:
1361 assert( 0 );
1362 break;
1363
1364 case TGSI_OPCODE_DPH:
1365 FETCH( func, *inst, 0, 0, CHAN_X );
1366 FETCH( func, *inst, 1, 1, CHAN_X );
1367 emit_mul( func, 0, 1 );
1368 FETCH( func, *inst, 1, 0, CHAN_Y );
1369 FETCH( func, *inst, 2, 1, CHAN_Y );
1370 emit_mul( func, 1, 2 );
1371 emit_add( func, 0, 1 );
1372 FETCH( func, *inst, 1, 0, CHAN_Z );
1373 FETCH( func, *inst, 2, 1, CHAN_Z );
1374 emit_mul( func, 1, 2 );
1375 emit_add( func, 0, 1 );
1376 FETCH( func, *inst, 1, 1, CHAN_W );
1377 emit_add( func, 0, 1 );
1378 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1379 STORE( func, *inst, 0, 0, chan_index );
1380 }
1381 break;
1382
1383 case TGSI_OPCODE_COS:
1384 FETCH( func, *inst, 0, 0, CHAN_X );
1385 emit_cos( func, 0 );
1386 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1387 STORE( func, *inst, 0, 0, chan_index );
1388 }
1389 break;
1390
1391 case TGSI_OPCODE_DDX:
1392 assert( 0 );
1393 break;
1394
1395 case TGSI_OPCODE_DDY:
1396 assert( 0 );
1397 break;
1398
1399 case TGSI_OPCODE_KIL:
1400 emit_kil( func, &inst->FullSrcRegisters[0] );
1401 break;
1402
1403 case TGSI_OPCODE_PK2H:
1404 assert( 0 );
1405 break;
1406
1407 case TGSI_OPCODE_PK2US:
1408 assert( 0 );
1409 break;
1410
1411 case TGSI_OPCODE_PK4B:
1412 assert( 0 );
1413 break;
1414
1415 case TGSI_OPCODE_PK4UB:
1416 assert( 0 );
1417 break;
1418
1419 case TGSI_OPCODE_RFL:
1420 assert( 0 );
1421 break;
1422
1423 case TGSI_OPCODE_SEQ:
1424 assert( 0 );
1425 break;
1426
1427 case TGSI_OPCODE_SFL:
1428 assert( 0 );
1429 break;
1430
1431 case TGSI_OPCODE_SGT:
1432 assert( 0 );
1433 break;
1434
1435 case TGSI_OPCODE_SIN:
1436 FETCH( func, *inst, 0, 0, CHAN_X );
1437 emit_sin( func, 0 );
1438 FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
1439 STORE( func, *inst, 0, 0, chan_index );
1440 }
1441 break;
1442
1443 case TGSI_OPCODE_SLE:
1444 assert( 0 );
1445 break;
1446
1447 case TGSI_OPCODE_SNE:
1448 assert( 0 );
1449 break;
1450
1451 case TGSI_OPCODE_STR:
1452 assert( 0 );
1453 break;
1454
1455 case TGSI_OPCODE_TEX:
1456 assert( 0 );
1457 break;
1458
1459 case TGSI_OPCODE_TXD:
1460 assert( 0 );
1461 break;
1462
1463 case TGSI_OPCODE_UP2H:
1464 assert( 0 );
1465 break;
1466
1467 case TGSI_OPCODE_UP2US:
1468 assert( 0 );
1469 break;
1470
1471 case TGSI_OPCODE_UP4B:
1472 assert( 0 );
1473 break;
1474
1475 case TGSI_OPCODE_UP4UB:
1476 assert( 0 );
1477 break;
1478
1479 case TGSI_OPCODE_X2D:
1480 assert( 0 );
1481 break;
1482
1483 case TGSI_OPCODE_ARA:
1484 assert( 0 );
1485 break;
1486
1487 case TGSI_OPCODE_ARR:
1488 assert( 0 );
1489 break;
1490
1491 case TGSI_OPCODE_BRA:
1492 assert( 0 );
1493 break;
1494
1495 case TGSI_OPCODE_CAL:
1496 assert( 0 );
1497 break;
1498
1499 case TGSI_OPCODE_RET:
1500 assert( 0 );
1501 break;
1502
1503 case TGSI_OPCODE_SSG:
1504 assert( 0 );
1505 break;
1506
1507 case TGSI_OPCODE_CMP:
1508 emit_cmp (func, inst);
1509 break;
1510
1511 case TGSI_OPCODE_SCS:
1512 IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) {
1513 FETCH( func, *inst, 0, 0, CHAN_X );
1514 emit_cos( func, 0 );
1515 STORE( func, *inst, 0, 0, CHAN_X );
1516 }
1517 IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) {
1518 FETCH( func, *inst, 0, 0, CHAN_Y );
1519 emit_sin( func, 0 );
1520 STORE( func, *inst, 0, 0, CHAN_Y );
1521 }
1522 IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z ) {
1523 FETCH( func, *inst, 0, TGSI_EXEC_TEMP_00000000_I, TGSI_EXEC_TEMP_00000000_C );
1524 STORE( func, *inst, 0, 0, CHAN_Z );
1525 }
1526 IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_W ) {
1527 FETCH( func, *inst, 0, TGSI_EXEC_TEMP_ONE_I, TGSI_EXEC_TEMP_ONE_C );
1528 STORE( func, *inst, 0, 0, CHAN_W );
1529 }
1530 break;
1531
1532 case TGSI_OPCODE_TXB:
1533 assert( 0 );
1534 break;
1535
1536 case TGSI_OPCODE_NRM:
1537 assert( 0 );
1538 break;
1539
1540 case TGSI_OPCODE_DIV:
1541 assert( 0 );
1542 break;
1543
1544 case TGSI_OPCODE_DP2:
1545 assert( 0 );
1546 break;
1547
1548 case TGSI_OPCODE_TXL:
1549 assert( 0 );
1550 break;
1551
1552 case TGSI_OPCODE_BRK:
1553 assert( 0 );
1554 break;
1555
1556 case TGSI_OPCODE_IF:
1557 assert( 0 );
1558 break;
1559
1560 case TGSI_OPCODE_LOOP:
1561 assert( 0 );
1562 break;
1563
1564 case TGSI_OPCODE_REP:
1565 assert( 0 );
1566 break;
1567
1568 case TGSI_OPCODE_ELSE:
1569 assert( 0 );
1570 break;
1571
1572 case TGSI_OPCODE_ENDIF:
1573 assert( 0 );
1574 break;
1575
1576 case TGSI_OPCODE_ENDLOOP:
1577 assert( 0 );
1578 break;
1579
1580 case TGSI_OPCODE_ENDREP:
1581 assert( 0 );
1582 break;
1583
1584 case TGSI_OPCODE_PUSHA:
1585 assert( 0 );
1586 break;
1587
1588 case TGSI_OPCODE_POPA:
1589 assert( 0 );
1590 break;
1591
1592 case TGSI_OPCODE_CEIL:
1593 assert( 0 );
1594 break;
1595
1596 case TGSI_OPCODE_I2F:
1597 assert( 0 );
1598 break;
1599
1600 case TGSI_OPCODE_NOT:
1601 assert( 0 );
1602 break;
1603
1604 case TGSI_OPCODE_TRUNC:
1605 assert( 0 );
1606 break;
1607
1608 case TGSI_OPCODE_SHL:
1609 assert( 0 );
1610 break;
1611
1612 case TGSI_OPCODE_SHR:
1613 assert( 0 );
1614 break;
1615
1616 case TGSI_OPCODE_AND:
1617 assert( 0 );
1618 break;
1619
1620 case TGSI_OPCODE_OR:
1621 assert( 0 );
1622 break;
1623
1624 case TGSI_OPCODE_MOD:
1625 assert( 0 );
1626 break;
1627
1628 case TGSI_OPCODE_XOR:
1629 assert( 0 );
1630 break;
1631
1632 case TGSI_OPCODE_SAD:
1633 assert( 0 );
1634 break;
1635
1636 case TGSI_OPCODE_TXF:
1637 assert( 0 );
1638 break;
1639
1640 case TGSI_OPCODE_TXQ:
1641 assert( 0 );
1642 break;
1643
1644 case TGSI_OPCODE_CONT:
1645 assert( 0 );
1646 break;
1647
1648 case TGSI_OPCODE_EMIT:
1649 assert( 0 );
1650 break;
1651
1652 case TGSI_OPCODE_ENDPRIM:
1653 assert( 0 );
1654 break;
1655
1656 default:
1657 assert( 0 );
1658 }
1659 }
1660
1661 unsigned
1662 tgsi_emit_sse2(
1663 struct tgsi_token *tokens,
1664 struct x86_function *func )
1665 {
1666 struct tgsi_parse_context parse;
1667
1668 func->csr = func->store;
1669
1670 x86_mov(
1671 func,
1672 get_input_base(),
1673 get_argument( 0 ) );
1674 x86_mov(
1675 func,
1676 get_output_base(),
1677 get_argument( 1 ) );
1678 x86_mov(
1679 func,
1680 get_const_base(),
1681 get_argument( 2 ) );
1682 x86_mov(
1683 func,
1684 get_temp_base(),
1685 get_argument( 3 ) );
1686
1687 tgsi_parse_init( &parse, tokens );
1688
1689 while( !tgsi_parse_end_of_tokens( &parse ) ) {
1690 tgsi_parse_token( &parse );
1691
1692 switch( parse.FullToken.Token.Type ) {
1693 case TGSI_TOKEN_TYPE_DECLARATION:
1694 break;
1695
1696 case TGSI_TOKEN_TYPE_INSTRUCTION:
1697 emit_instruction(
1698 func,
1699 &parse.FullToken.FullInstruction );
1700 break;
1701
1702 default:
1703 assert( 0 );
1704 }
1705 }
1706
1707 tgsi_parse_free( &parse );
1708
1709 #ifdef WIN32
1710 x86_retw( func, 16 );
1711 #else
1712 x86_ret( func );
1713 #endif
1714
1715 return 1;
1716 }
1717
1718 #endif