1 /*
2 * Copyright (C) 2014 Intel Corporation
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 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * 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 NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * Authors:
24 * Jason Ekstrand (jason@jlekstrand.net)
25 */
26
27 #include <math.h>
28 #include "main/core.h"
29 #include "util/rounding.h" /* for _mesa_roundeven */
30 #include "util/half_float.h"
31 #include "nir_constant_expressions.h"
32
33 /**
34 * Evaluate one component of packSnorm4x8.
35 */
36 static uint8_t
pack_snorm_1x8(float x)37 pack_snorm_1x8(float x)
38 {
39 /* From section 8.4 of the GLSL 4.30 spec:
40 *
41 * packSnorm4x8
42 * ------------
43 * The conversion for component c of v to fixed point is done as
44 * follows:
45 *
46 * packSnorm4x8: round(clamp(c, -1, +1) * 127.0)
47 *
48 * We must first cast the float to an int, because casting a negative
49 * float to a uint is undefined.
50 */
51 return (uint8_t) (int)
52 _mesa_roundevenf(CLAMP(x, -1.0f, +1.0f) * 127.0f);
53 }
54
55 /**
56 * Evaluate one component of packSnorm2x16.
57 */
58 static uint16_t
pack_snorm_1x16(float x)59 pack_snorm_1x16(float x)
60 {
61 /* From section 8.4 of the GLSL ES 3.00 spec:
62 *
63 * packSnorm2x16
64 * -------------
65 * The conversion for component c of v to fixed point is done as
66 * follows:
67 *
68 * packSnorm2x16: round(clamp(c, -1, +1) * 32767.0)
69 *
70 * We must first cast the float to an int, because casting a negative
71 * float to a uint is undefined.
72 */
73 return (uint16_t) (int)
74 _mesa_roundevenf(CLAMP(x, -1.0f, +1.0f) * 32767.0f);
75 }
76
77 /**
78 * Evaluate one component of unpackSnorm4x8.
79 */
80 static float
unpack_snorm_1x8(uint8_t u)81 unpack_snorm_1x8(uint8_t u)
82 {
83 /* From section 8.4 of the GLSL 4.30 spec:
84 *
85 * unpackSnorm4x8
86 * --------------
87 * The conversion for unpacked fixed-point value f to floating point is
88 * done as follows:
89 *
90 * unpackSnorm4x8: clamp(f / 127.0, -1, +1)
91 */
92 return CLAMP((int8_t) u / 127.0f, -1.0f, +1.0f);
93 }
94
95 /**
96 * Evaluate one component of unpackSnorm2x16.
97 */
98 static float
unpack_snorm_1x16(uint16_t u)99 unpack_snorm_1x16(uint16_t u)
100 {
101 /* From section 8.4 of the GLSL ES 3.00 spec:
102 *
103 * unpackSnorm2x16
104 * ---------------
105 * The conversion for unpacked fixed-point value f to floating point is
106 * done as follows:
107 *
108 * unpackSnorm2x16: clamp(f / 32767.0, -1, +1)
109 */
110 return CLAMP((int16_t) u / 32767.0f, -1.0f, +1.0f);
111 }
112
113 /**
114 * Evaluate one component packUnorm4x8.
115 */
116 static uint8_t
pack_unorm_1x8(float x)117 pack_unorm_1x8(float x)
118 {
119 /* From section 8.4 of the GLSL 4.30 spec:
120 *
121 * packUnorm4x8
122 * ------------
123 * The conversion for component c of v to fixed point is done as
124 * follows:
125 *
126 * packUnorm4x8: round(clamp(c, 0, +1) * 255.0)
127 */
128 return (uint8_t) (int)
129 _mesa_roundevenf(CLAMP(x, 0.0f, 1.0f) * 255.0f);
130 }
131
132 /**
133 * Evaluate one component packUnorm2x16.
134 */
135 static uint16_t
pack_unorm_1x16(float x)136 pack_unorm_1x16(float x)
137 {
138 /* From section 8.4 of the GLSL ES 3.00 spec:
139 *
140 * packUnorm2x16
141 * -------------
142 * The conversion for component c of v to fixed point is done as
143 * follows:
144 *
145 * packUnorm2x16: round(clamp(c, 0, +1) * 65535.0)
146 */
147 return (uint16_t) (int)
148 _mesa_roundevenf(CLAMP(x, 0.0f, 1.0f) * 65535.0f);
149 }
150
151 /**
152 * Evaluate one component of unpackUnorm4x8.
153 */
154 static float
unpack_unorm_1x8(uint8_t u)155 unpack_unorm_1x8(uint8_t u)
156 {
157 /* From section 8.4 of the GLSL 4.30 spec:
158 *
159 * unpackUnorm4x8
160 * --------------
161 * The conversion for unpacked fixed-point value f to floating point is
162 * done as follows:
163 *
164 * unpackUnorm4x8: f / 255.0
165 */
166 return (float) u / 255.0f;
167 }
168
169 /**
170 * Evaluate one component of unpackUnorm2x16.
171 */
172 static float
unpack_unorm_1x16(uint16_t u)173 unpack_unorm_1x16(uint16_t u)
174 {
175 /* From section 8.4 of the GLSL ES 3.00 spec:
176 *
177 * unpackUnorm2x16
178 * ---------------
179 * The conversion for unpacked fixed-point value f to floating point is
180 * done as follows:
181 *
182 * unpackUnorm2x16: f / 65535.0
183 */
184 return (float) u / 65535.0f;
185 }
186
187 /**
188 * Evaluate one component of packHalf2x16.
189 */
190 static uint16_t
pack_half_1x16(float x)191 pack_half_1x16(float x)
192 {
193 return _mesa_float_to_half(x);
194 }
195
196 /**
197 * Evaluate one component of unpackHalf2x16.
198 */
199 static float
unpack_half_1x16(uint16_t u)200 unpack_half_1x16(uint16_t u)
201 {
202 return _mesa_half_to_float(u);
203 }
204
205 /* Some typed vector structures to make things like src0.y work */
206 typedef float float16_t;
207 typedef float float32_t;
208 typedef double float64_t;
209 typedef bool bool32_t;
210 struct float16_vec {
211 float16_t x;
212 float16_t y;
213 float16_t z;
214 float16_t w;
215 };
216 struct float32_vec {
217 float32_t x;
218 float32_t y;
219 float32_t z;
220 float32_t w;
221 };
222 struct float64_vec {
223 float64_t x;
224 float64_t y;
225 float64_t z;
226 float64_t w;
227 };
228 struct int8_vec {
229 int8_t x;
230 int8_t y;
231 int8_t z;
232 int8_t w;
233 };
234 struct int16_vec {
235 int16_t x;
236 int16_t y;
237 int16_t z;
238 int16_t w;
239 };
240 struct int32_vec {
241 int32_t x;
242 int32_t y;
243 int32_t z;
244 int32_t w;
245 };
246 struct int64_vec {
247 int64_t x;
248 int64_t y;
249 int64_t z;
250 int64_t w;
251 };
252 struct uint8_vec {
253 uint8_t x;
254 uint8_t y;
255 uint8_t z;
256 uint8_t w;
257 };
258 struct uint16_vec {
259 uint16_t x;
260 uint16_t y;
261 uint16_t z;
262 uint16_t w;
263 };
264 struct uint32_vec {
265 uint32_t x;
266 uint32_t y;
267 uint32_t z;
268 uint32_t w;
269 };
270 struct uint64_vec {
271 uint64_t x;
272 uint64_t y;
273 uint64_t z;
274 uint64_t w;
275 };
276
277 struct bool32_vec {
278 bool x;
279 bool y;
280 bool z;
281 bool w;
282 };
283
284
285
286 static nir_const_value
evaluate_b2f(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)287 evaluate_b2f(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
288 MAYBE_UNUSED nir_const_value *_src)
289 {
290 nir_const_value _dst_val = { {0, } };
291
292 switch (bit_size) {
293 case 16: {
294
295
296
297
298 for (unsigned _i = 0; _i < num_components; _i++) {
299 const bool src0 = _src[0].u32[_i] != 0;
300
301 float16_t dst = src0 ? 1.0 : 0.0;
302
303 _dst_val.u16[_i] = _mesa_float_to_half(dst);
304 }
305
306 break;
307 }
308 case 32: {
309
310
311
312
313 for (unsigned _i = 0; _i < num_components; _i++) {
314 const bool src0 = _src[0].u32[_i] != 0;
315
316 float32_t dst = src0 ? 1.0 : 0.0;
317
318 _dst_val.f32[_i] = dst;
319 }
320
321 break;
322 }
323 case 64: {
324
325
326
327
328 for (unsigned _i = 0; _i < num_components; _i++) {
329 const bool src0 = _src[0].u32[_i] != 0;
330
331 float64_t dst = src0 ? 1.0 : 0.0;
332
333 _dst_val.f64[_i] = dst;
334 }
335
336 break;
337 }
338
339 default:
340 unreachable("unknown bit width");
341 }
342
343 return _dst_val;
344 }
345 static nir_const_value
evaluate_b2i(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)346 evaluate_b2i(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
347 MAYBE_UNUSED nir_const_value *_src)
348 {
349 nir_const_value _dst_val = { {0, } };
350
351 switch (bit_size) {
352 case 8: {
353
354
355
356
357 for (unsigned _i = 0; _i < num_components; _i++) {
358 const bool src0 = _src[0].u32[_i] != 0;
359
360 int8_t dst = src0 ? 1 : 0;
361
362 _dst_val.i8[_i] = dst;
363 }
364
365 break;
366 }
367 case 16: {
368
369
370
371
372 for (unsigned _i = 0; _i < num_components; _i++) {
373 const bool src0 = _src[0].u32[_i] != 0;
374
375 int16_t dst = src0 ? 1 : 0;
376
377 _dst_val.i16[_i] = dst;
378 }
379
380 break;
381 }
382 case 32: {
383
384
385
386
387 for (unsigned _i = 0; _i < num_components; _i++) {
388 const bool src0 = _src[0].u32[_i] != 0;
389
390 int32_t dst = src0 ? 1 : 0;
391
392 _dst_val.i32[_i] = dst;
393 }
394
395 break;
396 }
397 case 64: {
398
399
400
401
402 for (unsigned _i = 0; _i < num_components; _i++) {
403 const bool src0 = _src[0].u32[_i] != 0;
404
405 int64_t dst = src0 ? 1 : 0;
406
407 _dst_val.i64[_i] = dst;
408 }
409
410 break;
411 }
412
413 default:
414 unreachable("unknown bit width");
415 }
416
417 return _dst_val;
418 }
419 static nir_const_value
evaluate_ball_fequal2(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)420 evaluate_ball_fequal2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
421 MAYBE_UNUSED nir_const_value *_src)
422 {
423 nir_const_value _dst_val = { {0, } };
424
425 switch (bit_size) {
426 case 16: {
427
428
429
430
431 const struct float16_vec src0 = {
432 _mesa_half_to_float(_src[0].u16[0]),
433 _mesa_half_to_float(_src[0].u16[1]),
434 0,
435 0,
436 };
437
438 const struct float16_vec src1 = {
439 _mesa_half_to_float(_src[1].u16[0]),
440 _mesa_half_to_float(_src[1].u16[1]),
441 0,
442 0,
443 };
444
445 struct bool32_vec dst;
446
447 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y));
448
449 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
450
451 break;
452 }
453 case 32: {
454
455
456
457
458 const struct float32_vec src0 = {
459 _src[0].f32[0],
460 _src[0].f32[1],
461 0,
462 0,
463 };
464
465 const struct float32_vec src1 = {
466 _src[1].f32[0],
467 _src[1].f32[1],
468 0,
469 0,
470 };
471
472 struct bool32_vec dst;
473
474 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y));
475
476 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
477
478 break;
479 }
480 case 64: {
481
482
483
484
485 const struct float64_vec src0 = {
486 _src[0].f64[0],
487 _src[0].f64[1],
488 0,
489 0,
490 };
491
492 const struct float64_vec src1 = {
493 _src[1].f64[0],
494 _src[1].f64[1],
495 0,
496 0,
497 };
498
499 struct bool32_vec dst;
500
501 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y));
502
503 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
504
505 break;
506 }
507
508 default:
509 unreachable("unknown bit width");
510 }
511
512 return _dst_val;
513 }
514 static nir_const_value
evaluate_ball_fequal3(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)515 evaluate_ball_fequal3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
516 MAYBE_UNUSED nir_const_value *_src)
517 {
518 nir_const_value _dst_val = { {0, } };
519
520 switch (bit_size) {
521 case 16: {
522
523
524
525
526 const struct float16_vec src0 = {
527 _mesa_half_to_float(_src[0].u16[0]),
528 _mesa_half_to_float(_src[0].u16[1]),
529 _mesa_half_to_float(_src[0].u16[2]),
530 0,
531 };
532
533 const struct float16_vec src1 = {
534 _mesa_half_to_float(_src[1].u16[0]),
535 _mesa_half_to_float(_src[1].u16[1]),
536 _mesa_half_to_float(_src[1].u16[2]),
537 0,
538 };
539
540 struct bool32_vec dst;
541
542 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z));
543
544 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
545
546 break;
547 }
548 case 32: {
549
550
551
552
553 const struct float32_vec src0 = {
554 _src[0].f32[0],
555 _src[0].f32[1],
556 _src[0].f32[2],
557 0,
558 };
559
560 const struct float32_vec src1 = {
561 _src[1].f32[0],
562 _src[1].f32[1],
563 _src[1].f32[2],
564 0,
565 };
566
567 struct bool32_vec dst;
568
569 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z));
570
571 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
572
573 break;
574 }
575 case 64: {
576
577
578
579
580 const struct float64_vec src0 = {
581 _src[0].f64[0],
582 _src[0].f64[1],
583 _src[0].f64[2],
584 0,
585 };
586
587 const struct float64_vec src1 = {
588 _src[1].f64[0],
589 _src[1].f64[1],
590 _src[1].f64[2],
591 0,
592 };
593
594 struct bool32_vec dst;
595
596 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z));
597
598 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
599
600 break;
601 }
602
603 default:
604 unreachable("unknown bit width");
605 }
606
607 return _dst_val;
608 }
609 static nir_const_value
evaluate_ball_fequal4(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)610 evaluate_ball_fequal4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
611 MAYBE_UNUSED nir_const_value *_src)
612 {
613 nir_const_value _dst_val = { {0, } };
614
615 switch (bit_size) {
616 case 16: {
617
618
619
620
621 const struct float16_vec src0 = {
622 _mesa_half_to_float(_src[0].u16[0]),
623 _mesa_half_to_float(_src[0].u16[1]),
624 _mesa_half_to_float(_src[0].u16[2]),
625 _mesa_half_to_float(_src[0].u16[3]),
626 };
627
628 const struct float16_vec src1 = {
629 _mesa_half_to_float(_src[1].u16[0]),
630 _mesa_half_to_float(_src[1].u16[1]),
631 _mesa_half_to_float(_src[1].u16[2]),
632 _mesa_half_to_float(_src[1].u16[3]),
633 };
634
635 struct bool32_vec dst;
636
637 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z) && (src0.w == src1.w));
638
639 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
640
641 break;
642 }
643 case 32: {
644
645
646
647
648 const struct float32_vec src0 = {
649 _src[0].f32[0],
650 _src[0].f32[1],
651 _src[0].f32[2],
652 _src[0].f32[3],
653 };
654
655 const struct float32_vec src1 = {
656 _src[1].f32[0],
657 _src[1].f32[1],
658 _src[1].f32[2],
659 _src[1].f32[3],
660 };
661
662 struct bool32_vec dst;
663
664 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z) && (src0.w == src1.w));
665
666 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
667
668 break;
669 }
670 case 64: {
671
672
673
674
675 const struct float64_vec src0 = {
676 _src[0].f64[0],
677 _src[0].f64[1],
678 _src[0].f64[2],
679 _src[0].f64[3],
680 };
681
682 const struct float64_vec src1 = {
683 _src[1].f64[0],
684 _src[1].f64[1],
685 _src[1].f64[2],
686 _src[1].f64[3],
687 };
688
689 struct bool32_vec dst;
690
691 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z) && (src0.w == src1.w));
692
693 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
694
695 break;
696 }
697
698 default:
699 unreachable("unknown bit width");
700 }
701
702 return _dst_val;
703 }
704 static nir_const_value
evaluate_ball_iequal2(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)705 evaluate_ball_iequal2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
706 MAYBE_UNUSED nir_const_value *_src)
707 {
708 nir_const_value _dst_val = { {0, } };
709
710 switch (bit_size) {
711 case 8: {
712
713
714
715
716 const struct int8_vec src0 = {
717 _src[0].i8[0],
718 _src[0].i8[1],
719 0,
720 0,
721 };
722
723 const struct int8_vec src1 = {
724 _src[1].i8[0],
725 _src[1].i8[1],
726 0,
727 0,
728 };
729
730 struct bool32_vec dst;
731
732 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y));
733
734 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
735
736 break;
737 }
738 case 16: {
739
740
741
742
743 const struct int16_vec src0 = {
744 _src[0].i16[0],
745 _src[0].i16[1],
746 0,
747 0,
748 };
749
750 const struct int16_vec src1 = {
751 _src[1].i16[0],
752 _src[1].i16[1],
753 0,
754 0,
755 };
756
757 struct bool32_vec dst;
758
759 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y));
760
761 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
762
763 break;
764 }
765 case 32: {
766
767
768
769
770 const struct int32_vec src0 = {
771 _src[0].i32[0],
772 _src[0].i32[1],
773 0,
774 0,
775 };
776
777 const struct int32_vec src1 = {
778 _src[1].i32[0],
779 _src[1].i32[1],
780 0,
781 0,
782 };
783
784 struct bool32_vec dst;
785
786 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y));
787
788 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
789
790 break;
791 }
792 case 64: {
793
794
795
796
797 const struct int64_vec src0 = {
798 _src[0].i64[0],
799 _src[0].i64[1],
800 0,
801 0,
802 };
803
804 const struct int64_vec src1 = {
805 _src[1].i64[0],
806 _src[1].i64[1],
807 0,
808 0,
809 };
810
811 struct bool32_vec dst;
812
813 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y));
814
815 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
816
817 break;
818 }
819
820 default:
821 unreachable("unknown bit width");
822 }
823
824 return _dst_val;
825 }
826 static nir_const_value
evaluate_ball_iequal3(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)827 evaluate_ball_iequal3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
828 MAYBE_UNUSED nir_const_value *_src)
829 {
830 nir_const_value _dst_val = { {0, } };
831
832 switch (bit_size) {
833 case 8: {
834
835
836
837
838 const struct int8_vec src0 = {
839 _src[0].i8[0],
840 _src[0].i8[1],
841 _src[0].i8[2],
842 0,
843 };
844
845 const struct int8_vec src1 = {
846 _src[1].i8[0],
847 _src[1].i8[1],
848 _src[1].i8[2],
849 0,
850 };
851
852 struct bool32_vec dst;
853
854 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z));
855
856 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
857
858 break;
859 }
860 case 16: {
861
862
863
864
865 const struct int16_vec src0 = {
866 _src[0].i16[0],
867 _src[0].i16[1],
868 _src[0].i16[2],
869 0,
870 };
871
872 const struct int16_vec src1 = {
873 _src[1].i16[0],
874 _src[1].i16[1],
875 _src[1].i16[2],
876 0,
877 };
878
879 struct bool32_vec dst;
880
881 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z));
882
883 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
884
885 break;
886 }
887 case 32: {
888
889
890
891
892 const struct int32_vec src0 = {
893 _src[0].i32[0],
894 _src[0].i32[1],
895 _src[0].i32[2],
896 0,
897 };
898
899 const struct int32_vec src1 = {
900 _src[1].i32[0],
901 _src[1].i32[1],
902 _src[1].i32[2],
903 0,
904 };
905
906 struct bool32_vec dst;
907
908 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z));
909
910 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
911
912 break;
913 }
914 case 64: {
915
916
917
918
919 const struct int64_vec src0 = {
920 _src[0].i64[0],
921 _src[0].i64[1],
922 _src[0].i64[2],
923 0,
924 };
925
926 const struct int64_vec src1 = {
927 _src[1].i64[0],
928 _src[1].i64[1],
929 _src[1].i64[2],
930 0,
931 };
932
933 struct bool32_vec dst;
934
935 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z));
936
937 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
938
939 break;
940 }
941
942 default:
943 unreachable("unknown bit width");
944 }
945
946 return _dst_val;
947 }
948 static nir_const_value
evaluate_ball_iequal4(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)949 evaluate_ball_iequal4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
950 MAYBE_UNUSED nir_const_value *_src)
951 {
952 nir_const_value _dst_val = { {0, } };
953
954 switch (bit_size) {
955 case 8: {
956
957
958
959
960 const struct int8_vec src0 = {
961 _src[0].i8[0],
962 _src[0].i8[1],
963 _src[0].i8[2],
964 _src[0].i8[3],
965 };
966
967 const struct int8_vec src1 = {
968 _src[1].i8[0],
969 _src[1].i8[1],
970 _src[1].i8[2],
971 _src[1].i8[3],
972 };
973
974 struct bool32_vec dst;
975
976 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z) && (src0.w == src1.w));
977
978 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
979
980 break;
981 }
982 case 16: {
983
984
985
986
987 const struct int16_vec src0 = {
988 _src[0].i16[0],
989 _src[0].i16[1],
990 _src[0].i16[2],
991 _src[0].i16[3],
992 };
993
994 const struct int16_vec src1 = {
995 _src[1].i16[0],
996 _src[1].i16[1],
997 _src[1].i16[2],
998 _src[1].i16[3],
999 };
1000
1001 struct bool32_vec dst;
1002
1003 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z) && (src0.w == src1.w));
1004
1005 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1006
1007 break;
1008 }
1009 case 32: {
1010
1011
1012
1013
1014 const struct int32_vec src0 = {
1015 _src[0].i32[0],
1016 _src[0].i32[1],
1017 _src[0].i32[2],
1018 _src[0].i32[3],
1019 };
1020
1021 const struct int32_vec src1 = {
1022 _src[1].i32[0],
1023 _src[1].i32[1],
1024 _src[1].i32[2],
1025 _src[1].i32[3],
1026 };
1027
1028 struct bool32_vec dst;
1029
1030 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z) && (src0.w == src1.w));
1031
1032 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1033
1034 break;
1035 }
1036 case 64: {
1037
1038
1039
1040
1041 const struct int64_vec src0 = {
1042 _src[0].i64[0],
1043 _src[0].i64[1],
1044 _src[0].i64[2],
1045 _src[0].i64[3],
1046 };
1047
1048 const struct int64_vec src1 = {
1049 _src[1].i64[0],
1050 _src[1].i64[1],
1051 _src[1].i64[2],
1052 _src[1].i64[3],
1053 };
1054
1055 struct bool32_vec dst;
1056
1057 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z) && (src0.w == src1.w));
1058
1059 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1060
1061 break;
1062 }
1063
1064 default:
1065 unreachable("unknown bit width");
1066 }
1067
1068 return _dst_val;
1069 }
1070 static nir_const_value
evaluate_bany_fnequal2(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)1071 evaluate_bany_fnequal2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
1072 MAYBE_UNUSED nir_const_value *_src)
1073 {
1074 nir_const_value _dst_val = { {0, } };
1075
1076 switch (bit_size) {
1077 case 16: {
1078
1079
1080
1081
1082 const struct float16_vec src0 = {
1083 _mesa_half_to_float(_src[0].u16[0]),
1084 _mesa_half_to_float(_src[0].u16[1]),
1085 0,
1086 0,
1087 };
1088
1089 const struct float16_vec src1 = {
1090 _mesa_half_to_float(_src[1].u16[0]),
1091 _mesa_half_to_float(_src[1].u16[1]),
1092 0,
1093 0,
1094 };
1095
1096 struct bool32_vec dst;
1097
1098 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y));
1099
1100 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1101
1102 break;
1103 }
1104 case 32: {
1105
1106
1107
1108
1109 const struct float32_vec src0 = {
1110 _src[0].f32[0],
1111 _src[0].f32[1],
1112 0,
1113 0,
1114 };
1115
1116 const struct float32_vec src1 = {
1117 _src[1].f32[0],
1118 _src[1].f32[1],
1119 0,
1120 0,
1121 };
1122
1123 struct bool32_vec dst;
1124
1125 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y));
1126
1127 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1128
1129 break;
1130 }
1131 case 64: {
1132
1133
1134
1135
1136 const struct float64_vec src0 = {
1137 _src[0].f64[0],
1138 _src[0].f64[1],
1139 0,
1140 0,
1141 };
1142
1143 const struct float64_vec src1 = {
1144 _src[1].f64[0],
1145 _src[1].f64[1],
1146 0,
1147 0,
1148 };
1149
1150 struct bool32_vec dst;
1151
1152 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y));
1153
1154 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1155
1156 break;
1157 }
1158
1159 default:
1160 unreachable("unknown bit width");
1161 }
1162
1163 return _dst_val;
1164 }
1165 static nir_const_value
evaluate_bany_fnequal3(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)1166 evaluate_bany_fnequal3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
1167 MAYBE_UNUSED nir_const_value *_src)
1168 {
1169 nir_const_value _dst_val = { {0, } };
1170
1171 switch (bit_size) {
1172 case 16: {
1173
1174
1175
1176
1177 const struct float16_vec src0 = {
1178 _mesa_half_to_float(_src[0].u16[0]),
1179 _mesa_half_to_float(_src[0].u16[1]),
1180 _mesa_half_to_float(_src[0].u16[2]),
1181 0,
1182 };
1183
1184 const struct float16_vec src1 = {
1185 _mesa_half_to_float(_src[1].u16[0]),
1186 _mesa_half_to_float(_src[1].u16[1]),
1187 _mesa_half_to_float(_src[1].u16[2]),
1188 0,
1189 };
1190
1191 struct bool32_vec dst;
1192
1193 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z));
1194
1195 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1196
1197 break;
1198 }
1199 case 32: {
1200
1201
1202
1203
1204 const struct float32_vec src0 = {
1205 _src[0].f32[0],
1206 _src[0].f32[1],
1207 _src[0].f32[2],
1208 0,
1209 };
1210
1211 const struct float32_vec src1 = {
1212 _src[1].f32[0],
1213 _src[1].f32[1],
1214 _src[1].f32[2],
1215 0,
1216 };
1217
1218 struct bool32_vec dst;
1219
1220 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z));
1221
1222 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1223
1224 break;
1225 }
1226 case 64: {
1227
1228
1229
1230
1231 const struct float64_vec src0 = {
1232 _src[0].f64[0],
1233 _src[0].f64[1],
1234 _src[0].f64[2],
1235 0,
1236 };
1237
1238 const struct float64_vec src1 = {
1239 _src[1].f64[0],
1240 _src[1].f64[1],
1241 _src[1].f64[2],
1242 0,
1243 };
1244
1245 struct bool32_vec dst;
1246
1247 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z));
1248
1249 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1250
1251 break;
1252 }
1253
1254 default:
1255 unreachable("unknown bit width");
1256 }
1257
1258 return _dst_val;
1259 }
1260 static nir_const_value
evaluate_bany_fnequal4(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)1261 evaluate_bany_fnequal4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
1262 MAYBE_UNUSED nir_const_value *_src)
1263 {
1264 nir_const_value _dst_val = { {0, } };
1265
1266 switch (bit_size) {
1267 case 16: {
1268
1269
1270
1271
1272 const struct float16_vec src0 = {
1273 _mesa_half_to_float(_src[0].u16[0]),
1274 _mesa_half_to_float(_src[0].u16[1]),
1275 _mesa_half_to_float(_src[0].u16[2]),
1276 _mesa_half_to_float(_src[0].u16[3]),
1277 };
1278
1279 const struct float16_vec src1 = {
1280 _mesa_half_to_float(_src[1].u16[0]),
1281 _mesa_half_to_float(_src[1].u16[1]),
1282 _mesa_half_to_float(_src[1].u16[2]),
1283 _mesa_half_to_float(_src[1].u16[3]),
1284 };
1285
1286 struct bool32_vec dst;
1287
1288 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z) || (src0.w != src1.w));
1289
1290 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1291
1292 break;
1293 }
1294 case 32: {
1295
1296
1297
1298
1299 const struct float32_vec src0 = {
1300 _src[0].f32[0],
1301 _src[0].f32[1],
1302 _src[0].f32[2],
1303 _src[0].f32[3],
1304 };
1305
1306 const struct float32_vec src1 = {
1307 _src[1].f32[0],
1308 _src[1].f32[1],
1309 _src[1].f32[2],
1310 _src[1].f32[3],
1311 };
1312
1313 struct bool32_vec dst;
1314
1315 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z) || (src0.w != src1.w));
1316
1317 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1318
1319 break;
1320 }
1321 case 64: {
1322
1323
1324
1325
1326 const struct float64_vec src0 = {
1327 _src[0].f64[0],
1328 _src[0].f64[1],
1329 _src[0].f64[2],
1330 _src[0].f64[3],
1331 };
1332
1333 const struct float64_vec src1 = {
1334 _src[1].f64[0],
1335 _src[1].f64[1],
1336 _src[1].f64[2],
1337 _src[1].f64[3],
1338 };
1339
1340 struct bool32_vec dst;
1341
1342 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z) || (src0.w != src1.w));
1343
1344 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1345
1346 break;
1347 }
1348
1349 default:
1350 unreachable("unknown bit width");
1351 }
1352
1353 return _dst_val;
1354 }
1355 static nir_const_value
evaluate_bany_inequal2(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)1356 evaluate_bany_inequal2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
1357 MAYBE_UNUSED nir_const_value *_src)
1358 {
1359 nir_const_value _dst_val = { {0, } };
1360
1361 switch (bit_size) {
1362 case 8: {
1363
1364
1365
1366
1367 const struct int8_vec src0 = {
1368 _src[0].i8[0],
1369 _src[0].i8[1],
1370 0,
1371 0,
1372 };
1373
1374 const struct int8_vec src1 = {
1375 _src[1].i8[0],
1376 _src[1].i8[1],
1377 0,
1378 0,
1379 };
1380
1381 struct bool32_vec dst;
1382
1383 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y));
1384
1385 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1386
1387 break;
1388 }
1389 case 16: {
1390
1391
1392
1393
1394 const struct int16_vec src0 = {
1395 _src[0].i16[0],
1396 _src[0].i16[1],
1397 0,
1398 0,
1399 };
1400
1401 const struct int16_vec src1 = {
1402 _src[1].i16[0],
1403 _src[1].i16[1],
1404 0,
1405 0,
1406 };
1407
1408 struct bool32_vec dst;
1409
1410 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y));
1411
1412 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1413
1414 break;
1415 }
1416 case 32: {
1417
1418
1419
1420
1421 const struct int32_vec src0 = {
1422 _src[0].i32[0],
1423 _src[0].i32[1],
1424 0,
1425 0,
1426 };
1427
1428 const struct int32_vec src1 = {
1429 _src[1].i32[0],
1430 _src[1].i32[1],
1431 0,
1432 0,
1433 };
1434
1435 struct bool32_vec dst;
1436
1437 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y));
1438
1439 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1440
1441 break;
1442 }
1443 case 64: {
1444
1445
1446
1447
1448 const struct int64_vec src0 = {
1449 _src[0].i64[0],
1450 _src[0].i64[1],
1451 0,
1452 0,
1453 };
1454
1455 const struct int64_vec src1 = {
1456 _src[1].i64[0],
1457 _src[1].i64[1],
1458 0,
1459 0,
1460 };
1461
1462 struct bool32_vec dst;
1463
1464 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y));
1465
1466 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1467
1468 break;
1469 }
1470
1471 default:
1472 unreachable("unknown bit width");
1473 }
1474
1475 return _dst_val;
1476 }
1477 static nir_const_value
evaluate_bany_inequal3(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)1478 evaluate_bany_inequal3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
1479 MAYBE_UNUSED nir_const_value *_src)
1480 {
1481 nir_const_value _dst_val = { {0, } };
1482
1483 switch (bit_size) {
1484 case 8: {
1485
1486
1487
1488
1489 const struct int8_vec src0 = {
1490 _src[0].i8[0],
1491 _src[0].i8[1],
1492 _src[0].i8[2],
1493 0,
1494 };
1495
1496 const struct int8_vec src1 = {
1497 _src[1].i8[0],
1498 _src[1].i8[1],
1499 _src[1].i8[2],
1500 0,
1501 };
1502
1503 struct bool32_vec dst;
1504
1505 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z));
1506
1507 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1508
1509 break;
1510 }
1511 case 16: {
1512
1513
1514
1515
1516 const struct int16_vec src0 = {
1517 _src[0].i16[0],
1518 _src[0].i16[1],
1519 _src[0].i16[2],
1520 0,
1521 };
1522
1523 const struct int16_vec src1 = {
1524 _src[1].i16[0],
1525 _src[1].i16[1],
1526 _src[1].i16[2],
1527 0,
1528 };
1529
1530 struct bool32_vec dst;
1531
1532 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z));
1533
1534 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1535
1536 break;
1537 }
1538 case 32: {
1539
1540
1541
1542
1543 const struct int32_vec src0 = {
1544 _src[0].i32[0],
1545 _src[0].i32[1],
1546 _src[0].i32[2],
1547 0,
1548 };
1549
1550 const struct int32_vec src1 = {
1551 _src[1].i32[0],
1552 _src[1].i32[1],
1553 _src[1].i32[2],
1554 0,
1555 };
1556
1557 struct bool32_vec dst;
1558
1559 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z));
1560
1561 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1562
1563 break;
1564 }
1565 case 64: {
1566
1567
1568
1569
1570 const struct int64_vec src0 = {
1571 _src[0].i64[0],
1572 _src[0].i64[1],
1573 _src[0].i64[2],
1574 0,
1575 };
1576
1577 const struct int64_vec src1 = {
1578 _src[1].i64[0],
1579 _src[1].i64[1],
1580 _src[1].i64[2],
1581 0,
1582 };
1583
1584 struct bool32_vec dst;
1585
1586 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z));
1587
1588 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1589
1590 break;
1591 }
1592
1593 default:
1594 unreachable("unknown bit width");
1595 }
1596
1597 return _dst_val;
1598 }
1599 static nir_const_value
evaluate_bany_inequal4(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)1600 evaluate_bany_inequal4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
1601 MAYBE_UNUSED nir_const_value *_src)
1602 {
1603 nir_const_value _dst_val = { {0, } };
1604
1605 switch (bit_size) {
1606 case 8: {
1607
1608
1609
1610
1611 const struct int8_vec src0 = {
1612 _src[0].i8[0],
1613 _src[0].i8[1],
1614 _src[0].i8[2],
1615 _src[0].i8[3],
1616 };
1617
1618 const struct int8_vec src1 = {
1619 _src[1].i8[0],
1620 _src[1].i8[1],
1621 _src[1].i8[2],
1622 _src[1].i8[3],
1623 };
1624
1625 struct bool32_vec dst;
1626
1627 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z) || (src0.w != src1.w));
1628
1629 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1630
1631 break;
1632 }
1633 case 16: {
1634
1635
1636
1637
1638 const struct int16_vec src0 = {
1639 _src[0].i16[0],
1640 _src[0].i16[1],
1641 _src[0].i16[2],
1642 _src[0].i16[3],
1643 };
1644
1645 const struct int16_vec src1 = {
1646 _src[1].i16[0],
1647 _src[1].i16[1],
1648 _src[1].i16[2],
1649 _src[1].i16[3],
1650 };
1651
1652 struct bool32_vec dst;
1653
1654 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z) || (src0.w != src1.w));
1655
1656 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1657
1658 break;
1659 }
1660 case 32: {
1661
1662
1663
1664
1665 const struct int32_vec src0 = {
1666 _src[0].i32[0],
1667 _src[0].i32[1],
1668 _src[0].i32[2],
1669 _src[0].i32[3],
1670 };
1671
1672 const struct int32_vec src1 = {
1673 _src[1].i32[0],
1674 _src[1].i32[1],
1675 _src[1].i32[2],
1676 _src[1].i32[3],
1677 };
1678
1679 struct bool32_vec dst;
1680
1681 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z) || (src0.w != src1.w));
1682
1683 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1684
1685 break;
1686 }
1687 case 64: {
1688
1689
1690
1691
1692 const struct int64_vec src0 = {
1693 _src[0].i64[0],
1694 _src[0].i64[1],
1695 _src[0].i64[2],
1696 _src[0].i64[3],
1697 };
1698
1699 const struct int64_vec src1 = {
1700 _src[1].i64[0],
1701 _src[1].i64[1],
1702 _src[1].i64[2],
1703 _src[1].i64[3],
1704 };
1705
1706 struct bool32_vec dst;
1707
1708 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z) || (src0.w != src1.w));
1709
1710 _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
1711
1712 break;
1713 }
1714
1715 default:
1716 unreachable("unknown bit width");
1717 }
1718
1719 return _dst_val;
1720 }
1721 static nir_const_value
evaluate_bcsel(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)1722 evaluate_bcsel(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
1723 MAYBE_UNUSED nir_const_value *_src)
1724 {
1725 nir_const_value _dst_val = { {0, } };
1726
1727 switch (bit_size) {
1728 case 8: {
1729
1730
1731
1732
1733 for (unsigned _i = 0; _i < num_components; _i++) {
1734 const bool src0 = _src[0].u32[_i] != 0;
1735 const uint8_t src1 =
1736 _src[1].u8[_i];
1737 const uint8_t src2 =
1738 _src[2].u8[_i];
1739
1740 uint8_t dst = src0 ? src1 : src2;
1741
1742 _dst_val.u8[_i] = dst;
1743 }
1744
1745 break;
1746 }
1747 case 16: {
1748
1749
1750
1751
1752 for (unsigned _i = 0; _i < num_components; _i++) {
1753 const bool src0 = _src[0].u32[_i] != 0;
1754 const uint16_t src1 =
1755 _src[1].u16[_i];
1756 const uint16_t src2 =
1757 _src[2].u16[_i];
1758
1759 uint16_t dst = src0 ? src1 : src2;
1760
1761 _dst_val.u16[_i] = dst;
1762 }
1763
1764 break;
1765 }
1766 case 32: {
1767
1768
1769
1770
1771 for (unsigned _i = 0; _i < num_components; _i++) {
1772 const bool src0 = _src[0].u32[_i] != 0;
1773 const uint32_t src1 =
1774 _src[1].u32[_i];
1775 const uint32_t src2 =
1776 _src[2].u32[_i];
1777
1778 uint32_t dst = src0 ? src1 : src2;
1779
1780 _dst_val.u32[_i] = dst;
1781 }
1782
1783 break;
1784 }
1785 case 64: {
1786
1787
1788
1789
1790 for (unsigned _i = 0; _i < num_components; _i++) {
1791 const bool src0 = _src[0].u32[_i] != 0;
1792 const uint64_t src1 =
1793 _src[1].u64[_i];
1794 const uint64_t src2 =
1795 _src[2].u64[_i];
1796
1797 uint64_t dst = src0 ? src1 : src2;
1798
1799 _dst_val.u64[_i] = dst;
1800 }
1801
1802 break;
1803 }
1804
1805 default:
1806 unreachable("unknown bit width");
1807 }
1808
1809 return _dst_val;
1810 }
1811 static nir_const_value
evaluate_bfi(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)1812 evaluate_bfi(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
1813 MAYBE_UNUSED nir_const_value *_src)
1814 {
1815 nir_const_value _dst_val = { {0, } };
1816
1817
1818
1819
1820
1821 for (unsigned _i = 0; _i < num_components; _i++) {
1822 const uint32_t src0 =
1823 _src[0].u32[_i];
1824 const uint32_t src1 =
1825 _src[1].u32[_i];
1826 const uint32_t src2 =
1827 _src[2].u32[_i];
1828
1829 uint32_t dst;
1830
1831
1832 unsigned mask = src0, insert = src1, base = src2;
1833 if (mask == 0) {
1834 dst = base;
1835 } else {
1836 unsigned tmp = mask;
1837 while (!(tmp & 1)) {
1838 tmp >>= 1;
1839 insert <<= 1;
1840 }
1841 dst = (base & ~mask) | (insert & mask);
1842 }
1843
1844
1845 _dst_val.u32[_i] = dst;
1846 }
1847
1848
1849 return _dst_val;
1850 }
1851 static nir_const_value
evaluate_bfm(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)1852 evaluate_bfm(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
1853 MAYBE_UNUSED nir_const_value *_src)
1854 {
1855 nir_const_value _dst_val = { {0, } };
1856
1857
1858
1859
1860
1861 for (unsigned _i = 0; _i < num_components; _i++) {
1862 const int32_t src0 =
1863 _src[0].i32[_i];
1864 const int32_t src1 =
1865 _src[1].i32[_i];
1866
1867 uint32_t dst;
1868
1869
1870 int bits = src0, offset = src1;
1871 if (offset < 0 || bits < 0 || offset > 31 || bits > 31 || offset + bits > 32)
1872 dst = 0; /* undefined */
1873 else
1874 dst = ((1u << bits) - 1) << offset;
1875
1876
1877 _dst_val.u32[_i] = dst;
1878 }
1879
1880
1881 return _dst_val;
1882 }
1883 static nir_const_value
evaluate_bit_count(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)1884 evaluate_bit_count(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
1885 MAYBE_UNUSED nir_const_value *_src)
1886 {
1887 nir_const_value _dst_val = { {0, } };
1888
1889
1890
1891
1892
1893 for (unsigned _i = 0; _i < num_components; _i++) {
1894 const uint32_t src0 =
1895 _src[0].u32[_i];
1896
1897 uint32_t dst;
1898
1899
1900 dst = 0;
1901 for (unsigned bit = 0; bit < 32; bit++) {
1902 if ((src0 >> bit) & 1)
1903 dst++;
1904 }
1905
1906
1907 _dst_val.u32[_i] = dst;
1908 }
1909
1910
1911 return _dst_val;
1912 }
1913 static nir_const_value
evaluate_bitfield_insert(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)1914 evaluate_bitfield_insert(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
1915 MAYBE_UNUSED nir_const_value *_src)
1916 {
1917 nir_const_value _dst_val = { {0, } };
1918
1919
1920
1921
1922
1923 for (unsigned _i = 0; _i < num_components; _i++) {
1924 const uint32_t src0 =
1925 _src[0].u32[_i];
1926 const uint32_t src1 =
1927 _src[1].u32[_i];
1928 const int32_t src2 =
1929 _src[2].i32[_i];
1930 const int32_t src3 =
1931 _src[3].i32[_i];
1932
1933 uint32_t dst;
1934
1935
1936 unsigned base = src0, insert = src1;
1937 int offset = src2, bits = src3;
1938 if (bits == 0) {
1939 dst = base;
1940 } else if (offset < 0 || bits < 0 || bits + offset > 32) {
1941 dst = 0;
1942 } else {
1943 unsigned mask = ((1ull << bits) - 1) << offset;
1944 dst = (base & ~mask) | ((insert << offset) & mask);
1945 }
1946
1947
1948 _dst_val.u32[_i] = dst;
1949 }
1950
1951
1952 return _dst_val;
1953 }
1954 static nir_const_value
evaluate_bitfield_reverse(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)1955 evaluate_bitfield_reverse(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
1956 MAYBE_UNUSED nir_const_value *_src)
1957 {
1958 nir_const_value _dst_val = { {0, } };
1959
1960
1961
1962
1963
1964 for (unsigned _i = 0; _i < num_components; _i++) {
1965 const uint32_t src0 =
1966 _src[0].u32[_i];
1967
1968 uint32_t dst;
1969
1970
1971 /* we're not winning any awards for speed here, but that's ok */
1972 dst = 0;
1973 for (unsigned bit = 0; bit < 32; bit++)
1974 dst |= ((src0 >> bit) & 1) << (31 - bit);
1975
1976
1977 _dst_val.u32[_i] = dst;
1978 }
1979
1980
1981 return _dst_val;
1982 }
1983 static nir_const_value
evaluate_extract_i16(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)1984 evaluate_extract_i16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
1985 MAYBE_UNUSED nir_const_value *_src)
1986 {
1987 nir_const_value _dst_val = { {0, } };
1988
1989 switch (bit_size) {
1990 case 8: {
1991
1992
1993
1994
1995 for (unsigned _i = 0; _i < num_components; _i++) {
1996 const int8_t src0 =
1997 _src[0].i8[_i];
1998 const int8_t src1 =
1999 _src[1].i8[_i];
2000
2001 int8_t dst = (int16_t)(src0 >> (src1 * 16));
2002
2003 _dst_val.i8[_i] = dst;
2004 }
2005
2006 break;
2007 }
2008 case 16: {
2009
2010
2011
2012
2013 for (unsigned _i = 0; _i < num_components; _i++) {
2014 const int16_t src0 =
2015 _src[0].i16[_i];
2016 const int16_t src1 =
2017 _src[1].i16[_i];
2018
2019 int16_t dst = (int16_t)(src0 >> (src1 * 16));
2020
2021 _dst_val.i16[_i] = dst;
2022 }
2023
2024 break;
2025 }
2026 case 32: {
2027
2028
2029
2030
2031 for (unsigned _i = 0; _i < num_components; _i++) {
2032 const int32_t src0 =
2033 _src[0].i32[_i];
2034 const int32_t src1 =
2035 _src[1].i32[_i];
2036
2037 int32_t dst = (int16_t)(src0 >> (src1 * 16));
2038
2039 _dst_val.i32[_i] = dst;
2040 }
2041
2042 break;
2043 }
2044 case 64: {
2045
2046
2047
2048
2049 for (unsigned _i = 0; _i < num_components; _i++) {
2050 const int64_t src0 =
2051 _src[0].i64[_i];
2052 const int64_t src1 =
2053 _src[1].i64[_i];
2054
2055 int64_t dst = (int16_t)(src0 >> (src1 * 16));
2056
2057 _dst_val.i64[_i] = dst;
2058 }
2059
2060 break;
2061 }
2062
2063 default:
2064 unreachable("unknown bit width");
2065 }
2066
2067 return _dst_val;
2068 }
2069 static nir_const_value
evaluate_extract_i8(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)2070 evaluate_extract_i8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
2071 MAYBE_UNUSED nir_const_value *_src)
2072 {
2073 nir_const_value _dst_val = { {0, } };
2074
2075 switch (bit_size) {
2076 case 8: {
2077
2078
2079
2080
2081 for (unsigned _i = 0; _i < num_components; _i++) {
2082 const int8_t src0 =
2083 _src[0].i8[_i];
2084 const int8_t src1 =
2085 _src[1].i8[_i];
2086
2087 int8_t dst = (int8_t)(src0 >> (src1 * 8));
2088
2089 _dst_val.i8[_i] = dst;
2090 }
2091
2092 break;
2093 }
2094 case 16: {
2095
2096
2097
2098
2099 for (unsigned _i = 0; _i < num_components; _i++) {
2100 const int16_t src0 =
2101 _src[0].i16[_i];
2102 const int16_t src1 =
2103 _src[1].i16[_i];
2104
2105 int16_t dst = (int8_t)(src0 >> (src1 * 8));
2106
2107 _dst_val.i16[_i] = dst;
2108 }
2109
2110 break;
2111 }
2112 case 32: {
2113
2114
2115
2116
2117 for (unsigned _i = 0; _i < num_components; _i++) {
2118 const int32_t src0 =
2119 _src[0].i32[_i];
2120 const int32_t src1 =
2121 _src[1].i32[_i];
2122
2123 int32_t dst = (int8_t)(src0 >> (src1 * 8));
2124
2125 _dst_val.i32[_i] = dst;
2126 }
2127
2128 break;
2129 }
2130 case 64: {
2131
2132
2133
2134
2135 for (unsigned _i = 0; _i < num_components; _i++) {
2136 const int64_t src0 =
2137 _src[0].i64[_i];
2138 const int64_t src1 =
2139 _src[1].i64[_i];
2140
2141 int64_t dst = (int8_t)(src0 >> (src1 * 8));
2142
2143 _dst_val.i64[_i] = dst;
2144 }
2145
2146 break;
2147 }
2148
2149 default:
2150 unreachable("unknown bit width");
2151 }
2152
2153 return _dst_val;
2154 }
2155 static nir_const_value
evaluate_extract_u16(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)2156 evaluate_extract_u16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
2157 MAYBE_UNUSED nir_const_value *_src)
2158 {
2159 nir_const_value _dst_val = { {0, } };
2160
2161 switch (bit_size) {
2162 case 8: {
2163
2164
2165
2166
2167 for (unsigned _i = 0; _i < num_components; _i++) {
2168 const uint8_t src0 =
2169 _src[0].u8[_i];
2170 const uint8_t src1 =
2171 _src[1].u8[_i];
2172
2173 uint8_t dst = (uint16_t)(src0 >> (src1 * 16));
2174
2175 _dst_val.u8[_i] = dst;
2176 }
2177
2178 break;
2179 }
2180 case 16: {
2181
2182
2183
2184
2185 for (unsigned _i = 0; _i < num_components; _i++) {
2186 const uint16_t src0 =
2187 _src[0].u16[_i];
2188 const uint16_t src1 =
2189 _src[1].u16[_i];
2190
2191 uint16_t dst = (uint16_t)(src0 >> (src1 * 16));
2192
2193 _dst_val.u16[_i] = dst;
2194 }
2195
2196 break;
2197 }
2198 case 32: {
2199
2200
2201
2202
2203 for (unsigned _i = 0; _i < num_components; _i++) {
2204 const uint32_t src0 =
2205 _src[0].u32[_i];
2206 const uint32_t src1 =
2207 _src[1].u32[_i];
2208
2209 uint32_t dst = (uint16_t)(src0 >> (src1 * 16));
2210
2211 _dst_val.u32[_i] = dst;
2212 }
2213
2214 break;
2215 }
2216 case 64: {
2217
2218
2219
2220
2221 for (unsigned _i = 0; _i < num_components; _i++) {
2222 const uint64_t src0 =
2223 _src[0].u64[_i];
2224 const uint64_t src1 =
2225 _src[1].u64[_i];
2226
2227 uint64_t dst = (uint16_t)(src0 >> (src1 * 16));
2228
2229 _dst_val.u64[_i] = dst;
2230 }
2231
2232 break;
2233 }
2234
2235 default:
2236 unreachable("unknown bit width");
2237 }
2238
2239 return _dst_val;
2240 }
2241 static nir_const_value
evaluate_extract_u8(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)2242 evaluate_extract_u8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
2243 MAYBE_UNUSED nir_const_value *_src)
2244 {
2245 nir_const_value _dst_val = { {0, } };
2246
2247 switch (bit_size) {
2248 case 8: {
2249
2250
2251
2252
2253 for (unsigned _i = 0; _i < num_components; _i++) {
2254 const uint8_t src0 =
2255 _src[0].u8[_i];
2256 const uint8_t src1 =
2257 _src[1].u8[_i];
2258
2259 uint8_t dst = (uint8_t)(src0 >> (src1 * 8));
2260
2261 _dst_val.u8[_i] = dst;
2262 }
2263
2264 break;
2265 }
2266 case 16: {
2267
2268
2269
2270
2271 for (unsigned _i = 0; _i < num_components; _i++) {
2272 const uint16_t src0 =
2273 _src[0].u16[_i];
2274 const uint16_t src1 =
2275 _src[1].u16[_i];
2276
2277 uint16_t dst = (uint8_t)(src0 >> (src1 * 8));
2278
2279 _dst_val.u16[_i] = dst;
2280 }
2281
2282 break;
2283 }
2284 case 32: {
2285
2286
2287
2288
2289 for (unsigned _i = 0; _i < num_components; _i++) {
2290 const uint32_t src0 =
2291 _src[0].u32[_i];
2292 const uint32_t src1 =
2293 _src[1].u32[_i];
2294
2295 uint32_t dst = (uint8_t)(src0 >> (src1 * 8));
2296
2297 _dst_val.u32[_i] = dst;
2298 }
2299
2300 break;
2301 }
2302 case 64: {
2303
2304
2305
2306
2307 for (unsigned _i = 0; _i < num_components; _i++) {
2308 const uint64_t src0 =
2309 _src[0].u64[_i];
2310 const uint64_t src1 =
2311 _src[1].u64[_i];
2312
2313 uint64_t dst = (uint8_t)(src0 >> (src1 * 8));
2314
2315 _dst_val.u64[_i] = dst;
2316 }
2317
2318 break;
2319 }
2320
2321 default:
2322 unreachable("unknown bit width");
2323 }
2324
2325 return _dst_val;
2326 }
2327 static nir_const_value
evaluate_f2b(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)2328 evaluate_f2b(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
2329 MAYBE_UNUSED nir_const_value *_src)
2330 {
2331 nir_const_value _dst_val = { {0, } };
2332
2333 switch (bit_size) {
2334 case 16: {
2335
2336
2337
2338
2339 for (unsigned _i = 0; _i < num_components; _i++) {
2340 const float src0 =
2341 _mesa_half_to_float(_src[0].u16[_i]);
2342
2343 bool32_t dst = src0 != 0.0;
2344
2345 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
2346 }
2347
2348 break;
2349 }
2350 case 32: {
2351
2352
2353
2354
2355 for (unsigned _i = 0; _i < num_components; _i++) {
2356 const float32_t src0 =
2357 _src[0].f32[_i];
2358
2359 bool32_t dst = src0 != 0.0;
2360
2361 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
2362 }
2363
2364 break;
2365 }
2366 case 64: {
2367
2368
2369
2370
2371 for (unsigned _i = 0; _i < num_components; _i++) {
2372 const float64_t src0 =
2373 _src[0].f64[_i];
2374
2375 bool32_t dst = src0 != 0.0;
2376
2377 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
2378 }
2379
2380 break;
2381 }
2382
2383 default:
2384 unreachable("unknown bit width");
2385 }
2386
2387 return _dst_val;
2388 }
2389 static nir_const_value
evaluate_f2f16_rtne(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)2390 evaluate_f2f16_rtne(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
2391 MAYBE_UNUSED nir_const_value *_src)
2392 {
2393 nir_const_value _dst_val = { {0, } };
2394
2395 switch (bit_size) {
2396 case 16: {
2397
2398
2399
2400
2401 for (unsigned _i = 0; _i < num_components; _i++) {
2402 const float src0 =
2403 _mesa_half_to_float(_src[0].u16[_i]);
2404
2405 float16_t dst = src0;
2406
2407 _dst_val.u16[_i] = _mesa_float_to_half(dst);
2408 }
2409
2410 break;
2411 }
2412 case 32: {
2413
2414
2415
2416
2417 for (unsigned _i = 0; _i < num_components; _i++) {
2418 const float32_t src0 =
2419 _src[0].f32[_i];
2420
2421 float16_t dst = src0;
2422
2423 _dst_val.u16[_i] = _mesa_float_to_half(dst);
2424 }
2425
2426 break;
2427 }
2428 case 64: {
2429
2430
2431
2432
2433 for (unsigned _i = 0; _i < num_components; _i++) {
2434 const float64_t src0 =
2435 _src[0].f64[_i];
2436
2437 float16_t dst = src0;
2438
2439 _dst_val.u16[_i] = _mesa_float_to_half(dst);
2440 }
2441
2442 break;
2443 }
2444
2445 default:
2446 unreachable("unknown bit width");
2447 }
2448
2449 return _dst_val;
2450 }
2451 static nir_const_value
evaluate_f2f16_rtz(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)2452 evaluate_f2f16_rtz(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
2453 MAYBE_UNUSED nir_const_value *_src)
2454 {
2455 nir_const_value _dst_val = { {0, } };
2456
2457 switch (bit_size) {
2458 case 16: {
2459
2460
2461
2462
2463 for (unsigned _i = 0; _i < num_components; _i++) {
2464 const float src0 =
2465 _mesa_half_to_float(_src[0].u16[_i]);
2466
2467 float16_t dst = src0;
2468
2469 _dst_val.u16[_i] = _mesa_float_to_half(dst);
2470 }
2471
2472 break;
2473 }
2474 case 32: {
2475
2476
2477
2478
2479 for (unsigned _i = 0; _i < num_components; _i++) {
2480 const float32_t src0 =
2481 _src[0].f32[_i];
2482
2483 float16_t dst = src0;
2484
2485 _dst_val.u16[_i] = _mesa_float_to_half(dst);
2486 }
2487
2488 break;
2489 }
2490 case 64: {
2491
2492
2493
2494
2495 for (unsigned _i = 0; _i < num_components; _i++) {
2496 const float64_t src0 =
2497 _src[0].f64[_i];
2498
2499 float16_t dst = src0;
2500
2501 _dst_val.u16[_i] = _mesa_float_to_half(dst);
2502 }
2503
2504 break;
2505 }
2506
2507 default:
2508 unreachable("unknown bit width");
2509 }
2510
2511 return _dst_val;
2512 }
2513 static nir_const_value
evaluate_f2f16_undef(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)2514 evaluate_f2f16_undef(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
2515 MAYBE_UNUSED nir_const_value *_src)
2516 {
2517 nir_const_value _dst_val = { {0, } };
2518
2519 switch (bit_size) {
2520 case 16: {
2521
2522
2523
2524
2525 for (unsigned _i = 0; _i < num_components; _i++) {
2526 const float src0 =
2527 _mesa_half_to_float(_src[0].u16[_i]);
2528
2529 float16_t dst = src0;
2530
2531 _dst_val.u16[_i] = _mesa_float_to_half(dst);
2532 }
2533
2534 break;
2535 }
2536 case 32: {
2537
2538
2539
2540
2541 for (unsigned _i = 0; _i < num_components; _i++) {
2542 const float32_t src0 =
2543 _src[0].f32[_i];
2544
2545 float16_t dst = src0;
2546
2547 _dst_val.u16[_i] = _mesa_float_to_half(dst);
2548 }
2549
2550 break;
2551 }
2552 case 64: {
2553
2554
2555
2556
2557 for (unsigned _i = 0; _i < num_components; _i++) {
2558 const float64_t src0 =
2559 _src[0].f64[_i];
2560
2561 float16_t dst = src0;
2562
2563 _dst_val.u16[_i] = _mesa_float_to_half(dst);
2564 }
2565
2566 break;
2567 }
2568
2569 default:
2570 unreachable("unknown bit width");
2571 }
2572
2573 return _dst_val;
2574 }
2575 static nir_const_value
evaluate_f2f32(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)2576 evaluate_f2f32(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
2577 MAYBE_UNUSED nir_const_value *_src)
2578 {
2579 nir_const_value _dst_val = { {0, } };
2580
2581 switch (bit_size) {
2582 case 16: {
2583
2584
2585
2586
2587 for (unsigned _i = 0; _i < num_components; _i++) {
2588 const float src0 =
2589 _mesa_half_to_float(_src[0].u16[_i]);
2590
2591 float32_t dst = src0;
2592
2593 _dst_val.f32[_i] = dst;
2594 }
2595
2596 break;
2597 }
2598 case 32: {
2599
2600
2601
2602
2603 for (unsigned _i = 0; _i < num_components; _i++) {
2604 const float32_t src0 =
2605 _src[0].f32[_i];
2606
2607 float32_t dst = src0;
2608
2609 _dst_val.f32[_i] = dst;
2610 }
2611
2612 break;
2613 }
2614 case 64: {
2615
2616
2617
2618
2619 for (unsigned _i = 0; _i < num_components; _i++) {
2620 const float64_t src0 =
2621 _src[0].f64[_i];
2622
2623 float32_t dst = src0;
2624
2625 _dst_val.f32[_i] = dst;
2626 }
2627
2628 break;
2629 }
2630
2631 default:
2632 unreachable("unknown bit width");
2633 }
2634
2635 return _dst_val;
2636 }
2637 static nir_const_value
evaluate_f2f64(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)2638 evaluate_f2f64(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
2639 MAYBE_UNUSED nir_const_value *_src)
2640 {
2641 nir_const_value _dst_val = { {0, } };
2642
2643 switch (bit_size) {
2644 case 16: {
2645
2646
2647
2648
2649 for (unsigned _i = 0; _i < num_components; _i++) {
2650 const float src0 =
2651 _mesa_half_to_float(_src[0].u16[_i]);
2652
2653 float64_t dst = src0;
2654
2655 _dst_val.f64[_i] = dst;
2656 }
2657
2658 break;
2659 }
2660 case 32: {
2661
2662
2663
2664
2665 for (unsigned _i = 0; _i < num_components; _i++) {
2666 const float32_t src0 =
2667 _src[0].f32[_i];
2668
2669 float64_t dst = src0;
2670
2671 _dst_val.f64[_i] = dst;
2672 }
2673
2674 break;
2675 }
2676 case 64: {
2677
2678
2679
2680
2681 for (unsigned _i = 0; _i < num_components; _i++) {
2682 const float64_t src0 =
2683 _src[0].f64[_i];
2684
2685 float64_t dst = src0;
2686
2687 _dst_val.f64[_i] = dst;
2688 }
2689
2690 break;
2691 }
2692
2693 default:
2694 unreachable("unknown bit width");
2695 }
2696
2697 return _dst_val;
2698 }
2699 static nir_const_value
evaluate_f2i16(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)2700 evaluate_f2i16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
2701 MAYBE_UNUSED nir_const_value *_src)
2702 {
2703 nir_const_value _dst_val = { {0, } };
2704
2705 switch (bit_size) {
2706 case 16: {
2707
2708
2709
2710
2711 for (unsigned _i = 0; _i < num_components; _i++) {
2712 const float src0 =
2713 _mesa_half_to_float(_src[0].u16[_i]);
2714
2715 int16_t dst = src0;
2716
2717 _dst_val.i16[_i] = dst;
2718 }
2719
2720 break;
2721 }
2722 case 32: {
2723
2724
2725
2726
2727 for (unsigned _i = 0; _i < num_components; _i++) {
2728 const float32_t src0 =
2729 _src[0].f32[_i];
2730
2731 int16_t dst = src0;
2732
2733 _dst_val.i16[_i] = dst;
2734 }
2735
2736 break;
2737 }
2738 case 64: {
2739
2740
2741
2742
2743 for (unsigned _i = 0; _i < num_components; _i++) {
2744 const float64_t src0 =
2745 _src[0].f64[_i];
2746
2747 int16_t dst = src0;
2748
2749 _dst_val.i16[_i] = dst;
2750 }
2751
2752 break;
2753 }
2754
2755 default:
2756 unreachable("unknown bit width");
2757 }
2758
2759 return _dst_val;
2760 }
2761 static nir_const_value
evaluate_f2i32(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)2762 evaluate_f2i32(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
2763 MAYBE_UNUSED nir_const_value *_src)
2764 {
2765 nir_const_value _dst_val = { {0, } };
2766
2767 switch (bit_size) {
2768 case 16: {
2769
2770
2771
2772
2773 for (unsigned _i = 0; _i < num_components; _i++) {
2774 const float src0 =
2775 _mesa_half_to_float(_src[0].u16[_i]);
2776
2777 int32_t dst = src0;
2778
2779 _dst_val.i32[_i] = dst;
2780 }
2781
2782 break;
2783 }
2784 case 32: {
2785
2786
2787
2788
2789 for (unsigned _i = 0; _i < num_components; _i++) {
2790 const float32_t src0 =
2791 _src[0].f32[_i];
2792
2793 int32_t dst = src0;
2794
2795 _dst_val.i32[_i] = dst;
2796 }
2797
2798 break;
2799 }
2800 case 64: {
2801
2802
2803
2804
2805 for (unsigned _i = 0; _i < num_components; _i++) {
2806 const float64_t src0 =
2807 _src[0].f64[_i];
2808
2809 int32_t dst = src0;
2810
2811 _dst_val.i32[_i] = dst;
2812 }
2813
2814 break;
2815 }
2816
2817 default:
2818 unreachable("unknown bit width");
2819 }
2820
2821 return _dst_val;
2822 }
2823 static nir_const_value
evaluate_f2i64(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)2824 evaluate_f2i64(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
2825 MAYBE_UNUSED nir_const_value *_src)
2826 {
2827 nir_const_value _dst_val = { {0, } };
2828
2829 switch (bit_size) {
2830 case 16: {
2831
2832
2833
2834
2835 for (unsigned _i = 0; _i < num_components; _i++) {
2836 const float src0 =
2837 _mesa_half_to_float(_src[0].u16[_i]);
2838
2839 int64_t dst = src0;
2840
2841 _dst_val.i64[_i] = dst;
2842 }
2843
2844 break;
2845 }
2846 case 32: {
2847
2848
2849
2850
2851 for (unsigned _i = 0; _i < num_components; _i++) {
2852 const float32_t src0 =
2853 _src[0].f32[_i];
2854
2855 int64_t dst = src0;
2856
2857 _dst_val.i64[_i] = dst;
2858 }
2859
2860 break;
2861 }
2862 case 64: {
2863
2864
2865
2866
2867 for (unsigned _i = 0; _i < num_components; _i++) {
2868 const float64_t src0 =
2869 _src[0].f64[_i];
2870
2871 int64_t dst = src0;
2872
2873 _dst_val.i64[_i] = dst;
2874 }
2875
2876 break;
2877 }
2878
2879 default:
2880 unreachable("unknown bit width");
2881 }
2882
2883 return _dst_val;
2884 }
2885 static nir_const_value
evaluate_f2i8(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)2886 evaluate_f2i8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
2887 MAYBE_UNUSED nir_const_value *_src)
2888 {
2889 nir_const_value _dst_val = { {0, } };
2890
2891 switch (bit_size) {
2892 case 16: {
2893
2894
2895
2896
2897 for (unsigned _i = 0; _i < num_components; _i++) {
2898 const float src0 =
2899 _mesa_half_to_float(_src[0].u16[_i]);
2900
2901 int8_t dst = src0;
2902
2903 _dst_val.i8[_i] = dst;
2904 }
2905
2906 break;
2907 }
2908 case 32: {
2909
2910
2911
2912
2913 for (unsigned _i = 0; _i < num_components; _i++) {
2914 const float32_t src0 =
2915 _src[0].f32[_i];
2916
2917 int8_t dst = src0;
2918
2919 _dst_val.i8[_i] = dst;
2920 }
2921
2922 break;
2923 }
2924 case 64: {
2925
2926
2927
2928
2929 for (unsigned _i = 0; _i < num_components; _i++) {
2930 const float64_t src0 =
2931 _src[0].f64[_i];
2932
2933 int8_t dst = src0;
2934
2935 _dst_val.i8[_i] = dst;
2936 }
2937
2938 break;
2939 }
2940
2941 default:
2942 unreachable("unknown bit width");
2943 }
2944
2945 return _dst_val;
2946 }
2947 static nir_const_value
evaluate_f2u16(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)2948 evaluate_f2u16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
2949 MAYBE_UNUSED nir_const_value *_src)
2950 {
2951 nir_const_value _dst_val = { {0, } };
2952
2953 switch (bit_size) {
2954 case 16: {
2955
2956
2957
2958
2959 for (unsigned _i = 0; _i < num_components; _i++) {
2960 const float src0 =
2961 _mesa_half_to_float(_src[0].u16[_i]);
2962
2963 uint16_t dst = src0;
2964
2965 _dst_val.u16[_i] = dst;
2966 }
2967
2968 break;
2969 }
2970 case 32: {
2971
2972
2973
2974
2975 for (unsigned _i = 0; _i < num_components; _i++) {
2976 const float32_t src0 =
2977 _src[0].f32[_i];
2978
2979 uint16_t dst = src0;
2980
2981 _dst_val.u16[_i] = dst;
2982 }
2983
2984 break;
2985 }
2986 case 64: {
2987
2988
2989
2990
2991 for (unsigned _i = 0; _i < num_components; _i++) {
2992 const float64_t src0 =
2993 _src[0].f64[_i];
2994
2995 uint16_t dst = src0;
2996
2997 _dst_val.u16[_i] = dst;
2998 }
2999
3000 break;
3001 }
3002
3003 default:
3004 unreachable("unknown bit width");
3005 }
3006
3007 return _dst_val;
3008 }
3009 static nir_const_value
evaluate_f2u32(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3010 evaluate_f2u32(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3011 MAYBE_UNUSED nir_const_value *_src)
3012 {
3013 nir_const_value _dst_val = { {0, } };
3014
3015 switch (bit_size) {
3016 case 16: {
3017
3018
3019
3020
3021 for (unsigned _i = 0; _i < num_components; _i++) {
3022 const float src0 =
3023 _mesa_half_to_float(_src[0].u16[_i]);
3024
3025 uint32_t dst = src0;
3026
3027 _dst_val.u32[_i] = dst;
3028 }
3029
3030 break;
3031 }
3032 case 32: {
3033
3034
3035
3036
3037 for (unsigned _i = 0; _i < num_components; _i++) {
3038 const float32_t src0 =
3039 _src[0].f32[_i];
3040
3041 uint32_t dst = src0;
3042
3043 _dst_val.u32[_i] = dst;
3044 }
3045
3046 break;
3047 }
3048 case 64: {
3049
3050
3051
3052
3053 for (unsigned _i = 0; _i < num_components; _i++) {
3054 const float64_t src0 =
3055 _src[0].f64[_i];
3056
3057 uint32_t dst = src0;
3058
3059 _dst_val.u32[_i] = dst;
3060 }
3061
3062 break;
3063 }
3064
3065 default:
3066 unreachable("unknown bit width");
3067 }
3068
3069 return _dst_val;
3070 }
3071 static nir_const_value
evaluate_f2u64(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3072 evaluate_f2u64(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3073 MAYBE_UNUSED nir_const_value *_src)
3074 {
3075 nir_const_value _dst_val = { {0, } };
3076
3077 switch (bit_size) {
3078 case 16: {
3079
3080
3081
3082
3083 for (unsigned _i = 0; _i < num_components; _i++) {
3084 const float src0 =
3085 _mesa_half_to_float(_src[0].u16[_i]);
3086
3087 uint64_t dst = src0;
3088
3089 _dst_val.u64[_i] = dst;
3090 }
3091
3092 break;
3093 }
3094 case 32: {
3095
3096
3097
3098
3099 for (unsigned _i = 0; _i < num_components; _i++) {
3100 const float32_t src0 =
3101 _src[0].f32[_i];
3102
3103 uint64_t dst = src0;
3104
3105 _dst_val.u64[_i] = dst;
3106 }
3107
3108 break;
3109 }
3110 case 64: {
3111
3112
3113
3114
3115 for (unsigned _i = 0; _i < num_components; _i++) {
3116 const float64_t src0 =
3117 _src[0].f64[_i];
3118
3119 uint64_t dst = src0;
3120
3121 _dst_val.u64[_i] = dst;
3122 }
3123
3124 break;
3125 }
3126
3127 default:
3128 unreachable("unknown bit width");
3129 }
3130
3131 return _dst_val;
3132 }
3133 static nir_const_value
evaluate_f2u8(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3134 evaluate_f2u8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3135 MAYBE_UNUSED nir_const_value *_src)
3136 {
3137 nir_const_value _dst_val = { {0, } };
3138
3139 switch (bit_size) {
3140 case 16: {
3141
3142
3143
3144
3145 for (unsigned _i = 0; _i < num_components; _i++) {
3146 const float src0 =
3147 _mesa_half_to_float(_src[0].u16[_i]);
3148
3149 uint8_t dst = src0;
3150
3151 _dst_val.u8[_i] = dst;
3152 }
3153
3154 break;
3155 }
3156 case 32: {
3157
3158
3159
3160
3161 for (unsigned _i = 0; _i < num_components; _i++) {
3162 const float32_t src0 =
3163 _src[0].f32[_i];
3164
3165 uint8_t dst = src0;
3166
3167 _dst_val.u8[_i] = dst;
3168 }
3169
3170 break;
3171 }
3172 case 64: {
3173
3174
3175
3176
3177 for (unsigned _i = 0; _i < num_components; _i++) {
3178 const float64_t src0 =
3179 _src[0].f64[_i];
3180
3181 uint8_t dst = src0;
3182
3183 _dst_val.u8[_i] = dst;
3184 }
3185
3186 break;
3187 }
3188
3189 default:
3190 unreachable("unknown bit width");
3191 }
3192
3193 return _dst_val;
3194 }
3195 static nir_const_value
evaluate_fabs(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3196 evaluate_fabs(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3197 MAYBE_UNUSED nir_const_value *_src)
3198 {
3199 nir_const_value _dst_val = { {0, } };
3200
3201 switch (bit_size) {
3202 case 16: {
3203
3204
3205
3206
3207 for (unsigned _i = 0; _i < num_components; _i++) {
3208 const float src0 =
3209 _mesa_half_to_float(_src[0].u16[_i]);
3210
3211 float16_t dst = fabs(src0);
3212
3213 _dst_val.u16[_i] = _mesa_float_to_half(dst);
3214 }
3215
3216 break;
3217 }
3218 case 32: {
3219
3220
3221
3222
3223 for (unsigned _i = 0; _i < num_components; _i++) {
3224 const float32_t src0 =
3225 _src[0].f32[_i];
3226
3227 float32_t dst = fabs(src0);
3228
3229 _dst_val.f32[_i] = dst;
3230 }
3231
3232 break;
3233 }
3234 case 64: {
3235
3236
3237
3238
3239 for (unsigned _i = 0; _i < num_components; _i++) {
3240 const float64_t src0 =
3241 _src[0].f64[_i];
3242
3243 float64_t dst = fabs(src0);
3244
3245 _dst_val.f64[_i] = dst;
3246 }
3247
3248 break;
3249 }
3250
3251 default:
3252 unreachable("unknown bit width");
3253 }
3254
3255 return _dst_val;
3256 }
3257 static nir_const_value
evaluate_fadd(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3258 evaluate_fadd(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3259 MAYBE_UNUSED nir_const_value *_src)
3260 {
3261 nir_const_value _dst_val = { {0, } };
3262
3263 switch (bit_size) {
3264 case 16: {
3265
3266
3267
3268
3269 for (unsigned _i = 0; _i < num_components; _i++) {
3270 const float src0 =
3271 _mesa_half_to_float(_src[0].u16[_i]);
3272 const float src1 =
3273 _mesa_half_to_float(_src[1].u16[_i]);
3274
3275 float16_t dst = src0 + src1;
3276
3277 _dst_val.u16[_i] = _mesa_float_to_half(dst);
3278 }
3279
3280 break;
3281 }
3282 case 32: {
3283
3284
3285
3286
3287 for (unsigned _i = 0; _i < num_components; _i++) {
3288 const float32_t src0 =
3289 _src[0].f32[_i];
3290 const float32_t src1 =
3291 _src[1].f32[_i];
3292
3293 float32_t dst = src0 + src1;
3294
3295 _dst_val.f32[_i] = dst;
3296 }
3297
3298 break;
3299 }
3300 case 64: {
3301
3302
3303
3304
3305 for (unsigned _i = 0; _i < num_components; _i++) {
3306 const float64_t src0 =
3307 _src[0].f64[_i];
3308 const float64_t src1 =
3309 _src[1].f64[_i];
3310
3311 float64_t dst = src0 + src1;
3312
3313 _dst_val.f64[_i] = dst;
3314 }
3315
3316 break;
3317 }
3318
3319 default:
3320 unreachable("unknown bit width");
3321 }
3322
3323 return _dst_val;
3324 }
3325 static nir_const_value
evaluate_fall_equal2(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3326 evaluate_fall_equal2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3327 MAYBE_UNUSED nir_const_value *_src)
3328 {
3329 nir_const_value _dst_val = { {0, } };
3330
3331
3332
3333
3334
3335 const struct float32_vec src0 = {
3336 _src[0].f32[0],
3337 _src[0].f32[1],
3338 0,
3339 0,
3340 };
3341
3342 const struct float32_vec src1 = {
3343 _src[1].f32[0],
3344 _src[1].f32[1],
3345 0,
3346 0,
3347 };
3348
3349 struct float32_vec dst;
3350
3351 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y)) ? 1.0f : 0.0f;
3352
3353 _dst_val.f32[0] = dst.x;
3354
3355
3356 return _dst_val;
3357 }
3358 static nir_const_value
evaluate_fall_equal3(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3359 evaluate_fall_equal3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3360 MAYBE_UNUSED nir_const_value *_src)
3361 {
3362 nir_const_value _dst_val = { {0, } };
3363
3364
3365
3366
3367
3368 const struct float32_vec src0 = {
3369 _src[0].f32[0],
3370 _src[0].f32[1],
3371 _src[0].f32[2],
3372 0,
3373 };
3374
3375 const struct float32_vec src1 = {
3376 _src[1].f32[0],
3377 _src[1].f32[1],
3378 _src[1].f32[2],
3379 0,
3380 };
3381
3382 struct float32_vec dst;
3383
3384 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z)) ? 1.0f : 0.0f;
3385
3386 _dst_val.f32[0] = dst.x;
3387
3388
3389 return _dst_val;
3390 }
3391 static nir_const_value
evaluate_fall_equal4(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3392 evaluate_fall_equal4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3393 MAYBE_UNUSED nir_const_value *_src)
3394 {
3395 nir_const_value _dst_val = { {0, } };
3396
3397
3398
3399
3400
3401 const struct float32_vec src0 = {
3402 _src[0].f32[0],
3403 _src[0].f32[1],
3404 _src[0].f32[2],
3405 _src[0].f32[3],
3406 };
3407
3408 const struct float32_vec src1 = {
3409 _src[1].f32[0],
3410 _src[1].f32[1],
3411 _src[1].f32[2],
3412 _src[1].f32[3],
3413 };
3414
3415 struct float32_vec dst;
3416
3417 dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z) && (src0.w == src1.w)) ? 1.0f : 0.0f;
3418
3419 _dst_val.f32[0] = dst.x;
3420
3421
3422 return _dst_val;
3423 }
3424 static nir_const_value
evaluate_fand(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3425 evaluate_fand(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3426 MAYBE_UNUSED nir_const_value *_src)
3427 {
3428 nir_const_value _dst_val = { {0, } };
3429
3430
3431
3432
3433
3434 for (unsigned _i = 0; _i < num_components; _i++) {
3435 const float32_t src0 =
3436 _src[0].f32[_i];
3437 const float32_t src1 =
3438 _src[1].f32[_i];
3439
3440 float32_t dst = ((src0 != 0.0f) && (src1 != 0.0f)) ? 1.0f : 0.0f;
3441
3442 _dst_val.f32[_i] = dst;
3443 }
3444
3445
3446 return _dst_val;
3447 }
3448 static nir_const_value
evaluate_fany_nequal2(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3449 evaluate_fany_nequal2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3450 MAYBE_UNUSED nir_const_value *_src)
3451 {
3452 nir_const_value _dst_val = { {0, } };
3453
3454
3455
3456
3457
3458 const struct float32_vec src0 = {
3459 _src[0].f32[0],
3460 _src[0].f32[1],
3461 0,
3462 0,
3463 };
3464
3465 const struct float32_vec src1 = {
3466 _src[1].f32[0],
3467 _src[1].f32[1],
3468 0,
3469 0,
3470 };
3471
3472 struct float32_vec dst;
3473
3474 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y)) ? 1.0f : 0.0f;
3475
3476 _dst_val.f32[0] = dst.x;
3477
3478
3479 return _dst_val;
3480 }
3481 static nir_const_value
evaluate_fany_nequal3(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3482 evaluate_fany_nequal3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3483 MAYBE_UNUSED nir_const_value *_src)
3484 {
3485 nir_const_value _dst_val = { {0, } };
3486
3487
3488
3489
3490
3491 const struct float32_vec src0 = {
3492 _src[0].f32[0],
3493 _src[0].f32[1],
3494 _src[0].f32[2],
3495 0,
3496 };
3497
3498 const struct float32_vec src1 = {
3499 _src[1].f32[0],
3500 _src[1].f32[1],
3501 _src[1].f32[2],
3502 0,
3503 };
3504
3505 struct float32_vec dst;
3506
3507 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z)) ? 1.0f : 0.0f;
3508
3509 _dst_val.f32[0] = dst.x;
3510
3511
3512 return _dst_val;
3513 }
3514 static nir_const_value
evaluate_fany_nequal4(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3515 evaluate_fany_nequal4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3516 MAYBE_UNUSED nir_const_value *_src)
3517 {
3518 nir_const_value _dst_val = { {0, } };
3519
3520
3521
3522
3523
3524 const struct float32_vec src0 = {
3525 _src[0].f32[0],
3526 _src[0].f32[1],
3527 _src[0].f32[2],
3528 _src[0].f32[3],
3529 };
3530
3531 const struct float32_vec src1 = {
3532 _src[1].f32[0],
3533 _src[1].f32[1],
3534 _src[1].f32[2],
3535 _src[1].f32[3],
3536 };
3537
3538 struct float32_vec dst;
3539
3540 dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z) || (src0.w != src1.w)) ? 1.0f : 0.0f;
3541
3542 _dst_val.f32[0] = dst.x;
3543
3544
3545 return _dst_val;
3546 }
3547 static nir_const_value
evaluate_fceil(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3548 evaluate_fceil(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3549 MAYBE_UNUSED nir_const_value *_src)
3550 {
3551 nir_const_value _dst_val = { {0, } };
3552
3553 switch (bit_size) {
3554 case 16: {
3555
3556
3557
3558
3559 for (unsigned _i = 0; _i < num_components; _i++) {
3560 const float src0 =
3561 _mesa_half_to_float(_src[0].u16[_i]);
3562
3563 float16_t dst = bit_size == 64 ? ceil(src0) : ceilf(src0);
3564
3565 _dst_val.u16[_i] = _mesa_float_to_half(dst);
3566 }
3567
3568 break;
3569 }
3570 case 32: {
3571
3572
3573
3574
3575 for (unsigned _i = 0; _i < num_components; _i++) {
3576 const float32_t src0 =
3577 _src[0].f32[_i];
3578
3579 float32_t dst = bit_size == 64 ? ceil(src0) : ceilf(src0);
3580
3581 _dst_val.f32[_i] = dst;
3582 }
3583
3584 break;
3585 }
3586 case 64: {
3587
3588
3589
3590
3591 for (unsigned _i = 0; _i < num_components; _i++) {
3592 const float64_t src0 =
3593 _src[0].f64[_i];
3594
3595 float64_t dst = bit_size == 64 ? ceil(src0) : ceilf(src0);
3596
3597 _dst_val.f64[_i] = dst;
3598 }
3599
3600 break;
3601 }
3602
3603 default:
3604 unreachable("unknown bit width");
3605 }
3606
3607 return _dst_val;
3608 }
3609 static nir_const_value
evaluate_fcos(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3610 evaluate_fcos(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3611 MAYBE_UNUSED nir_const_value *_src)
3612 {
3613 nir_const_value _dst_val = { {0, } };
3614
3615 switch (bit_size) {
3616 case 16: {
3617
3618
3619
3620
3621 for (unsigned _i = 0; _i < num_components; _i++) {
3622 const float src0 =
3623 _mesa_half_to_float(_src[0].u16[_i]);
3624
3625 float16_t dst = bit_size == 64 ? cos(src0) : cosf(src0);
3626
3627 _dst_val.u16[_i] = _mesa_float_to_half(dst);
3628 }
3629
3630 break;
3631 }
3632 case 32: {
3633
3634
3635
3636
3637 for (unsigned _i = 0; _i < num_components; _i++) {
3638 const float32_t src0 =
3639 _src[0].f32[_i];
3640
3641 float32_t dst = bit_size == 64 ? cos(src0) : cosf(src0);
3642
3643 _dst_val.f32[_i] = dst;
3644 }
3645
3646 break;
3647 }
3648 case 64: {
3649
3650
3651
3652
3653 for (unsigned _i = 0; _i < num_components; _i++) {
3654 const float64_t src0 =
3655 _src[0].f64[_i];
3656
3657 float64_t dst = bit_size == 64 ? cos(src0) : cosf(src0);
3658
3659 _dst_val.f64[_i] = dst;
3660 }
3661
3662 break;
3663 }
3664
3665 default:
3666 unreachable("unknown bit width");
3667 }
3668
3669 return _dst_val;
3670 }
3671 static nir_const_value
evaluate_fcsel(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3672 evaluate_fcsel(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3673 MAYBE_UNUSED nir_const_value *_src)
3674 {
3675 nir_const_value _dst_val = { {0, } };
3676
3677
3678
3679
3680
3681 for (unsigned _i = 0; _i < num_components; _i++) {
3682 const float32_t src0 =
3683 _src[0].f32[_i];
3684 const float32_t src1 =
3685 _src[1].f32[_i];
3686 const float32_t src2 =
3687 _src[2].f32[_i];
3688
3689 float32_t dst = (src0 != 0.0f) ? src1 : src2;
3690
3691 _dst_val.f32[_i] = dst;
3692 }
3693
3694
3695 return _dst_val;
3696 }
3697 static nir_const_value
evaluate_fddx(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3698 evaluate_fddx(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3699 MAYBE_UNUSED nir_const_value *_src)
3700 {
3701 nir_const_value _dst_val = { {0, } };
3702
3703 switch (bit_size) {
3704 case 16: {
3705
3706
3707
3708
3709 for (unsigned _i = 0; _i < num_components; _i++) {
3710
3711 float16_t dst = 0.0;
3712
3713 _dst_val.u16[_i] = _mesa_float_to_half(dst);
3714 }
3715
3716 break;
3717 }
3718 case 32: {
3719
3720
3721
3722
3723 for (unsigned _i = 0; _i < num_components; _i++) {
3724
3725 float32_t dst = 0.0;
3726
3727 _dst_val.f32[_i] = dst;
3728 }
3729
3730 break;
3731 }
3732 case 64: {
3733
3734
3735
3736
3737 for (unsigned _i = 0; _i < num_components; _i++) {
3738
3739 float64_t dst = 0.0;
3740
3741 _dst_val.f64[_i] = dst;
3742 }
3743
3744 break;
3745 }
3746
3747 default:
3748 unreachable("unknown bit width");
3749 }
3750
3751 return _dst_val;
3752 }
3753 static nir_const_value
evaluate_fddx_coarse(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3754 evaluate_fddx_coarse(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3755 MAYBE_UNUSED nir_const_value *_src)
3756 {
3757 nir_const_value _dst_val = { {0, } };
3758
3759 switch (bit_size) {
3760 case 16: {
3761
3762
3763
3764
3765 for (unsigned _i = 0; _i < num_components; _i++) {
3766
3767 float16_t dst = 0.0;
3768
3769 _dst_val.u16[_i] = _mesa_float_to_half(dst);
3770 }
3771
3772 break;
3773 }
3774 case 32: {
3775
3776
3777
3778
3779 for (unsigned _i = 0; _i < num_components; _i++) {
3780
3781 float32_t dst = 0.0;
3782
3783 _dst_val.f32[_i] = dst;
3784 }
3785
3786 break;
3787 }
3788 case 64: {
3789
3790
3791
3792
3793 for (unsigned _i = 0; _i < num_components; _i++) {
3794
3795 float64_t dst = 0.0;
3796
3797 _dst_val.f64[_i] = dst;
3798 }
3799
3800 break;
3801 }
3802
3803 default:
3804 unreachable("unknown bit width");
3805 }
3806
3807 return _dst_val;
3808 }
3809 static nir_const_value
evaluate_fddx_fine(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3810 evaluate_fddx_fine(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3811 MAYBE_UNUSED nir_const_value *_src)
3812 {
3813 nir_const_value _dst_val = { {0, } };
3814
3815 switch (bit_size) {
3816 case 16: {
3817
3818
3819
3820
3821 for (unsigned _i = 0; _i < num_components; _i++) {
3822
3823 float16_t dst = 0.0;
3824
3825 _dst_val.u16[_i] = _mesa_float_to_half(dst);
3826 }
3827
3828 break;
3829 }
3830 case 32: {
3831
3832
3833
3834
3835 for (unsigned _i = 0; _i < num_components; _i++) {
3836
3837 float32_t dst = 0.0;
3838
3839 _dst_val.f32[_i] = dst;
3840 }
3841
3842 break;
3843 }
3844 case 64: {
3845
3846
3847
3848
3849 for (unsigned _i = 0; _i < num_components; _i++) {
3850
3851 float64_t dst = 0.0;
3852
3853 _dst_val.f64[_i] = dst;
3854 }
3855
3856 break;
3857 }
3858
3859 default:
3860 unreachable("unknown bit width");
3861 }
3862
3863 return _dst_val;
3864 }
3865 static nir_const_value
evaluate_fddy(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3866 evaluate_fddy(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3867 MAYBE_UNUSED nir_const_value *_src)
3868 {
3869 nir_const_value _dst_val = { {0, } };
3870
3871 switch (bit_size) {
3872 case 16: {
3873
3874
3875
3876
3877 for (unsigned _i = 0; _i < num_components; _i++) {
3878
3879 float16_t dst = 0.0;
3880
3881 _dst_val.u16[_i] = _mesa_float_to_half(dst);
3882 }
3883
3884 break;
3885 }
3886 case 32: {
3887
3888
3889
3890
3891 for (unsigned _i = 0; _i < num_components; _i++) {
3892
3893 float32_t dst = 0.0;
3894
3895 _dst_val.f32[_i] = dst;
3896 }
3897
3898 break;
3899 }
3900 case 64: {
3901
3902
3903
3904
3905 for (unsigned _i = 0; _i < num_components; _i++) {
3906
3907 float64_t dst = 0.0;
3908
3909 _dst_val.f64[_i] = dst;
3910 }
3911
3912 break;
3913 }
3914
3915 default:
3916 unreachable("unknown bit width");
3917 }
3918
3919 return _dst_val;
3920 }
3921 static nir_const_value
evaluate_fddy_coarse(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3922 evaluate_fddy_coarse(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3923 MAYBE_UNUSED nir_const_value *_src)
3924 {
3925 nir_const_value _dst_val = { {0, } };
3926
3927 switch (bit_size) {
3928 case 16: {
3929
3930
3931
3932
3933 for (unsigned _i = 0; _i < num_components; _i++) {
3934
3935 float16_t dst = 0.0;
3936
3937 _dst_val.u16[_i] = _mesa_float_to_half(dst);
3938 }
3939
3940 break;
3941 }
3942 case 32: {
3943
3944
3945
3946
3947 for (unsigned _i = 0; _i < num_components; _i++) {
3948
3949 float32_t dst = 0.0;
3950
3951 _dst_val.f32[_i] = dst;
3952 }
3953
3954 break;
3955 }
3956 case 64: {
3957
3958
3959
3960
3961 for (unsigned _i = 0; _i < num_components; _i++) {
3962
3963 float64_t dst = 0.0;
3964
3965 _dst_val.f64[_i] = dst;
3966 }
3967
3968 break;
3969 }
3970
3971 default:
3972 unreachable("unknown bit width");
3973 }
3974
3975 return _dst_val;
3976 }
3977 static nir_const_value
evaluate_fddy_fine(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)3978 evaluate_fddy_fine(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
3979 MAYBE_UNUSED nir_const_value *_src)
3980 {
3981 nir_const_value _dst_val = { {0, } };
3982
3983 switch (bit_size) {
3984 case 16: {
3985
3986
3987
3988
3989 for (unsigned _i = 0; _i < num_components; _i++) {
3990
3991 float16_t dst = 0.0;
3992
3993 _dst_val.u16[_i] = _mesa_float_to_half(dst);
3994 }
3995
3996 break;
3997 }
3998 case 32: {
3999
4000
4001
4002
4003 for (unsigned _i = 0; _i < num_components; _i++) {
4004
4005 float32_t dst = 0.0;
4006
4007 _dst_val.f32[_i] = dst;
4008 }
4009
4010 break;
4011 }
4012 case 64: {
4013
4014
4015
4016
4017 for (unsigned _i = 0; _i < num_components; _i++) {
4018
4019 float64_t dst = 0.0;
4020
4021 _dst_val.f64[_i] = dst;
4022 }
4023
4024 break;
4025 }
4026
4027 default:
4028 unreachable("unknown bit width");
4029 }
4030
4031 return _dst_val;
4032 }
4033 static nir_const_value
evaluate_fdiv(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)4034 evaluate_fdiv(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
4035 MAYBE_UNUSED nir_const_value *_src)
4036 {
4037 nir_const_value _dst_val = { {0, } };
4038
4039 switch (bit_size) {
4040 case 16: {
4041
4042
4043
4044
4045 for (unsigned _i = 0; _i < num_components; _i++) {
4046 const float src0 =
4047 _mesa_half_to_float(_src[0].u16[_i]);
4048 const float src1 =
4049 _mesa_half_to_float(_src[1].u16[_i]);
4050
4051 float16_t dst = src0 / src1;
4052
4053 _dst_val.u16[_i] = _mesa_float_to_half(dst);
4054 }
4055
4056 break;
4057 }
4058 case 32: {
4059
4060
4061
4062
4063 for (unsigned _i = 0; _i < num_components; _i++) {
4064 const float32_t src0 =
4065 _src[0].f32[_i];
4066 const float32_t src1 =
4067 _src[1].f32[_i];
4068
4069 float32_t dst = src0 / src1;
4070
4071 _dst_val.f32[_i] = dst;
4072 }
4073
4074 break;
4075 }
4076 case 64: {
4077
4078
4079
4080
4081 for (unsigned _i = 0; _i < num_components; _i++) {
4082 const float64_t src0 =
4083 _src[0].f64[_i];
4084 const float64_t src1 =
4085 _src[1].f64[_i];
4086
4087 float64_t dst = src0 / src1;
4088
4089 _dst_val.f64[_i] = dst;
4090 }
4091
4092 break;
4093 }
4094
4095 default:
4096 unreachable("unknown bit width");
4097 }
4098
4099 return _dst_val;
4100 }
4101 static nir_const_value
evaluate_fdot2(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)4102 evaluate_fdot2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
4103 MAYBE_UNUSED nir_const_value *_src)
4104 {
4105 nir_const_value _dst_val = { {0, } };
4106
4107 switch (bit_size) {
4108 case 16: {
4109
4110
4111
4112
4113 const struct float16_vec src0 = {
4114 _mesa_half_to_float(_src[0].u16[0]),
4115 _mesa_half_to_float(_src[0].u16[1]),
4116 0,
4117 0,
4118 };
4119
4120 const struct float16_vec src1 = {
4121 _mesa_half_to_float(_src[1].u16[0]),
4122 _mesa_half_to_float(_src[1].u16[1]),
4123 0,
4124 0,
4125 };
4126
4127 struct float16_vec dst;
4128
4129 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y));
4130
4131 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
4132
4133 break;
4134 }
4135 case 32: {
4136
4137
4138
4139
4140 const struct float32_vec src0 = {
4141 _src[0].f32[0],
4142 _src[0].f32[1],
4143 0,
4144 0,
4145 };
4146
4147 const struct float32_vec src1 = {
4148 _src[1].f32[0],
4149 _src[1].f32[1],
4150 0,
4151 0,
4152 };
4153
4154 struct float32_vec dst;
4155
4156 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y));
4157
4158 _dst_val.f32[0] = dst.x;
4159
4160 break;
4161 }
4162 case 64: {
4163
4164
4165
4166
4167 const struct float64_vec src0 = {
4168 _src[0].f64[0],
4169 _src[0].f64[1],
4170 0,
4171 0,
4172 };
4173
4174 const struct float64_vec src1 = {
4175 _src[1].f64[0],
4176 _src[1].f64[1],
4177 0,
4178 0,
4179 };
4180
4181 struct float64_vec dst;
4182
4183 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y));
4184
4185 _dst_val.f64[0] = dst.x;
4186
4187 break;
4188 }
4189
4190 default:
4191 unreachable("unknown bit width");
4192 }
4193
4194 return _dst_val;
4195 }
4196 static nir_const_value
evaluate_fdot3(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)4197 evaluate_fdot3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
4198 MAYBE_UNUSED nir_const_value *_src)
4199 {
4200 nir_const_value _dst_val = { {0, } };
4201
4202 switch (bit_size) {
4203 case 16: {
4204
4205
4206
4207
4208 const struct float16_vec src0 = {
4209 _mesa_half_to_float(_src[0].u16[0]),
4210 _mesa_half_to_float(_src[0].u16[1]),
4211 _mesa_half_to_float(_src[0].u16[2]),
4212 0,
4213 };
4214
4215 const struct float16_vec src1 = {
4216 _mesa_half_to_float(_src[1].u16[0]),
4217 _mesa_half_to_float(_src[1].u16[1]),
4218 _mesa_half_to_float(_src[1].u16[2]),
4219 0,
4220 };
4221
4222 struct float16_vec dst;
4223
4224 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z));
4225
4226 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
4227
4228 break;
4229 }
4230 case 32: {
4231
4232
4233
4234
4235 const struct float32_vec src0 = {
4236 _src[0].f32[0],
4237 _src[0].f32[1],
4238 _src[0].f32[2],
4239 0,
4240 };
4241
4242 const struct float32_vec src1 = {
4243 _src[1].f32[0],
4244 _src[1].f32[1],
4245 _src[1].f32[2],
4246 0,
4247 };
4248
4249 struct float32_vec dst;
4250
4251 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z));
4252
4253 _dst_val.f32[0] = dst.x;
4254
4255 break;
4256 }
4257 case 64: {
4258
4259
4260
4261
4262 const struct float64_vec src0 = {
4263 _src[0].f64[0],
4264 _src[0].f64[1],
4265 _src[0].f64[2],
4266 0,
4267 };
4268
4269 const struct float64_vec src1 = {
4270 _src[1].f64[0],
4271 _src[1].f64[1],
4272 _src[1].f64[2],
4273 0,
4274 };
4275
4276 struct float64_vec dst;
4277
4278 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z));
4279
4280 _dst_val.f64[0] = dst.x;
4281
4282 break;
4283 }
4284
4285 default:
4286 unreachable("unknown bit width");
4287 }
4288
4289 return _dst_val;
4290 }
4291 static nir_const_value
evaluate_fdot4(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)4292 evaluate_fdot4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
4293 MAYBE_UNUSED nir_const_value *_src)
4294 {
4295 nir_const_value _dst_val = { {0, } };
4296
4297 switch (bit_size) {
4298 case 16: {
4299
4300
4301
4302
4303 const struct float16_vec src0 = {
4304 _mesa_half_to_float(_src[0].u16[0]),
4305 _mesa_half_to_float(_src[0].u16[1]),
4306 _mesa_half_to_float(_src[0].u16[2]),
4307 _mesa_half_to_float(_src[0].u16[3]),
4308 };
4309
4310 const struct float16_vec src1 = {
4311 _mesa_half_to_float(_src[1].u16[0]),
4312 _mesa_half_to_float(_src[1].u16[1]),
4313 _mesa_half_to_float(_src[1].u16[2]),
4314 _mesa_half_to_float(_src[1].u16[3]),
4315 };
4316
4317 struct float16_vec dst;
4318
4319 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z) + (src0.w * src1.w));
4320
4321 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
4322
4323 break;
4324 }
4325 case 32: {
4326
4327
4328
4329
4330 const struct float32_vec src0 = {
4331 _src[0].f32[0],
4332 _src[0].f32[1],
4333 _src[0].f32[2],
4334 _src[0].f32[3],
4335 };
4336
4337 const struct float32_vec src1 = {
4338 _src[1].f32[0],
4339 _src[1].f32[1],
4340 _src[1].f32[2],
4341 _src[1].f32[3],
4342 };
4343
4344 struct float32_vec dst;
4345
4346 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z) + (src0.w * src1.w));
4347
4348 _dst_val.f32[0] = dst.x;
4349
4350 break;
4351 }
4352 case 64: {
4353
4354
4355
4356
4357 const struct float64_vec src0 = {
4358 _src[0].f64[0],
4359 _src[0].f64[1],
4360 _src[0].f64[2],
4361 _src[0].f64[3],
4362 };
4363
4364 const struct float64_vec src1 = {
4365 _src[1].f64[0],
4366 _src[1].f64[1],
4367 _src[1].f64[2],
4368 _src[1].f64[3],
4369 };
4370
4371 struct float64_vec dst;
4372
4373 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z) + (src0.w * src1.w));
4374
4375 _dst_val.f64[0] = dst.x;
4376
4377 break;
4378 }
4379
4380 default:
4381 unreachable("unknown bit width");
4382 }
4383
4384 return _dst_val;
4385 }
4386 static nir_const_value
evaluate_fdot_replicated2(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)4387 evaluate_fdot_replicated2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
4388 MAYBE_UNUSED nir_const_value *_src)
4389 {
4390 nir_const_value _dst_val = { {0, } };
4391
4392 switch (bit_size) {
4393 case 16: {
4394
4395
4396
4397
4398 const struct float16_vec src0 = {
4399 _mesa_half_to_float(_src[0].u16[0]),
4400 _mesa_half_to_float(_src[0].u16[1]),
4401 0,
4402 0,
4403 };
4404
4405 const struct float16_vec src1 = {
4406 _mesa_half_to_float(_src[1].u16[0]),
4407 _mesa_half_to_float(_src[1].u16[1]),
4408 0,
4409 0,
4410 };
4411
4412 struct float16_vec dst;
4413
4414 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y));
4415
4416 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
4417 _dst_val.u16[1] = _mesa_float_to_half(dst.y);
4418 _dst_val.u16[2] = _mesa_float_to_half(dst.z);
4419 _dst_val.u16[3] = _mesa_float_to_half(dst.w);
4420
4421 break;
4422 }
4423 case 32: {
4424
4425
4426
4427
4428 const struct float32_vec src0 = {
4429 _src[0].f32[0],
4430 _src[0].f32[1],
4431 0,
4432 0,
4433 };
4434
4435 const struct float32_vec src1 = {
4436 _src[1].f32[0],
4437 _src[1].f32[1],
4438 0,
4439 0,
4440 };
4441
4442 struct float32_vec dst;
4443
4444 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y));
4445
4446 _dst_val.f32[0] = dst.x;
4447 _dst_val.f32[1] = dst.y;
4448 _dst_val.f32[2] = dst.z;
4449 _dst_val.f32[3] = dst.w;
4450
4451 break;
4452 }
4453 case 64: {
4454
4455
4456
4457
4458 const struct float64_vec src0 = {
4459 _src[0].f64[0],
4460 _src[0].f64[1],
4461 0,
4462 0,
4463 };
4464
4465 const struct float64_vec src1 = {
4466 _src[1].f64[0],
4467 _src[1].f64[1],
4468 0,
4469 0,
4470 };
4471
4472 struct float64_vec dst;
4473
4474 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y));
4475
4476 _dst_val.f64[0] = dst.x;
4477 _dst_val.f64[1] = dst.y;
4478 _dst_val.f64[2] = dst.z;
4479 _dst_val.f64[3] = dst.w;
4480
4481 break;
4482 }
4483
4484 default:
4485 unreachable("unknown bit width");
4486 }
4487
4488 return _dst_val;
4489 }
4490 static nir_const_value
evaluate_fdot_replicated3(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)4491 evaluate_fdot_replicated3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
4492 MAYBE_UNUSED nir_const_value *_src)
4493 {
4494 nir_const_value _dst_val = { {0, } };
4495
4496 switch (bit_size) {
4497 case 16: {
4498
4499
4500
4501
4502 const struct float16_vec src0 = {
4503 _mesa_half_to_float(_src[0].u16[0]),
4504 _mesa_half_to_float(_src[0].u16[1]),
4505 _mesa_half_to_float(_src[0].u16[2]),
4506 0,
4507 };
4508
4509 const struct float16_vec src1 = {
4510 _mesa_half_to_float(_src[1].u16[0]),
4511 _mesa_half_to_float(_src[1].u16[1]),
4512 _mesa_half_to_float(_src[1].u16[2]),
4513 0,
4514 };
4515
4516 struct float16_vec dst;
4517
4518 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z));
4519
4520 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
4521 _dst_val.u16[1] = _mesa_float_to_half(dst.y);
4522 _dst_val.u16[2] = _mesa_float_to_half(dst.z);
4523 _dst_val.u16[3] = _mesa_float_to_half(dst.w);
4524
4525 break;
4526 }
4527 case 32: {
4528
4529
4530
4531
4532 const struct float32_vec src0 = {
4533 _src[0].f32[0],
4534 _src[0].f32[1],
4535 _src[0].f32[2],
4536 0,
4537 };
4538
4539 const struct float32_vec src1 = {
4540 _src[1].f32[0],
4541 _src[1].f32[1],
4542 _src[1].f32[2],
4543 0,
4544 };
4545
4546 struct float32_vec dst;
4547
4548 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z));
4549
4550 _dst_val.f32[0] = dst.x;
4551 _dst_val.f32[1] = dst.y;
4552 _dst_val.f32[2] = dst.z;
4553 _dst_val.f32[3] = dst.w;
4554
4555 break;
4556 }
4557 case 64: {
4558
4559
4560
4561
4562 const struct float64_vec src0 = {
4563 _src[0].f64[0],
4564 _src[0].f64[1],
4565 _src[0].f64[2],
4566 0,
4567 };
4568
4569 const struct float64_vec src1 = {
4570 _src[1].f64[0],
4571 _src[1].f64[1],
4572 _src[1].f64[2],
4573 0,
4574 };
4575
4576 struct float64_vec dst;
4577
4578 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z));
4579
4580 _dst_val.f64[0] = dst.x;
4581 _dst_val.f64[1] = dst.y;
4582 _dst_val.f64[2] = dst.z;
4583 _dst_val.f64[3] = dst.w;
4584
4585 break;
4586 }
4587
4588 default:
4589 unreachable("unknown bit width");
4590 }
4591
4592 return _dst_val;
4593 }
4594 static nir_const_value
evaluate_fdot_replicated4(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)4595 evaluate_fdot_replicated4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
4596 MAYBE_UNUSED nir_const_value *_src)
4597 {
4598 nir_const_value _dst_val = { {0, } };
4599
4600 switch (bit_size) {
4601 case 16: {
4602
4603
4604
4605
4606 const struct float16_vec src0 = {
4607 _mesa_half_to_float(_src[0].u16[0]),
4608 _mesa_half_to_float(_src[0].u16[1]),
4609 _mesa_half_to_float(_src[0].u16[2]),
4610 _mesa_half_to_float(_src[0].u16[3]),
4611 };
4612
4613 const struct float16_vec src1 = {
4614 _mesa_half_to_float(_src[1].u16[0]),
4615 _mesa_half_to_float(_src[1].u16[1]),
4616 _mesa_half_to_float(_src[1].u16[2]),
4617 _mesa_half_to_float(_src[1].u16[3]),
4618 };
4619
4620 struct float16_vec dst;
4621
4622 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z) + (src0.w * src1.w));
4623
4624 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
4625 _dst_val.u16[1] = _mesa_float_to_half(dst.y);
4626 _dst_val.u16[2] = _mesa_float_to_half(dst.z);
4627 _dst_val.u16[3] = _mesa_float_to_half(dst.w);
4628
4629 break;
4630 }
4631 case 32: {
4632
4633
4634
4635
4636 const struct float32_vec src0 = {
4637 _src[0].f32[0],
4638 _src[0].f32[1],
4639 _src[0].f32[2],
4640 _src[0].f32[3],
4641 };
4642
4643 const struct float32_vec src1 = {
4644 _src[1].f32[0],
4645 _src[1].f32[1],
4646 _src[1].f32[2],
4647 _src[1].f32[3],
4648 };
4649
4650 struct float32_vec dst;
4651
4652 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z) + (src0.w * src1.w));
4653
4654 _dst_val.f32[0] = dst.x;
4655 _dst_val.f32[1] = dst.y;
4656 _dst_val.f32[2] = dst.z;
4657 _dst_val.f32[3] = dst.w;
4658
4659 break;
4660 }
4661 case 64: {
4662
4663
4664
4665
4666 const struct float64_vec src0 = {
4667 _src[0].f64[0],
4668 _src[0].f64[1],
4669 _src[0].f64[2],
4670 _src[0].f64[3],
4671 };
4672
4673 const struct float64_vec src1 = {
4674 _src[1].f64[0],
4675 _src[1].f64[1],
4676 _src[1].f64[2],
4677 _src[1].f64[3],
4678 };
4679
4680 struct float64_vec dst;
4681
4682 dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z) + (src0.w * src1.w));
4683
4684 _dst_val.f64[0] = dst.x;
4685 _dst_val.f64[1] = dst.y;
4686 _dst_val.f64[2] = dst.z;
4687 _dst_val.f64[3] = dst.w;
4688
4689 break;
4690 }
4691
4692 default:
4693 unreachable("unknown bit width");
4694 }
4695
4696 return _dst_val;
4697 }
4698 static nir_const_value
evaluate_fdph(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)4699 evaluate_fdph(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
4700 MAYBE_UNUSED nir_const_value *_src)
4701 {
4702 nir_const_value _dst_val = { {0, } };
4703
4704 switch (bit_size) {
4705 case 16: {
4706
4707
4708
4709
4710 const struct float16_vec src0 = {
4711 _mesa_half_to_float(_src[0].u16[0]),
4712 _mesa_half_to_float(_src[0].u16[1]),
4713 _mesa_half_to_float(_src[0].u16[2]),
4714 0,
4715 };
4716
4717 const struct float16_vec src1 = {
4718 _mesa_half_to_float(_src[1].u16[0]),
4719 _mesa_half_to_float(_src[1].u16[1]),
4720 _mesa_half_to_float(_src[1].u16[2]),
4721 _mesa_half_to_float(_src[1].u16[3]),
4722 };
4723
4724 struct float16_vec dst;
4725
4726 dst.x = dst.y = dst.z = dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w;
4727
4728 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
4729
4730 break;
4731 }
4732 case 32: {
4733
4734
4735
4736
4737 const struct float32_vec src0 = {
4738 _src[0].f32[0],
4739 _src[0].f32[1],
4740 _src[0].f32[2],
4741 0,
4742 };
4743
4744 const struct float32_vec src1 = {
4745 _src[1].f32[0],
4746 _src[1].f32[1],
4747 _src[1].f32[2],
4748 _src[1].f32[3],
4749 };
4750
4751 struct float32_vec dst;
4752
4753 dst.x = dst.y = dst.z = dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w;
4754
4755 _dst_val.f32[0] = dst.x;
4756
4757 break;
4758 }
4759 case 64: {
4760
4761
4762
4763
4764 const struct float64_vec src0 = {
4765 _src[0].f64[0],
4766 _src[0].f64[1],
4767 _src[0].f64[2],
4768 0,
4769 };
4770
4771 const struct float64_vec src1 = {
4772 _src[1].f64[0],
4773 _src[1].f64[1],
4774 _src[1].f64[2],
4775 _src[1].f64[3],
4776 };
4777
4778 struct float64_vec dst;
4779
4780 dst.x = dst.y = dst.z = dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w;
4781
4782 _dst_val.f64[0] = dst.x;
4783
4784 break;
4785 }
4786
4787 default:
4788 unreachable("unknown bit width");
4789 }
4790
4791 return _dst_val;
4792 }
4793 static nir_const_value
evaluate_fdph_replicated(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)4794 evaluate_fdph_replicated(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
4795 MAYBE_UNUSED nir_const_value *_src)
4796 {
4797 nir_const_value _dst_val = { {0, } };
4798
4799 switch (bit_size) {
4800 case 16: {
4801
4802
4803
4804
4805 const struct float16_vec src0 = {
4806 _mesa_half_to_float(_src[0].u16[0]),
4807 _mesa_half_to_float(_src[0].u16[1]),
4808 _mesa_half_to_float(_src[0].u16[2]),
4809 0,
4810 };
4811
4812 const struct float16_vec src1 = {
4813 _mesa_half_to_float(_src[1].u16[0]),
4814 _mesa_half_to_float(_src[1].u16[1]),
4815 _mesa_half_to_float(_src[1].u16[2]),
4816 _mesa_half_to_float(_src[1].u16[3]),
4817 };
4818
4819 struct float16_vec dst;
4820
4821 dst.x = dst.y = dst.z = dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w;
4822
4823 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
4824 _dst_val.u16[1] = _mesa_float_to_half(dst.y);
4825 _dst_val.u16[2] = _mesa_float_to_half(dst.z);
4826 _dst_val.u16[3] = _mesa_float_to_half(dst.w);
4827
4828 break;
4829 }
4830 case 32: {
4831
4832
4833
4834
4835 const struct float32_vec src0 = {
4836 _src[0].f32[0],
4837 _src[0].f32[1],
4838 _src[0].f32[2],
4839 0,
4840 };
4841
4842 const struct float32_vec src1 = {
4843 _src[1].f32[0],
4844 _src[1].f32[1],
4845 _src[1].f32[2],
4846 _src[1].f32[3],
4847 };
4848
4849 struct float32_vec dst;
4850
4851 dst.x = dst.y = dst.z = dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w;
4852
4853 _dst_val.f32[0] = dst.x;
4854 _dst_val.f32[1] = dst.y;
4855 _dst_val.f32[2] = dst.z;
4856 _dst_val.f32[3] = dst.w;
4857
4858 break;
4859 }
4860 case 64: {
4861
4862
4863
4864
4865 const struct float64_vec src0 = {
4866 _src[0].f64[0],
4867 _src[0].f64[1],
4868 _src[0].f64[2],
4869 0,
4870 };
4871
4872 const struct float64_vec src1 = {
4873 _src[1].f64[0],
4874 _src[1].f64[1],
4875 _src[1].f64[2],
4876 _src[1].f64[3],
4877 };
4878
4879 struct float64_vec dst;
4880
4881 dst.x = dst.y = dst.z = dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w;
4882
4883 _dst_val.f64[0] = dst.x;
4884 _dst_val.f64[1] = dst.y;
4885 _dst_val.f64[2] = dst.z;
4886 _dst_val.f64[3] = dst.w;
4887
4888 break;
4889 }
4890
4891 default:
4892 unreachable("unknown bit width");
4893 }
4894
4895 return _dst_val;
4896 }
4897 static nir_const_value
evaluate_feq(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)4898 evaluate_feq(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
4899 MAYBE_UNUSED nir_const_value *_src)
4900 {
4901 nir_const_value _dst_val = { {0, } };
4902
4903 switch (bit_size) {
4904 case 16: {
4905
4906
4907
4908
4909 for (unsigned _i = 0; _i < num_components; _i++) {
4910 const float src0 =
4911 _mesa_half_to_float(_src[0].u16[_i]);
4912 const float src1 =
4913 _mesa_half_to_float(_src[1].u16[_i]);
4914
4915 bool32_t dst = src0 == src1;
4916
4917 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
4918 }
4919
4920 break;
4921 }
4922 case 32: {
4923
4924
4925
4926
4927 for (unsigned _i = 0; _i < num_components; _i++) {
4928 const float32_t src0 =
4929 _src[0].f32[_i];
4930 const float32_t src1 =
4931 _src[1].f32[_i];
4932
4933 bool32_t dst = src0 == src1;
4934
4935 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
4936 }
4937
4938 break;
4939 }
4940 case 64: {
4941
4942
4943
4944
4945 for (unsigned _i = 0; _i < num_components; _i++) {
4946 const float64_t src0 =
4947 _src[0].f64[_i];
4948 const float64_t src1 =
4949 _src[1].f64[_i];
4950
4951 bool32_t dst = src0 == src1;
4952
4953 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
4954 }
4955
4956 break;
4957 }
4958
4959 default:
4960 unreachable("unknown bit width");
4961 }
4962
4963 return _dst_val;
4964 }
4965 static nir_const_value
evaluate_fexp2(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)4966 evaluate_fexp2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
4967 MAYBE_UNUSED nir_const_value *_src)
4968 {
4969 nir_const_value _dst_val = { {0, } };
4970
4971 switch (bit_size) {
4972 case 16: {
4973
4974
4975
4976
4977 for (unsigned _i = 0; _i < num_components; _i++) {
4978 const float src0 =
4979 _mesa_half_to_float(_src[0].u16[_i]);
4980
4981 float16_t dst = exp2f(src0);
4982
4983 _dst_val.u16[_i] = _mesa_float_to_half(dst);
4984 }
4985
4986 break;
4987 }
4988 case 32: {
4989
4990
4991
4992
4993 for (unsigned _i = 0; _i < num_components; _i++) {
4994 const float32_t src0 =
4995 _src[0].f32[_i];
4996
4997 float32_t dst = exp2f(src0);
4998
4999 _dst_val.f32[_i] = dst;
5000 }
5001
5002 break;
5003 }
5004 case 64: {
5005
5006
5007
5008
5009 for (unsigned _i = 0; _i < num_components; _i++) {
5010 const float64_t src0 =
5011 _src[0].f64[_i];
5012
5013 float64_t dst = exp2f(src0);
5014
5015 _dst_val.f64[_i] = dst;
5016 }
5017
5018 break;
5019 }
5020
5021 default:
5022 unreachable("unknown bit width");
5023 }
5024
5025 return _dst_val;
5026 }
5027 static nir_const_value
evaluate_ffloor(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)5028 evaluate_ffloor(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
5029 MAYBE_UNUSED nir_const_value *_src)
5030 {
5031 nir_const_value _dst_val = { {0, } };
5032
5033 switch (bit_size) {
5034 case 16: {
5035
5036
5037
5038
5039 for (unsigned _i = 0; _i < num_components; _i++) {
5040 const float src0 =
5041 _mesa_half_to_float(_src[0].u16[_i]);
5042
5043 float16_t dst = bit_size == 64 ? floor(src0) : floorf(src0);
5044
5045 _dst_val.u16[_i] = _mesa_float_to_half(dst);
5046 }
5047
5048 break;
5049 }
5050 case 32: {
5051
5052
5053
5054
5055 for (unsigned _i = 0; _i < num_components; _i++) {
5056 const float32_t src0 =
5057 _src[0].f32[_i];
5058
5059 float32_t dst = bit_size == 64 ? floor(src0) : floorf(src0);
5060
5061 _dst_val.f32[_i] = dst;
5062 }
5063
5064 break;
5065 }
5066 case 64: {
5067
5068
5069
5070
5071 for (unsigned _i = 0; _i < num_components; _i++) {
5072 const float64_t src0 =
5073 _src[0].f64[_i];
5074
5075 float64_t dst = bit_size == 64 ? floor(src0) : floorf(src0);
5076
5077 _dst_val.f64[_i] = dst;
5078 }
5079
5080 break;
5081 }
5082
5083 default:
5084 unreachable("unknown bit width");
5085 }
5086
5087 return _dst_val;
5088 }
5089 static nir_const_value
evaluate_ffma(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)5090 evaluate_ffma(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
5091 MAYBE_UNUSED nir_const_value *_src)
5092 {
5093 nir_const_value _dst_val = { {0, } };
5094
5095 switch (bit_size) {
5096 case 16: {
5097
5098
5099
5100
5101 for (unsigned _i = 0; _i < num_components; _i++) {
5102 const float src0 =
5103 _mesa_half_to_float(_src[0].u16[_i]);
5104 const float src1 =
5105 _mesa_half_to_float(_src[1].u16[_i]);
5106 const float src2 =
5107 _mesa_half_to_float(_src[2].u16[_i]);
5108
5109 float16_t dst = src0 * src1 + src2;
5110
5111 _dst_val.u16[_i] = _mesa_float_to_half(dst);
5112 }
5113
5114 break;
5115 }
5116 case 32: {
5117
5118
5119
5120
5121 for (unsigned _i = 0; _i < num_components; _i++) {
5122 const float32_t src0 =
5123 _src[0].f32[_i];
5124 const float32_t src1 =
5125 _src[1].f32[_i];
5126 const float32_t src2 =
5127 _src[2].f32[_i];
5128
5129 float32_t dst = src0 * src1 + src2;
5130
5131 _dst_val.f32[_i] = dst;
5132 }
5133
5134 break;
5135 }
5136 case 64: {
5137
5138
5139
5140
5141 for (unsigned _i = 0; _i < num_components; _i++) {
5142 const float64_t src0 =
5143 _src[0].f64[_i];
5144 const float64_t src1 =
5145 _src[1].f64[_i];
5146 const float64_t src2 =
5147 _src[2].f64[_i];
5148
5149 float64_t dst = src0 * src1 + src2;
5150
5151 _dst_val.f64[_i] = dst;
5152 }
5153
5154 break;
5155 }
5156
5157 default:
5158 unreachable("unknown bit width");
5159 }
5160
5161 return _dst_val;
5162 }
5163 static nir_const_value
evaluate_ffract(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)5164 evaluate_ffract(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
5165 MAYBE_UNUSED nir_const_value *_src)
5166 {
5167 nir_const_value _dst_val = { {0, } };
5168
5169 switch (bit_size) {
5170 case 16: {
5171
5172
5173
5174
5175 for (unsigned _i = 0; _i < num_components; _i++) {
5176 const float src0 =
5177 _mesa_half_to_float(_src[0].u16[_i]);
5178
5179 float16_t dst = src0 - (bit_size == 64 ? floor(src0) : floorf(src0));
5180
5181 _dst_val.u16[_i] = _mesa_float_to_half(dst);
5182 }
5183
5184 break;
5185 }
5186 case 32: {
5187
5188
5189
5190
5191 for (unsigned _i = 0; _i < num_components; _i++) {
5192 const float32_t src0 =
5193 _src[0].f32[_i];
5194
5195 float32_t dst = src0 - (bit_size == 64 ? floor(src0) : floorf(src0));
5196
5197 _dst_val.f32[_i] = dst;
5198 }
5199
5200 break;
5201 }
5202 case 64: {
5203
5204
5205
5206
5207 for (unsigned _i = 0; _i < num_components; _i++) {
5208 const float64_t src0 =
5209 _src[0].f64[_i];
5210
5211 float64_t dst = src0 - (bit_size == 64 ? floor(src0) : floorf(src0));
5212
5213 _dst_val.f64[_i] = dst;
5214 }
5215
5216 break;
5217 }
5218
5219 default:
5220 unreachable("unknown bit width");
5221 }
5222
5223 return _dst_val;
5224 }
5225 static nir_const_value
evaluate_fge(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)5226 evaluate_fge(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
5227 MAYBE_UNUSED nir_const_value *_src)
5228 {
5229 nir_const_value _dst_val = { {0, } };
5230
5231 switch (bit_size) {
5232 case 16: {
5233
5234
5235
5236
5237 for (unsigned _i = 0; _i < num_components; _i++) {
5238 const float src0 =
5239 _mesa_half_to_float(_src[0].u16[_i]);
5240 const float src1 =
5241 _mesa_half_to_float(_src[1].u16[_i]);
5242
5243 bool32_t dst = src0 >= src1;
5244
5245 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
5246 }
5247
5248 break;
5249 }
5250 case 32: {
5251
5252
5253
5254
5255 for (unsigned _i = 0; _i < num_components; _i++) {
5256 const float32_t src0 =
5257 _src[0].f32[_i];
5258 const float32_t src1 =
5259 _src[1].f32[_i];
5260
5261 bool32_t dst = src0 >= src1;
5262
5263 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
5264 }
5265
5266 break;
5267 }
5268 case 64: {
5269
5270
5271
5272
5273 for (unsigned _i = 0; _i < num_components; _i++) {
5274 const float64_t src0 =
5275 _src[0].f64[_i];
5276 const float64_t src1 =
5277 _src[1].f64[_i];
5278
5279 bool32_t dst = src0 >= src1;
5280
5281 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
5282 }
5283
5284 break;
5285 }
5286
5287 default:
5288 unreachable("unknown bit width");
5289 }
5290
5291 return _dst_val;
5292 }
5293 static nir_const_value
evaluate_find_lsb(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)5294 evaluate_find_lsb(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
5295 MAYBE_UNUSED nir_const_value *_src)
5296 {
5297 nir_const_value _dst_val = { {0, } };
5298
5299
5300
5301
5302
5303 for (unsigned _i = 0; _i < num_components; _i++) {
5304 const int32_t src0 =
5305 _src[0].i32[_i];
5306
5307 int32_t dst;
5308
5309
5310 dst = -1;
5311 for (unsigned bit = 0; bit < 32; bit++) {
5312 if ((src0 >> bit) & 1) {
5313 dst = bit;
5314 break;
5315 }
5316 }
5317
5318
5319 _dst_val.i32[_i] = dst;
5320 }
5321
5322
5323 return _dst_val;
5324 }
5325 static nir_const_value
evaluate_flog2(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)5326 evaluate_flog2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
5327 MAYBE_UNUSED nir_const_value *_src)
5328 {
5329 nir_const_value _dst_val = { {0, } };
5330
5331 switch (bit_size) {
5332 case 16: {
5333
5334
5335
5336
5337 for (unsigned _i = 0; _i < num_components; _i++) {
5338 const float src0 =
5339 _mesa_half_to_float(_src[0].u16[_i]);
5340
5341 float16_t dst = log2f(src0);
5342
5343 _dst_val.u16[_i] = _mesa_float_to_half(dst);
5344 }
5345
5346 break;
5347 }
5348 case 32: {
5349
5350
5351
5352
5353 for (unsigned _i = 0; _i < num_components; _i++) {
5354 const float32_t src0 =
5355 _src[0].f32[_i];
5356
5357 float32_t dst = log2f(src0);
5358
5359 _dst_val.f32[_i] = dst;
5360 }
5361
5362 break;
5363 }
5364 case 64: {
5365
5366
5367
5368
5369 for (unsigned _i = 0; _i < num_components; _i++) {
5370 const float64_t src0 =
5371 _src[0].f64[_i];
5372
5373 float64_t dst = log2f(src0);
5374
5375 _dst_val.f64[_i] = dst;
5376 }
5377
5378 break;
5379 }
5380
5381 default:
5382 unreachable("unknown bit width");
5383 }
5384
5385 return _dst_val;
5386 }
5387 static nir_const_value
evaluate_flrp(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)5388 evaluate_flrp(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
5389 MAYBE_UNUSED nir_const_value *_src)
5390 {
5391 nir_const_value _dst_val = { {0, } };
5392
5393 switch (bit_size) {
5394 case 16: {
5395
5396
5397
5398
5399 for (unsigned _i = 0; _i < num_components; _i++) {
5400 const float src0 =
5401 _mesa_half_to_float(_src[0].u16[_i]);
5402 const float src1 =
5403 _mesa_half_to_float(_src[1].u16[_i]);
5404 const float src2 =
5405 _mesa_half_to_float(_src[2].u16[_i]);
5406
5407 float16_t dst = src0 * (1 - src2) + src1 * src2;
5408
5409 _dst_val.u16[_i] = _mesa_float_to_half(dst);
5410 }
5411
5412 break;
5413 }
5414 case 32: {
5415
5416
5417
5418
5419 for (unsigned _i = 0; _i < num_components; _i++) {
5420 const float32_t src0 =
5421 _src[0].f32[_i];
5422 const float32_t src1 =
5423 _src[1].f32[_i];
5424 const float32_t src2 =
5425 _src[2].f32[_i];
5426
5427 float32_t dst = src0 * (1 - src2) + src1 * src2;
5428
5429 _dst_val.f32[_i] = dst;
5430 }
5431
5432 break;
5433 }
5434 case 64: {
5435
5436
5437
5438
5439 for (unsigned _i = 0; _i < num_components; _i++) {
5440 const float64_t src0 =
5441 _src[0].f64[_i];
5442 const float64_t src1 =
5443 _src[1].f64[_i];
5444 const float64_t src2 =
5445 _src[2].f64[_i];
5446
5447 float64_t dst = src0 * (1 - src2) + src1 * src2;
5448
5449 _dst_val.f64[_i] = dst;
5450 }
5451
5452 break;
5453 }
5454
5455 default:
5456 unreachable("unknown bit width");
5457 }
5458
5459 return _dst_val;
5460 }
5461 static nir_const_value
evaluate_flt(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)5462 evaluate_flt(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
5463 MAYBE_UNUSED nir_const_value *_src)
5464 {
5465 nir_const_value _dst_val = { {0, } };
5466
5467 switch (bit_size) {
5468 case 16: {
5469
5470
5471
5472
5473 for (unsigned _i = 0; _i < num_components; _i++) {
5474 const float src0 =
5475 _mesa_half_to_float(_src[0].u16[_i]);
5476 const float src1 =
5477 _mesa_half_to_float(_src[1].u16[_i]);
5478
5479 bool32_t dst = src0 < src1;
5480
5481 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
5482 }
5483
5484 break;
5485 }
5486 case 32: {
5487
5488
5489
5490
5491 for (unsigned _i = 0; _i < num_components; _i++) {
5492 const float32_t src0 =
5493 _src[0].f32[_i];
5494 const float32_t src1 =
5495 _src[1].f32[_i];
5496
5497 bool32_t dst = src0 < src1;
5498
5499 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
5500 }
5501
5502 break;
5503 }
5504 case 64: {
5505
5506
5507
5508
5509 for (unsigned _i = 0; _i < num_components; _i++) {
5510 const float64_t src0 =
5511 _src[0].f64[_i];
5512 const float64_t src1 =
5513 _src[1].f64[_i];
5514
5515 bool32_t dst = src0 < src1;
5516
5517 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
5518 }
5519
5520 break;
5521 }
5522
5523 default:
5524 unreachable("unknown bit width");
5525 }
5526
5527 return _dst_val;
5528 }
5529 static nir_const_value
evaluate_fmax(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)5530 evaluate_fmax(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
5531 MAYBE_UNUSED nir_const_value *_src)
5532 {
5533 nir_const_value _dst_val = { {0, } };
5534
5535 switch (bit_size) {
5536 case 16: {
5537
5538
5539
5540
5541 for (unsigned _i = 0; _i < num_components; _i++) {
5542 const float src0 =
5543 _mesa_half_to_float(_src[0].u16[_i]);
5544 const float src1 =
5545 _mesa_half_to_float(_src[1].u16[_i]);
5546
5547 float16_t dst = fmaxf(src0, src1);
5548
5549 _dst_val.u16[_i] = _mesa_float_to_half(dst);
5550 }
5551
5552 break;
5553 }
5554 case 32: {
5555
5556
5557
5558
5559 for (unsigned _i = 0; _i < num_components; _i++) {
5560 const float32_t src0 =
5561 _src[0].f32[_i];
5562 const float32_t src1 =
5563 _src[1].f32[_i];
5564
5565 float32_t dst = fmaxf(src0, src1);
5566
5567 _dst_val.f32[_i] = dst;
5568 }
5569
5570 break;
5571 }
5572 case 64: {
5573
5574
5575
5576
5577 for (unsigned _i = 0; _i < num_components; _i++) {
5578 const float64_t src0 =
5579 _src[0].f64[_i];
5580 const float64_t src1 =
5581 _src[1].f64[_i];
5582
5583 float64_t dst = fmaxf(src0, src1);
5584
5585 _dst_val.f64[_i] = dst;
5586 }
5587
5588 break;
5589 }
5590
5591 default:
5592 unreachable("unknown bit width");
5593 }
5594
5595 return _dst_val;
5596 }
5597 static nir_const_value
evaluate_fmin(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)5598 evaluate_fmin(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
5599 MAYBE_UNUSED nir_const_value *_src)
5600 {
5601 nir_const_value _dst_val = { {0, } };
5602
5603 switch (bit_size) {
5604 case 16: {
5605
5606
5607
5608
5609 for (unsigned _i = 0; _i < num_components; _i++) {
5610 const float src0 =
5611 _mesa_half_to_float(_src[0].u16[_i]);
5612 const float src1 =
5613 _mesa_half_to_float(_src[1].u16[_i]);
5614
5615 float16_t dst = fminf(src0, src1);
5616
5617 _dst_val.u16[_i] = _mesa_float_to_half(dst);
5618 }
5619
5620 break;
5621 }
5622 case 32: {
5623
5624
5625
5626
5627 for (unsigned _i = 0; _i < num_components; _i++) {
5628 const float32_t src0 =
5629 _src[0].f32[_i];
5630 const float32_t src1 =
5631 _src[1].f32[_i];
5632
5633 float32_t dst = fminf(src0, src1);
5634
5635 _dst_val.f32[_i] = dst;
5636 }
5637
5638 break;
5639 }
5640 case 64: {
5641
5642
5643
5644
5645 for (unsigned _i = 0; _i < num_components; _i++) {
5646 const float64_t src0 =
5647 _src[0].f64[_i];
5648 const float64_t src1 =
5649 _src[1].f64[_i];
5650
5651 float64_t dst = fminf(src0, src1);
5652
5653 _dst_val.f64[_i] = dst;
5654 }
5655
5656 break;
5657 }
5658
5659 default:
5660 unreachable("unknown bit width");
5661 }
5662
5663 return _dst_val;
5664 }
5665 static nir_const_value
evaluate_fmod(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)5666 evaluate_fmod(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
5667 MAYBE_UNUSED nir_const_value *_src)
5668 {
5669 nir_const_value _dst_val = { {0, } };
5670
5671 switch (bit_size) {
5672 case 16: {
5673
5674
5675
5676
5677 for (unsigned _i = 0; _i < num_components; _i++) {
5678 const float src0 =
5679 _mesa_half_to_float(_src[0].u16[_i]);
5680 const float src1 =
5681 _mesa_half_to_float(_src[1].u16[_i]);
5682
5683 float16_t dst = src0 - src1 * floorf(src0 / src1);
5684
5685 _dst_val.u16[_i] = _mesa_float_to_half(dst);
5686 }
5687
5688 break;
5689 }
5690 case 32: {
5691
5692
5693
5694
5695 for (unsigned _i = 0; _i < num_components; _i++) {
5696 const float32_t src0 =
5697 _src[0].f32[_i];
5698 const float32_t src1 =
5699 _src[1].f32[_i];
5700
5701 float32_t dst = src0 - src1 * floorf(src0 / src1);
5702
5703 _dst_val.f32[_i] = dst;
5704 }
5705
5706 break;
5707 }
5708 case 64: {
5709
5710
5711
5712
5713 for (unsigned _i = 0; _i < num_components; _i++) {
5714 const float64_t src0 =
5715 _src[0].f64[_i];
5716 const float64_t src1 =
5717 _src[1].f64[_i];
5718
5719 float64_t dst = src0 - src1 * floorf(src0 / src1);
5720
5721 _dst_val.f64[_i] = dst;
5722 }
5723
5724 break;
5725 }
5726
5727 default:
5728 unreachable("unknown bit width");
5729 }
5730
5731 return _dst_val;
5732 }
5733 static nir_const_value
evaluate_fmov(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)5734 evaluate_fmov(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
5735 MAYBE_UNUSED nir_const_value *_src)
5736 {
5737 nir_const_value _dst_val = { {0, } };
5738
5739 switch (bit_size) {
5740 case 16: {
5741
5742
5743
5744
5745 for (unsigned _i = 0; _i < num_components; _i++) {
5746 const float src0 =
5747 _mesa_half_to_float(_src[0].u16[_i]);
5748
5749 float16_t dst = src0;
5750
5751 _dst_val.u16[_i] = _mesa_float_to_half(dst);
5752 }
5753
5754 break;
5755 }
5756 case 32: {
5757
5758
5759
5760
5761 for (unsigned _i = 0; _i < num_components; _i++) {
5762 const float32_t src0 =
5763 _src[0].f32[_i];
5764
5765 float32_t dst = src0;
5766
5767 _dst_val.f32[_i] = dst;
5768 }
5769
5770 break;
5771 }
5772 case 64: {
5773
5774
5775
5776
5777 for (unsigned _i = 0; _i < num_components; _i++) {
5778 const float64_t src0 =
5779 _src[0].f64[_i];
5780
5781 float64_t dst = src0;
5782
5783 _dst_val.f64[_i] = dst;
5784 }
5785
5786 break;
5787 }
5788
5789 default:
5790 unreachable("unknown bit width");
5791 }
5792
5793 return _dst_val;
5794 }
5795 static nir_const_value
evaluate_fmul(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)5796 evaluate_fmul(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
5797 MAYBE_UNUSED nir_const_value *_src)
5798 {
5799 nir_const_value _dst_val = { {0, } };
5800
5801 switch (bit_size) {
5802 case 16: {
5803
5804
5805
5806
5807 for (unsigned _i = 0; _i < num_components; _i++) {
5808 const float src0 =
5809 _mesa_half_to_float(_src[0].u16[_i]);
5810 const float src1 =
5811 _mesa_half_to_float(_src[1].u16[_i]);
5812
5813 float16_t dst = src0 * src1;
5814
5815 _dst_val.u16[_i] = _mesa_float_to_half(dst);
5816 }
5817
5818 break;
5819 }
5820 case 32: {
5821
5822
5823
5824
5825 for (unsigned _i = 0; _i < num_components; _i++) {
5826 const float32_t src0 =
5827 _src[0].f32[_i];
5828 const float32_t src1 =
5829 _src[1].f32[_i];
5830
5831 float32_t dst = src0 * src1;
5832
5833 _dst_val.f32[_i] = dst;
5834 }
5835
5836 break;
5837 }
5838 case 64: {
5839
5840
5841
5842
5843 for (unsigned _i = 0; _i < num_components; _i++) {
5844 const float64_t src0 =
5845 _src[0].f64[_i];
5846 const float64_t src1 =
5847 _src[1].f64[_i];
5848
5849 float64_t dst = src0 * src1;
5850
5851 _dst_val.f64[_i] = dst;
5852 }
5853
5854 break;
5855 }
5856
5857 default:
5858 unreachable("unknown bit width");
5859 }
5860
5861 return _dst_val;
5862 }
5863 static nir_const_value
evaluate_fne(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)5864 evaluate_fne(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
5865 MAYBE_UNUSED nir_const_value *_src)
5866 {
5867 nir_const_value _dst_val = { {0, } };
5868
5869 switch (bit_size) {
5870 case 16: {
5871
5872
5873
5874
5875 for (unsigned _i = 0; _i < num_components; _i++) {
5876 const float src0 =
5877 _mesa_half_to_float(_src[0].u16[_i]);
5878 const float src1 =
5879 _mesa_half_to_float(_src[1].u16[_i]);
5880
5881 bool32_t dst = src0 != src1;
5882
5883 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
5884 }
5885
5886 break;
5887 }
5888 case 32: {
5889
5890
5891
5892
5893 for (unsigned _i = 0; _i < num_components; _i++) {
5894 const float32_t src0 =
5895 _src[0].f32[_i];
5896 const float32_t src1 =
5897 _src[1].f32[_i];
5898
5899 bool32_t dst = src0 != src1;
5900
5901 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
5902 }
5903
5904 break;
5905 }
5906 case 64: {
5907
5908
5909
5910
5911 for (unsigned _i = 0; _i < num_components; _i++) {
5912 const float64_t src0 =
5913 _src[0].f64[_i];
5914 const float64_t src1 =
5915 _src[1].f64[_i];
5916
5917 bool32_t dst = src0 != src1;
5918
5919 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
5920 }
5921
5922 break;
5923 }
5924
5925 default:
5926 unreachable("unknown bit width");
5927 }
5928
5929 return _dst_val;
5930 }
5931 static nir_const_value
evaluate_fneg(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)5932 evaluate_fneg(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
5933 MAYBE_UNUSED nir_const_value *_src)
5934 {
5935 nir_const_value _dst_val = { {0, } };
5936
5937 switch (bit_size) {
5938 case 16: {
5939
5940
5941
5942
5943 for (unsigned _i = 0; _i < num_components; _i++) {
5944 const float src0 =
5945 _mesa_half_to_float(_src[0].u16[_i]);
5946
5947 float16_t dst = -src0;
5948
5949 _dst_val.u16[_i] = _mesa_float_to_half(dst);
5950 }
5951
5952 break;
5953 }
5954 case 32: {
5955
5956
5957
5958
5959 for (unsigned _i = 0; _i < num_components; _i++) {
5960 const float32_t src0 =
5961 _src[0].f32[_i];
5962
5963 float32_t dst = -src0;
5964
5965 _dst_val.f32[_i] = dst;
5966 }
5967
5968 break;
5969 }
5970 case 64: {
5971
5972
5973
5974
5975 for (unsigned _i = 0; _i < num_components; _i++) {
5976 const float64_t src0 =
5977 _src[0].f64[_i];
5978
5979 float64_t dst = -src0;
5980
5981 _dst_val.f64[_i] = dst;
5982 }
5983
5984 break;
5985 }
5986
5987 default:
5988 unreachable("unknown bit width");
5989 }
5990
5991 return _dst_val;
5992 }
5993 static nir_const_value
evaluate_fnoise1_1(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)5994 evaluate_fnoise1_1(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
5995 MAYBE_UNUSED nir_const_value *_src)
5996 {
5997 nir_const_value _dst_val = { {0, } };
5998
5999 switch (bit_size) {
6000 case 16: {
6001
6002
6003
6004
6005 struct float16_vec dst;
6006
6007 dst.x = dst.y = dst.z = dst.w = 0.0f;
6008
6009 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
6010
6011 break;
6012 }
6013 case 32: {
6014
6015
6016
6017
6018 struct float32_vec dst;
6019
6020 dst.x = dst.y = dst.z = dst.w = 0.0f;
6021
6022 _dst_val.f32[0] = dst.x;
6023
6024 break;
6025 }
6026 case 64: {
6027
6028
6029
6030
6031 struct float64_vec dst;
6032
6033 dst.x = dst.y = dst.z = dst.w = 0.0f;
6034
6035 _dst_val.f64[0] = dst.x;
6036
6037 break;
6038 }
6039
6040 default:
6041 unreachable("unknown bit width");
6042 }
6043
6044 return _dst_val;
6045 }
6046 static nir_const_value
evaluate_fnoise1_2(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)6047 evaluate_fnoise1_2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
6048 MAYBE_UNUSED nir_const_value *_src)
6049 {
6050 nir_const_value _dst_val = { {0, } };
6051
6052 switch (bit_size) {
6053 case 16: {
6054
6055
6056
6057
6058 struct float16_vec dst;
6059
6060 dst.x = dst.y = dst.z = dst.w = 0.0f;
6061
6062 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
6063
6064 break;
6065 }
6066 case 32: {
6067
6068
6069
6070
6071 struct float32_vec dst;
6072
6073 dst.x = dst.y = dst.z = dst.w = 0.0f;
6074
6075 _dst_val.f32[0] = dst.x;
6076
6077 break;
6078 }
6079 case 64: {
6080
6081
6082
6083
6084 struct float64_vec dst;
6085
6086 dst.x = dst.y = dst.z = dst.w = 0.0f;
6087
6088 _dst_val.f64[0] = dst.x;
6089
6090 break;
6091 }
6092
6093 default:
6094 unreachable("unknown bit width");
6095 }
6096
6097 return _dst_val;
6098 }
6099 static nir_const_value
evaluate_fnoise1_3(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)6100 evaluate_fnoise1_3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
6101 MAYBE_UNUSED nir_const_value *_src)
6102 {
6103 nir_const_value _dst_val = { {0, } };
6104
6105 switch (bit_size) {
6106 case 16: {
6107
6108
6109
6110
6111 struct float16_vec dst;
6112
6113 dst.x = dst.y = dst.z = dst.w = 0.0f;
6114
6115 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
6116
6117 break;
6118 }
6119 case 32: {
6120
6121
6122
6123
6124 struct float32_vec dst;
6125
6126 dst.x = dst.y = dst.z = dst.w = 0.0f;
6127
6128 _dst_val.f32[0] = dst.x;
6129
6130 break;
6131 }
6132 case 64: {
6133
6134
6135
6136
6137 struct float64_vec dst;
6138
6139 dst.x = dst.y = dst.z = dst.w = 0.0f;
6140
6141 _dst_val.f64[0] = dst.x;
6142
6143 break;
6144 }
6145
6146 default:
6147 unreachable("unknown bit width");
6148 }
6149
6150 return _dst_val;
6151 }
6152 static nir_const_value
evaluate_fnoise1_4(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)6153 evaluate_fnoise1_4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
6154 MAYBE_UNUSED nir_const_value *_src)
6155 {
6156 nir_const_value _dst_val = { {0, } };
6157
6158 switch (bit_size) {
6159 case 16: {
6160
6161
6162
6163
6164 struct float16_vec dst;
6165
6166 dst.x = dst.y = dst.z = dst.w = 0.0f;
6167
6168 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
6169
6170 break;
6171 }
6172 case 32: {
6173
6174
6175
6176
6177 struct float32_vec dst;
6178
6179 dst.x = dst.y = dst.z = dst.w = 0.0f;
6180
6181 _dst_val.f32[0] = dst.x;
6182
6183 break;
6184 }
6185 case 64: {
6186
6187
6188
6189
6190 struct float64_vec dst;
6191
6192 dst.x = dst.y = dst.z = dst.w = 0.0f;
6193
6194 _dst_val.f64[0] = dst.x;
6195
6196 break;
6197 }
6198
6199 default:
6200 unreachable("unknown bit width");
6201 }
6202
6203 return _dst_val;
6204 }
6205 static nir_const_value
evaluate_fnoise2_1(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)6206 evaluate_fnoise2_1(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
6207 MAYBE_UNUSED nir_const_value *_src)
6208 {
6209 nir_const_value _dst_val = { {0, } };
6210
6211 switch (bit_size) {
6212 case 16: {
6213
6214
6215
6216
6217 struct float16_vec dst;
6218
6219 dst.x = dst.y = dst.z = dst.w = 0.0f;
6220
6221 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
6222 _dst_val.u16[1] = _mesa_float_to_half(dst.y);
6223
6224 break;
6225 }
6226 case 32: {
6227
6228
6229
6230
6231 struct float32_vec dst;
6232
6233 dst.x = dst.y = dst.z = dst.w = 0.0f;
6234
6235 _dst_val.f32[0] = dst.x;
6236 _dst_val.f32[1] = dst.y;
6237
6238 break;
6239 }
6240 case 64: {
6241
6242
6243
6244
6245 struct float64_vec dst;
6246
6247 dst.x = dst.y = dst.z = dst.w = 0.0f;
6248
6249 _dst_val.f64[0] = dst.x;
6250 _dst_val.f64[1] = dst.y;
6251
6252 break;
6253 }
6254
6255 default:
6256 unreachable("unknown bit width");
6257 }
6258
6259 return _dst_val;
6260 }
6261 static nir_const_value
evaluate_fnoise2_2(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)6262 evaluate_fnoise2_2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
6263 MAYBE_UNUSED nir_const_value *_src)
6264 {
6265 nir_const_value _dst_val = { {0, } };
6266
6267 switch (bit_size) {
6268 case 16: {
6269
6270
6271
6272
6273 struct float16_vec dst;
6274
6275 dst.x = dst.y = dst.z = dst.w = 0.0f;
6276
6277 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
6278 _dst_val.u16[1] = _mesa_float_to_half(dst.y);
6279
6280 break;
6281 }
6282 case 32: {
6283
6284
6285
6286
6287 struct float32_vec dst;
6288
6289 dst.x = dst.y = dst.z = dst.w = 0.0f;
6290
6291 _dst_val.f32[0] = dst.x;
6292 _dst_val.f32[1] = dst.y;
6293
6294 break;
6295 }
6296 case 64: {
6297
6298
6299
6300
6301 struct float64_vec dst;
6302
6303 dst.x = dst.y = dst.z = dst.w = 0.0f;
6304
6305 _dst_val.f64[0] = dst.x;
6306 _dst_val.f64[1] = dst.y;
6307
6308 break;
6309 }
6310
6311 default:
6312 unreachable("unknown bit width");
6313 }
6314
6315 return _dst_val;
6316 }
6317 static nir_const_value
evaluate_fnoise2_3(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)6318 evaluate_fnoise2_3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
6319 MAYBE_UNUSED nir_const_value *_src)
6320 {
6321 nir_const_value _dst_val = { {0, } };
6322
6323 switch (bit_size) {
6324 case 16: {
6325
6326
6327
6328
6329 struct float16_vec dst;
6330
6331 dst.x = dst.y = dst.z = dst.w = 0.0f;
6332
6333 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
6334 _dst_val.u16[1] = _mesa_float_to_half(dst.y);
6335
6336 break;
6337 }
6338 case 32: {
6339
6340
6341
6342
6343 struct float32_vec dst;
6344
6345 dst.x = dst.y = dst.z = dst.w = 0.0f;
6346
6347 _dst_val.f32[0] = dst.x;
6348 _dst_val.f32[1] = dst.y;
6349
6350 break;
6351 }
6352 case 64: {
6353
6354
6355
6356
6357 struct float64_vec dst;
6358
6359 dst.x = dst.y = dst.z = dst.w = 0.0f;
6360
6361 _dst_val.f64[0] = dst.x;
6362 _dst_val.f64[1] = dst.y;
6363
6364 break;
6365 }
6366
6367 default:
6368 unreachable("unknown bit width");
6369 }
6370
6371 return _dst_val;
6372 }
6373 static nir_const_value
evaluate_fnoise2_4(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)6374 evaluate_fnoise2_4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
6375 MAYBE_UNUSED nir_const_value *_src)
6376 {
6377 nir_const_value _dst_val = { {0, } };
6378
6379 switch (bit_size) {
6380 case 16: {
6381
6382
6383
6384
6385 struct float16_vec dst;
6386
6387 dst.x = dst.y = dst.z = dst.w = 0.0f;
6388
6389 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
6390 _dst_val.u16[1] = _mesa_float_to_half(dst.y);
6391
6392 break;
6393 }
6394 case 32: {
6395
6396
6397
6398
6399 struct float32_vec dst;
6400
6401 dst.x = dst.y = dst.z = dst.w = 0.0f;
6402
6403 _dst_val.f32[0] = dst.x;
6404 _dst_val.f32[1] = dst.y;
6405
6406 break;
6407 }
6408 case 64: {
6409
6410
6411
6412
6413 struct float64_vec dst;
6414
6415 dst.x = dst.y = dst.z = dst.w = 0.0f;
6416
6417 _dst_val.f64[0] = dst.x;
6418 _dst_val.f64[1] = dst.y;
6419
6420 break;
6421 }
6422
6423 default:
6424 unreachable("unknown bit width");
6425 }
6426
6427 return _dst_val;
6428 }
6429 static nir_const_value
evaluate_fnoise3_1(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)6430 evaluate_fnoise3_1(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
6431 MAYBE_UNUSED nir_const_value *_src)
6432 {
6433 nir_const_value _dst_val = { {0, } };
6434
6435 switch (bit_size) {
6436 case 16: {
6437
6438
6439
6440
6441 struct float16_vec dst;
6442
6443 dst.x = dst.y = dst.z = dst.w = 0.0f;
6444
6445 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
6446 _dst_val.u16[1] = _mesa_float_to_half(dst.y);
6447 _dst_val.u16[2] = _mesa_float_to_half(dst.z);
6448
6449 break;
6450 }
6451 case 32: {
6452
6453
6454
6455
6456 struct float32_vec dst;
6457
6458 dst.x = dst.y = dst.z = dst.w = 0.0f;
6459
6460 _dst_val.f32[0] = dst.x;
6461 _dst_val.f32[1] = dst.y;
6462 _dst_val.f32[2] = dst.z;
6463
6464 break;
6465 }
6466 case 64: {
6467
6468
6469
6470
6471 struct float64_vec dst;
6472
6473 dst.x = dst.y = dst.z = dst.w = 0.0f;
6474
6475 _dst_val.f64[0] = dst.x;
6476 _dst_val.f64[1] = dst.y;
6477 _dst_val.f64[2] = dst.z;
6478
6479 break;
6480 }
6481
6482 default:
6483 unreachable("unknown bit width");
6484 }
6485
6486 return _dst_val;
6487 }
6488 static nir_const_value
evaluate_fnoise3_2(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)6489 evaluate_fnoise3_2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
6490 MAYBE_UNUSED nir_const_value *_src)
6491 {
6492 nir_const_value _dst_val = { {0, } };
6493
6494 switch (bit_size) {
6495 case 16: {
6496
6497
6498
6499
6500 struct float16_vec dst;
6501
6502 dst.x = dst.y = dst.z = dst.w = 0.0f;
6503
6504 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
6505 _dst_val.u16[1] = _mesa_float_to_half(dst.y);
6506 _dst_val.u16[2] = _mesa_float_to_half(dst.z);
6507
6508 break;
6509 }
6510 case 32: {
6511
6512
6513
6514
6515 struct float32_vec dst;
6516
6517 dst.x = dst.y = dst.z = dst.w = 0.0f;
6518
6519 _dst_val.f32[0] = dst.x;
6520 _dst_val.f32[1] = dst.y;
6521 _dst_val.f32[2] = dst.z;
6522
6523 break;
6524 }
6525 case 64: {
6526
6527
6528
6529
6530 struct float64_vec dst;
6531
6532 dst.x = dst.y = dst.z = dst.w = 0.0f;
6533
6534 _dst_val.f64[0] = dst.x;
6535 _dst_val.f64[1] = dst.y;
6536 _dst_val.f64[2] = dst.z;
6537
6538 break;
6539 }
6540
6541 default:
6542 unreachable("unknown bit width");
6543 }
6544
6545 return _dst_val;
6546 }
6547 static nir_const_value
evaluate_fnoise3_3(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)6548 evaluate_fnoise3_3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
6549 MAYBE_UNUSED nir_const_value *_src)
6550 {
6551 nir_const_value _dst_val = { {0, } };
6552
6553 switch (bit_size) {
6554 case 16: {
6555
6556
6557
6558
6559 struct float16_vec dst;
6560
6561 dst.x = dst.y = dst.z = dst.w = 0.0f;
6562
6563 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
6564 _dst_val.u16[1] = _mesa_float_to_half(dst.y);
6565 _dst_val.u16[2] = _mesa_float_to_half(dst.z);
6566
6567 break;
6568 }
6569 case 32: {
6570
6571
6572
6573
6574 struct float32_vec dst;
6575
6576 dst.x = dst.y = dst.z = dst.w = 0.0f;
6577
6578 _dst_val.f32[0] = dst.x;
6579 _dst_val.f32[1] = dst.y;
6580 _dst_val.f32[2] = dst.z;
6581
6582 break;
6583 }
6584 case 64: {
6585
6586
6587
6588
6589 struct float64_vec dst;
6590
6591 dst.x = dst.y = dst.z = dst.w = 0.0f;
6592
6593 _dst_val.f64[0] = dst.x;
6594 _dst_val.f64[1] = dst.y;
6595 _dst_val.f64[2] = dst.z;
6596
6597 break;
6598 }
6599
6600 default:
6601 unreachable("unknown bit width");
6602 }
6603
6604 return _dst_val;
6605 }
6606 static nir_const_value
evaluate_fnoise3_4(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)6607 evaluate_fnoise3_4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
6608 MAYBE_UNUSED nir_const_value *_src)
6609 {
6610 nir_const_value _dst_val = { {0, } };
6611
6612 switch (bit_size) {
6613 case 16: {
6614
6615
6616
6617
6618 struct float16_vec dst;
6619
6620 dst.x = dst.y = dst.z = dst.w = 0.0f;
6621
6622 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
6623 _dst_val.u16[1] = _mesa_float_to_half(dst.y);
6624 _dst_val.u16[2] = _mesa_float_to_half(dst.z);
6625
6626 break;
6627 }
6628 case 32: {
6629
6630
6631
6632
6633 struct float32_vec dst;
6634
6635 dst.x = dst.y = dst.z = dst.w = 0.0f;
6636
6637 _dst_val.f32[0] = dst.x;
6638 _dst_val.f32[1] = dst.y;
6639 _dst_val.f32[2] = dst.z;
6640
6641 break;
6642 }
6643 case 64: {
6644
6645
6646
6647
6648 struct float64_vec dst;
6649
6650 dst.x = dst.y = dst.z = dst.w = 0.0f;
6651
6652 _dst_val.f64[0] = dst.x;
6653 _dst_val.f64[1] = dst.y;
6654 _dst_val.f64[2] = dst.z;
6655
6656 break;
6657 }
6658
6659 default:
6660 unreachable("unknown bit width");
6661 }
6662
6663 return _dst_val;
6664 }
6665 static nir_const_value
evaluate_fnoise4_1(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)6666 evaluate_fnoise4_1(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
6667 MAYBE_UNUSED nir_const_value *_src)
6668 {
6669 nir_const_value _dst_val = { {0, } };
6670
6671 switch (bit_size) {
6672 case 16: {
6673
6674
6675
6676
6677 struct float16_vec dst;
6678
6679 dst.x = dst.y = dst.z = dst.w = 0.0f;
6680
6681 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
6682 _dst_val.u16[1] = _mesa_float_to_half(dst.y);
6683 _dst_val.u16[2] = _mesa_float_to_half(dst.z);
6684 _dst_val.u16[3] = _mesa_float_to_half(dst.w);
6685
6686 break;
6687 }
6688 case 32: {
6689
6690
6691
6692
6693 struct float32_vec dst;
6694
6695 dst.x = dst.y = dst.z = dst.w = 0.0f;
6696
6697 _dst_val.f32[0] = dst.x;
6698 _dst_val.f32[1] = dst.y;
6699 _dst_val.f32[2] = dst.z;
6700 _dst_val.f32[3] = dst.w;
6701
6702 break;
6703 }
6704 case 64: {
6705
6706
6707
6708
6709 struct float64_vec dst;
6710
6711 dst.x = dst.y = dst.z = dst.w = 0.0f;
6712
6713 _dst_val.f64[0] = dst.x;
6714 _dst_val.f64[1] = dst.y;
6715 _dst_val.f64[2] = dst.z;
6716 _dst_val.f64[3] = dst.w;
6717
6718 break;
6719 }
6720
6721 default:
6722 unreachable("unknown bit width");
6723 }
6724
6725 return _dst_val;
6726 }
6727 static nir_const_value
evaluate_fnoise4_2(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)6728 evaluate_fnoise4_2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
6729 MAYBE_UNUSED nir_const_value *_src)
6730 {
6731 nir_const_value _dst_val = { {0, } };
6732
6733 switch (bit_size) {
6734 case 16: {
6735
6736
6737
6738
6739 struct float16_vec dst;
6740
6741 dst.x = dst.y = dst.z = dst.w = 0.0f;
6742
6743 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
6744 _dst_val.u16[1] = _mesa_float_to_half(dst.y);
6745 _dst_val.u16[2] = _mesa_float_to_half(dst.z);
6746 _dst_val.u16[3] = _mesa_float_to_half(dst.w);
6747
6748 break;
6749 }
6750 case 32: {
6751
6752
6753
6754
6755 struct float32_vec dst;
6756
6757 dst.x = dst.y = dst.z = dst.w = 0.0f;
6758
6759 _dst_val.f32[0] = dst.x;
6760 _dst_val.f32[1] = dst.y;
6761 _dst_val.f32[2] = dst.z;
6762 _dst_val.f32[3] = dst.w;
6763
6764 break;
6765 }
6766 case 64: {
6767
6768
6769
6770
6771 struct float64_vec dst;
6772
6773 dst.x = dst.y = dst.z = dst.w = 0.0f;
6774
6775 _dst_val.f64[0] = dst.x;
6776 _dst_val.f64[1] = dst.y;
6777 _dst_val.f64[2] = dst.z;
6778 _dst_val.f64[3] = dst.w;
6779
6780 break;
6781 }
6782
6783 default:
6784 unreachable("unknown bit width");
6785 }
6786
6787 return _dst_val;
6788 }
6789 static nir_const_value
evaluate_fnoise4_3(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)6790 evaluate_fnoise4_3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
6791 MAYBE_UNUSED nir_const_value *_src)
6792 {
6793 nir_const_value _dst_val = { {0, } };
6794
6795 switch (bit_size) {
6796 case 16: {
6797
6798
6799
6800
6801 struct float16_vec dst;
6802
6803 dst.x = dst.y = dst.z = dst.w = 0.0f;
6804
6805 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
6806 _dst_val.u16[1] = _mesa_float_to_half(dst.y);
6807 _dst_val.u16[2] = _mesa_float_to_half(dst.z);
6808 _dst_val.u16[3] = _mesa_float_to_half(dst.w);
6809
6810 break;
6811 }
6812 case 32: {
6813
6814
6815
6816
6817 struct float32_vec dst;
6818
6819 dst.x = dst.y = dst.z = dst.w = 0.0f;
6820
6821 _dst_val.f32[0] = dst.x;
6822 _dst_val.f32[1] = dst.y;
6823 _dst_val.f32[2] = dst.z;
6824 _dst_val.f32[3] = dst.w;
6825
6826 break;
6827 }
6828 case 64: {
6829
6830
6831
6832
6833 struct float64_vec dst;
6834
6835 dst.x = dst.y = dst.z = dst.w = 0.0f;
6836
6837 _dst_val.f64[0] = dst.x;
6838 _dst_val.f64[1] = dst.y;
6839 _dst_val.f64[2] = dst.z;
6840 _dst_val.f64[3] = dst.w;
6841
6842 break;
6843 }
6844
6845 default:
6846 unreachable("unknown bit width");
6847 }
6848
6849 return _dst_val;
6850 }
6851 static nir_const_value
evaluate_fnoise4_4(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)6852 evaluate_fnoise4_4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
6853 MAYBE_UNUSED nir_const_value *_src)
6854 {
6855 nir_const_value _dst_val = { {0, } };
6856
6857 switch (bit_size) {
6858 case 16: {
6859
6860
6861
6862
6863 struct float16_vec dst;
6864
6865 dst.x = dst.y = dst.z = dst.w = 0.0f;
6866
6867 _dst_val.u16[0] = _mesa_float_to_half(dst.x);
6868 _dst_val.u16[1] = _mesa_float_to_half(dst.y);
6869 _dst_val.u16[2] = _mesa_float_to_half(dst.z);
6870 _dst_val.u16[3] = _mesa_float_to_half(dst.w);
6871
6872 break;
6873 }
6874 case 32: {
6875
6876
6877
6878
6879 struct float32_vec dst;
6880
6881 dst.x = dst.y = dst.z = dst.w = 0.0f;
6882
6883 _dst_val.f32[0] = dst.x;
6884 _dst_val.f32[1] = dst.y;
6885 _dst_val.f32[2] = dst.z;
6886 _dst_val.f32[3] = dst.w;
6887
6888 break;
6889 }
6890 case 64: {
6891
6892
6893
6894
6895 struct float64_vec dst;
6896
6897 dst.x = dst.y = dst.z = dst.w = 0.0f;
6898
6899 _dst_val.f64[0] = dst.x;
6900 _dst_val.f64[1] = dst.y;
6901 _dst_val.f64[2] = dst.z;
6902 _dst_val.f64[3] = dst.w;
6903
6904 break;
6905 }
6906
6907 default:
6908 unreachable("unknown bit width");
6909 }
6910
6911 return _dst_val;
6912 }
6913 static nir_const_value
evaluate_fnot(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)6914 evaluate_fnot(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
6915 MAYBE_UNUSED nir_const_value *_src)
6916 {
6917 nir_const_value _dst_val = { {0, } };
6918
6919 switch (bit_size) {
6920 case 16: {
6921
6922
6923
6924
6925 for (unsigned _i = 0; _i < num_components; _i++) {
6926 const float src0 =
6927 _mesa_half_to_float(_src[0].u16[_i]);
6928
6929 float16_t dst = bit_size == 64 ? ((src0 == 0.0) ? 1.0 : 0.0f) : ((src0 == 0.0f) ? 1.0f : 0.0f);
6930
6931 _dst_val.u16[_i] = _mesa_float_to_half(dst);
6932 }
6933
6934 break;
6935 }
6936 case 32: {
6937
6938
6939
6940
6941 for (unsigned _i = 0; _i < num_components; _i++) {
6942 const float32_t src0 =
6943 _src[0].f32[_i];
6944
6945 float32_t dst = bit_size == 64 ? ((src0 == 0.0) ? 1.0 : 0.0f) : ((src0 == 0.0f) ? 1.0f : 0.0f);
6946
6947 _dst_val.f32[_i] = dst;
6948 }
6949
6950 break;
6951 }
6952 case 64: {
6953
6954
6955
6956
6957 for (unsigned _i = 0; _i < num_components; _i++) {
6958 const float64_t src0 =
6959 _src[0].f64[_i];
6960
6961 float64_t dst = bit_size == 64 ? ((src0 == 0.0) ? 1.0 : 0.0f) : ((src0 == 0.0f) ? 1.0f : 0.0f);
6962
6963 _dst_val.f64[_i] = dst;
6964 }
6965
6966 break;
6967 }
6968
6969 default:
6970 unreachable("unknown bit width");
6971 }
6972
6973 return _dst_val;
6974 }
6975 static nir_const_value
evaluate_for(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)6976 evaluate_for(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
6977 MAYBE_UNUSED nir_const_value *_src)
6978 {
6979 nir_const_value _dst_val = { {0, } };
6980
6981
6982
6983
6984
6985 for (unsigned _i = 0; _i < num_components; _i++) {
6986 const float32_t src0 =
6987 _src[0].f32[_i];
6988 const float32_t src1 =
6989 _src[1].f32[_i];
6990
6991 float32_t dst = ((src0 != 0.0f) || (src1 != 0.0f)) ? 1.0f : 0.0f;
6992
6993 _dst_val.f32[_i] = dst;
6994 }
6995
6996
6997 return _dst_val;
6998 }
6999 static nir_const_value
evaluate_fpow(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)7000 evaluate_fpow(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
7001 MAYBE_UNUSED nir_const_value *_src)
7002 {
7003 nir_const_value _dst_val = { {0, } };
7004
7005 switch (bit_size) {
7006 case 16: {
7007
7008
7009
7010
7011 for (unsigned _i = 0; _i < num_components; _i++) {
7012 const float src0 =
7013 _mesa_half_to_float(_src[0].u16[_i]);
7014 const float src1 =
7015 _mesa_half_to_float(_src[1].u16[_i]);
7016
7017 float16_t dst = bit_size == 64 ? powf(src0, src1) : pow(src0, src1);
7018
7019 _dst_val.u16[_i] = _mesa_float_to_half(dst);
7020 }
7021
7022 break;
7023 }
7024 case 32: {
7025
7026
7027
7028
7029 for (unsigned _i = 0; _i < num_components; _i++) {
7030 const float32_t src0 =
7031 _src[0].f32[_i];
7032 const float32_t src1 =
7033 _src[1].f32[_i];
7034
7035 float32_t dst = bit_size == 64 ? powf(src0, src1) : pow(src0, src1);
7036
7037 _dst_val.f32[_i] = dst;
7038 }
7039
7040 break;
7041 }
7042 case 64: {
7043
7044
7045
7046
7047 for (unsigned _i = 0; _i < num_components; _i++) {
7048 const float64_t src0 =
7049 _src[0].f64[_i];
7050 const float64_t src1 =
7051 _src[1].f64[_i];
7052
7053 float64_t dst = bit_size == 64 ? powf(src0, src1) : pow(src0, src1);
7054
7055 _dst_val.f64[_i] = dst;
7056 }
7057
7058 break;
7059 }
7060
7061 default:
7062 unreachable("unknown bit width");
7063 }
7064
7065 return _dst_val;
7066 }
7067 static nir_const_value
evaluate_fquantize2f16(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)7068 evaluate_fquantize2f16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
7069 MAYBE_UNUSED nir_const_value *_src)
7070 {
7071 nir_const_value _dst_val = { {0, } };
7072
7073 switch (bit_size) {
7074 case 16: {
7075
7076
7077
7078
7079 for (unsigned _i = 0; _i < num_components; _i++) {
7080 const float src0 =
7081 _mesa_half_to_float(_src[0].u16[_i]);
7082
7083 float16_t dst = (fabs(src0) < ldexpf(1.0, -14)) ? copysignf(0.0f, src0) : _mesa_half_to_float(_mesa_float_to_half(src0));
7084
7085 _dst_val.u16[_i] = _mesa_float_to_half(dst);
7086 }
7087
7088 break;
7089 }
7090 case 32: {
7091
7092
7093
7094
7095 for (unsigned _i = 0; _i < num_components; _i++) {
7096 const float32_t src0 =
7097 _src[0].f32[_i];
7098
7099 float32_t dst = (fabs(src0) < ldexpf(1.0, -14)) ? copysignf(0.0f, src0) : _mesa_half_to_float(_mesa_float_to_half(src0));
7100
7101 _dst_val.f32[_i] = dst;
7102 }
7103
7104 break;
7105 }
7106 case 64: {
7107
7108
7109
7110
7111 for (unsigned _i = 0; _i < num_components; _i++) {
7112 const float64_t src0 =
7113 _src[0].f64[_i];
7114
7115 float64_t dst = (fabs(src0) < ldexpf(1.0, -14)) ? copysignf(0.0f, src0) : _mesa_half_to_float(_mesa_float_to_half(src0));
7116
7117 _dst_val.f64[_i] = dst;
7118 }
7119
7120 break;
7121 }
7122
7123 default:
7124 unreachable("unknown bit width");
7125 }
7126
7127 return _dst_val;
7128 }
7129 static nir_const_value
evaluate_frcp(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)7130 evaluate_frcp(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
7131 MAYBE_UNUSED nir_const_value *_src)
7132 {
7133 nir_const_value _dst_val = { {0, } };
7134
7135 switch (bit_size) {
7136 case 16: {
7137
7138
7139
7140
7141 for (unsigned _i = 0; _i < num_components; _i++) {
7142 const float src0 =
7143 _mesa_half_to_float(_src[0].u16[_i]);
7144
7145 float16_t dst = bit_size == 64 ? 1.0 / src0 : 1.0f / src0;
7146
7147 _dst_val.u16[_i] = _mesa_float_to_half(dst);
7148 }
7149
7150 break;
7151 }
7152 case 32: {
7153
7154
7155
7156
7157 for (unsigned _i = 0; _i < num_components; _i++) {
7158 const float32_t src0 =
7159 _src[0].f32[_i];
7160
7161 float32_t dst = bit_size == 64 ? 1.0 / src0 : 1.0f / src0;
7162
7163 _dst_val.f32[_i] = dst;
7164 }
7165
7166 break;
7167 }
7168 case 64: {
7169
7170
7171
7172
7173 for (unsigned _i = 0; _i < num_components; _i++) {
7174 const float64_t src0 =
7175 _src[0].f64[_i];
7176
7177 float64_t dst = bit_size == 64 ? 1.0 / src0 : 1.0f / src0;
7178
7179 _dst_val.f64[_i] = dst;
7180 }
7181
7182 break;
7183 }
7184
7185 default:
7186 unreachable("unknown bit width");
7187 }
7188
7189 return _dst_val;
7190 }
7191 static nir_const_value
evaluate_frem(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)7192 evaluate_frem(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
7193 MAYBE_UNUSED nir_const_value *_src)
7194 {
7195 nir_const_value _dst_val = { {0, } };
7196
7197 switch (bit_size) {
7198 case 16: {
7199
7200
7201
7202
7203 for (unsigned _i = 0; _i < num_components; _i++) {
7204 const float src0 =
7205 _mesa_half_to_float(_src[0].u16[_i]);
7206 const float src1 =
7207 _mesa_half_to_float(_src[1].u16[_i]);
7208
7209 float16_t dst = src0 - src1 * truncf(src0 / src1);
7210
7211 _dst_val.u16[_i] = _mesa_float_to_half(dst);
7212 }
7213
7214 break;
7215 }
7216 case 32: {
7217
7218
7219
7220
7221 for (unsigned _i = 0; _i < num_components; _i++) {
7222 const float32_t src0 =
7223 _src[0].f32[_i];
7224 const float32_t src1 =
7225 _src[1].f32[_i];
7226
7227 float32_t dst = src0 - src1 * truncf(src0 / src1);
7228
7229 _dst_val.f32[_i] = dst;
7230 }
7231
7232 break;
7233 }
7234 case 64: {
7235
7236
7237
7238
7239 for (unsigned _i = 0; _i < num_components; _i++) {
7240 const float64_t src0 =
7241 _src[0].f64[_i];
7242 const float64_t src1 =
7243 _src[1].f64[_i];
7244
7245 float64_t dst = src0 - src1 * truncf(src0 / src1);
7246
7247 _dst_val.f64[_i] = dst;
7248 }
7249
7250 break;
7251 }
7252
7253 default:
7254 unreachable("unknown bit width");
7255 }
7256
7257 return _dst_val;
7258 }
7259 static nir_const_value
evaluate_fround_even(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)7260 evaluate_fround_even(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
7261 MAYBE_UNUSED nir_const_value *_src)
7262 {
7263 nir_const_value _dst_val = { {0, } };
7264
7265 switch (bit_size) {
7266 case 16: {
7267
7268
7269
7270
7271 for (unsigned _i = 0; _i < num_components; _i++) {
7272 const float src0 =
7273 _mesa_half_to_float(_src[0].u16[_i]);
7274
7275 float16_t dst = bit_size == 64 ? _mesa_roundeven(src0) : _mesa_roundevenf(src0);
7276
7277 _dst_val.u16[_i] = _mesa_float_to_half(dst);
7278 }
7279
7280 break;
7281 }
7282 case 32: {
7283
7284
7285
7286
7287 for (unsigned _i = 0; _i < num_components; _i++) {
7288 const float32_t src0 =
7289 _src[0].f32[_i];
7290
7291 float32_t dst = bit_size == 64 ? _mesa_roundeven(src0) : _mesa_roundevenf(src0);
7292
7293 _dst_val.f32[_i] = dst;
7294 }
7295
7296 break;
7297 }
7298 case 64: {
7299
7300
7301
7302
7303 for (unsigned _i = 0; _i < num_components; _i++) {
7304 const float64_t src0 =
7305 _src[0].f64[_i];
7306
7307 float64_t dst = bit_size == 64 ? _mesa_roundeven(src0) : _mesa_roundevenf(src0);
7308
7309 _dst_val.f64[_i] = dst;
7310 }
7311
7312 break;
7313 }
7314
7315 default:
7316 unreachable("unknown bit width");
7317 }
7318
7319 return _dst_val;
7320 }
7321 static nir_const_value
evaluate_frsq(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)7322 evaluate_frsq(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
7323 MAYBE_UNUSED nir_const_value *_src)
7324 {
7325 nir_const_value _dst_val = { {0, } };
7326
7327 switch (bit_size) {
7328 case 16: {
7329
7330
7331
7332
7333 for (unsigned _i = 0; _i < num_components; _i++) {
7334 const float src0 =
7335 _mesa_half_to_float(_src[0].u16[_i]);
7336
7337 float16_t dst = bit_size == 64 ? 1.0 / sqrt(src0) : 1.0f / sqrtf(src0);
7338
7339 _dst_val.u16[_i] = _mesa_float_to_half(dst);
7340 }
7341
7342 break;
7343 }
7344 case 32: {
7345
7346
7347
7348
7349 for (unsigned _i = 0; _i < num_components; _i++) {
7350 const float32_t src0 =
7351 _src[0].f32[_i];
7352
7353 float32_t dst = bit_size == 64 ? 1.0 / sqrt(src0) : 1.0f / sqrtf(src0);
7354
7355 _dst_val.f32[_i] = dst;
7356 }
7357
7358 break;
7359 }
7360 case 64: {
7361
7362
7363
7364
7365 for (unsigned _i = 0; _i < num_components; _i++) {
7366 const float64_t src0 =
7367 _src[0].f64[_i];
7368
7369 float64_t dst = bit_size == 64 ? 1.0 / sqrt(src0) : 1.0f / sqrtf(src0);
7370
7371 _dst_val.f64[_i] = dst;
7372 }
7373
7374 break;
7375 }
7376
7377 default:
7378 unreachable("unknown bit width");
7379 }
7380
7381 return _dst_val;
7382 }
7383 static nir_const_value
evaluate_fsat(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)7384 evaluate_fsat(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
7385 MAYBE_UNUSED nir_const_value *_src)
7386 {
7387 nir_const_value _dst_val = { {0, } };
7388
7389 switch (bit_size) {
7390 case 16: {
7391
7392
7393
7394
7395 for (unsigned _i = 0; _i < num_components; _i++) {
7396 const float src0 =
7397 _mesa_half_to_float(_src[0].u16[_i]);
7398
7399 float16_t dst = bit_size == 64 ? ((src0 > 1.0) ? 1.0 : ((src0 <= 0.0) ? 0.0 : src0)) : ((src0 > 1.0f) ? 1.0f : ((src0 <= 0.0f) ? 0.0f : src0));
7400
7401 _dst_val.u16[_i] = _mesa_float_to_half(dst);
7402 }
7403
7404 break;
7405 }
7406 case 32: {
7407
7408
7409
7410
7411 for (unsigned _i = 0; _i < num_components; _i++) {
7412 const float32_t src0 =
7413 _src[0].f32[_i];
7414
7415 float32_t dst = bit_size == 64 ? ((src0 > 1.0) ? 1.0 : ((src0 <= 0.0) ? 0.0 : src0)) : ((src0 > 1.0f) ? 1.0f : ((src0 <= 0.0f) ? 0.0f : src0));
7416
7417 _dst_val.f32[_i] = dst;
7418 }
7419
7420 break;
7421 }
7422 case 64: {
7423
7424
7425
7426
7427 for (unsigned _i = 0; _i < num_components; _i++) {
7428 const float64_t src0 =
7429 _src[0].f64[_i];
7430
7431 float64_t dst = bit_size == 64 ? ((src0 > 1.0) ? 1.0 : ((src0 <= 0.0) ? 0.0 : src0)) : ((src0 > 1.0f) ? 1.0f : ((src0 <= 0.0f) ? 0.0f : src0));
7432
7433 _dst_val.f64[_i] = dst;
7434 }
7435
7436 break;
7437 }
7438
7439 default:
7440 unreachable("unknown bit width");
7441 }
7442
7443 return _dst_val;
7444 }
7445 static nir_const_value
evaluate_fsign(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)7446 evaluate_fsign(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
7447 MAYBE_UNUSED nir_const_value *_src)
7448 {
7449 nir_const_value _dst_val = { {0, } };
7450
7451 switch (bit_size) {
7452 case 16: {
7453
7454
7455
7456
7457 for (unsigned _i = 0; _i < num_components; _i++) {
7458 const float src0 =
7459 _mesa_half_to_float(_src[0].u16[_i]);
7460
7461 float16_t dst = bit_size == 64 ? ((src0 == 0.0) ? 0.0 : ((src0 > 0.0) ? 1.0 : -1.0)) : ((src0 == 0.0f) ? 0.0f : ((src0 > 0.0f) ? 1.0f : -1.0f));
7462
7463 _dst_val.u16[_i] = _mesa_float_to_half(dst);
7464 }
7465
7466 break;
7467 }
7468 case 32: {
7469
7470
7471
7472
7473 for (unsigned _i = 0; _i < num_components; _i++) {
7474 const float32_t src0 =
7475 _src[0].f32[_i];
7476
7477 float32_t dst = bit_size == 64 ? ((src0 == 0.0) ? 0.0 : ((src0 > 0.0) ? 1.0 : -1.0)) : ((src0 == 0.0f) ? 0.0f : ((src0 > 0.0f) ? 1.0f : -1.0f));
7478
7479 _dst_val.f32[_i] = dst;
7480 }
7481
7482 break;
7483 }
7484 case 64: {
7485
7486
7487
7488
7489 for (unsigned _i = 0; _i < num_components; _i++) {
7490 const float64_t src0 =
7491 _src[0].f64[_i];
7492
7493 float64_t dst = bit_size == 64 ? ((src0 == 0.0) ? 0.0 : ((src0 > 0.0) ? 1.0 : -1.0)) : ((src0 == 0.0f) ? 0.0f : ((src0 > 0.0f) ? 1.0f : -1.0f));
7494
7495 _dst_val.f64[_i] = dst;
7496 }
7497
7498 break;
7499 }
7500
7501 default:
7502 unreachable("unknown bit width");
7503 }
7504
7505 return _dst_val;
7506 }
7507 static nir_const_value
evaluate_fsin(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)7508 evaluate_fsin(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
7509 MAYBE_UNUSED nir_const_value *_src)
7510 {
7511 nir_const_value _dst_val = { {0, } };
7512
7513 switch (bit_size) {
7514 case 16: {
7515
7516
7517
7518
7519 for (unsigned _i = 0; _i < num_components; _i++) {
7520 const float src0 =
7521 _mesa_half_to_float(_src[0].u16[_i]);
7522
7523 float16_t dst = bit_size == 64 ? sin(src0) : sinf(src0);
7524
7525 _dst_val.u16[_i] = _mesa_float_to_half(dst);
7526 }
7527
7528 break;
7529 }
7530 case 32: {
7531
7532
7533
7534
7535 for (unsigned _i = 0; _i < num_components; _i++) {
7536 const float32_t src0 =
7537 _src[0].f32[_i];
7538
7539 float32_t dst = bit_size == 64 ? sin(src0) : sinf(src0);
7540
7541 _dst_val.f32[_i] = dst;
7542 }
7543
7544 break;
7545 }
7546 case 64: {
7547
7548
7549
7550
7551 for (unsigned _i = 0; _i < num_components; _i++) {
7552 const float64_t src0 =
7553 _src[0].f64[_i];
7554
7555 float64_t dst = bit_size == 64 ? sin(src0) : sinf(src0);
7556
7557 _dst_val.f64[_i] = dst;
7558 }
7559
7560 break;
7561 }
7562
7563 default:
7564 unreachable("unknown bit width");
7565 }
7566
7567 return _dst_val;
7568 }
7569 static nir_const_value
evaluate_fsqrt(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)7570 evaluate_fsqrt(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
7571 MAYBE_UNUSED nir_const_value *_src)
7572 {
7573 nir_const_value _dst_val = { {0, } };
7574
7575 switch (bit_size) {
7576 case 16: {
7577
7578
7579
7580
7581 for (unsigned _i = 0; _i < num_components; _i++) {
7582 const float src0 =
7583 _mesa_half_to_float(_src[0].u16[_i]);
7584
7585 float16_t dst = bit_size == 64 ? sqrt(src0) : sqrtf(src0);
7586
7587 _dst_val.u16[_i] = _mesa_float_to_half(dst);
7588 }
7589
7590 break;
7591 }
7592 case 32: {
7593
7594
7595
7596
7597 for (unsigned _i = 0; _i < num_components; _i++) {
7598 const float32_t src0 =
7599 _src[0].f32[_i];
7600
7601 float32_t dst = bit_size == 64 ? sqrt(src0) : sqrtf(src0);
7602
7603 _dst_val.f32[_i] = dst;
7604 }
7605
7606 break;
7607 }
7608 case 64: {
7609
7610
7611
7612
7613 for (unsigned _i = 0; _i < num_components; _i++) {
7614 const float64_t src0 =
7615 _src[0].f64[_i];
7616
7617 float64_t dst = bit_size == 64 ? sqrt(src0) : sqrtf(src0);
7618
7619 _dst_val.f64[_i] = dst;
7620 }
7621
7622 break;
7623 }
7624
7625 default:
7626 unreachable("unknown bit width");
7627 }
7628
7629 return _dst_val;
7630 }
7631 static nir_const_value
evaluate_fsub(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)7632 evaluate_fsub(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
7633 MAYBE_UNUSED nir_const_value *_src)
7634 {
7635 nir_const_value _dst_val = { {0, } };
7636
7637 switch (bit_size) {
7638 case 16: {
7639
7640
7641
7642
7643 for (unsigned _i = 0; _i < num_components; _i++) {
7644 const float src0 =
7645 _mesa_half_to_float(_src[0].u16[_i]);
7646 const float src1 =
7647 _mesa_half_to_float(_src[1].u16[_i]);
7648
7649 float16_t dst = src0 - src1;
7650
7651 _dst_val.u16[_i] = _mesa_float_to_half(dst);
7652 }
7653
7654 break;
7655 }
7656 case 32: {
7657
7658
7659
7660
7661 for (unsigned _i = 0; _i < num_components; _i++) {
7662 const float32_t src0 =
7663 _src[0].f32[_i];
7664 const float32_t src1 =
7665 _src[1].f32[_i];
7666
7667 float32_t dst = src0 - src1;
7668
7669 _dst_val.f32[_i] = dst;
7670 }
7671
7672 break;
7673 }
7674 case 64: {
7675
7676
7677
7678
7679 for (unsigned _i = 0; _i < num_components; _i++) {
7680 const float64_t src0 =
7681 _src[0].f64[_i];
7682 const float64_t src1 =
7683 _src[1].f64[_i];
7684
7685 float64_t dst = src0 - src1;
7686
7687 _dst_val.f64[_i] = dst;
7688 }
7689
7690 break;
7691 }
7692
7693 default:
7694 unreachable("unknown bit width");
7695 }
7696
7697 return _dst_val;
7698 }
7699 static nir_const_value
evaluate_ftrunc(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)7700 evaluate_ftrunc(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
7701 MAYBE_UNUSED nir_const_value *_src)
7702 {
7703 nir_const_value _dst_val = { {0, } };
7704
7705 switch (bit_size) {
7706 case 16: {
7707
7708
7709
7710
7711 for (unsigned _i = 0; _i < num_components; _i++) {
7712 const float src0 =
7713 _mesa_half_to_float(_src[0].u16[_i]);
7714
7715 float16_t dst = bit_size == 64 ? trunc(src0) : truncf(src0);
7716
7717 _dst_val.u16[_i] = _mesa_float_to_half(dst);
7718 }
7719
7720 break;
7721 }
7722 case 32: {
7723
7724
7725
7726
7727 for (unsigned _i = 0; _i < num_components; _i++) {
7728 const float32_t src0 =
7729 _src[0].f32[_i];
7730
7731 float32_t dst = bit_size == 64 ? trunc(src0) : truncf(src0);
7732
7733 _dst_val.f32[_i] = dst;
7734 }
7735
7736 break;
7737 }
7738 case 64: {
7739
7740
7741
7742
7743 for (unsigned _i = 0; _i < num_components; _i++) {
7744 const float64_t src0 =
7745 _src[0].f64[_i];
7746
7747 float64_t dst = bit_size == 64 ? trunc(src0) : truncf(src0);
7748
7749 _dst_val.f64[_i] = dst;
7750 }
7751
7752 break;
7753 }
7754
7755 default:
7756 unreachable("unknown bit width");
7757 }
7758
7759 return _dst_val;
7760 }
7761 static nir_const_value
evaluate_fxor(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)7762 evaluate_fxor(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
7763 MAYBE_UNUSED nir_const_value *_src)
7764 {
7765 nir_const_value _dst_val = { {0, } };
7766
7767
7768
7769
7770
7771 for (unsigned _i = 0; _i < num_components; _i++) {
7772 const float32_t src0 =
7773 _src[0].f32[_i];
7774 const float32_t src1 =
7775 _src[1].f32[_i];
7776
7777 float32_t dst = (src0 != 0.0f && src1 == 0.0f) || (src0 == 0.0f && src1 != 0.0f) ? 1.0f : 0.0f;
7778
7779 _dst_val.f32[_i] = dst;
7780 }
7781
7782
7783 return _dst_val;
7784 }
7785 static nir_const_value
evaluate_i2b(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)7786 evaluate_i2b(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
7787 MAYBE_UNUSED nir_const_value *_src)
7788 {
7789 nir_const_value _dst_val = { {0, } };
7790
7791 switch (bit_size) {
7792 case 8: {
7793
7794
7795
7796
7797 for (unsigned _i = 0; _i < num_components; _i++) {
7798 const int8_t src0 =
7799 _src[0].i8[_i];
7800
7801 bool32_t dst = src0 != 0;
7802
7803 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
7804 }
7805
7806 break;
7807 }
7808 case 16: {
7809
7810
7811
7812
7813 for (unsigned _i = 0; _i < num_components; _i++) {
7814 const int16_t src0 =
7815 _src[0].i16[_i];
7816
7817 bool32_t dst = src0 != 0;
7818
7819 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
7820 }
7821
7822 break;
7823 }
7824 case 32: {
7825
7826
7827
7828
7829 for (unsigned _i = 0; _i < num_components; _i++) {
7830 const int32_t src0 =
7831 _src[0].i32[_i];
7832
7833 bool32_t dst = src0 != 0;
7834
7835 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
7836 }
7837
7838 break;
7839 }
7840 case 64: {
7841
7842
7843
7844
7845 for (unsigned _i = 0; _i < num_components; _i++) {
7846 const int64_t src0 =
7847 _src[0].i64[_i];
7848
7849 bool32_t dst = src0 != 0;
7850
7851 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
7852 }
7853
7854 break;
7855 }
7856
7857 default:
7858 unreachable("unknown bit width");
7859 }
7860
7861 return _dst_val;
7862 }
7863 static nir_const_value
evaluate_i2f16(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)7864 evaluate_i2f16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
7865 MAYBE_UNUSED nir_const_value *_src)
7866 {
7867 nir_const_value _dst_val = { {0, } };
7868
7869 switch (bit_size) {
7870 case 8: {
7871
7872
7873
7874
7875 for (unsigned _i = 0; _i < num_components; _i++) {
7876 const int8_t src0 =
7877 _src[0].i8[_i];
7878
7879 float16_t dst = src0;
7880
7881 _dst_val.u16[_i] = _mesa_float_to_half(dst);
7882 }
7883
7884 break;
7885 }
7886 case 16: {
7887
7888
7889
7890
7891 for (unsigned _i = 0; _i < num_components; _i++) {
7892 const int16_t src0 =
7893 _src[0].i16[_i];
7894
7895 float16_t dst = src0;
7896
7897 _dst_val.u16[_i] = _mesa_float_to_half(dst);
7898 }
7899
7900 break;
7901 }
7902 case 32: {
7903
7904
7905
7906
7907 for (unsigned _i = 0; _i < num_components; _i++) {
7908 const int32_t src0 =
7909 _src[0].i32[_i];
7910
7911 float16_t dst = src0;
7912
7913 _dst_val.u16[_i] = _mesa_float_to_half(dst);
7914 }
7915
7916 break;
7917 }
7918 case 64: {
7919
7920
7921
7922
7923 for (unsigned _i = 0; _i < num_components; _i++) {
7924 const int64_t src0 =
7925 _src[0].i64[_i];
7926
7927 float16_t dst = src0;
7928
7929 _dst_val.u16[_i] = _mesa_float_to_half(dst);
7930 }
7931
7932 break;
7933 }
7934
7935 default:
7936 unreachable("unknown bit width");
7937 }
7938
7939 return _dst_val;
7940 }
7941 static nir_const_value
evaluate_i2f32(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)7942 evaluate_i2f32(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
7943 MAYBE_UNUSED nir_const_value *_src)
7944 {
7945 nir_const_value _dst_val = { {0, } };
7946
7947 switch (bit_size) {
7948 case 8: {
7949
7950
7951
7952
7953 for (unsigned _i = 0; _i < num_components; _i++) {
7954 const int8_t src0 =
7955 _src[0].i8[_i];
7956
7957 float32_t dst = src0;
7958
7959 _dst_val.f32[_i] = dst;
7960 }
7961
7962 break;
7963 }
7964 case 16: {
7965
7966
7967
7968
7969 for (unsigned _i = 0; _i < num_components; _i++) {
7970 const int16_t src0 =
7971 _src[0].i16[_i];
7972
7973 float32_t dst = src0;
7974
7975 _dst_val.f32[_i] = dst;
7976 }
7977
7978 break;
7979 }
7980 case 32: {
7981
7982
7983
7984
7985 for (unsigned _i = 0; _i < num_components; _i++) {
7986 const int32_t src0 =
7987 _src[0].i32[_i];
7988
7989 float32_t dst = src0;
7990
7991 _dst_val.f32[_i] = dst;
7992 }
7993
7994 break;
7995 }
7996 case 64: {
7997
7998
7999
8000
8001 for (unsigned _i = 0; _i < num_components; _i++) {
8002 const int64_t src0 =
8003 _src[0].i64[_i];
8004
8005 float32_t dst = src0;
8006
8007 _dst_val.f32[_i] = dst;
8008 }
8009
8010 break;
8011 }
8012
8013 default:
8014 unreachable("unknown bit width");
8015 }
8016
8017 return _dst_val;
8018 }
8019 static nir_const_value
evaluate_i2f64(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)8020 evaluate_i2f64(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
8021 MAYBE_UNUSED nir_const_value *_src)
8022 {
8023 nir_const_value _dst_val = { {0, } };
8024
8025 switch (bit_size) {
8026 case 8: {
8027
8028
8029
8030
8031 for (unsigned _i = 0; _i < num_components; _i++) {
8032 const int8_t src0 =
8033 _src[0].i8[_i];
8034
8035 float64_t dst = src0;
8036
8037 _dst_val.f64[_i] = dst;
8038 }
8039
8040 break;
8041 }
8042 case 16: {
8043
8044
8045
8046
8047 for (unsigned _i = 0; _i < num_components; _i++) {
8048 const int16_t src0 =
8049 _src[0].i16[_i];
8050
8051 float64_t dst = src0;
8052
8053 _dst_val.f64[_i] = dst;
8054 }
8055
8056 break;
8057 }
8058 case 32: {
8059
8060
8061
8062
8063 for (unsigned _i = 0; _i < num_components; _i++) {
8064 const int32_t src0 =
8065 _src[0].i32[_i];
8066
8067 float64_t dst = src0;
8068
8069 _dst_val.f64[_i] = dst;
8070 }
8071
8072 break;
8073 }
8074 case 64: {
8075
8076
8077
8078
8079 for (unsigned _i = 0; _i < num_components; _i++) {
8080 const int64_t src0 =
8081 _src[0].i64[_i];
8082
8083 float64_t dst = src0;
8084
8085 _dst_val.f64[_i] = dst;
8086 }
8087
8088 break;
8089 }
8090
8091 default:
8092 unreachable("unknown bit width");
8093 }
8094
8095 return _dst_val;
8096 }
8097 static nir_const_value
evaluate_i2i16(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)8098 evaluate_i2i16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
8099 MAYBE_UNUSED nir_const_value *_src)
8100 {
8101 nir_const_value _dst_val = { {0, } };
8102
8103 switch (bit_size) {
8104 case 8: {
8105
8106
8107
8108
8109 for (unsigned _i = 0; _i < num_components; _i++) {
8110 const int8_t src0 =
8111 _src[0].i8[_i];
8112
8113 int16_t dst = src0;
8114
8115 _dst_val.i16[_i] = dst;
8116 }
8117
8118 break;
8119 }
8120 case 16: {
8121
8122
8123
8124
8125 for (unsigned _i = 0; _i < num_components; _i++) {
8126 const int16_t src0 =
8127 _src[0].i16[_i];
8128
8129 int16_t dst = src0;
8130
8131 _dst_val.i16[_i] = dst;
8132 }
8133
8134 break;
8135 }
8136 case 32: {
8137
8138
8139
8140
8141 for (unsigned _i = 0; _i < num_components; _i++) {
8142 const int32_t src0 =
8143 _src[0].i32[_i];
8144
8145 int16_t dst = src0;
8146
8147 _dst_val.i16[_i] = dst;
8148 }
8149
8150 break;
8151 }
8152 case 64: {
8153
8154
8155
8156
8157 for (unsigned _i = 0; _i < num_components; _i++) {
8158 const int64_t src0 =
8159 _src[0].i64[_i];
8160
8161 int16_t dst = src0;
8162
8163 _dst_val.i16[_i] = dst;
8164 }
8165
8166 break;
8167 }
8168
8169 default:
8170 unreachable("unknown bit width");
8171 }
8172
8173 return _dst_val;
8174 }
8175 static nir_const_value
evaluate_i2i32(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)8176 evaluate_i2i32(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
8177 MAYBE_UNUSED nir_const_value *_src)
8178 {
8179 nir_const_value _dst_val = { {0, } };
8180
8181 switch (bit_size) {
8182 case 8: {
8183
8184
8185
8186
8187 for (unsigned _i = 0; _i < num_components; _i++) {
8188 const int8_t src0 =
8189 _src[0].i8[_i];
8190
8191 int32_t dst = src0;
8192
8193 _dst_val.i32[_i] = dst;
8194 }
8195
8196 break;
8197 }
8198 case 16: {
8199
8200
8201
8202
8203 for (unsigned _i = 0; _i < num_components; _i++) {
8204 const int16_t src0 =
8205 _src[0].i16[_i];
8206
8207 int32_t dst = src0;
8208
8209 _dst_val.i32[_i] = dst;
8210 }
8211
8212 break;
8213 }
8214 case 32: {
8215
8216
8217
8218
8219 for (unsigned _i = 0; _i < num_components; _i++) {
8220 const int32_t src0 =
8221 _src[0].i32[_i];
8222
8223 int32_t dst = src0;
8224
8225 _dst_val.i32[_i] = dst;
8226 }
8227
8228 break;
8229 }
8230 case 64: {
8231
8232
8233
8234
8235 for (unsigned _i = 0; _i < num_components; _i++) {
8236 const int64_t src0 =
8237 _src[0].i64[_i];
8238
8239 int32_t dst = src0;
8240
8241 _dst_val.i32[_i] = dst;
8242 }
8243
8244 break;
8245 }
8246
8247 default:
8248 unreachable("unknown bit width");
8249 }
8250
8251 return _dst_val;
8252 }
8253 static nir_const_value
evaluate_i2i64(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)8254 evaluate_i2i64(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
8255 MAYBE_UNUSED nir_const_value *_src)
8256 {
8257 nir_const_value _dst_val = { {0, } };
8258
8259 switch (bit_size) {
8260 case 8: {
8261
8262
8263
8264
8265 for (unsigned _i = 0; _i < num_components; _i++) {
8266 const int8_t src0 =
8267 _src[0].i8[_i];
8268
8269 int64_t dst = src0;
8270
8271 _dst_val.i64[_i] = dst;
8272 }
8273
8274 break;
8275 }
8276 case 16: {
8277
8278
8279
8280
8281 for (unsigned _i = 0; _i < num_components; _i++) {
8282 const int16_t src0 =
8283 _src[0].i16[_i];
8284
8285 int64_t dst = src0;
8286
8287 _dst_val.i64[_i] = dst;
8288 }
8289
8290 break;
8291 }
8292 case 32: {
8293
8294
8295
8296
8297 for (unsigned _i = 0; _i < num_components; _i++) {
8298 const int32_t src0 =
8299 _src[0].i32[_i];
8300
8301 int64_t dst = src0;
8302
8303 _dst_val.i64[_i] = dst;
8304 }
8305
8306 break;
8307 }
8308 case 64: {
8309
8310
8311
8312
8313 for (unsigned _i = 0; _i < num_components; _i++) {
8314 const int64_t src0 =
8315 _src[0].i64[_i];
8316
8317 int64_t dst = src0;
8318
8319 _dst_val.i64[_i] = dst;
8320 }
8321
8322 break;
8323 }
8324
8325 default:
8326 unreachable("unknown bit width");
8327 }
8328
8329 return _dst_val;
8330 }
8331 static nir_const_value
evaluate_i2i8(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)8332 evaluate_i2i8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
8333 MAYBE_UNUSED nir_const_value *_src)
8334 {
8335 nir_const_value _dst_val = { {0, } };
8336
8337 switch (bit_size) {
8338 case 8: {
8339
8340
8341
8342
8343 for (unsigned _i = 0; _i < num_components; _i++) {
8344 const int8_t src0 =
8345 _src[0].i8[_i];
8346
8347 int8_t dst = src0;
8348
8349 _dst_val.i8[_i] = dst;
8350 }
8351
8352 break;
8353 }
8354 case 16: {
8355
8356
8357
8358
8359 for (unsigned _i = 0; _i < num_components; _i++) {
8360 const int16_t src0 =
8361 _src[0].i16[_i];
8362
8363 int8_t dst = src0;
8364
8365 _dst_val.i8[_i] = dst;
8366 }
8367
8368 break;
8369 }
8370 case 32: {
8371
8372
8373
8374
8375 for (unsigned _i = 0; _i < num_components; _i++) {
8376 const int32_t src0 =
8377 _src[0].i32[_i];
8378
8379 int8_t dst = src0;
8380
8381 _dst_val.i8[_i] = dst;
8382 }
8383
8384 break;
8385 }
8386 case 64: {
8387
8388
8389
8390
8391 for (unsigned _i = 0; _i < num_components; _i++) {
8392 const int64_t src0 =
8393 _src[0].i64[_i];
8394
8395 int8_t dst = src0;
8396
8397 _dst_val.i8[_i] = dst;
8398 }
8399
8400 break;
8401 }
8402
8403 default:
8404 unreachable("unknown bit width");
8405 }
8406
8407 return _dst_val;
8408 }
8409 static nir_const_value
evaluate_iabs(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)8410 evaluate_iabs(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
8411 MAYBE_UNUSED nir_const_value *_src)
8412 {
8413 nir_const_value _dst_val = { {0, } };
8414
8415 switch (bit_size) {
8416 case 8: {
8417
8418
8419
8420
8421 for (unsigned _i = 0; _i < num_components; _i++) {
8422 const int8_t src0 =
8423 _src[0].i8[_i];
8424
8425 int8_t dst = (src0 < 0) ? -src0 : src0;
8426
8427 _dst_val.i8[_i] = dst;
8428 }
8429
8430 break;
8431 }
8432 case 16: {
8433
8434
8435
8436
8437 for (unsigned _i = 0; _i < num_components; _i++) {
8438 const int16_t src0 =
8439 _src[0].i16[_i];
8440
8441 int16_t dst = (src0 < 0) ? -src0 : src0;
8442
8443 _dst_val.i16[_i] = dst;
8444 }
8445
8446 break;
8447 }
8448 case 32: {
8449
8450
8451
8452
8453 for (unsigned _i = 0; _i < num_components; _i++) {
8454 const int32_t src0 =
8455 _src[0].i32[_i];
8456
8457 int32_t dst = (src0 < 0) ? -src0 : src0;
8458
8459 _dst_val.i32[_i] = dst;
8460 }
8461
8462 break;
8463 }
8464 case 64: {
8465
8466
8467
8468
8469 for (unsigned _i = 0; _i < num_components; _i++) {
8470 const int64_t src0 =
8471 _src[0].i64[_i];
8472
8473 int64_t dst = (src0 < 0) ? -src0 : src0;
8474
8475 _dst_val.i64[_i] = dst;
8476 }
8477
8478 break;
8479 }
8480
8481 default:
8482 unreachable("unknown bit width");
8483 }
8484
8485 return _dst_val;
8486 }
8487 static nir_const_value
evaluate_iadd(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)8488 evaluate_iadd(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
8489 MAYBE_UNUSED nir_const_value *_src)
8490 {
8491 nir_const_value _dst_val = { {0, } };
8492
8493 switch (bit_size) {
8494 case 8: {
8495
8496
8497
8498
8499 for (unsigned _i = 0; _i < num_components; _i++) {
8500 const int8_t src0 =
8501 _src[0].i8[_i];
8502 const int8_t src1 =
8503 _src[1].i8[_i];
8504
8505 int8_t dst = src0 + src1;
8506
8507 _dst_val.i8[_i] = dst;
8508 }
8509
8510 break;
8511 }
8512 case 16: {
8513
8514
8515
8516
8517 for (unsigned _i = 0; _i < num_components; _i++) {
8518 const int16_t src0 =
8519 _src[0].i16[_i];
8520 const int16_t src1 =
8521 _src[1].i16[_i];
8522
8523 int16_t dst = src0 + src1;
8524
8525 _dst_val.i16[_i] = dst;
8526 }
8527
8528 break;
8529 }
8530 case 32: {
8531
8532
8533
8534
8535 for (unsigned _i = 0; _i < num_components; _i++) {
8536 const int32_t src0 =
8537 _src[0].i32[_i];
8538 const int32_t src1 =
8539 _src[1].i32[_i];
8540
8541 int32_t dst = src0 + src1;
8542
8543 _dst_val.i32[_i] = dst;
8544 }
8545
8546 break;
8547 }
8548 case 64: {
8549
8550
8551
8552
8553 for (unsigned _i = 0; _i < num_components; _i++) {
8554 const int64_t src0 =
8555 _src[0].i64[_i];
8556 const int64_t src1 =
8557 _src[1].i64[_i];
8558
8559 int64_t dst = src0 + src1;
8560
8561 _dst_val.i64[_i] = dst;
8562 }
8563
8564 break;
8565 }
8566
8567 default:
8568 unreachable("unknown bit width");
8569 }
8570
8571 return _dst_val;
8572 }
8573 static nir_const_value
evaluate_iand(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)8574 evaluate_iand(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
8575 MAYBE_UNUSED nir_const_value *_src)
8576 {
8577 nir_const_value _dst_val = { {0, } };
8578
8579 switch (bit_size) {
8580 case 8: {
8581
8582
8583
8584
8585 for (unsigned _i = 0; _i < num_components; _i++) {
8586 const uint8_t src0 =
8587 _src[0].u8[_i];
8588 const uint8_t src1 =
8589 _src[1].u8[_i];
8590
8591 uint8_t dst = src0 & src1;
8592
8593 _dst_val.u8[_i] = dst;
8594 }
8595
8596 break;
8597 }
8598 case 16: {
8599
8600
8601
8602
8603 for (unsigned _i = 0; _i < num_components; _i++) {
8604 const uint16_t src0 =
8605 _src[0].u16[_i];
8606 const uint16_t src1 =
8607 _src[1].u16[_i];
8608
8609 uint16_t dst = src0 & src1;
8610
8611 _dst_val.u16[_i] = dst;
8612 }
8613
8614 break;
8615 }
8616 case 32: {
8617
8618
8619
8620
8621 for (unsigned _i = 0; _i < num_components; _i++) {
8622 const uint32_t src0 =
8623 _src[0].u32[_i];
8624 const uint32_t src1 =
8625 _src[1].u32[_i];
8626
8627 uint32_t dst = src0 & src1;
8628
8629 _dst_val.u32[_i] = dst;
8630 }
8631
8632 break;
8633 }
8634 case 64: {
8635
8636
8637
8638
8639 for (unsigned _i = 0; _i < num_components; _i++) {
8640 const uint64_t src0 =
8641 _src[0].u64[_i];
8642 const uint64_t src1 =
8643 _src[1].u64[_i];
8644
8645 uint64_t dst = src0 & src1;
8646
8647 _dst_val.u64[_i] = dst;
8648 }
8649
8650 break;
8651 }
8652
8653 default:
8654 unreachable("unknown bit width");
8655 }
8656
8657 return _dst_val;
8658 }
8659 static nir_const_value
evaluate_ibfe(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)8660 evaluate_ibfe(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
8661 MAYBE_UNUSED nir_const_value *_src)
8662 {
8663 nir_const_value _dst_val = { {0, } };
8664
8665
8666
8667
8668
8669 for (unsigned _i = 0; _i < num_components; _i++) {
8670 const int32_t src0 =
8671 _src[0].i32[_i];
8672 const int32_t src1 =
8673 _src[1].i32[_i];
8674 const int32_t src2 =
8675 _src[2].i32[_i];
8676
8677 int32_t dst;
8678
8679
8680 int base = src0;
8681 int offset = src1, bits = src2;
8682 if (bits == 0) {
8683 dst = 0;
8684 } else if (bits < 0 || offset < 0) {
8685 dst = 0; /* undefined */
8686 } else if (offset + bits < 32) {
8687 dst = (base << (32 - bits - offset)) >> (32 - bits);
8688 } else {
8689 dst = base >> offset;
8690 }
8691
8692
8693 _dst_val.i32[_i] = dst;
8694 }
8695
8696
8697 return _dst_val;
8698 }
8699 static nir_const_value
evaluate_ibitfield_extract(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)8700 evaluate_ibitfield_extract(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
8701 MAYBE_UNUSED nir_const_value *_src)
8702 {
8703 nir_const_value _dst_val = { {0, } };
8704
8705
8706
8707
8708
8709 for (unsigned _i = 0; _i < num_components; _i++) {
8710 const int32_t src0 =
8711 _src[0].i32[_i];
8712 const int32_t src1 =
8713 _src[1].i32[_i];
8714 const int32_t src2 =
8715 _src[2].i32[_i];
8716
8717 int32_t dst;
8718
8719
8720 int base = src0;
8721 int offset = src1, bits = src2;
8722 if (bits == 0) {
8723 dst = 0;
8724 } else if (offset < 0 || bits < 0 || offset + bits > 32) {
8725 dst = 0;
8726 } else {
8727 dst = (base << (32 - offset - bits)) >> offset; /* use sign-extending shift */
8728 }
8729
8730
8731 _dst_val.i32[_i] = dst;
8732 }
8733
8734
8735 return _dst_val;
8736 }
8737 static nir_const_value
evaluate_idiv(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)8738 evaluate_idiv(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
8739 MAYBE_UNUSED nir_const_value *_src)
8740 {
8741 nir_const_value _dst_val = { {0, } };
8742
8743 switch (bit_size) {
8744 case 8: {
8745
8746
8747
8748
8749 for (unsigned _i = 0; _i < num_components; _i++) {
8750 const int8_t src0 =
8751 _src[0].i8[_i];
8752 const int8_t src1 =
8753 _src[1].i8[_i];
8754
8755 int8_t dst = src1 == 0 ? 0 : (src0 / src1);
8756
8757 _dst_val.i8[_i] = dst;
8758 }
8759
8760 break;
8761 }
8762 case 16: {
8763
8764
8765
8766
8767 for (unsigned _i = 0; _i < num_components; _i++) {
8768 const int16_t src0 =
8769 _src[0].i16[_i];
8770 const int16_t src1 =
8771 _src[1].i16[_i];
8772
8773 int16_t dst = src1 == 0 ? 0 : (src0 / src1);
8774
8775 _dst_val.i16[_i] = dst;
8776 }
8777
8778 break;
8779 }
8780 case 32: {
8781
8782
8783
8784
8785 for (unsigned _i = 0; _i < num_components; _i++) {
8786 const int32_t src0 =
8787 _src[0].i32[_i];
8788 const int32_t src1 =
8789 _src[1].i32[_i];
8790
8791 int32_t dst = src1 == 0 ? 0 : (src0 / src1);
8792
8793 _dst_val.i32[_i] = dst;
8794 }
8795
8796 break;
8797 }
8798 case 64: {
8799
8800
8801
8802
8803 for (unsigned _i = 0; _i < num_components; _i++) {
8804 const int64_t src0 =
8805 _src[0].i64[_i];
8806 const int64_t src1 =
8807 _src[1].i64[_i];
8808
8809 int64_t dst = src1 == 0 ? 0 : (src0 / src1);
8810
8811 _dst_val.i64[_i] = dst;
8812 }
8813
8814 break;
8815 }
8816
8817 default:
8818 unreachable("unknown bit width");
8819 }
8820
8821 return _dst_val;
8822 }
8823 static nir_const_value
evaluate_ieq(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)8824 evaluate_ieq(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
8825 MAYBE_UNUSED nir_const_value *_src)
8826 {
8827 nir_const_value _dst_val = { {0, } };
8828
8829 switch (bit_size) {
8830 case 8: {
8831
8832
8833
8834
8835 for (unsigned _i = 0; _i < num_components; _i++) {
8836 const int8_t src0 =
8837 _src[0].i8[_i];
8838 const int8_t src1 =
8839 _src[1].i8[_i];
8840
8841 bool32_t dst = src0 == src1;
8842
8843 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
8844 }
8845
8846 break;
8847 }
8848 case 16: {
8849
8850
8851
8852
8853 for (unsigned _i = 0; _i < num_components; _i++) {
8854 const int16_t src0 =
8855 _src[0].i16[_i];
8856 const int16_t src1 =
8857 _src[1].i16[_i];
8858
8859 bool32_t dst = src0 == src1;
8860
8861 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
8862 }
8863
8864 break;
8865 }
8866 case 32: {
8867
8868
8869
8870
8871 for (unsigned _i = 0; _i < num_components; _i++) {
8872 const int32_t src0 =
8873 _src[0].i32[_i];
8874 const int32_t src1 =
8875 _src[1].i32[_i];
8876
8877 bool32_t dst = src0 == src1;
8878
8879 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
8880 }
8881
8882 break;
8883 }
8884 case 64: {
8885
8886
8887
8888
8889 for (unsigned _i = 0; _i < num_components; _i++) {
8890 const int64_t src0 =
8891 _src[0].i64[_i];
8892 const int64_t src1 =
8893 _src[1].i64[_i];
8894
8895 bool32_t dst = src0 == src1;
8896
8897 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
8898 }
8899
8900 break;
8901 }
8902
8903 default:
8904 unreachable("unknown bit width");
8905 }
8906
8907 return _dst_val;
8908 }
8909 static nir_const_value
evaluate_ifind_msb(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)8910 evaluate_ifind_msb(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
8911 MAYBE_UNUSED nir_const_value *_src)
8912 {
8913 nir_const_value _dst_val = { {0, } };
8914
8915
8916
8917
8918
8919 for (unsigned _i = 0; _i < num_components; _i++) {
8920 const int32_t src0 =
8921 _src[0].i32[_i];
8922
8923 int32_t dst;
8924
8925
8926 dst = -1;
8927 for (int bit = 31; bit >= 0; bit--) {
8928 /* If src0 < 0, we're looking for the first 0 bit.
8929 * if src0 >= 0, we're looking for the first 1 bit.
8930 */
8931 if ((((src0 >> bit) & 1) && (src0 >= 0)) ||
8932 (!((src0 >> bit) & 1) && (src0 < 0))) {
8933 dst = bit;
8934 break;
8935 }
8936 }
8937
8938
8939 _dst_val.i32[_i] = dst;
8940 }
8941
8942
8943 return _dst_val;
8944 }
8945 static nir_const_value
evaluate_ige(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)8946 evaluate_ige(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
8947 MAYBE_UNUSED nir_const_value *_src)
8948 {
8949 nir_const_value _dst_val = { {0, } };
8950
8951 switch (bit_size) {
8952 case 8: {
8953
8954
8955
8956
8957 for (unsigned _i = 0; _i < num_components; _i++) {
8958 const int8_t src0 =
8959 _src[0].i8[_i];
8960 const int8_t src1 =
8961 _src[1].i8[_i];
8962
8963 bool32_t dst = src0 >= src1;
8964
8965 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
8966 }
8967
8968 break;
8969 }
8970 case 16: {
8971
8972
8973
8974
8975 for (unsigned _i = 0; _i < num_components; _i++) {
8976 const int16_t src0 =
8977 _src[0].i16[_i];
8978 const int16_t src1 =
8979 _src[1].i16[_i];
8980
8981 bool32_t dst = src0 >= src1;
8982
8983 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
8984 }
8985
8986 break;
8987 }
8988 case 32: {
8989
8990
8991
8992
8993 for (unsigned _i = 0; _i < num_components; _i++) {
8994 const int32_t src0 =
8995 _src[0].i32[_i];
8996 const int32_t src1 =
8997 _src[1].i32[_i];
8998
8999 bool32_t dst = src0 >= src1;
9000
9001 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
9002 }
9003
9004 break;
9005 }
9006 case 64: {
9007
9008
9009
9010
9011 for (unsigned _i = 0; _i < num_components; _i++) {
9012 const int64_t src0 =
9013 _src[0].i64[_i];
9014 const int64_t src1 =
9015 _src[1].i64[_i];
9016
9017 bool32_t dst = src0 >= src1;
9018
9019 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
9020 }
9021
9022 break;
9023 }
9024
9025 default:
9026 unreachable("unknown bit width");
9027 }
9028
9029 return _dst_val;
9030 }
9031 static nir_const_value
evaluate_ilt(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)9032 evaluate_ilt(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
9033 MAYBE_UNUSED nir_const_value *_src)
9034 {
9035 nir_const_value _dst_val = { {0, } };
9036
9037 switch (bit_size) {
9038 case 8: {
9039
9040
9041
9042
9043 for (unsigned _i = 0; _i < num_components; _i++) {
9044 const int8_t src0 =
9045 _src[0].i8[_i];
9046 const int8_t src1 =
9047 _src[1].i8[_i];
9048
9049 bool32_t dst = src0 < src1;
9050
9051 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
9052 }
9053
9054 break;
9055 }
9056 case 16: {
9057
9058
9059
9060
9061 for (unsigned _i = 0; _i < num_components; _i++) {
9062 const int16_t src0 =
9063 _src[0].i16[_i];
9064 const int16_t src1 =
9065 _src[1].i16[_i];
9066
9067 bool32_t dst = src0 < src1;
9068
9069 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
9070 }
9071
9072 break;
9073 }
9074 case 32: {
9075
9076
9077
9078
9079 for (unsigned _i = 0; _i < num_components; _i++) {
9080 const int32_t src0 =
9081 _src[0].i32[_i];
9082 const int32_t src1 =
9083 _src[1].i32[_i];
9084
9085 bool32_t dst = src0 < src1;
9086
9087 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
9088 }
9089
9090 break;
9091 }
9092 case 64: {
9093
9094
9095
9096
9097 for (unsigned _i = 0; _i < num_components; _i++) {
9098 const int64_t src0 =
9099 _src[0].i64[_i];
9100 const int64_t src1 =
9101 _src[1].i64[_i];
9102
9103 bool32_t dst = src0 < src1;
9104
9105 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
9106 }
9107
9108 break;
9109 }
9110
9111 default:
9112 unreachable("unknown bit width");
9113 }
9114
9115 return _dst_val;
9116 }
9117 static nir_const_value
evaluate_imax(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)9118 evaluate_imax(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
9119 MAYBE_UNUSED nir_const_value *_src)
9120 {
9121 nir_const_value _dst_val = { {0, } };
9122
9123 switch (bit_size) {
9124 case 8: {
9125
9126
9127
9128
9129 for (unsigned _i = 0; _i < num_components; _i++) {
9130 const int8_t src0 =
9131 _src[0].i8[_i];
9132 const int8_t src1 =
9133 _src[1].i8[_i];
9134
9135 int8_t dst = src1 > src0 ? src1 : src0;
9136
9137 _dst_val.i8[_i] = dst;
9138 }
9139
9140 break;
9141 }
9142 case 16: {
9143
9144
9145
9146
9147 for (unsigned _i = 0; _i < num_components; _i++) {
9148 const int16_t src0 =
9149 _src[0].i16[_i];
9150 const int16_t src1 =
9151 _src[1].i16[_i];
9152
9153 int16_t dst = src1 > src0 ? src1 : src0;
9154
9155 _dst_val.i16[_i] = dst;
9156 }
9157
9158 break;
9159 }
9160 case 32: {
9161
9162
9163
9164
9165 for (unsigned _i = 0; _i < num_components; _i++) {
9166 const int32_t src0 =
9167 _src[0].i32[_i];
9168 const int32_t src1 =
9169 _src[1].i32[_i];
9170
9171 int32_t dst = src1 > src0 ? src1 : src0;
9172
9173 _dst_val.i32[_i] = dst;
9174 }
9175
9176 break;
9177 }
9178 case 64: {
9179
9180
9181
9182
9183 for (unsigned _i = 0; _i < num_components; _i++) {
9184 const int64_t src0 =
9185 _src[0].i64[_i];
9186 const int64_t src1 =
9187 _src[1].i64[_i];
9188
9189 int64_t dst = src1 > src0 ? src1 : src0;
9190
9191 _dst_val.i64[_i] = dst;
9192 }
9193
9194 break;
9195 }
9196
9197 default:
9198 unreachable("unknown bit width");
9199 }
9200
9201 return _dst_val;
9202 }
9203 static nir_const_value
evaluate_imin(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)9204 evaluate_imin(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
9205 MAYBE_UNUSED nir_const_value *_src)
9206 {
9207 nir_const_value _dst_val = { {0, } };
9208
9209 switch (bit_size) {
9210 case 8: {
9211
9212
9213
9214
9215 for (unsigned _i = 0; _i < num_components; _i++) {
9216 const int8_t src0 =
9217 _src[0].i8[_i];
9218 const int8_t src1 =
9219 _src[1].i8[_i];
9220
9221 int8_t dst = src1 > src0 ? src0 : src1;
9222
9223 _dst_val.i8[_i] = dst;
9224 }
9225
9226 break;
9227 }
9228 case 16: {
9229
9230
9231
9232
9233 for (unsigned _i = 0; _i < num_components; _i++) {
9234 const int16_t src0 =
9235 _src[0].i16[_i];
9236 const int16_t src1 =
9237 _src[1].i16[_i];
9238
9239 int16_t dst = src1 > src0 ? src0 : src1;
9240
9241 _dst_val.i16[_i] = dst;
9242 }
9243
9244 break;
9245 }
9246 case 32: {
9247
9248
9249
9250
9251 for (unsigned _i = 0; _i < num_components; _i++) {
9252 const int32_t src0 =
9253 _src[0].i32[_i];
9254 const int32_t src1 =
9255 _src[1].i32[_i];
9256
9257 int32_t dst = src1 > src0 ? src0 : src1;
9258
9259 _dst_val.i32[_i] = dst;
9260 }
9261
9262 break;
9263 }
9264 case 64: {
9265
9266
9267
9268
9269 for (unsigned _i = 0; _i < num_components; _i++) {
9270 const int64_t src0 =
9271 _src[0].i64[_i];
9272 const int64_t src1 =
9273 _src[1].i64[_i];
9274
9275 int64_t dst = src1 > src0 ? src0 : src1;
9276
9277 _dst_val.i64[_i] = dst;
9278 }
9279
9280 break;
9281 }
9282
9283 default:
9284 unreachable("unknown bit width");
9285 }
9286
9287 return _dst_val;
9288 }
9289 static nir_const_value
evaluate_imod(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)9290 evaluate_imod(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
9291 MAYBE_UNUSED nir_const_value *_src)
9292 {
9293 nir_const_value _dst_val = { {0, } };
9294
9295 switch (bit_size) {
9296 case 8: {
9297
9298
9299
9300
9301 for (unsigned _i = 0; _i < num_components; _i++) {
9302 const int8_t src0 =
9303 _src[0].i8[_i];
9304 const int8_t src1 =
9305 _src[1].i8[_i];
9306
9307 int8_t dst = src1 == 0 ? 0 : ((src0 % src1 == 0 || (src0 >= 0) == (src1 >= 0)) ? src0 % src1 : src0 % src1 + src1);
9308
9309 _dst_val.i8[_i] = dst;
9310 }
9311
9312 break;
9313 }
9314 case 16: {
9315
9316
9317
9318
9319 for (unsigned _i = 0; _i < num_components; _i++) {
9320 const int16_t src0 =
9321 _src[0].i16[_i];
9322 const int16_t src1 =
9323 _src[1].i16[_i];
9324
9325 int16_t dst = src1 == 0 ? 0 : ((src0 % src1 == 0 || (src0 >= 0) == (src1 >= 0)) ? src0 % src1 : src0 % src1 + src1);
9326
9327 _dst_val.i16[_i] = dst;
9328 }
9329
9330 break;
9331 }
9332 case 32: {
9333
9334
9335
9336
9337 for (unsigned _i = 0; _i < num_components; _i++) {
9338 const int32_t src0 =
9339 _src[0].i32[_i];
9340 const int32_t src1 =
9341 _src[1].i32[_i];
9342
9343 int32_t dst = src1 == 0 ? 0 : ((src0 % src1 == 0 || (src0 >= 0) == (src1 >= 0)) ? src0 % src1 : src0 % src1 + src1);
9344
9345 _dst_val.i32[_i] = dst;
9346 }
9347
9348 break;
9349 }
9350 case 64: {
9351
9352
9353
9354
9355 for (unsigned _i = 0; _i < num_components; _i++) {
9356 const int64_t src0 =
9357 _src[0].i64[_i];
9358 const int64_t src1 =
9359 _src[1].i64[_i];
9360
9361 int64_t dst = src1 == 0 ? 0 : ((src0 % src1 == 0 || (src0 >= 0) == (src1 >= 0)) ? src0 % src1 : src0 % src1 + src1);
9362
9363 _dst_val.i64[_i] = dst;
9364 }
9365
9366 break;
9367 }
9368
9369 default:
9370 unreachable("unknown bit width");
9371 }
9372
9373 return _dst_val;
9374 }
9375 static nir_const_value
evaluate_imov(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)9376 evaluate_imov(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
9377 MAYBE_UNUSED nir_const_value *_src)
9378 {
9379 nir_const_value _dst_val = { {0, } };
9380
9381 switch (bit_size) {
9382 case 8: {
9383
9384
9385
9386
9387 for (unsigned _i = 0; _i < num_components; _i++) {
9388 const int8_t src0 =
9389 _src[0].i8[_i];
9390
9391 int8_t dst = src0;
9392
9393 _dst_val.i8[_i] = dst;
9394 }
9395
9396 break;
9397 }
9398 case 16: {
9399
9400
9401
9402
9403 for (unsigned _i = 0; _i < num_components; _i++) {
9404 const int16_t src0 =
9405 _src[0].i16[_i];
9406
9407 int16_t dst = src0;
9408
9409 _dst_val.i16[_i] = dst;
9410 }
9411
9412 break;
9413 }
9414 case 32: {
9415
9416
9417
9418
9419 for (unsigned _i = 0; _i < num_components; _i++) {
9420 const int32_t src0 =
9421 _src[0].i32[_i];
9422
9423 int32_t dst = src0;
9424
9425 _dst_val.i32[_i] = dst;
9426 }
9427
9428 break;
9429 }
9430 case 64: {
9431
9432
9433
9434
9435 for (unsigned _i = 0; _i < num_components; _i++) {
9436 const int64_t src0 =
9437 _src[0].i64[_i];
9438
9439 int64_t dst = src0;
9440
9441 _dst_val.i64[_i] = dst;
9442 }
9443
9444 break;
9445 }
9446
9447 default:
9448 unreachable("unknown bit width");
9449 }
9450
9451 return _dst_val;
9452 }
9453 static nir_const_value
evaluate_imul(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)9454 evaluate_imul(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
9455 MAYBE_UNUSED nir_const_value *_src)
9456 {
9457 nir_const_value _dst_val = { {0, } };
9458
9459 switch (bit_size) {
9460 case 8: {
9461
9462
9463
9464
9465 for (unsigned _i = 0; _i < num_components; _i++) {
9466 const int8_t src0 =
9467 _src[0].i8[_i];
9468 const int8_t src1 =
9469 _src[1].i8[_i];
9470
9471 int8_t dst = src0 * src1;
9472
9473 _dst_val.i8[_i] = dst;
9474 }
9475
9476 break;
9477 }
9478 case 16: {
9479
9480
9481
9482
9483 for (unsigned _i = 0; _i < num_components; _i++) {
9484 const int16_t src0 =
9485 _src[0].i16[_i];
9486 const int16_t src1 =
9487 _src[1].i16[_i];
9488
9489 int16_t dst = src0 * src1;
9490
9491 _dst_val.i16[_i] = dst;
9492 }
9493
9494 break;
9495 }
9496 case 32: {
9497
9498
9499
9500
9501 for (unsigned _i = 0; _i < num_components; _i++) {
9502 const int32_t src0 =
9503 _src[0].i32[_i];
9504 const int32_t src1 =
9505 _src[1].i32[_i];
9506
9507 int32_t dst = src0 * src1;
9508
9509 _dst_val.i32[_i] = dst;
9510 }
9511
9512 break;
9513 }
9514 case 64: {
9515
9516
9517
9518
9519 for (unsigned _i = 0; _i < num_components; _i++) {
9520 const int64_t src0 =
9521 _src[0].i64[_i];
9522 const int64_t src1 =
9523 _src[1].i64[_i];
9524
9525 int64_t dst = src0 * src1;
9526
9527 _dst_val.i64[_i] = dst;
9528 }
9529
9530 break;
9531 }
9532
9533 default:
9534 unreachable("unknown bit width");
9535 }
9536
9537 return _dst_val;
9538 }
9539 static nir_const_value
evaluate_imul_high(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)9540 evaluate_imul_high(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
9541 MAYBE_UNUSED nir_const_value *_src)
9542 {
9543 nir_const_value _dst_val = { {0, } };
9544
9545
9546
9547
9548
9549 for (unsigned _i = 0; _i < num_components; _i++) {
9550 const int32_t src0 =
9551 _src[0].i32[_i];
9552 const int32_t src1 =
9553 _src[1].i32[_i];
9554
9555 int32_t dst = (int32_t)(((int64_t) src0 * (int64_t) src1) >> 32);
9556
9557 _dst_val.i32[_i] = dst;
9558 }
9559
9560
9561 return _dst_val;
9562 }
9563 static nir_const_value
evaluate_ine(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)9564 evaluate_ine(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
9565 MAYBE_UNUSED nir_const_value *_src)
9566 {
9567 nir_const_value _dst_val = { {0, } };
9568
9569 switch (bit_size) {
9570 case 8: {
9571
9572
9573
9574
9575 for (unsigned _i = 0; _i < num_components; _i++) {
9576 const int8_t src0 =
9577 _src[0].i8[_i];
9578 const int8_t src1 =
9579 _src[1].i8[_i];
9580
9581 bool32_t dst = src0 != src1;
9582
9583 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
9584 }
9585
9586 break;
9587 }
9588 case 16: {
9589
9590
9591
9592
9593 for (unsigned _i = 0; _i < num_components; _i++) {
9594 const int16_t src0 =
9595 _src[0].i16[_i];
9596 const int16_t src1 =
9597 _src[1].i16[_i];
9598
9599 bool32_t dst = src0 != src1;
9600
9601 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
9602 }
9603
9604 break;
9605 }
9606 case 32: {
9607
9608
9609
9610
9611 for (unsigned _i = 0; _i < num_components; _i++) {
9612 const int32_t src0 =
9613 _src[0].i32[_i];
9614 const int32_t src1 =
9615 _src[1].i32[_i];
9616
9617 bool32_t dst = src0 != src1;
9618
9619 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
9620 }
9621
9622 break;
9623 }
9624 case 64: {
9625
9626
9627
9628
9629 for (unsigned _i = 0; _i < num_components; _i++) {
9630 const int64_t src0 =
9631 _src[0].i64[_i];
9632 const int64_t src1 =
9633 _src[1].i64[_i];
9634
9635 bool32_t dst = src0 != src1;
9636
9637 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
9638 }
9639
9640 break;
9641 }
9642
9643 default:
9644 unreachable("unknown bit width");
9645 }
9646
9647 return _dst_val;
9648 }
9649 static nir_const_value
evaluate_ineg(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)9650 evaluate_ineg(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
9651 MAYBE_UNUSED nir_const_value *_src)
9652 {
9653 nir_const_value _dst_val = { {0, } };
9654
9655 switch (bit_size) {
9656 case 8: {
9657
9658
9659
9660
9661 for (unsigned _i = 0; _i < num_components; _i++) {
9662 const int8_t src0 =
9663 _src[0].i8[_i];
9664
9665 int8_t dst = -src0;
9666
9667 _dst_val.i8[_i] = dst;
9668 }
9669
9670 break;
9671 }
9672 case 16: {
9673
9674
9675
9676
9677 for (unsigned _i = 0; _i < num_components; _i++) {
9678 const int16_t src0 =
9679 _src[0].i16[_i];
9680
9681 int16_t dst = -src0;
9682
9683 _dst_val.i16[_i] = dst;
9684 }
9685
9686 break;
9687 }
9688 case 32: {
9689
9690
9691
9692
9693 for (unsigned _i = 0; _i < num_components; _i++) {
9694 const int32_t src0 =
9695 _src[0].i32[_i];
9696
9697 int32_t dst = -src0;
9698
9699 _dst_val.i32[_i] = dst;
9700 }
9701
9702 break;
9703 }
9704 case 64: {
9705
9706
9707
9708
9709 for (unsigned _i = 0; _i < num_components; _i++) {
9710 const int64_t src0 =
9711 _src[0].i64[_i];
9712
9713 int64_t dst = -src0;
9714
9715 _dst_val.i64[_i] = dst;
9716 }
9717
9718 break;
9719 }
9720
9721 default:
9722 unreachable("unknown bit width");
9723 }
9724
9725 return _dst_val;
9726 }
9727 static nir_const_value
evaluate_inot(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)9728 evaluate_inot(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
9729 MAYBE_UNUSED nir_const_value *_src)
9730 {
9731 nir_const_value _dst_val = { {0, } };
9732
9733 switch (bit_size) {
9734 case 8: {
9735
9736
9737
9738
9739 for (unsigned _i = 0; _i < num_components; _i++) {
9740 const int8_t src0 =
9741 _src[0].i8[_i];
9742
9743 int8_t dst = ~src0;
9744
9745 _dst_val.i8[_i] = dst;
9746 }
9747
9748 break;
9749 }
9750 case 16: {
9751
9752
9753
9754
9755 for (unsigned _i = 0; _i < num_components; _i++) {
9756 const int16_t src0 =
9757 _src[0].i16[_i];
9758
9759 int16_t dst = ~src0;
9760
9761 _dst_val.i16[_i] = dst;
9762 }
9763
9764 break;
9765 }
9766 case 32: {
9767
9768
9769
9770
9771 for (unsigned _i = 0; _i < num_components; _i++) {
9772 const int32_t src0 =
9773 _src[0].i32[_i];
9774
9775 int32_t dst = ~src0;
9776
9777 _dst_val.i32[_i] = dst;
9778 }
9779
9780 break;
9781 }
9782 case 64: {
9783
9784
9785
9786
9787 for (unsigned _i = 0; _i < num_components; _i++) {
9788 const int64_t src0 =
9789 _src[0].i64[_i];
9790
9791 int64_t dst = ~src0;
9792
9793 _dst_val.i64[_i] = dst;
9794 }
9795
9796 break;
9797 }
9798
9799 default:
9800 unreachable("unknown bit width");
9801 }
9802
9803 return _dst_val;
9804 }
9805 static nir_const_value
evaluate_ior(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)9806 evaluate_ior(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
9807 MAYBE_UNUSED nir_const_value *_src)
9808 {
9809 nir_const_value _dst_val = { {0, } };
9810
9811 switch (bit_size) {
9812 case 8: {
9813
9814
9815
9816
9817 for (unsigned _i = 0; _i < num_components; _i++) {
9818 const uint8_t src0 =
9819 _src[0].u8[_i];
9820 const uint8_t src1 =
9821 _src[1].u8[_i];
9822
9823 uint8_t dst = src0 | src1;
9824
9825 _dst_val.u8[_i] = dst;
9826 }
9827
9828 break;
9829 }
9830 case 16: {
9831
9832
9833
9834
9835 for (unsigned _i = 0; _i < num_components; _i++) {
9836 const uint16_t src0 =
9837 _src[0].u16[_i];
9838 const uint16_t src1 =
9839 _src[1].u16[_i];
9840
9841 uint16_t dst = src0 | src1;
9842
9843 _dst_val.u16[_i] = dst;
9844 }
9845
9846 break;
9847 }
9848 case 32: {
9849
9850
9851
9852
9853 for (unsigned _i = 0; _i < num_components; _i++) {
9854 const uint32_t src0 =
9855 _src[0].u32[_i];
9856 const uint32_t src1 =
9857 _src[1].u32[_i];
9858
9859 uint32_t dst = src0 | src1;
9860
9861 _dst_val.u32[_i] = dst;
9862 }
9863
9864 break;
9865 }
9866 case 64: {
9867
9868
9869
9870
9871 for (unsigned _i = 0; _i < num_components; _i++) {
9872 const uint64_t src0 =
9873 _src[0].u64[_i];
9874 const uint64_t src1 =
9875 _src[1].u64[_i];
9876
9877 uint64_t dst = src0 | src1;
9878
9879 _dst_val.u64[_i] = dst;
9880 }
9881
9882 break;
9883 }
9884
9885 default:
9886 unreachable("unknown bit width");
9887 }
9888
9889 return _dst_val;
9890 }
9891 static nir_const_value
evaluate_irem(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)9892 evaluate_irem(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
9893 MAYBE_UNUSED nir_const_value *_src)
9894 {
9895 nir_const_value _dst_val = { {0, } };
9896
9897 switch (bit_size) {
9898 case 8: {
9899
9900
9901
9902
9903 for (unsigned _i = 0; _i < num_components; _i++) {
9904 const int8_t src0 =
9905 _src[0].i8[_i];
9906 const int8_t src1 =
9907 _src[1].i8[_i];
9908
9909 int8_t dst = src1 == 0 ? 0 : src0 % src1;
9910
9911 _dst_val.i8[_i] = dst;
9912 }
9913
9914 break;
9915 }
9916 case 16: {
9917
9918
9919
9920
9921 for (unsigned _i = 0; _i < num_components; _i++) {
9922 const int16_t src0 =
9923 _src[0].i16[_i];
9924 const int16_t src1 =
9925 _src[1].i16[_i];
9926
9927 int16_t dst = src1 == 0 ? 0 : src0 % src1;
9928
9929 _dst_val.i16[_i] = dst;
9930 }
9931
9932 break;
9933 }
9934 case 32: {
9935
9936
9937
9938
9939 for (unsigned _i = 0; _i < num_components; _i++) {
9940 const int32_t src0 =
9941 _src[0].i32[_i];
9942 const int32_t src1 =
9943 _src[1].i32[_i];
9944
9945 int32_t dst = src1 == 0 ? 0 : src0 % src1;
9946
9947 _dst_val.i32[_i] = dst;
9948 }
9949
9950 break;
9951 }
9952 case 64: {
9953
9954
9955
9956
9957 for (unsigned _i = 0; _i < num_components; _i++) {
9958 const int64_t src0 =
9959 _src[0].i64[_i];
9960 const int64_t src1 =
9961 _src[1].i64[_i];
9962
9963 int64_t dst = src1 == 0 ? 0 : src0 % src1;
9964
9965 _dst_val.i64[_i] = dst;
9966 }
9967
9968 break;
9969 }
9970
9971 default:
9972 unreachable("unknown bit width");
9973 }
9974
9975 return _dst_val;
9976 }
9977 static nir_const_value
evaluate_ishl(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)9978 evaluate_ishl(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
9979 MAYBE_UNUSED nir_const_value *_src)
9980 {
9981 nir_const_value _dst_val = { {0, } };
9982
9983 switch (bit_size) {
9984 case 8: {
9985
9986
9987
9988
9989 for (unsigned _i = 0; _i < num_components; _i++) {
9990 const int8_t src0 =
9991 _src[0].i8[_i];
9992 const uint32_t src1 =
9993 _src[1].u32[_i];
9994
9995 int8_t dst = src0 << src1;
9996
9997 _dst_val.i8[_i] = dst;
9998 }
9999
10000 break;
10001 }
10002 case 16: {
10003
10004
10005
10006
10007 for (unsigned _i = 0; _i < num_components; _i++) {
10008 const int16_t src0 =
10009 _src[0].i16[_i];
10010 const uint32_t src1 =
10011 _src[1].u32[_i];
10012
10013 int16_t dst = src0 << src1;
10014
10015 _dst_val.i16[_i] = dst;
10016 }
10017
10018 break;
10019 }
10020 case 32: {
10021
10022
10023
10024
10025 for (unsigned _i = 0; _i < num_components; _i++) {
10026 const int32_t src0 =
10027 _src[0].i32[_i];
10028 const uint32_t src1 =
10029 _src[1].u32[_i];
10030
10031 int32_t dst = src0 << src1;
10032
10033 _dst_val.i32[_i] = dst;
10034 }
10035
10036 break;
10037 }
10038 case 64: {
10039
10040
10041
10042
10043 for (unsigned _i = 0; _i < num_components; _i++) {
10044 const int64_t src0 =
10045 _src[0].i64[_i];
10046 const uint32_t src1 =
10047 _src[1].u32[_i];
10048
10049 int64_t dst = src0 << src1;
10050
10051 _dst_val.i64[_i] = dst;
10052 }
10053
10054 break;
10055 }
10056
10057 default:
10058 unreachable("unknown bit width");
10059 }
10060
10061 return _dst_val;
10062 }
10063 static nir_const_value
evaluate_ishr(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10064 evaluate_ishr(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10065 MAYBE_UNUSED nir_const_value *_src)
10066 {
10067 nir_const_value _dst_val = { {0, } };
10068
10069 switch (bit_size) {
10070 case 8: {
10071
10072
10073
10074
10075 for (unsigned _i = 0; _i < num_components; _i++) {
10076 const int8_t src0 =
10077 _src[0].i8[_i];
10078 const uint32_t src1 =
10079 _src[1].u32[_i];
10080
10081 int8_t dst = src0 >> src1;
10082
10083 _dst_val.i8[_i] = dst;
10084 }
10085
10086 break;
10087 }
10088 case 16: {
10089
10090
10091
10092
10093 for (unsigned _i = 0; _i < num_components; _i++) {
10094 const int16_t src0 =
10095 _src[0].i16[_i];
10096 const uint32_t src1 =
10097 _src[1].u32[_i];
10098
10099 int16_t dst = src0 >> src1;
10100
10101 _dst_val.i16[_i] = dst;
10102 }
10103
10104 break;
10105 }
10106 case 32: {
10107
10108
10109
10110
10111 for (unsigned _i = 0; _i < num_components; _i++) {
10112 const int32_t src0 =
10113 _src[0].i32[_i];
10114 const uint32_t src1 =
10115 _src[1].u32[_i];
10116
10117 int32_t dst = src0 >> src1;
10118
10119 _dst_val.i32[_i] = dst;
10120 }
10121
10122 break;
10123 }
10124 case 64: {
10125
10126
10127
10128
10129 for (unsigned _i = 0; _i < num_components; _i++) {
10130 const int64_t src0 =
10131 _src[0].i64[_i];
10132 const uint32_t src1 =
10133 _src[1].u32[_i];
10134
10135 int64_t dst = src0 >> src1;
10136
10137 _dst_val.i64[_i] = dst;
10138 }
10139
10140 break;
10141 }
10142
10143 default:
10144 unreachable("unknown bit width");
10145 }
10146
10147 return _dst_val;
10148 }
10149 static nir_const_value
evaluate_isign(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10150 evaluate_isign(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10151 MAYBE_UNUSED nir_const_value *_src)
10152 {
10153 nir_const_value _dst_val = { {0, } };
10154
10155 switch (bit_size) {
10156 case 8: {
10157
10158
10159
10160
10161 for (unsigned _i = 0; _i < num_components; _i++) {
10162 const int8_t src0 =
10163 _src[0].i8[_i];
10164
10165 int8_t dst = (src0 == 0) ? 0 : ((src0 > 0) ? 1 : -1);
10166
10167 _dst_val.i8[_i] = dst;
10168 }
10169
10170 break;
10171 }
10172 case 16: {
10173
10174
10175
10176
10177 for (unsigned _i = 0; _i < num_components; _i++) {
10178 const int16_t src0 =
10179 _src[0].i16[_i];
10180
10181 int16_t dst = (src0 == 0) ? 0 : ((src0 > 0) ? 1 : -1);
10182
10183 _dst_val.i16[_i] = dst;
10184 }
10185
10186 break;
10187 }
10188 case 32: {
10189
10190
10191
10192
10193 for (unsigned _i = 0; _i < num_components; _i++) {
10194 const int32_t src0 =
10195 _src[0].i32[_i];
10196
10197 int32_t dst = (src0 == 0) ? 0 : ((src0 > 0) ? 1 : -1);
10198
10199 _dst_val.i32[_i] = dst;
10200 }
10201
10202 break;
10203 }
10204 case 64: {
10205
10206
10207
10208
10209 for (unsigned _i = 0; _i < num_components; _i++) {
10210 const int64_t src0 =
10211 _src[0].i64[_i];
10212
10213 int64_t dst = (src0 == 0) ? 0 : ((src0 > 0) ? 1 : -1);
10214
10215 _dst_val.i64[_i] = dst;
10216 }
10217
10218 break;
10219 }
10220
10221 default:
10222 unreachable("unknown bit width");
10223 }
10224
10225 return _dst_val;
10226 }
10227 static nir_const_value
evaluate_isub(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10228 evaluate_isub(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10229 MAYBE_UNUSED nir_const_value *_src)
10230 {
10231 nir_const_value _dst_val = { {0, } };
10232
10233 switch (bit_size) {
10234 case 8: {
10235
10236
10237
10238
10239 for (unsigned _i = 0; _i < num_components; _i++) {
10240 const int8_t src0 =
10241 _src[0].i8[_i];
10242 const int8_t src1 =
10243 _src[1].i8[_i];
10244
10245 int8_t dst = src0 - src1;
10246
10247 _dst_val.i8[_i] = dst;
10248 }
10249
10250 break;
10251 }
10252 case 16: {
10253
10254
10255
10256
10257 for (unsigned _i = 0; _i < num_components; _i++) {
10258 const int16_t src0 =
10259 _src[0].i16[_i];
10260 const int16_t src1 =
10261 _src[1].i16[_i];
10262
10263 int16_t dst = src0 - src1;
10264
10265 _dst_val.i16[_i] = dst;
10266 }
10267
10268 break;
10269 }
10270 case 32: {
10271
10272
10273
10274
10275 for (unsigned _i = 0; _i < num_components; _i++) {
10276 const int32_t src0 =
10277 _src[0].i32[_i];
10278 const int32_t src1 =
10279 _src[1].i32[_i];
10280
10281 int32_t dst = src0 - src1;
10282
10283 _dst_val.i32[_i] = dst;
10284 }
10285
10286 break;
10287 }
10288 case 64: {
10289
10290
10291
10292
10293 for (unsigned _i = 0; _i < num_components; _i++) {
10294 const int64_t src0 =
10295 _src[0].i64[_i];
10296 const int64_t src1 =
10297 _src[1].i64[_i];
10298
10299 int64_t dst = src0 - src1;
10300
10301 _dst_val.i64[_i] = dst;
10302 }
10303
10304 break;
10305 }
10306
10307 default:
10308 unreachable("unknown bit width");
10309 }
10310
10311 return _dst_val;
10312 }
10313 static nir_const_value
evaluate_ixor(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10314 evaluate_ixor(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10315 MAYBE_UNUSED nir_const_value *_src)
10316 {
10317 nir_const_value _dst_val = { {0, } };
10318
10319 switch (bit_size) {
10320 case 8: {
10321
10322
10323
10324
10325 for (unsigned _i = 0; _i < num_components; _i++) {
10326 const uint8_t src0 =
10327 _src[0].u8[_i];
10328 const uint8_t src1 =
10329 _src[1].u8[_i];
10330
10331 uint8_t dst = src0 ^ src1;
10332
10333 _dst_val.u8[_i] = dst;
10334 }
10335
10336 break;
10337 }
10338 case 16: {
10339
10340
10341
10342
10343 for (unsigned _i = 0; _i < num_components; _i++) {
10344 const uint16_t src0 =
10345 _src[0].u16[_i];
10346 const uint16_t src1 =
10347 _src[1].u16[_i];
10348
10349 uint16_t dst = src0 ^ src1;
10350
10351 _dst_val.u16[_i] = dst;
10352 }
10353
10354 break;
10355 }
10356 case 32: {
10357
10358
10359
10360
10361 for (unsigned _i = 0; _i < num_components; _i++) {
10362 const uint32_t src0 =
10363 _src[0].u32[_i];
10364 const uint32_t src1 =
10365 _src[1].u32[_i];
10366
10367 uint32_t dst = src0 ^ src1;
10368
10369 _dst_val.u32[_i] = dst;
10370 }
10371
10372 break;
10373 }
10374 case 64: {
10375
10376
10377
10378
10379 for (unsigned _i = 0; _i < num_components; _i++) {
10380 const uint64_t src0 =
10381 _src[0].u64[_i];
10382 const uint64_t src1 =
10383 _src[1].u64[_i];
10384
10385 uint64_t dst = src0 ^ src1;
10386
10387 _dst_val.u64[_i] = dst;
10388 }
10389
10390 break;
10391 }
10392
10393 default:
10394 unreachable("unknown bit width");
10395 }
10396
10397 return _dst_val;
10398 }
10399 static nir_const_value
evaluate_ldexp(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10400 evaluate_ldexp(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10401 MAYBE_UNUSED nir_const_value *_src)
10402 {
10403 nir_const_value _dst_val = { {0, } };
10404
10405 switch (bit_size) {
10406 case 16: {
10407
10408
10409
10410
10411 for (unsigned _i = 0; _i < num_components; _i++) {
10412 const float src0 =
10413 _mesa_half_to_float(_src[0].u16[_i]);
10414 const int32_t src1 =
10415 _src[1].i32[_i];
10416
10417 float16_t dst;
10418
10419
10420 dst = (bit_size == 64) ? ldexp(src0, src1) : ldexpf(src0, src1);
10421 /* flush denormals to zero. */
10422 if (!isnormal(dst))
10423 dst = copysignf(0.0f, src0);
10424
10425
10426 _dst_val.u16[_i] = _mesa_float_to_half(dst);
10427 }
10428
10429 break;
10430 }
10431 case 32: {
10432
10433
10434
10435
10436 for (unsigned _i = 0; _i < num_components; _i++) {
10437 const float32_t src0 =
10438 _src[0].f32[_i];
10439 const int32_t src1 =
10440 _src[1].i32[_i];
10441
10442 float32_t dst;
10443
10444
10445 dst = (bit_size == 64) ? ldexp(src0, src1) : ldexpf(src0, src1);
10446 /* flush denormals to zero. */
10447 if (!isnormal(dst))
10448 dst = copysignf(0.0f, src0);
10449
10450
10451 _dst_val.f32[_i] = dst;
10452 }
10453
10454 break;
10455 }
10456 case 64: {
10457
10458
10459
10460
10461 for (unsigned _i = 0; _i < num_components; _i++) {
10462 const float64_t src0 =
10463 _src[0].f64[_i];
10464 const int32_t src1 =
10465 _src[1].i32[_i];
10466
10467 float64_t dst;
10468
10469
10470 dst = (bit_size == 64) ? ldexp(src0, src1) : ldexpf(src0, src1);
10471 /* flush denormals to zero. */
10472 if (!isnormal(dst))
10473 dst = copysignf(0.0f, src0);
10474
10475
10476 _dst_val.f64[_i] = dst;
10477 }
10478
10479 break;
10480 }
10481
10482 default:
10483 unreachable("unknown bit width");
10484 }
10485
10486 return _dst_val;
10487 }
10488 static nir_const_value
evaluate_pack_64_2x32(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10489 evaluate_pack_64_2x32(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10490 MAYBE_UNUSED nir_const_value *_src)
10491 {
10492 nir_const_value _dst_val = { {0, } };
10493
10494
10495
10496
10497
10498 const struct uint32_vec src0 = {
10499 _src[0].u32[0],
10500 _src[0].u32[1],
10501 0,
10502 0,
10503 };
10504
10505 struct uint64_vec dst;
10506
10507 dst.x = src0.x | ((uint64_t)src0.y << 32);
10508
10509 _dst_val.u64[0] = dst.x;
10510
10511
10512 return _dst_val;
10513 }
10514 static nir_const_value
evaluate_pack_64_2x32_split(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10515 evaluate_pack_64_2x32_split(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10516 MAYBE_UNUSED nir_const_value *_src)
10517 {
10518 nir_const_value _dst_val = { {0, } };
10519
10520
10521
10522
10523
10524 for (unsigned _i = 0; _i < num_components; _i++) {
10525 const uint32_t src0 =
10526 _src[0].u32[_i];
10527 const uint32_t src1 =
10528 _src[1].u32[_i];
10529
10530 uint64_t dst = src0 | ((uint64_t)src1 << 32);
10531
10532 _dst_val.u64[_i] = dst;
10533 }
10534
10535
10536 return _dst_val;
10537 }
10538 static nir_const_value
evaluate_pack_half_2x16(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10539 evaluate_pack_half_2x16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10540 MAYBE_UNUSED nir_const_value *_src)
10541 {
10542 nir_const_value _dst_val = { {0, } };
10543
10544
10545
10546
10547
10548 const struct float32_vec src0 = {
10549 _src[0].f32[0],
10550 _src[0].f32[1],
10551 0,
10552 0,
10553 };
10554
10555 struct uint32_vec dst;
10556
10557
10558 dst.x = (uint32_t) pack_half_1x16(src0.x);
10559 dst.x |= ((uint32_t) pack_half_1x16(src0.y)) << 16;
10560
10561
10562 _dst_val.u32[0] = dst.x;
10563
10564
10565 return _dst_val;
10566 }
10567 static nir_const_value
evaluate_pack_half_2x16_split(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10568 evaluate_pack_half_2x16_split(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10569 MAYBE_UNUSED nir_const_value *_src)
10570 {
10571 nir_const_value _dst_val = { {0, } };
10572
10573
10574
10575
10576
10577 const struct float32_vec src0 = {
10578 _src[0].f32[0],
10579 0,
10580 0,
10581 0,
10582 };
10583
10584 const struct float32_vec src1 = {
10585 _src[1].f32[0],
10586 0,
10587 0,
10588 0,
10589 };
10590
10591 struct uint32_vec dst;
10592
10593 dst.x = dst.y = dst.z = dst.w = pack_half_1x16(src0.x) | (pack_half_1x16(src1.x) << 16);
10594
10595 _dst_val.u32[0] = dst.x;
10596
10597
10598 return _dst_val;
10599 }
10600 static nir_const_value
evaluate_pack_snorm_2x16(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10601 evaluate_pack_snorm_2x16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10602 MAYBE_UNUSED nir_const_value *_src)
10603 {
10604 nir_const_value _dst_val = { {0, } };
10605
10606
10607
10608
10609
10610 const struct float32_vec src0 = {
10611 _src[0].f32[0],
10612 _src[0].f32[1],
10613 0,
10614 0,
10615 };
10616
10617 struct uint32_vec dst;
10618
10619
10620 dst.x = (uint32_t) pack_snorm_1x16(src0.x);
10621 dst.x |= ((uint32_t) pack_snorm_1x16(src0.y)) << 16;
10622
10623
10624 _dst_val.u32[0] = dst.x;
10625
10626
10627 return _dst_val;
10628 }
10629 static nir_const_value
evaluate_pack_snorm_4x8(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10630 evaluate_pack_snorm_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10631 MAYBE_UNUSED nir_const_value *_src)
10632 {
10633 nir_const_value _dst_val = { {0, } };
10634
10635
10636
10637
10638
10639 const struct float32_vec src0 = {
10640 _src[0].f32[0],
10641 _src[0].f32[1],
10642 _src[0].f32[2],
10643 _src[0].f32[3],
10644 };
10645
10646 struct uint32_vec dst;
10647
10648
10649 dst.x = (uint32_t) pack_snorm_1x8(src0.x);
10650 dst.x |= ((uint32_t) pack_snorm_1x8(src0.y)) << 8;
10651 dst.x |= ((uint32_t) pack_snorm_1x8(src0.z)) << 16;
10652 dst.x |= ((uint32_t) pack_snorm_1x8(src0.w)) << 24;
10653
10654
10655 _dst_val.u32[0] = dst.x;
10656
10657
10658 return _dst_val;
10659 }
10660 static nir_const_value
evaluate_pack_unorm_2x16(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10661 evaluate_pack_unorm_2x16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10662 MAYBE_UNUSED nir_const_value *_src)
10663 {
10664 nir_const_value _dst_val = { {0, } };
10665
10666
10667
10668
10669
10670 const struct float32_vec src0 = {
10671 _src[0].f32[0],
10672 _src[0].f32[1],
10673 0,
10674 0,
10675 };
10676
10677 struct uint32_vec dst;
10678
10679
10680 dst.x = (uint32_t) pack_unorm_1x16(src0.x);
10681 dst.x |= ((uint32_t) pack_unorm_1x16(src0.y)) << 16;
10682
10683
10684 _dst_val.u32[0] = dst.x;
10685
10686
10687 return _dst_val;
10688 }
10689 static nir_const_value
evaluate_pack_unorm_4x8(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10690 evaluate_pack_unorm_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10691 MAYBE_UNUSED nir_const_value *_src)
10692 {
10693 nir_const_value _dst_val = { {0, } };
10694
10695
10696
10697
10698
10699 const struct float32_vec src0 = {
10700 _src[0].f32[0],
10701 _src[0].f32[1],
10702 _src[0].f32[2],
10703 _src[0].f32[3],
10704 };
10705
10706 struct uint32_vec dst;
10707
10708
10709 dst.x = (uint32_t) pack_unorm_1x8(src0.x);
10710 dst.x |= ((uint32_t) pack_unorm_1x8(src0.y)) << 8;
10711 dst.x |= ((uint32_t) pack_unorm_1x8(src0.z)) << 16;
10712 dst.x |= ((uint32_t) pack_unorm_1x8(src0.w)) << 24;
10713
10714
10715 _dst_val.u32[0] = dst.x;
10716
10717
10718 return _dst_val;
10719 }
10720 static nir_const_value
evaluate_pack_uvec2_to_uint(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10721 evaluate_pack_uvec2_to_uint(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10722 MAYBE_UNUSED nir_const_value *_src)
10723 {
10724 nir_const_value _dst_val = { {0, } };
10725
10726
10727
10728
10729
10730 const struct uint32_vec src0 = {
10731 _src[0].u32[0],
10732 _src[0].u32[1],
10733 0,
10734 0,
10735 };
10736
10737 struct uint32_vec dst;
10738
10739
10740 dst.x = (src0.x & 0xffff) | (src0.y << 16);
10741
10742
10743 _dst_val.u32[0] = dst.x;
10744
10745
10746 return _dst_val;
10747 }
10748 static nir_const_value
evaluate_pack_uvec4_to_uint(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10749 evaluate_pack_uvec4_to_uint(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10750 MAYBE_UNUSED nir_const_value *_src)
10751 {
10752 nir_const_value _dst_val = { {0, } };
10753
10754
10755
10756
10757
10758 const struct uint32_vec src0 = {
10759 _src[0].u32[0],
10760 _src[0].u32[1],
10761 _src[0].u32[2],
10762 _src[0].u32[3],
10763 };
10764
10765 struct uint32_vec dst;
10766
10767
10768 dst.x = (src0.x << 0) |
10769 (src0.y << 8) |
10770 (src0.z << 16) |
10771 (src0.w << 24);
10772
10773
10774 _dst_val.u32[0] = dst.x;
10775
10776
10777 return _dst_val;
10778 }
10779 static nir_const_value
evaluate_seq(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10780 evaluate_seq(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10781 MAYBE_UNUSED nir_const_value *_src)
10782 {
10783 nir_const_value _dst_val = { {0, } };
10784
10785
10786
10787
10788
10789 for (unsigned _i = 0; _i < num_components; _i++) {
10790 const float32_t src0 =
10791 _src[0].f32[_i];
10792 const float32_t src1 =
10793 _src[1].f32[_i];
10794
10795 float32_t dst = (src0 == src1) ? 1.0f : 0.0f;
10796
10797 _dst_val.f32[_i] = dst;
10798 }
10799
10800
10801 return _dst_val;
10802 }
10803 static nir_const_value
evaluate_sge(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10804 evaluate_sge(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10805 MAYBE_UNUSED nir_const_value *_src)
10806 {
10807 nir_const_value _dst_val = { {0, } };
10808
10809 switch (bit_size) {
10810 case 16: {
10811
10812
10813
10814
10815 for (unsigned _i = 0; _i < num_components; _i++) {
10816 const float src0 =
10817 _mesa_half_to_float(_src[0].u16[_i]);
10818 const float src1 =
10819 _mesa_half_to_float(_src[1].u16[_i]);
10820
10821 float16_t dst = (src0 >= src1) ? 1.0f : 0.0f;
10822
10823 _dst_val.u16[_i] = _mesa_float_to_half(dst);
10824 }
10825
10826 break;
10827 }
10828 case 32: {
10829
10830
10831
10832
10833 for (unsigned _i = 0; _i < num_components; _i++) {
10834 const float32_t src0 =
10835 _src[0].f32[_i];
10836 const float32_t src1 =
10837 _src[1].f32[_i];
10838
10839 float32_t dst = (src0 >= src1) ? 1.0f : 0.0f;
10840
10841 _dst_val.f32[_i] = dst;
10842 }
10843
10844 break;
10845 }
10846 case 64: {
10847
10848
10849
10850
10851 for (unsigned _i = 0; _i < num_components; _i++) {
10852 const float64_t src0 =
10853 _src[0].f64[_i];
10854 const float64_t src1 =
10855 _src[1].f64[_i];
10856
10857 float64_t dst = (src0 >= src1) ? 1.0f : 0.0f;
10858
10859 _dst_val.f64[_i] = dst;
10860 }
10861
10862 break;
10863 }
10864
10865 default:
10866 unreachable("unknown bit width");
10867 }
10868
10869 return _dst_val;
10870 }
10871 static nir_const_value
evaluate_slt(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10872 evaluate_slt(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10873 MAYBE_UNUSED nir_const_value *_src)
10874 {
10875 nir_const_value _dst_val = { {0, } };
10876
10877
10878
10879
10880
10881 for (unsigned _i = 0; _i < num_components; _i++) {
10882 const float32_t src0 =
10883 _src[0].f32[_i];
10884 const float32_t src1 =
10885 _src[1].f32[_i];
10886
10887 float32_t dst = (src0 < src1) ? 1.0f : 0.0f;
10888
10889 _dst_val.f32[_i] = dst;
10890 }
10891
10892
10893 return _dst_val;
10894 }
10895 static nir_const_value
evaluate_sne(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10896 evaluate_sne(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10897 MAYBE_UNUSED nir_const_value *_src)
10898 {
10899 nir_const_value _dst_val = { {0, } };
10900
10901
10902
10903
10904
10905 for (unsigned _i = 0; _i < num_components; _i++) {
10906 const float32_t src0 =
10907 _src[0].f32[_i];
10908 const float32_t src1 =
10909 _src[1].f32[_i];
10910
10911 float32_t dst = (src0 != src1) ? 1.0f : 0.0f;
10912
10913 _dst_val.f32[_i] = dst;
10914 }
10915
10916
10917 return _dst_val;
10918 }
10919 static nir_const_value
evaluate_u2f16(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10920 evaluate_u2f16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10921 MAYBE_UNUSED nir_const_value *_src)
10922 {
10923 nir_const_value _dst_val = { {0, } };
10924
10925 switch (bit_size) {
10926 case 8: {
10927
10928
10929
10930
10931 for (unsigned _i = 0; _i < num_components; _i++) {
10932 const uint8_t src0 =
10933 _src[0].u8[_i];
10934
10935 float16_t dst = src0;
10936
10937 _dst_val.u16[_i] = _mesa_float_to_half(dst);
10938 }
10939
10940 break;
10941 }
10942 case 16: {
10943
10944
10945
10946
10947 for (unsigned _i = 0; _i < num_components; _i++) {
10948 const uint16_t src0 =
10949 _src[0].u16[_i];
10950
10951 float16_t dst = src0;
10952
10953 _dst_val.u16[_i] = _mesa_float_to_half(dst);
10954 }
10955
10956 break;
10957 }
10958 case 32: {
10959
10960
10961
10962
10963 for (unsigned _i = 0; _i < num_components; _i++) {
10964 const uint32_t src0 =
10965 _src[0].u32[_i];
10966
10967 float16_t dst = src0;
10968
10969 _dst_val.u16[_i] = _mesa_float_to_half(dst);
10970 }
10971
10972 break;
10973 }
10974 case 64: {
10975
10976
10977
10978
10979 for (unsigned _i = 0; _i < num_components; _i++) {
10980 const uint64_t src0 =
10981 _src[0].u64[_i];
10982
10983 float16_t dst = src0;
10984
10985 _dst_val.u16[_i] = _mesa_float_to_half(dst);
10986 }
10987
10988 break;
10989 }
10990
10991 default:
10992 unreachable("unknown bit width");
10993 }
10994
10995 return _dst_val;
10996 }
10997 static nir_const_value
evaluate_u2f32(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)10998 evaluate_u2f32(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
10999 MAYBE_UNUSED nir_const_value *_src)
11000 {
11001 nir_const_value _dst_val = { {0, } };
11002
11003 switch (bit_size) {
11004 case 8: {
11005
11006
11007
11008
11009 for (unsigned _i = 0; _i < num_components; _i++) {
11010 const uint8_t src0 =
11011 _src[0].u8[_i];
11012
11013 float32_t dst = src0;
11014
11015 _dst_val.f32[_i] = dst;
11016 }
11017
11018 break;
11019 }
11020 case 16: {
11021
11022
11023
11024
11025 for (unsigned _i = 0; _i < num_components; _i++) {
11026 const uint16_t src0 =
11027 _src[0].u16[_i];
11028
11029 float32_t dst = src0;
11030
11031 _dst_val.f32[_i] = dst;
11032 }
11033
11034 break;
11035 }
11036 case 32: {
11037
11038
11039
11040
11041 for (unsigned _i = 0; _i < num_components; _i++) {
11042 const uint32_t src0 =
11043 _src[0].u32[_i];
11044
11045 float32_t dst = src0;
11046
11047 _dst_val.f32[_i] = dst;
11048 }
11049
11050 break;
11051 }
11052 case 64: {
11053
11054
11055
11056
11057 for (unsigned _i = 0; _i < num_components; _i++) {
11058 const uint64_t src0 =
11059 _src[0].u64[_i];
11060
11061 float32_t dst = src0;
11062
11063 _dst_val.f32[_i] = dst;
11064 }
11065
11066 break;
11067 }
11068
11069 default:
11070 unreachable("unknown bit width");
11071 }
11072
11073 return _dst_val;
11074 }
11075 static nir_const_value
evaluate_u2f64(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)11076 evaluate_u2f64(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
11077 MAYBE_UNUSED nir_const_value *_src)
11078 {
11079 nir_const_value _dst_val = { {0, } };
11080
11081 switch (bit_size) {
11082 case 8: {
11083
11084
11085
11086
11087 for (unsigned _i = 0; _i < num_components; _i++) {
11088 const uint8_t src0 =
11089 _src[0].u8[_i];
11090
11091 float64_t dst = src0;
11092
11093 _dst_val.f64[_i] = dst;
11094 }
11095
11096 break;
11097 }
11098 case 16: {
11099
11100
11101
11102
11103 for (unsigned _i = 0; _i < num_components; _i++) {
11104 const uint16_t src0 =
11105 _src[0].u16[_i];
11106
11107 float64_t dst = src0;
11108
11109 _dst_val.f64[_i] = dst;
11110 }
11111
11112 break;
11113 }
11114 case 32: {
11115
11116
11117
11118
11119 for (unsigned _i = 0; _i < num_components; _i++) {
11120 const uint32_t src0 =
11121 _src[0].u32[_i];
11122
11123 float64_t dst = src0;
11124
11125 _dst_val.f64[_i] = dst;
11126 }
11127
11128 break;
11129 }
11130 case 64: {
11131
11132
11133
11134
11135 for (unsigned _i = 0; _i < num_components; _i++) {
11136 const uint64_t src0 =
11137 _src[0].u64[_i];
11138
11139 float64_t dst = src0;
11140
11141 _dst_val.f64[_i] = dst;
11142 }
11143
11144 break;
11145 }
11146
11147 default:
11148 unreachable("unknown bit width");
11149 }
11150
11151 return _dst_val;
11152 }
11153 static nir_const_value
evaluate_u2u16(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)11154 evaluate_u2u16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
11155 MAYBE_UNUSED nir_const_value *_src)
11156 {
11157 nir_const_value _dst_val = { {0, } };
11158
11159 switch (bit_size) {
11160 case 8: {
11161
11162
11163
11164
11165 for (unsigned _i = 0; _i < num_components; _i++) {
11166 const uint8_t src0 =
11167 _src[0].u8[_i];
11168
11169 uint16_t dst = src0;
11170
11171 _dst_val.u16[_i] = dst;
11172 }
11173
11174 break;
11175 }
11176 case 16: {
11177
11178
11179
11180
11181 for (unsigned _i = 0; _i < num_components; _i++) {
11182 const uint16_t src0 =
11183 _src[0].u16[_i];
11184
11185 uint16_t dst = src0;
11186
11187 _dst_val.u16[_i] = dst;
11188 }
11189
11190 break;
11191 }
11192 case 32: {
11193
11194
11195
11196
11197 for (unsigned _i = 0; _i < num_components; _i++) {
11198 const uint32_t src0 =
11199 _src[0].u32[_i];
11200
11201 uint16_t dst = src0;
11202
11203 _dst_val.u16[_i] = dst;
11204 }
11205
11206 break;
11207 }
11208 case 64: {
11209
11210
11211
11212
11213 for (unsigned _i = 0; _i < num_components; _i++) {
11214 const uint64_t src0 =
11215 _src[0].u64[_i];
11216
11217 uint16_t dst = src0;
11218
11219 _dst_val.u16[_i] = dst;
11220 }
11221
11222 break;
11223 }
11224
11225 default:
11226 unreachable("unknown bit width");
11227 }
11228
11229 return _dst_val;
11230 }
11231 static nir_const_value
evaluate_u2u32(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)11232 evaluate_u2u32(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
11233 MAYBE_UNUSED nir_const_value *_src)
11234 {
11235 nir_const_value _dst_val = { {0, } };
11236
11237 switch (bit_size) {
11238 case 8: {
11239
11240
11241
11242
11243 for (unsigned _i = 0; _i < num_components; _i++) {
11244 const uint8_t src0 =
11245 _src[0].u8[_i];
11246
11247 uint32_t dst = src0;
11248
11249 _dst_val.u32[_i] = dst;
11250 }
11251
11252 break;
11253 }
11254 case 16: {
11255
11256
11257
11258
11259 for (unsigned _i = 0; _i < num_components; _i++) {
11260 const uint16_t src0 =
11261 _src[0].u16[_i];
11262
11263 uint32_t dst = src0;
11264
11265 _dst_val.u32[_i] = dst;
11266 }
11267
11268 break;
11269 }
11270 case 32: {
11271
11272
11273
11274
11275 for (unsigned _i = 0; _i < num_components; _i++) {
11276 const uint32_t src0 =
11277 _src[0].u32[_i];
11278
11279 uint32_t dst = src0;
11280
11281 _dst_val.u32[_i] = dst;
11282 }
11283
11284 break;
11285 }
11286 case 64: {
11287
11288
11289
11290
11291 for (unsigned _i = 0; _i < num_components; _i++) {
11292 const uint64_t src0 =
11293 _src[0].u64[_i];
11294
11295 uint32_t dst = src0;
11296
11297 _dst_val.u32[_i] = dst;
11298 }
11299
11300 break;
11301 }
11302
11303 default:
11304 unreachable("unknown bit width");
11305 }
11306
11307 return _dst_val;
11308 }
11309 static nir_const_value
evaluate_u2u64(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)11310 evaluate_u2u64(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
11311 MAYBE_UNUSED nir_const_value *_src)
11312 {
11313 nir_const_value _dst_val = { {0, } };
11314
11315 switch (bit_size) {
11316 case 8: {
11317
11318
11319
11320
11321 for (unsigned _i = 0; _i < num_components; _i++) {
11322 const uint8_t src0 =
11323 _src[0].u8[_i];
11324
11325 uint64_t dst = src0;
11326
11327 _dst_val.u64[_i] = dst;
11328 }
11329
11330 break;
11331 }
11332 case 16: {
11333
11334
11335
11336
11337 for (unsigned _i = 0; _i < num_components; _i++) {
11338 const uint16_t src0 =
11339 _src[0].u16[_i];
11340
11341 uint64_t dst = src0;
11342
11343 _dst_val.u64[_i] = dst;
11344 }
11345
11346 break;
11347 }
11348 case 32: {
11349
11350
11351
11352
11353 for (unsigned _i = 0; _i < num_components; _i++) {
11354 const uint32_t src0 =
11355 _src[0].u32[_i];
11356
11357 uint64_t dst = src0;
11358
11359 _dst_val.u64[_i] = dst;
11360 }
11361
11362 break;
11363 }
11364 case 64: {
11365
11366
11367
11368
11369 for (unsigned _i = 0; _i < num_components; _i++) {
11370 const uint64_t src0 =
11371 _src[0].u64[_i];
11372
11373 uint64_t dst = src0;
11374
11375 _dst_val.u64[_i] = dst;
11376 }
11377
11378 break;
11379 }
11380
11381 default:
11382 unreachable("unknown bit width");
11383 }
11384
11385 return _dst_val;
11386 }
11387 static nir_const_value
evaluate_u2u8(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)11388 evaluate_u2u8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
11389 MAYBE_UNUSED nir_const_value *_src)
11390 {
11391 nir_const_value _dst_val = { {0, } };
11392
11393 switch (bit_size) {
11394 case 8: {
11395
11396
11397
11398
11399 for (unsigned _i = 0; _i < num_components; _i++) {
11400 const uint8_t src0 =
11401 _src[0].u8[_i];
11402
11403 uint8_t dst = src0;
11404
11405 _dst_val.u8[_i] = dst;
11406 }
11407
11408 break;
11409 }
11410 case 16: {
11411
11412
11413
11414
11415 for (unsigned _i = 0; _i < num_components; _i++) {
11416 const uint16_t src0 =
11417 _src[0].u16[_i];
11418
11419 uint8_t dst = src0;
11420
11421 _dst_val.u8[_i] = dst;
11422 }
11423
11424 break;
11425 }
11426 case 32: {
11427
11428
11429
11430
11431 for (unsigned _i = 0; _i < num_components; _i++) {
11432 const uint32_t src0 =
11433 _src[0].u32[_i];
11434
11435 uint8_t dst = src0;
11436
11437 _dst_val.u8[_i] = dst;
11438 }
11439
11440 break;
11441 }
11442 case 64: {
11443
11444
11445
11446
11447 for (unsigned _i = 0; _i < num_components; _i++) {
11448 const uint64_t src0 =
11449 _src[0].u64[_i];
11450
11451 uint8_t dst = src0;
11452
11453 _dst_val.u8[_i] = dst;
11454 }
11455
11456 break;
11457 }
11458
11459 default:
11460 unreachable("unknown bit width");
11461 }
11462
11463 return _dst_val;
11464 }
11465 static nir_const_value
evaluate_uadd_carry(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)11466 evaluate_uadd_carry(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
11467 MAYBE_UNUSED nir_const_value *_src)
11468 {
11469 nir_const_value _dst_val = { {0, } };
11470
11471 switch (bit_size) {
11472 case 8: {
11473
11474
11475
11476
11477 for (unsigned _i = 0; _i < num_components; _i++) {
11478 const uint8_t src0 =
11479 _src[0].u8[_i];
11480 const uint8_t src1 =
11481 _src[1].u8[_i];
11482
11483 uint8_t dst = src0 + src1 < src0;
11484
11485 _dst_val.u8[_i] = dst;
11486 }
11487
11488 break;
11489 }
11490 case 16: {
11491
11492
11493
11494
11495 for (unsigned _i = 0; _i < num_components; _i++) {
11496 const uint16_t src0 =
11497 _src[0].u16[_i];
11498 const uint16_t src1 =
11499 _src[1].u16[_i];
11500
11501 uint16_t dst = src0 + src1 < src0;
11502
11503 _dst_val.u16[_i] = dst;
11504 }
11505
11506 break;
11507 }
11508 case 32: {
11509
11510
11511
11512
11513 for (unsigned _i = 0; _i < num_components; _i++) {
11514 const uint32_t src0 =
11515 _src[0].u32[_i];
11516 const uint32_t src1 =
11517 _src[1].u32[_i];
11518
11519 uint32_t dst = src0 + src1 < src0;
11520
11521 _dst_val.u32[_i] = dst;
11522 }
11523
11524 break;
11525 }
11526 case 64: {
11527
11528
11529
11530
11531 for (unsigned _i = 0; _i < num_components; _i++) {
11532 const uint64_t src0 =
11533 _src[0].u64[_i];
11534 const uint64_t src1 =
11535 _src[1].u64[_i];
11536
11537 uint64_t dst = src0 + src1 < src0;
11538
11539 _dst_val.u64[_i] = dst;
11540 }
11541
11542 break;
11543 }
11544
11545 default:
11546 unreachable("unknown bit width");
11547 }
11548
11549 return _dst_val;
11550 }
11551 static nir_const_value
evaluate_ubfe(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)11552 evaluate_ubfe(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
11553 MAYBE_UNUSED nir_const_value *_src)
11554 {
11555 nir_const_value _dst_val = { {0, } };
11556
11557
11558
11559
11560
11561 for (unsigned _i = 0; _i < num_components; _i++) {
11562 const uint32_t src0 =
11563 _src[0].u32[_i];
11564 const int32_t src1 =
11565 _src[1].i32[_i];
11566 const int32_t src2 =
11567 _src[2].i32[_i];
11568
11569 uint32_t dst;
11570
11571
11572 unsigned base = src0;
11573 int offset = src1, bits = src2;
11574 if (bits == 0) {
11575 dst = 0;
11576 } else if (bits < 0 || offset < 0) {
11577 dst = 0; /* undefined */
11578 } else if (offset + bits < 32) {
11579 dst = (base << (32 - bits - offset)) >> (32 - bits);
11580 } else {
11581 dst = base >> offset;
11582 }
11583
11584
11585 _dst_val.u32[_i] = dst;
11586 }
11587
11588
11589 return _dst_val;
11590 }
11591 static nir_const_value
evaluate_ubitfield_extract(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)11592 evaluate_ubitfield_extract(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
11593 MAYBE_UNUSED nir_const_value *_src)
11594 {
11595 nir_const_value _dst_val = { {0, } };
11596
11597
11598
11599
11600
11601 for (unsigned _i = 0; _i < num_components; _i++) {
11602 const uint32_t src0 =
11603 _src[0].u32[_i];
11604 const int32_t src1 =
11605 _src[1].i32[_i];
11606 const int32_t src2 =
11607 _src[2].i32[_i];
11608
11609 uint32_t dst;
11610
11611
11612 unsigned base = src0;
11613 int offset = src1, bits = src2;
11614 if (bits == 0) {
11615 dst = 0;
11616 } else if (bits < 0 || offset < 0 || offset + bits > 32) {
11617 dst = 0; /* undefined per the spec */
11618 } else {
11619 dst = (base >> offset) & ((1ull << bits) - 1);
11620 }
11621
11622
11623 _dst_val.u32[_i] = dst;
11624 }
11625
11626
11627 return _dst_val;
11628 }
11629 static nir_const_value
evaluate_udiv(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)11630 evaluate_udiv(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
11631 MAYBE_UNUSED nir_const_value *_src)
11632 {
11633 nir_const_value _dst_val = { {0, } };
11634
11635 switch (bit_size) {
11636 case 8: {
11637
11638
11639
11640
11641 for (unsigned _i = 0; _i < num_components; _i++) {
11642 const uint8_t src0 =
11643 _src[0].u8[_i];
11644 const uint8_t src1 =
11645 _src[1].u8[_i];
11646
11647 uint8_t dst = src1 == 0 ? 0 : (src0 / src1);
11648
11649 _dst_val.u8[_i] = dst;
11650 }
11651
11652 break;
11653 }
11654 case 16: {
11655
11656
11657
11658
11659 for (unsigned _i = 0; _i < num_components; _i++) {
11660 const uint16_t src0 =
11661 _src[0].u16[_i];
11662 const uint16_t src1 =
11663 _src[1].u16[_i];
11664
11665 uint16_t dst = src1 == 0 ? 0 : (src0 / src1);
11666
11667 _dst_val.u16[_i] = dst;
11668 }
11669
11670 break;
11671 }
11672 case 32: {
11673
11674
11675
11676
11677 for (unsigned _i = 0; _i < num_components; _i++) {
11678 const uint32_t src0 =
11679 _src[0].u32[_i];
11680 const uint32_t src1 =
11681 _src[1].u32[_i];
11682
11683 uint32_t dst = src1 == 0 ? 0 : (src0 / src1);
11684
11685 _dst_val.u32[_i] = dst;
11686 }
11687
11688 break;
11689 }
11690 case 64: {
11691
11692
11693
11694
11695 for (unsigned _i = 0; _i < num_components; _i++) {
11696 const uint64_t src0 =
11697 _src[0].u64[_i];
11698 const uint64_t src1 =
11699 _src[1].u64[_i];
11700
11701 uint64_t dst = src1 == 0 ? 0 : (src0 / src1);
11702
11703 _dst_val.u64[_i] = dst;
11704 }
11705
11706 break;
11707 }
11708
11709 default:
11710 unreachable("unknown bit width");
11711 }
11712
11713 return _dst_val;
11714 }
11715 static nir_const_value
evaluate_ufind_msb(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)11716 evaluate_ufind_msb(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
11717 MAYBE_UNUSED nir_const_value *_src)
11718 {
11719 nir_const_value _dst_val = { {0, } };
11720
11721
11722
11723
11724
11725 for (unsigned _i = 0; _i < num_components; _i++) {
11726 const uint32_t src0 =
11727 _src[0].u32[_i];
11728
11729 int32_t dst;
11730
11731
11732 dst = -1;
11733 for (int bit = 31; bit >= 0; bit--) {
11734 if ((src0 >> bit) & 1) {
11735 dst = bit;
11736 break;
11737 }
11738 }
11739
11740
11741 _dst_val.i32[_i] = dst;
11742 }
11743
11744
11745 return _dst_val;
11746 }
11747 static nir_const_value
evaluate_uge(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)11748 evaluate_uge(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
11749 MAYBE_UNUSED nir_const_value *_src)
11750 {
11751 nir_const_value _dst_val = { {0, } };
11752
11753 switch (bit_size) {
11754 case 8: {
11755
11756
11757
11758
11759 for (unsigned _i = 0; _i < num_components; _i++) {
11760 const uint8_t src0 =
11761 _src[0].u8[_i];
11762 const uint8_t src1 =
11763 _src[1].u8[_i];
11764
11765 bool32_t dst = src0 >= src1;
11766
11767 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
11768 }
11769
11770 break;
11771 }
11772 case 16: {
11773
11774
11775
11776
11777 for (unsigned _i = 0; _i < num_components; _i++) {
11778 const uint16_t src0 =
11779 _src[0].u16[_i];
11780 const uint16_t src1 =
11781 _src[1].u16[_i];
11782
11783 bool32_t dst = src0 >= src1;
11784
11785 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
11786 }
11787
11788 break;
11789 }
11790 case 32: {
11791
11792
11793
11794
11795 for (unsigned _i = 0; _i < num_components; _i++) {
11796 const uint32_t src0 =
11797 _src[0].u32[_i];
11798 const uint32_t src1 =
11799 _src[1].u32[_i];
11800
11801 bool32_t dst = src0 >= src1;
11802
11803 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
11804 }
11805
11806 break;
11807 }
11808 case 64: {
11809
11810
11811
11812
11813 for (unsigned _i = 0; _i < num_components; _i++) {
11814 const uint64_t src0 =
11815 _src[0].u64[_i];
11816 const uint64_t src1 =
11817 _src[1].u64[_i];
11818
11819 bool32_t dst = src0 >= src1;
11820
11821 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
11822 }
11823
11824 break;
11825 }
11826
11827 default:
11828 unreachable("unknown bit width");
11829 }
11830
11831 return _dst_val;
11832 }
11833 static nir_const_value
evaluate_ult(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)11834 evaluate_ult(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
11835 MAYBE_UNUSED nir_const_value *_src)
11836 {
11837 nir_const_value _dst_val = { {0, } };
11838
11839 switch (bit_size) {
11840 case 8: {
11841
11842
11843
11844
11845 for (unsigned _i = 0; _i < num_components; _i++) {
11846 const uint8_t src0 =
11847 _src[0].u8[_i];
11848 const uint8_t src1 =
11849 _src[1].u8[_i];
11850
11851 bool32_t dst = src0 < src1;
11852
11853 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
11854 }
11855
11856 break;
11857 }
11858 case 16: {
11859
11860
11861
11862
11863 for (unsigned _i = 0; _i < num_components; _i++) {
11864 const uint16_t src0 =
11865 _src[0].u16[_i];
11866 const uint16_t src1 =
11867 _src[1].u16[_i];
11868
11869 bool32_t dst = src0 < src1;
11870
11871 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
11872 }
11873
11874 break;
11875 }
11876 case 32: {
11877
11878
11879
11880
11881 for (unsigned _i = 0; _i < num_components; _i++) {
11882 const uint32_t src0 =
11883 _src[0].u32[_i];
11884 const uint32_t src1 =
11885 _src[1].u32[_i];
11886
11887 bool32_t dst = src0 < src1;
11888
11889 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
11890 }
11891
11892 break;
11893 }
11894 case 64: {
11895
11896
11897
11898
11899 for (unsigned _i = 0; _i < num_components; _i++) {
11900 const uint64_t src0 =
11901 _src[0].u64[_i];
11902 const uint64_t src1 =
11903 _src[1].u64[_i];
11904
11905 bool32_t dst = src0 < src1;
11906
11907 _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
11908 }
11909
11910 break;
11911 }
11912
11913 default:
11914 unreachable("unknown bit width");
11915 }
11916
11917 return _dst_val;
11918 }
11919 static nir_const_value
evaluate_umax(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)11920 evaluate_umax(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
11921 MAYBE_UNUSED nir_const_value *_src)
11922 {
11923 nir_const_value _dst_val = { {0, } };
11924
11925 switch (bit_size) {
11926 case 8: {
11927
11928
11929
11930
11931 for (unsigned _i = 0; _i < num_components; _i++) {
11932 const uint8_t src0 =
11933 _src[0].u8[_i];
11934 const uint8_t src1 =
11935 _src[1].u8[_i];
11936
11937 uint8_t dst = src1 > src0 ? src1 : src0;
11938
11939 _dst_val.u8[_i] = dst;
11940 }
11941
11942 break;
11943 }
11944 case 16: {
11945
11946
11947
11948
11949 for (unsigned _i = 0; _i < num_components; _i++) {
11950 const uint16_t src0 =
11951 _src[0].u16[_i];
11952 const uint16_t src1 =
11953 _src[1].u16[_i];
11954
11955 uint16_t dst = src1 > src0 ? src1 : src0;
11956
11957 _dst_val.u16[_i] = dst;
11958 }
11959
11960 break;
11961 }
11962 case 32: {
11963
11964
11965
11966
11967 for (unsigned _i = 0; _i < num_components; _i++) {
11968 const uint32_t src0 =
11969 _src[0].u32[_i];
11970 const uint32_t src1 =
11971 _src[1].u32[_i];
11972
11973 uint32_t dst = src1 > src0 ? src1 : src0;
11974
11975 _dst_val.u32[_i] = dst;
11976 }
11977
11978 break;
11979 }
11980 case 64: {
11981
11982
11983
11984
11985 for (unsigned _i = 0; _i < num_components; _i++) {
11986 const uint64_t src0 =
11987 _src[0].u64[_i];
11988 const uint64_t src1 =
11989 _src[1].u64[_i];
11990
11991 uint64_t dst = src1 > src0 ? src1 : src0;
11992
11993 _dst_val.u64[_i] = dst;
11994 }
11995
11996 break;
11997 }
11998
11999 default:
12000 unreachable("unknown bit width");
12001 }
12002
12003 return _dst_val;
12004 }
12005 static nir_const_value
evaluate_umax_4x8(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12006 evaluate_umax_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12007 MAYBE_UNUSED nir_const_value *_src)
12008 {
12009 nir_const_value _dst_val = { {0, } };
12010
12011
12012
12013
12014
12015 for (unsigned _i = 0; _i < num_components; _i++) {
12016 const int32_t src0 =
12017 _src[0].i32[_i];
12018 const int32_t src1 =
12019 _src[1].i32[_i];
12020
12021 int32_t dst;
12022
12023
12024 dst = 0;
12025 for (int i = 0; i < 32; i += 8) {
12026 dst |= MAX2((src0 >> i) & 0xff, (src1 >> i) & 0xff) << i;
12027 }
12028
12029
12030 _dst_val.i32[_i] = dst;
12031 }
12032
12033
12034 return _dst_val;
12035 }
12036 static nir_const_value
evaluate_umin(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12037 evaluate_umin(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12038 MAYBE_UNUSED nir_const_value *_src)
12039 {
12040 nir_const_value _dst_val = { {0, } };
12041
12042 switch (bit_size) {
12043 case 8: {
12044
12045
12046
12047
12048 for (unsigned _i = 0; _i < num_components; _i++) {
12049 const uint8_t src0 =
12050 _src[0].u8[_i];
12051 const uint8_t src1 =
12052 _src[1].u8[_i];
12053
12054 uint8_t dst = src1 > src0 ? src0 : src1;
12055
12056 _dst_val.u8[_i] = dst;
12057 }
12058
12059 break;
12060 }
12061 case 16: {
12062
12063
12064
12065
12066 for (unsigned _i = 0; _i < num_components; _i++) {
12067 const uint16_t src0 =
12068 _src[0].u16[_i];
12069 const uint16_t src1 =
12070 _src[1].u16[_i];
12071
12072 uint16_t dst = src1 > src0 ? src0 : src1;
12073
12074 _dst_val.u16[_i] = dst;
12075 }
12076
12077 break;
12078 }
12079 case 32: {
12080
12081
12082
12083
12084 for (unsigned _i = 0; _i < num_components; _i++) {
12085 const uint32_t src0 =
12086 _src[0].u32[_i];
12087 const uint32_t src1 =
12088 _src[1].u32[_i];
12089
12090 uint32_t dst = src1 > src0 ? src0 : src1;
12091
12092 _dst_val.u32[_i] = dst;
12093 }
12094
12095 break;
12096 }
12097 case 64: {
12098
12099
12100
12101
12102 for (unsigned _i = 0; _i < num_components; _i++) {
12103 const uint64_t src0 =
12104 _src[0].u64[_i];
12105 const uint64_t src1 =
12106 _src[1].u64[_i];
12107
12108 uint64_t dst = src1 > src0 ? src0 : src1;
12109
12110 _dst_val.u64[_i] = dst;
12111 }
12112
12113 break;
12114 }
12115
12116 default:
12117 unreachable("unknown bit width");
12118 }
12119
12120 return _dst_val;
12121 }
12122 static nir_const_value
evaluate_umin_4x8(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12123 evaluate_umin_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12124 MAYBE_UNUSED nir_const_value *_src)
12125 {
12126 nir_const_value _dst_val = { {0, } };
12127
12128
12129
12130
12131
12132 for (unsigned _i = 0; _i < num_components; _i++) {
12133 const int32_t src0 =
12134 _src[0].i32[_i];
12135 const int32_t src1 =
12136 _src[1].i32[_i];
12137
12138 int32_t dst;
12139
12140
12141 dst = 0;
12142 for (int i = 0; i < 32; i += 8) {
12143 dst |= MIN2((src0 >> i) & 0xff, (src1 >> i) & 0xff) << i;
12144 }
12145
12146
12147 _dst_val.i32[_i] = dst;
12148 }
12149
12150
12151 return _dst_val;
12152 }
12153 static nir_const_value
evaluate_umod(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12154 evaluate_umod(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12155 MAYBE_UNUSED nir_const_value *_src)
12156 {
12157 nir_const_value _dst_val = { {0, } };
12158
12159 switch (bit_size) {
12160 case 8: {
12161
12162
12163
12164
12165 for (unsigned _i = 0; _i < num_components; _i++) {
12166 const uint8_t src0 =
12167 _src[0].u8[_i];
12168 const uint8_t src1 =
12169 _src[1].u8[_i];
12170
12171 uint8_t dst = src1 == 0 ? 0 : src0 % src1;
12172
12173 _dst_val.u8[_i] = dst;
12174 }
12175
12176 break;
12177 }
12178 case 16: {
12179
12180
12181
12182
12183 for (unsigned _i = 0; _i < num_components; _i++) {
12184 const uint16_t src0 =
12185 _src[0].u16[_i];
12186 const uint16_t src1 =
12187 _src[1].u16[_i];
12188
12189 uint16_t dst = src1 == 0 ? 0 : src0 % src1;
12190
12191 _dst_val.u16[_i] = dst;
12192 }
12193
12194 break;
12195 }
12196 case 32: {
12197
12198
12199
12200
12201 for (unsigned _i = 0; _i < num_components; _i++) {
12202 const uint32_t src0 =
12203 _src[0].u32[_i];
12204 const uint32_t src1 =
12205 _src[1].u32[_i];
12206
12207 uint32_t dst = src1 == 0 ? 0 : src0 % src1;
12208
12209 _dst_val.u32[_i] = dst;
12210 }
12211
12212 break;
12213 }
12214 case 64: {
12215
12216
12217
12218
12219 for (unsigned _i = 0; _i < num_components; _i++) {
12220 const uint64_t src0 =
12221 _src[0].u64[_i];
12222 const uint64_t src1 =
12223 _src[1].u64[_i];
12224
12225 uint64_t dst = src1 == 0 ? 0 : src0 % src1;
12226
12227 _dst_val.u64[_i] = dst;
12228 }
12229
12230 break;
12231 }
12232
12233 default:
12234 unreachable("unknown bit width");
12235 }
12236
12237 return _dst_val;
12238 }
12239 static nir_const_value
evaluate_umul_high(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12240 evaluate_umul_high(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12241 MAYBE_UNUSED nir_const_value *_src)
12242 {
12243 nir_const_value _dst_val = { {0, } };
12244
12245
12246
12247
12248
12249 for (unsigned _i = 0; _i < num_components; _i++) {
12250 const uint32_t src0 =
12251 _src[0].u32[_i];
12252 const uint32_t src1 =
12253 _src[1].u32[_i];
12254
12255 uint32_t dst = (uint32_t)(((uint64_t) src0 * (uint64_t) src1) >> 32);
12256
12257 _dst_val.u32[_i] = dst;
12258 }
12259
12260
12261 return _dst_val;
12262 }
12263 static nir_const_value
evaluate_umul_unorm_4x8(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12264 evaluate_umul_unorm_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12265 MAYBE_UNUSED nir_const_value *_src)
12266 {
12267 nir_const_value _dst_val = { {0, } };
12268
12269
12270
12271
12272
12273 for (unsigned _i = 0; _i < num_components; _i++) {
12274 const int32_t src0 =
12275 _src[0].i32[_i];
12276 const int32_t src1 =
12277 _src[1].i32[_i];
12278
12279 int32_t dst;
12280
12281
12282 dst = 0;
12283 for (int i = 0; i < 32; i += 8) {
12284 int src0_chan = (src0 >> i) & 0xff;
12285 int src1_chan = (src1 >> i) & 0xff;
12286 dst |= ((src0_chan * src1_chan) / 255) << i;
12287 }
12288
12289
12290 _dst_val.i32[_i] = dst;
12291 }
12292
12293
12294 return _dst_val;
12295 }
12296 static nir_const_value
evaluate_unpack_64_2x32(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12297 evaluate_unpack_64_2x32(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12298 MAYBE_UNUSED nir_const_value *_src)
12299 {
12300 nir_const_value _dst_val = { {0, } };
12301
12302
12303
12304
12305
12306 const struct uint64_vec src0 = {
12307 _src[0].u64[0],
12308 0,
12309 0,
12310 0,
12311 };
12312
12313 struct uint32_vec dst;
12314
12315 dst.x = src0.x; dst.y = src0.x >> 32;
12316
12317 _dst_val.u32[0] = dst.x;
12318 _dst_val.u32[1] = dst.y;
12319
12320
12321 return _dst_val;
12322 }
12323 static nir_const_value
evaluate_unpack_64_2x32_split_x(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12324 evaluate_unpack_64_2x32_split_x(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12325 MAYBE_UNUSED nir_const_value *_src)
12326 {
12327 nir_const_value _dst_val = { {0, } };
12328
12329
12330
12331
12332
12333 for (unsigned _i = 0; _i < num_components; _i++) {
12334 const uint64_t src0 =
12335 _src[0].u64[_i];
12336
12337 uint32_t dst = src0;
12338
12339 _dst_val.u32[_i] = dst;
12340 }
12341
12342
12343 return _dst_val;
12344 }
12345 static nir_const_value
evaluate_unpack_64_2x32_split_y(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12346 evaluate_unpack_64_2x32_split_y(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12347 MAYBE_UNUSED nir_const_value *_src)
12348 {
12349 nir_const_value _dst_val = { {0, } };
12350
12351
12352
12353
12354
12355 for (unsigned _i = 0; _i < num_components; _i++) {
12356 const uint64_t src0 =
12357 _src[0].u64[_i];
12358
12359 uint32_t dst = src0 >> 32;
12360
12361 _dst_val.u32[_i] = dst;
12362 }
12363
12364
12365 return _dst_val;
12366 }
12367 static nir_const_value
evaluate_unpack_half_2x16(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12368 evaluate_unpack_half_2x16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12369 MAYBE_UNUSED nir_const_value *_src)
12370 {
12371 nir_const_value _dst_val = { {0, } };
12372
12373
12374
12375
12376
12377 const struct uint32_vec src0 = {
12378 _src[0].u32[0],
12379 0,
12380 0,
12381 0,
12382 };
12383
12384 struct float32_vec dst;
12385
12386
12387 dst.x = unpack_half_1x16((uint16_t)(src0.x & 0xffff));
12388 dst.y = unpack_half_1x16((uint16_t)(src0.x << 16));
12389
12390
12391 _dst_val.f32[0] = dst.x;
12392 _dst_val.f32[1] = dst.y;
12393
12394
12395 return _dst_val;
12396 }
12397 static nir_const_value
evaluate_unpack_half_2x16_split_x(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12398 evaluate_unpack_half_2x16_split_x(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12399 MAYBE_UNUSED nir_const_value *_src)
12400 {
12401 nir_const_value _dst_val = { {0, } };
12402
12403
12404
12405
12406
12407 const struct uint32_vec src0 = {
12408 _src[0].u32[0],
12409 0,
12410 0,
12411 0,
12412 };
12413
12414 struct float32_vec dst;
12415
12416 dst.x = dst.y = dst.z = dst.w = unpack_half_1x16((uint16_t)(src0.x & 0xffff));
12417
12418 _dst_val.f32[0] = dst.x;
12419
12420
12421 return _dst_val;
12422 }
12423 static nir_const_value
evaluate_unpack_half_2x16_split_y(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12424 evaluate_unpack_half_2x16_split_y(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12425 MAYBE_UNUSED nir_const_value *_src)
12426 {
12427 nir_const_value _dst_val = { {0, } };
12428
12429
12430
12431
12432
12433 const struct uint32_vec src0 = {
12434 _src[0].u32[0],
12435 0,
12436 0,
12437 0,
12438 };
12439
12440 struct float32_vec dst;
12441
12442 dst.x = dst.y = dst.z = dst.w = unpack_half_1x16((uint16_t)(src0.x >> 16));
12443
12444 _dst_val.f32[0] = dst.x;
12445
12446
12447 return _dst_val;
12448 }
12449 static nir_const_value
evaluate_unpack_snorm_2x16(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12450 evaluate_unpack_snorm_2x16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12451 MAYBE_UNUSED nir_const_value *_src)
12452 {
12453 nir_const_value _dst_val = { {0, } };
12454
12455
12456
12457
12458
12459 const struct uint32_vec src0 = {
12460 _src[0].u32[0],
12461 0,
12462 0,
12463 0,
12464 };
12465
12466 struct float32_vec dst;
12467
12468
12469 dst.x = unpack_snorm_1x16((uint16_t)(src0.x & 0xffff));
12470 dst.y = unpack_snorm_1x16((uint16_t)(src0.x << 16));
12471
12472
12473 _dst_val.f32[0] = dst.x;
12474 _dst_val.f32[1] = dst.y;
12475
12476
12477 return _dst_val;
12478 }
12479 static nir_const_value
evaluate_unpack_snorm_4x8(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12480 evaluate_unpack_snorm_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12481 MAYBE_UNUSED nir_const_value *_src)
12482 {
12483 nir_const_value _dst_val = { {0, } };
12484
12485
12486
12487
12488
12489 const struct uint32_vec src0 = {
12490 _src[0].u32[0],
12491 0,
12492 0,
12493 0,
12494 };
12495
12496 struct float32_vec dst;
12497
12498
12499 dst.x = unpack_snorm_1x8((uint8_t)(src0.x & 0xff));
12500 dst.y = unpack_snorm_1x8((uint8_t)((src0.x >> 8) & 0xff));
12501 dst.z = unpack_snorm_1x8((uint8_t)((src0.x >> 16) & 0xff));
12502 dst.w = unpack_snorm_1x8((uint8_t)(src0.x >> 24));
12503
12504
12505 _dst_val.f32[0] = dst.x;
12506 _dst_val.f32[1] = dst.y;
12507 _dst_val.f32[2] = dst.z;
12508 _dst_val.f32[3] = dst.w;
12509
12510
12511 return _dst_val;
12512 }
12513 static nir_const_value
evaluate_unpack_unorm_2x16(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12514 evaluate_unpack_unorm_2x16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12515 MAYBE_UNUSED nir_const_value *_src)
12516 {
12517 nir_const_value _dst_val = { {0, } };
12518
12519
12520
12521
12522
12523 const struct uint32_vec src0 = {
12524 _src[0].u32[0],
12525 0,
12526 0,
12527 0,
12528 };
12529
12530 struct float32_vec dst;
12531
12532
12533 dst.x = unpack_unorm_1x16((uint16_t)(src0.x & 0xffff));
12534 dst.y = unpack_unorm_1x16((uint16_t)(src0.x << 16));
12535
12536
12537 _dst_val.f32[0] = dst.x;
12538 _dst_val.f32[1] = dst.y;
12539
12540
12541 return _dst_val;
12542 }
12543 static nir_const_value
evaluate_unpack_unorm_4x8(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12544 evaluate_unpack_unorm_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12545 MAYBE_UNUSED nir_const_value *_src)
12546 {
12547 nir_const_value _dst_val = { {0, } };
12548
12549
12550
12551
12552
12553 const struct uint32_vec src0 = {
12554 _src[0].u32[0],
12555 0,
12556 0,
12557 0,
12558 };
12559
12560 struct float32_vec dst;
12561
12562
12563 dst.x = unpack_unorm_1x8((uint8_t)(src0.x & 0xff));
12564 dst.y = unpack_unorm_1x8((uint8_t)((src0.x >> 8) & 0xff));
12565 dst.z = unpack_unorm_1x8((uint8_t)((src0.x >> 16) & 0xff));
12566 dst.w = unpack_unorm_1x8((uint8_t)(src0.x >> 24));
12567
12568
12569 _dst_val.f32[0] = dst.x;
12570 _dst_val.f32[1] = dst.y;
12571 _dst_val.f32[2] = dst.z;
12572 _dst_val.f32[3] = dst.w;
12573
12574
12575 return _dst_val;
12576 }
12577 static nir_const_value
evaluate_usadd_4x8(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12578 evaluate_usadd_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12579 MAYBE_UNUSED nir_const_value *_src)
12580 {
12581 nir_const_value _dst_val = { {0, } };
12582
12583
12584
12585
12586
12587 for (unsigned _i = 0; _i < num_components; _i++) {
12588 const int32_t src0 =
12589 _src[0].i32[_i];
12590 const int32_t src1 =
12591 _src[1].i32[_i];
12592
12593 int32_t dst;
12594
12595
12596 dst = 0;
12597 for (int i = 0; i < 32; i += 8) {
12598 dst |= MIN2(((src0 >> i) & 0xff) + ((src1 >> i) & 0xff), 0xff) << i;
12599 }
12600
12601
12602 _dst_val.i32[_i] = dst;
12603 }
12604
12605
12606 return _dst_val;
12607 }
12608 static nir_const_value
evaluate_ushr(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12609 evaluate_ushr(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12610 MAYBE_UNUSED nir_const_value *_src)
12611 {
12612 nir_const_value _dst_val = { {0, } };
12613
12614 switch (bit_size) {
12615 case 8: {
12616
12617
12618
12619
12620 for (unsigned _i = 0; _i < num_components; _i++) {
12621 const uint8_t src0 =
12622 _src[0].u8[_i];
12623 const uint32_t src1 =
12624 _src[1].u32[_i];
12625
12626 uint8_t dst = src0 >> src1;
12627
12628 _dst_val.u8[_i] = dst;
12629 }
12630
12631 break;
12632 }
12633 case 16: {
12634
12635
12636
12637
12638 for (unsigned _i = 0; _i < num_components; _i++) {
12639 const uint16_t src0 =
12640 _src[0].u16[_i];
12641 const uint32_t src1 =
12642 _src[1].u32[_i];
12643
12644 uint16_t dst = src0 >> src1;
12645
12646 _dst_val.u16[_i] = dst;
12647 }
12648
12649 break;
12650 }
12651 case 32: {
12652
12653
12654
12655
12656 for (unsigned _i = 0; _i < num_components; _i++) {
12657 const uint32_t src0 =
12658 _src[0].u32[_i];
12659 const uint32_t src1 =
12660 _src[1].u32[_i];
12661
12662 uint32_t dst = src0 >> src1;
12663
12664 _dst_val.u32[_i] = dst;
12665 }
12666
12667 break;
12668 }
12669 case 64: {
12670
12671
12672
12673
12674 for (unsigned _i = 0; _i < num_components; _i++) {
12675 const uint64_t src0 =
12676 _src[0].u64[_i];
12677 const uint32_t src1 =
12678 _src[1].u32[_i];
12679
12680 uint64_t dst = src0 >> src1;
12681
12682 _dst_val.u64[_i] = dst;
12683 }
12684
12685 break;
12686 }
12687
12688 default:
12689 unreachable("unknown bit width");
12690 }
12691
12692 return _dst_val;
12693 }
12694 static nir_const_value
evaluate_ussub_4x8(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12695 evaluate_ussub_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12696 MAYBE_UNUSED nir_const_value *_src)
12697 {
12698 nir_const_value _dst_val = { {0, } };
12699
12700
12701
12702
12703
12704 for (unsigned _i = 0; _i < num_components; _i++) {
12705 const int32_t src0 =
12706 _src[0].i32[_i];
12707 const int32_t src1 =
12708 _src[1].i32[_i];
12709
12710 int32_t dst;
12711
12712
12713 dst = 0;
12714 for (int i = 0; i < 32; i += 8) {
12715 int src0_chan = (src0 >> i) & 0xff;
12716 int src1_chan = (src1 >> i) & 0xff;
12717 if (src0_chan > src1_chan)
12718 dst |= (src0_chan - src1_chan) << i;
12719 }
12720
12721
12722 _dst_val.i32[_i] = dst;
12723 }
12724
12725
12726 return _dst_val;
12727 }
12728 static nir_const_value
evaluate_usub_borrow(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12729 evaluate_usub_borrow(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12730 MAYBE_UNUSED nir_const_value *_src)
12731 {
12732 nir_const_value _dst_val = { {0, } };
12733
12734 switch (bit_size) {
12735 case 8: {
12736
12737
12738
12739
12740 for (unsigned _i = 0; _i < num_components; _i++) {
12741 const uint8_t src0 =
12742 _src[0].u8[_i];
12743 const uint8_t src1 =
12744 _src[1].u8[_i];
12745
12746 uint8_t dst = src0 < src1;
12747
12748 _dst_val.u8[_i] = dst;
12749 }
12750
12751 break;
12752 }
12753 case 16: {
12754
12755
12756
12757
12758 for (unsigned _i = 0; _i < num_components; _i++) {
12759 const uint16_t src0 =
12760 _src[0].u16[_i];
12761 const uint16_t src1 =
12762 _src[1].u16[_i];
12763
12764 uint16_t dst = src0 < src1;
12765
12766 _dst_val.u16[_i] = dst;
12767 }
12768
12769 break;
12770 }
12771 case 32: {
12772
12773
12774
12775
12776 for (unsigned _i = 0; _i < num_components; _i++) {
12777 const uint32_t src0 =
12778 _src[0].u32[_i];
12779 const uint32_t src1 =
12780 _src[1].u32[_i];
12781
12782 uint32_t dst = src0 < src1;
12783
12784 _dst_val.u32[_i] = dst;
12785 }
12786
12787 break;
12788 }
12789 case 64: {
12790
12791
12792
12793
12794 for (unsigned _i = 0; _i < num_components; _i++) {
12795 const uint64_t src0 =
12796 _src[0].u64[_i];
12797 const uint64_t src1 =
12798 _src[1].u64[_i];
12799
12800 uint64_t dst = src0 < src1;
12801
12802 _dst_val.u64[_i] = dst;
12803 }
12804
12805 break;
12806 }
12807
12808 default:
12809 unreachable("unknown bit width");
12810 }
12811
12812 return _dst_val;
12813 }
12814 static nir_const_value
evaluate_vec2(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12815 evaluate_vec2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12816 MAYBE_UNUSED nir_const_value *_src)
12817 {
12818 nir_const_value _dst_val = { {0, } };
12819
12820 switch (bit_size) {
12821 case 8: {
12822
12823
12824
12825
12826 const struct uint8_vec src0 = {
12827 _src[0].u8[0],
12828 0,
12829 0,
12830 0,
12831 };
12832
12833 const struct uint8_vec src1 = {
12834 _src[1].u8[0],
12835 0,
12836 0,
12837 0,
12838 };
12839
12840 struct uint8_vec dst;
12841
12842
12843 dst.x = src0.x;
12844 dst.y = src1.x;
12845
12846
12847 _dst_val.u8[0] = dst.x;
12848 _dst_val.u8[1] = dst.y;
12849
12850 break;
12851 }
12852 case 16: {
12853
12854
12855
12856
12857 const struct uint16_vec src0 = {
12858 _src[0].u16[0],
12859 0,
12860 0,
12861 0,
12862 };
12863
12864 const struct uint16_vec src1 = {
12865 _src[1].u16[0],
12866 0,
12867 0,
12868 0,
12869 };
12870
12871 struct uint16_vec dst;
12872
12873
12874 dst.x = src0.x;
12875 dst.y = src1.x;
12876
12877
12878 _dst_val.u16[0] = dst.x;
12879 _dst_val.u16[1] = dst.y;
12880
12881 break;
12882 }
12883 case 32: {
12884
12885
12886
12887
12888 const struct uint32_vec src0 = {
12889 _src[0].u32[0],
12890 0,
12891 0,
12892 0,
12893 };
12894
12895 const struct uint32_vec src1 = {
12896 _src[1].u32[0],
12897 0,
12898 0,
12899 0,
12900 };
12901
12902 struct uint32_vec dst;
12903
12904
12905 dst.x = src0.x;
12906 dst.y = src1.x;
12907
12908
12909 _dst_val.u32[0] = dst.x;
12910 _dst_val.u32[1] = dst.y;
12911
12912 break;
12913 }
12914 case 64: {
12915
12916
12917
12918
12919 const struct uint64_vec src0 = {
12920 _src[0].u64[0],
12921 0,
12922 0,
12923 0,
12924 };
12925
12926 const struct uint64_vec src1 = {
12927 _src[1].u64[0],
12928 0,
12929 0,
12930 0,
12931 };
12932
12933 struct uint64_vec dst;
12934
12935
12936 dst.x = src0.x;
12937 dst.y = src1.x;
12938
12939
12940 _dst_val.u64[0] = dst.x;
12941 _dst_val.u64[1] = dst.y;
12942
12943 break;
12944 }
12945
12946 default:
12947 unreachable("unknown bit width");
12948 }
12949
12950 return _dst_val;
12951 }
12952 static nir_const_value
evaluate_vec3(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)12953 evaluate_vec3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
12954 MAYBE_UNUSED nir_const_value *_src)
12955 {
12956 nir_const_value _dst_val = { {0, } };
12957
12958 switch (bit_size) {
12959 case 8: {
12960
12961
12962
12963
12964 const struct uint8_vec src0 = {
12965 _src[0].u8[0],
12966 0,
12967 0,
12968 0,
12969 };
12970
12971 const struct uint8_vec src1 = {
12972 _src[1].u8[0],
12973 0,
12974 0,
12975 0,
12976 };
12977
12978 const struct uint8_vec src2 = {
12979 _src[2].u8[0],
12980 0,
12981 0,
12982 0,
12983 };
12984
12985 struct uint8_vec dst;
12986
12987
12988 dst.x = src0.x;
12989 dst.y = src1.x;
12990 dst.z = src2.x;
12991
12992
12993 _dst_val.u8[0] = dst.x;
12994 _dst_val.u8[1] = dst.y;
12995 _dst_val.u8[2] = dst.z;
12996
12997 break;
12998 }
12999 case 16: {
13000
13001
13002
13003
13004 const struct uint16_vec src0 = {
13005 _src[0].u16[0],
13006 0,
13007 0,
13008 0,
13009 };
13010
13011 const struct uint16_vec src1 = {
13012 _src[1].u16[0],
13013 0,
13014 0,
13015 0,
13016 };
13017
13018 const struct uint16_vec src2 = {
13019 _src[2].u16[0],
13020 0,
13021 0,
13022 0,
13023 };
13024
13025 struct uint16_vec dst;
13026
13027
13028 dst.x = src0.x;
13029 dst.y = src1.x;
13030 dst.z = src2.x;
13031
13032
13033 _dst_val.u16[0] = dst.x;
13034 _dst_val.u16[1] = dst.y;
13035 _dst_val.u16[2] = dst.z;
13036
13037 break;
13038 }
13039 case 32: {
13040
13041
13042
13043
13044 const struct uint32_vec src0 = {
13045 _src[0].u32[0],
13046 0,
13047 0,
13048 0,
13049 };
13050
13051 const struct uint32_vec src1 = {
13052 _src[1].u32[0],
13053 0,
13054 0,
13055 0,
13056 };
13057
13058 const struct uint32_vec src2 = {
13059 _src[2].u32[0],
13060 0,
13061 0,
13062 0,
13063 };
13064
13065 struct uint32_vec dst;
13066
13067
13068 dst.x = src0.x;
13069 dst.y = src1.x;
13070 dst.z = src2.x;
13071
13072
13073 _dst_val.u32[0] = dst.x;
13074 _dst_val.u32[1] = dst.y;
13075 _dst_val.u32[2] = dst.z;
13076
13077 break;
13078 }
13079 case 64: {
13080
13081
13082
13083
13084 const struct uint64_vec src0 = {
13085 _src[0].u64[0],
13086 0,
13087 0,
13088 0,
13089 };
13090
13091 const struct uint64_vec src1 = {
13092 _src[1].u64[0],
13093 0,
13094 0,
13095 0,
13096 };
13097
13098 const struct uint64_vec src2 = {
13099 _src[2].u64[0],
13100 0,
13101 0,
13102 0,
13103 };
13104
13105 struct uint64_vec dst;
13106
13107
13108 dst.x = src0.x;
13109 dst.y = src1.x;
13110 dst.z = src2.x;
13111
13112
13113 _dst_val.u64[0] = dst.x;
13114 _dst_val.u64[1] = dst.y;
13115 _dst_val.u64[2] = dst.z;
13116
13117 break;
13118 }
13119
13120 default:
13121 unreachable("unknown bit width");
13122 }
13123
13124 return _dst_val;
13125 }
13126 static nir_const_value
evaluate_vec4(MAYBE_UNUSED unsigned num_components,unsigned bit_size,MAYBE_UNUSED nir_const_value * _src)13127 evaluate_vec4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
13128 MAYBE_UNUSED nir_const_value *_src)
13129 {
13130 nir_const_value _dst_val = { {0, } };
13131
13132 switch (bit_size) {
13133 case 8: {
13134
13135
13136
13137
13138 const struct uint8_vec src0 = {
13139 _src[0].u8[0],
13140 0,
13141 0,
13142 0,
13143 };
13144
13145 const struct uint8_vec src1 = {
13146 _src[1].u8[0],
13147 0,
13148 0,
13149 0,
13150 };
13151
13152 const struct uint8_vec src2 = {
13153 _src[2].u8[0],
13154 0,
13155 0,
13156 0,
13157 };
13158
13159 const struct uint8_vec src3 = {
13160 _src[3].u8[0],
13161 0,
13162 0,
13163 0,
13164 };
13165
13166 struct uint8_vec dst;
13167
13168
13169 dst.x = src0.x;
13170 dst.y = src1.x;
13171 dst.z = src2.x;
13172 dst.w = src3.x;
13173
13174
13175 _dst_val.u8[0] = dst.x;
13176 _dst_val.u8[1] = dst.y;
13177 _dst_val.u8[2] = dst.z;
13178 _dst_val.u8[3] = dst.w;
13179
13180 break;
13181 }
13182 case 16: {
13183
13184
13185
13186
13187 const struct uint16_vec src0 = {
13188 _src[0].u16[0],
13189 0,
13190 0,
13191 0,
13192 };
13193
13194 const struct uint16_vec src1 = {
13195 _src[1].u16[0],
13196 0,
13197 0,
13198 0,
13199 };
13200
13201 const struct uint16_vec src2 = {
13202 _src[2].u16[0],
13203 0,
13204 0,
13205 0,
13206 };
13207
13208 const struct uint16_vec src3 = {
13209 _src[3].u16[0],
13210 0,
13211 0,
13212 0,
13213 };
13214
13215 struct uint16_vec dst;
13216
13217
13218 dst.x = src0.x;
13219 dst.y = src1.x;
13220 dst.z = src2.x;
13221 dst.w = src3.x;
13222
13223
13224 _dst_val.u16[0] = dst.x;
13225 _dst_val.u16[1] = dst.y;
13226 _dst_val.u16[2] = dst.z;
13227 _dst_val.u16[3] = dst.w;
13228
13229 break;
13230 }
13231 case 32: {
13232
13233
13234
13235
13236 const struct uint32_vec src0 = {
13237 _src[0].u32[0],
13238 0,
13239 0,
13240 0,
13241 };
13242
13243 const struct uint32_vec src1 = {
13244 _src[1].u32[0],
13245 0,
13246 0,
13247 0,
13248 };
13249
13250 const struct uint32_vec src2 = {
13251 _src[2].u32[0],
13252 0,
13253 0,
13254 0,
13255 };
13256
13257 const struct uint32_vec src3 = {
13258 _src[3].u32[0],
13259 0,
13260 0,
13261 0,
13262 };
13263
13264 struct uint32_vec dst;
13265
13266
13267 dst.x = src0.x;
13268 dst.y = src1.x;
13269 dst.z = src2.x;
13270 dst.w = src3.x;
13271
13272
13273 _dst_val.u32[0] = dst.x;
13274 _dst_val.u32[1] = dst.y;
13275 _dst_val.u32[2] = dst.z;
13276 _dst_val.u32[3] = dst.w;
13277
13278 break;
13279 }
13280 case 64: {
13281
13282
13283
13284
13285 const struct uint64_vec src0 = {
13286 _src[0].u64[0],
13287 0,
13288 0,
13289 0,
13290 };
13291
13292 const struct uint64_vec src1 = {
13293 _src[1].u64[0],
13294 0,
13295 0,
13296 0,
13297 };
13298
13299 const struct uint64_vec src2 = {
13300 _src[2].u64[0],
13301 0,
13302 0,
13303 0,
13304 };
13305
13306 const struct uint64_vec src3 = {
13307 _src[3].u64[0],
13308 0,
13309 0,
13310 0,
13311 };
13312
13313 struct uint64_vec dst;
13314
13315
13316 dst.x = src0.x;
13317 dst.y = src1.x;
13318 dst.z = src2.x;
13319 dst.w = src3.x;
13320
13321
13322 _dst_val.u64[0] = dst.x;
13323 _dst_val.u64[1] = dst.y;
13324 _dst_val.u64[2] = dst.z;
13325 _dst_val.u64[3] = dst.w;
13326
13327 break;
13328 }
13329
13330 default:
13331 unreachable("unknown bit width");
13332 }
13333
13334 return _dst_val;
13335 }
13336
13337 nir_const_value
nir_eval_const_opcode(nir_op op,unsigned num_components,unsigned bit_width,nir_const_value * src)13338 nir_eval_const_opcode(nir_op op, unsigned num_components,
13339 unsigned bit_width, nir_const_value *src)
13340 {
13341 switch (op) {
13342 case nir_op_b2f:
13343 return evaluate_b2f(num_components, bit_width, src);
13344 case nir_op_b2i:
13345 return evaluate_b2i(num_components, bit_width, src);
13346 case nir_op_ball_fequal2:
13347 return evaluate_ball_fequal2(num_components, bit_width, src);
13348 case nir_op_ball_fequal3:
13349 return evaluate_ball_fequal3(num_components, bit_width, src);
13350 case nir_op_ball_fequal4:
13351 return evaluate_ball_fequal4(num_components, bit_width, src);
13352 case nir_op_ball_iequal2:
13353 return evaluate_ball_iequal2(num_components, bit_width, src);
13354 case nir_op_ball_iequal3:
13355 return evaluate_ball_iequal3(num_components, bit_width, src);
13356 case nir_op_ball_iequal4:
13357 return evaluate_ball_iequal4(num_components, bit_width, src);
13358 case nir_op_bany_fnequal2:
13359 return evaluate_bany_fnequal2(num_components, bit_width, src);
13360 case nir_op_bany_fnequal3:
13361 return evaluate_bany_fnequal3(num_components, bit_width, src);
13362 case nir_op_bany_fnequal4:
13363 return evaluate_bany_fnequal4(num_components, bit_width, src);
13364 case nir_op_bany_inequal2:
13365 return evaluate_bany_inequal2(num_components, bit_width, src);
13366 case nir_op_bany_inequal3:
13367 return evaluate_bany_inequal3(num_components, bit_width, src);
13368 case nir_op_bany_inequal4:
13369 return evaluate_bany_inequal4(num_components, bit_width, src);
13370 case nir_op_bcsel:
13371 return evaluate_bcsel(num_components, bit_width, src);
13372 case nir_op_bfi:
13373 return evaluate_bfi(num_components, bit_width, src);
13374 case nir_op_bfm:
13375 return evaluate_bfm(num_components, bit_width, src);
13376 case nir_op_bit_count:
13377 return evaluate_bit_count(num_components, bit_width, src);
13378 case nir_op_bitfield_insert:
13379 return evaluate_bitfield_insert(num_components, bit_width, src);
13380 case nir_op_bitfield_reverse:
13381 return evaluate_bitfield_reverse(num_components, bit_width, src);
13382 case nir_op_extract_i16:
13383 return evaluate_extract_i16(num_components, bit_width, src);
13384 case nir_op_extract_i8:
13385 return evaluate_extract_i8(num_components, bit_width, src);
13386 case nir_op_extract_u16:
13387 return evaluate_extract_u16(num_components, bit_width, src);
13388 case nir_op_extract_u8:
13389 return evaluate_extract_u8(num_components, bit_width, src);
13390 case nir_op_f2b:
13391 return evaluate_f2b(num_components, bit_width, src);
13392 case nir_op_f2f16_rtne:
13393 return evaluate_f2f16_rtne(num_components, bit_width, src);
13394 case nir_op_f2f16_rtz:
13395 return evaluate_f2f16_rtz(num_components, bit_width, src);
13396 case nir_op_f2f16_undef:
13397 return evaluate_f2f16_undef(num_components, bit_width, src);
13398 case nir_op_f2f32:
13399 return evaluate_f2f32(num_components, bit_width, src);
13400 case nir_op_f2f64:
13401 return evaluate_f2f64(num_components, bit_width, src);
13402 case nir_op_f2i16:
13403 return evaluate_f2i16(num_components, bit_width, src);
13404 case nir_op_f2i32:
13405 return evaluate_f2i32(num_components, bit_width, src);
13406 case nir_op_f2i64:
13407 return evaluate_f2i64(num_components, bit_width, src);
13408 case nir_op_f2i8:
13409 return evaluate_f2i8(num_components, bit_width, src);
13410 case nir_op_f2u16:
13411 return evaluate_f2u16(num_components, bit_width, src);
13412 case nir_op_f2u32:
13413 return evaluate_f2u32(num_components, bit_width, src);
13414 case nir_op_f2u64:
13415 return evaluate_f2u64(num_components, bit_width, src);
13416 case nir_op_f2u8:
13417 return evaluate_f2u8(num_components, bit_width, src);
13418 case nir_op_fabs:
13419 return evaluate_fabs(num_components, bit_width, src);
13420 case nir_op_fadd:
13421 return evaluate_fadd(num_components, bit_width, src);
13422 case nir_op_fall_equal2:
13423 return evaluate_fall_equal2(num_components, bit_width, src);
13424 case nir_op_fall_equal3:
13425 return evaluate_fall_equal3(num_components, bit_width, src);
13426 case nir_op_fall_equal4:
13427 return evaluate_fall_equal4(num_components, bit_width, src);
13428 case nir_op_fand:
13429 return evaluate_fand(num_components, bit_width, src);
13430 case nir_op_fany_nequal2:
13431 return evaluate_fany_nequal2(num_components, bit_width, src);
13432 case nir_op_fany_nequal3:
13433 return evaluate_fany_nequal3(num_components, bit_width, src);
13434 case nir_op_fany_nequal4:
13435 return evaluate_fany_nequal4(num_components, bit_width, src);
13436 case nir_op_fceil:
13437 return evaluate_fceil(num_components, bit_width, src);
13438 case nir_op_fcos:
13439 return evaluate_fcos(num_components, bit_width, src);
13440 case nir_op_fcsel:
13441 return evaluate_fcsel(num_components, bit_width, src);
13442 case nir_op_fddx:
13443 return evaluate_fddx(num_components, bit_width, src);
13444 case nir_op_fddx_coarse:
13445 return evaluate_fddx_coarse(num_components, bit_width, src);
13446 case nir_op_fddx_fine:
13447 return evaluate_fddx_fine(num_components, bit_width, src);
13448 case nir_op_fddy:
13449 return evaluate_fddy(num_components, bit_width, src);
13450 case nir_op_fddy_coarse:
13451 return evaluate_fddy_coarse(num_components, bit_width, src);
13452 case nir_op_fddy_fine:
13453 return evaluate_fddy_fine(num_components, bit_width, src);
13454 case nir_op_fdiv:
13455 return evaluate_fdiv(num_components, bit_width, src);
13456 case nir_op_fdot2:
13457 return evaluate_fdot2(num_components, bit_width, src);
13458 case nir_op_fdot3:
13459 return evaluate_fdot3(num_components, bit_width, src);
13460 case nir_op_fdot4:
13461 return evaluate_fdot4(num_components, bit_width, src);
13462 case nir_op_fdot_replicated2:
13463 return evaluate_fdot_replicated2(num_components, bit_width, src);
13464 case nir_op_fdot_replicated3:
13465 return evaluate_fdot_replicated3(num_components, bit_width, src);
13466 case nir_op_fdot_replicated4:
13467 return evaluate_fdot_replicated4(num_components, bit_width, src);
13468 case nir_op_fdph:
13469 return evaluate_fdph(num_components, bit_width, src);
13470 case nir_op_fdph_replicated:
13471 return evaluate_fdph_replicated(num_components, bit_width, src);
13472 case nir_op_feq:
13473 return evaluate_feq(num_components, bit_width, src);
13474 case nir_op_fexp2:
13475 return evaluate_fexp2(num_components, bit_width, src);
13476 case nir_op_ffloor:
13477 return evaluate_ffloor(num_components, bit_width, src);
13478 case nir_op_ffma:
13479 return evaluate_ffma(num_components, bit_width, src);
13480 case nir_op_ffract:
13481 return evaluate_ffract(num_components, bit_width, src);
13482 case nir_op_fge:
13483 return evaluate_fge(num_components, bit_width, src);
13484 case nir_op_find_lsb:
13485 return evaluate_find_lsb(num_components, bit_width, src);
13486 case nir_op_flog2:
13487 return evaluate_flog2(num_components, bit_width, src);
13488 case nir_op_flrp:
13489 return evaluate_flrp(num_components, bit_width, src);
13490 case nir_op_flt:
13491 return evaluate_flt(num_components, bit_width, src);
13492 case nir_op_fmax:
13493 return evaluate_fmax(num_components, bit_width, src);
13494 case nir_op_fmin:
13495 return evaluate_fmin(num_components, bit_width, src);
13496 case nir_op_fmod:
13497 return evaluate_fmod(num_components, bit_width, src);
13498 case nir_op_fmov:
13499 return evaluate_fmov(num_components, bit_width, src);
13500 case nir_op_fmul:
13501 return evaluate_fmul(num_components, bit_width, src);
13502 case nir_op_fne:
13503 return evaluate_fne(num_components, bit_width, src);
13504 case nir_op_fneg:
13505 return evaluate_fneg(num_components, bit_width, src);
13506 case nir_op_fnoise1_1:
13507 return evaluate_fnoise1_1(num_components, bit_width, src);
13508 case nir_op_fnoise1_2:
13509 return evaluate_fnoise1_2(num_components, bit_width, src);
13510 case nir_op_fnoise1_3:
13511 return evaluate_fnoise1_3(num_components, bit_width, src);
13512 case nir_op_fnoise1_4:
13513 return evaluate_fnoise1_4(num_components, bit_width, src);
13514 case nir_op_fnoise2_1:
13515 return evaluate_fnoise2_1(num_components, bit_width, src);
13516 case nir_op_fnoise2_2:
13517 return evaluate_fnoise2_2(num_components, bit_width, src);
13518 case nir_op_fnoise2_3:
13519 return evaluate_fnoise2_3(num_components, bit_width, src);
13520 case nir_op_fnoise2_4:
13521 return evaluate_fnoise2_4(num_components, bit_width, src);
13522 case nir_op_fnoise3_1:
13523 return evaluate_fnoise3_1(num_components, bit_width, src);
13524 case nir_op_fnoise3_2:
13525 return evaluate_fnoise3_2(num_components, bit_width, src);
13526 case nir_op_fnoise3_3:
13527 return evaluate_fnoise3_3(num_components, bit_width, src);
13528 case nir_op_fnoise3_4:
13529 return evaluate_fnoise3_4(num_components, bit_width, src);
13530 case nir_op_fnoise4_1:
13531 return evaluate_fnoise4_1(num_components, bit_width, src);
13532 case nir_op_fnoise4_2:
13533 return evaluate_fnoise4_2(num_components, bit_width, src);
13534 case nir_op_fnoise4_3:
13535 return evaluate_fnoise4_3(num_components, bit_width, src);
13536 case nir_op_fnoise4_4:
13537 return evaluate_fnoise4_4(num_components, bit_width, src);
13538 case nir_op_fnot:
13539 return evaluate_fnot(num_components, bit_width, src);
13540 case nir_op_for:
13541 return evaluate_for(num_components, bit_width, src);
13542 case nir_op_fpow:
13543 return evaluate_fpow(num_components, bit_width, src);
13544 case nir_op_fquantize2f16:
13545 return evaluate_fquantize2f16(num_components, bit_width, src);
13546 case nir_op_frcp:
13547 return evaluate_frcp(num_components, bit_width, src);
13548 case nir_op_frem:
13549 return evaluate_frem(num_components, bit_width, src);
13550 case nir_op_fround_even:
13551 return evaluate_fround_even(num_components, bit_width, src);
13552 case nir_op_frsq:
13553 return evaluate_frsq(num_components, bit_width, src);
13554 case nir_op_fsat:
13555 return evaluate_fsat(num_components, bit_width, src);
13556 case nir_op_fsign:
13557 return evaluate_fsign(num_components, bit_width, src);
13558 case nir_op_fsin:
13559 return evaluate_fsin(num_components, bit_width, src);
13560 case nir_op_fsqrt:
13561 return evaluate_fsqrt(num_components, bit_width, src);
13562 case nir_op_fsub:
13563 return evaluate_fsub(num_components, bit_width, src);
13564 case nir_op_ftrunc:
13565 return evaluate_ftrunc(num_components, bit_width, src);
13566 case nir_op_fxor:
13567 return evaluate_fxor(num_components, bit_width, src);
13568 case nir_op_i2b:
13569 return evaluate_i2b(num_components, bit_width, src);
13570 case nir_op_i2f16:
13571 return evaluate_i2f16(num_components, bit_width, src);
13572 case nir_op_i2f32:
13573 return evaluate_i2f32(num_components, bit_width, src);
13574 case nir_op_i2f64:
13575 return evaluate_i2f64(num_components, bit_width, src);
13576 case nir_op_i2i16:
13577 return evaluate_i2i16(num_components, bit_width, src);
13578 case nir_op_i2i32:
13579 return evaluate_i2i32(num_components, bit_width, src);
13580 case nir_op_i2i64:
13581 return evaluate_i2i64(num_components, bit_width, src);
13582 case nir_op_i2i8:
13583 return evaluate_i2i8(num_components, bit_width, src);
13584 case nir_op_iabs:
13585 return evaluate_iabs(num_components, bit_width, src);
13586 case nir_op_iadd:
13587 return evaluate_iadd(num_components, bit_width, src);
13588 case nir_op_iand:
13589 return evaluate_iand(num_components, bit_width, src);
13590 case nir_op_ibfe:
13591 return evaluate_ibfe(num_components, bit_width, src);
13592 case nir_op_ibitfield_extract:
13593 return evaluate_ibitfield_extract(num_components, bit_width, src);
13594 case nir_op_idiv:
13595 return evaluate_idiv(num_components, bit_width, src);
13596 case nir_op_ieq:
13597 return evaluate_ieq(num_components, bit_width, src);
13598 case nir_op_ifind_msb:
13599 return evaluate_ifind_msb(num_components, bit_width, src);
13600 case nir_op_ige:
13601 return evaluate_ige(num_components, bit_width, src);
13602 case nir_op_ilt:
13603 return evaluate_ilt(num_components, bit_width, src);
13604 case nir_op_imax:
13605 return evaluate_imax(num_components, bit_width, src);
13606 case nir_op_imin:
13607 return evaluate_imin(num_components, bit_width, src);
13608 case nir_op_imod:
13609 return evaluate_imod(num_components, bit_width, src);
13610 case nir_op_imov:
13611 return evaluate_imov(num_components, bit_width, src);
13612 case nir_op_imul:
13613 return evaluate_imul(num_components, bit_width, src);
13614 case nir_op_imul_high:
13615 return evaluate_imul_high(num_components, bit_width, src);
13616 case nir_op_ine:
13617 return evaluate_ine(num_components, bit_width, src);
13618 case nir_op_ineg:
13619 return evaluate_ineg(num_components, bit_width, src);
13620 case nir_op_inot:
13621 return evaluate_inot(num_components, bit_width, src);
13622 case nir_op_ior:
13623 return evaluate_ior(num_components, bit_width, src);
13624 case nir_op_irem:
13625 return evaluate_irem(num_components, bit_width, src);
13626 case nir_op_ishl:
13627 return evaluate_ishl(num_components, bit_width, src);
13628 case nir_op_ishr:
13629 return evaluate_ishr(num_components, bit_width, src);
13630 case nir_op_isign:
13631 return evaluate_isign(num_components, bit_width, src);
13632 case nir_op_isub:
13633 return evaluate_isub(num_components, bit_width, src);
13634 case nir_op_ixor:
13635 return evaluate_ixor(num_components, bit_width, src);
13636 case nir_op_ldexp:
13637 return evaluate_ldexp(num_components, bit_width, src);
13638 case nir_op_pack_64_2x32:
13639 return evaluate_pack_64_2x32(num_components, bit_width, src);
13640 case nir_op_pack_64_2x32_split:
13641 return evaluate_pack_64_2x32_split(num_components, bit_width, src);
13642 case nir_op_pack_half_2x16:
13643 return evaluate_pack_half_2x16(num_components, bit_width, src);
13644 case nir_op_pack_half_2x16_split:
13645 return evaluate_pack_half_2x16_split(num_components, bit_width, src);
13646 case nir_op_pack_snorm_2x16:
13647 return evaluate_pack_snorm_2x16(num_components, bit_width, src);
13648 case nir_op_pack_snorm_4x8:
13649 return evaluate_pack_snorm_4x8(num_components, bit_width, src);
13650 case nir_op_pack_unorm_2x16:
13651 return evaluate_pack_unorm_2x16(num_components, bit_width, src);
13652 case nir_op_pack_unorm_4x8:
13653 return evaluate_pack_unorm_4x8(num_components, bit_width, src);
13654 case nir_op_pack_uvec2_to_uint:
13655 return evaluate_pack_uvec2_to_uint(num_components, bit_width, src);
13656 case nir_op_pack_uvec4_to_uint:
13657 return evaluate_pack_uvec4_to_uint(num_components, bit_width, src);
13658 case nir_op_seq:
13659 return evaluate_seq(num_components, bit_width, src);
13660 case nir_op_sge:
13661 return evaluate_sge(num_components, bit_width, src);
13662 case nir_op_slt:
13663 return evaluate_slt(num_components, bit_width, src);
13664 case nir_op_sne:
13665 return evaluate_sne(num_components, bit_width, src);
13666 case nir_op_u2f16:
13667 return evaluate_u2f16(num_components, bit_width, src);
13668 case nir_op_u2f32:
13669 return evaluate_u2f32(num_components, bit_width, src);
13670 case nir_op_u2f64:
13671 return evaluate_u2f64(num_components, bit_width, src);
13672 case nir_op_u2u16:
13673 return evaluate_u2u16(num_components, bit_width, src);
13674 case nir_op_u2u32:
13675 return evaluate_u2u32(num_components, bit_width, src);
13676 case nir_op_u2u64:
13677 return evaluate_u2u64(num_components, bit_width, src);
13678 case nir_op_u2u8:
13679 return evaluate_u2u8(num_components, bit_width, src);
13680 case nir_op_uadd_carry:
13681 return evaluate_uadd_carry(num_components, bit_width, src);
13682 case nir_op_ubfe:
13683 return evaluate_ubfe(num_components, bit_width, src);
13684 case nir_op_ubitfield_extract:
13685 return evaluate_ubitfield_extract(num_components, bit_width, src);
13686 case nir_op_udiv:
13687 return evaluate_udiv(num_components, bit_width, src);
13688 case nir_op_ufind_msb:
13689 return evaluate_ufind_msb(num_components, bit_width, src);
13690 case nir_op_uge:
13691 return evaluate_uge(num_components, bit_width, src);
13692 case nir_op_ult:
13693 return evaluate_ult(num_components, bit_width, src);
13694 case nir_op_umax:
13695 return evaluate_umax(num_components, bit_width, src);
13696 case nir_op_umax_4x8:
13697 return evaluate_umax_4x8(num_components, bit_width, src);
13698 case nir_op_umin:
13699 return evaluate_umin(num_components, bit_width, src);
13700 case nir_op_umin_4x8:
13701 return evaluate_umin_4x8(num_components, bit_width, src);
13702 case nir_op_umod:
13703 return evaluate_umod(num_components, bit_width, src);
13704 case nir_op_umul_high:
13705 return evaluate_umul_high(num_components, bit_width, src);
13706 case nir_op_umul_unorm_4x8:
13707 return evaluate_umul_unorm_4x8(num_components, bit_width, src);
13708 case nir_op_unpack_64_2x32:
13709 return evaluate_unpack_64_2x32(num_components, bit_width, src);
13710 case nir_op_unpack_64_2x32_split_x:
13711 return evaluate_unpack_64_2x32_split_x(num_components, bit_width, src);
13712 case nir_op_unpack_64_2x32_split_y:
13713 return evaluate_unpack_64_2x32_split_y(num_components, bit_width, src);
13714 case nir_op_unpack_half_2x16:
13715 return evaluate_unpack_half_2x16(num_components, bit_width, src);
13716 case nir_op_unpack_half_2x16_split_x:
13717 return evaluate_unpack_half_2x16_split_x(num_components, bit_width, src);
13718 case nir_op_unpack_half_2x16_split_y:
13719 return evaluate_unpack_half_2x16_split_y(num_components, bit_width, src);
13720 case nir_op_unpack_snorm_2x16:
13721 return evaluate_unpack_snorm_2x16(num_components, bit_width, src);
13722 case nir_op_unpack_snorm_4x8:
13723 return evaluate_unpack_snorm_4x8(num_components, bit_width, src);
13724 case nir_op_unpack_unorm_2x16:
13725 return evaluate_unpack_unorm_2x16(num_components, bit_width, src);
13726 case nir_op_unpack_unorm_4x8:
13727 return evaluate_unpack_unorm_4x8(num_components, bit_width, src);
13728 case nir_op_usadd_4x8:
13729 return evaluate_usadd_4x8(num_components, bit_width, src);
13730 case nir_op_ushr:
13731 return evaluate_ushr(num_components, bit_width, src);
13732 case nir_op_ussub_4x8:
13733 return evaluate_ussub_4x8(num_components, bit_width, src);
13734 case nir_op_usub_borrow:
13735 return evaluate_usub_borrow(num_components, bit_width, src);
13736 case nir_op_vec2:
13737 return evaluate_vec2(num_components, bit_width, src);
13738 case nir_op_vec3:
13739 return evaluate_vec3(num_components, bit_width, src);
13740 case nir_op_vec4:
13741 return evaluate_vec4(num_components, bit_width, src);
13742 default:
13743 unreachable("shouldn't get here");
13744 }
13745 }
13746