• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1    switch (this->operation) {
2    case ir_unop_bit_not:
3       for (unsigned c = 0; c < op[0]->type->components(); c++) {
4          switch (op[0]->type->base_type) {
5          case GLSL_TYPE_UINT:
6             data.u[c] = ~ op[0]->value.u[c];
7             break;
8          case GLSL_TYPE_INT:
9             data.i[c] = ~ op[0]->value.i[c];
10             break;
11          default:
12             unreachable("invalid type");
13          }
14       }
15       break;
16 
17    case ir_unop_logic_not:
18       for (unsigned c = 0; c < op[0]->type->components(); c++) {
19          switch (op[0]->type->base_type) {
20          case GLSL_TYPE_BOOL:
21             data.b[c] = !op[0]->value.b[c];
22             break;
23          default:
24             unreachable("invalid type");
25          }
26       }
27       break;
28 
29    case ir_unop_neg:
30       for (unsigned c = 0; c < op[0]->type->components(); c++) {
31          switch (op[0]->type->base_type) {
32          case GLSL_TYPE_UINT:
33             data.u[c] = -((int) op[0]->value.u[c]);
34             break;
35          case GLSL_TYPE_INT:
36             data.i[c] = -op[0]->value.i[c];
37             break;
38          case GLSL_TYPE_FLOAT:
39             data.f[c] = -op[0]->value.f[c];
40             break;
41          case GLSL_TYPE_DOUBLE:
42             data.d[c] = -op[0]->value.d[c];
43             break;
44          default:
45             unreachable("invalid type");
46          }
47       }
48       break;
49 
50    case ir_unop_abs:
51       for (unsigned c = 0; c < op[0]->type->components(); c++) {
52          switch (op[0]->type->base_type) {
53          case GLSL_TYPE_INT:
54             data.i[c] = op[0]->value.i[c] < 0 ? -op[0]->value.i[c] : op[0]->value.i[c];
55             break;
56          case GLSL_TYPE_FLOAT:
57             data.f[c] = fabsf(op[0]->value.f[c]);
58             break;
59          case GLSL_TYPE_DOUBLE:
60             data.d[c] = fabs(op[0]->value.d[c]);
61             break;
62          default:
63             unreachable("invalid type");
64          }
65       }
66       break;
67 
68    case ir_unop_sign:
69       for (unsigned c = 0; c < op[0]->type->components(); c++) {
70          switch (op[0]->type->base_type) {
71          case GLSL_TYPE_INT:
72             data.i[c] = (op[0]->value.i[c] > 0) - (op[0]->value.i[c] < 0);
73             break;
74          case GLSL_TYPE_FLOAT:
75             data.f[c] = float((op[0]->value.f[c] > 0.0F) - (op[0]->value.f[c] < 0.0F));
76             break;
77          case GLSL_TYPE_DOUBLE:
78             data.d[c] = double((op[0]->value.d[c] > 0.0) - (op[0]->value.d[c] < 0.0));
79             break;
80          default:
81             unreachable("invalid type");
82          }
83       }
84       break;
85 
86    case ir_unop_rcp:
87       for (unsigned c = 0; c < op[0]->type->components(); c++) {
88          switch (op[0]->type->base_type) {
89          case GLSL_TYPE_FLOAT:
90             data.f[c] = op[0]->value.f[c] != 0.0F ? 1.0F / op[0]->value.f[c] : 0.0F;
91             break;
92          case GLSL_TYPE_DOUBLE:
93             data.d[c] = op[0]->value.d[c] != 0.0 ? 1.0 / op[0]->value.d[c] : 0.0;
94             break;
95          default:
96             unreachable("invalid type");
97          }
98       }
99       break;
100 
101    case ir_unop_rsq:
102       for (unsigned c = 0; c < op[0]->type->components(); c++) {
103          switch (op[0]->type->base_type) {
104          case GLSL_TYPE_FLOAT:
105             data.f[c] = 1.0F / sqrtf(op[0]->value.f[c]);
106             break;
107          case GLSL_TYPE_DOUBLE:
108             data.d[c] = 1.0 / sqrt(op[0]->value.d[c]);
109             break;
110          default:
111             unreachable("invalid type");
112          }
113       }
114       break;
115 
116    case ir_unop_sqrt:
117       for (unsigned c = 0; c < op[0]->type->components(); c++) {
118          switch (op[0]->type->base_type) {
119          case GLSL_TYPE_FLOAT:
120             data.f[c] = sqrtf(op[0]->value.f[c]);
121             break;
122          case GLSL_TYPE_DOUBLE:
123             data.d[c] = sqrt(op[0]->value.d[c]);
124             break;
125          default:
126             unreachable("invalid type");
127          }
128       }
129       break;
130 
131    case ir_unop_exp:
132       for (unsigned c = 0; c < op[0]->type->components(); c++) {
133          switch (op[0]->type->base_type) {
134          case GLSL_TYPE_FLOAT:
135             data.f[c] = expf(op[0]->value.f[c]);
136             break;
137          default:
138             unreachable("invalid type");
139          }
140       }
141       break;
142 
143    case ir_unop_log:
144       for (unsigned c = 0; c < op[0]->type->components(); c++) {
145          switch (op[0]->type->base_type) {
146          case GLSL_TYPE_FLOAT:
147             data.f[c] = logf(op[0]->value.f[c]);
148             break;
149          default:
150             unreachable("invalid type");
151          }
152       }
153       break;
154 
155    case ir_unop_exp2:
156       for (unsigned c = 0; c < op[0]->type->components(); c++) {
157          switch (op[0]->type->base_type) {
158          case GLSL_TYPE_FLOAT:
159             data.f[c] = exp2f(op[0]->value.f[c]);
160             break;
161          default:
162             unreachable("invalid type");
163          }
164       }
165       break;
166 
167    case ir_unop_log2:
168       for (unsigned c = 0; c < op[0]->type->components(); c++) {
169          switch (op[0]->type->base_type) {
170          case GLSL_TYPE_FLOAT:
171             data.f[c] = log2f(op[0]->value.f[c]);
172             break;
173          default:
174             unreachable("invalid type");
175          }
176       }
177       break;
178 
179    case ir_unop_f2i:
180       for (unsigned c = 0; c < op[0]->type->components(); c++) {
181          switch (op[0]->type->base_type) {
182          case GLSL_TYPE_FLOAT:
183             data.i[c] = (int) op[0]->value.f[c];
184             break;
185          default:
186             unreachable("invalid type");
187          }
188       }
189       break;
190 
191    case ir_unop_f2u:
192       for (unsigned c = 0; c < op[0]->type->components(); c++) {
193          switch (op[0]->type->base_type) {
194          case GLSL_TYPE_FLOAT:
195             data.u[c] = (unsigned) op[0]->value.f[c];
196             break;
197          default:
198             unreachable("invalid type");
199          }
200       }
201       break;
202 
203    case ir_unop_i2f:
204       for (unsigned c = 0; c < op[0]->type->components(); c++) {
205          switch (op[0]->type->base_type) {
206          case GLSL_TYPE_INT:
207             data.f[c] = (float) op[0]->value.i[c];
208             break;
209          default:
210             unreachable("invalid type");
211          }
212       }
213       break;
214 
215    case ir_unop_f2b:
216       for (unsigned c = 0; c < op[0]->type->components(); c++) {
217          switch (op[0]->type->base_type) {
218          case GLSL_TYPE_FLOAT:
219             data.b[c] = op[0]->value.f[c] != 0.0F ? true : false;
220             break;
221          default:
222             unreachable("invalid type");
223          }
224       }
225       break;
226 
227    case ir_unop_b2f:
228       for (unsigned c = 0; c < op[0]->type->components(); c++) {
229          switch (op[0]->type->base_type) {
230          case GLSL_TYPE_BOOL:
231             data.f[c] = op[0]->value.b[c] ? 1.0F : 0.0F;
232             break;
233          default:
234             unreachable("invalid type");
235          }
236       }
237       break;
238 
239    case ir_unop_i2b:
240       for (unsigned c = 0; c < op[0]->type->components(); c++) {
241          switch (op[0]->type->base_type) {
242          case GLSL_TYPE_UINT:
243             data.b[c] = op[0]->value.u[c] ? true : false;
244             break;
245          case GLSL_TYPE_INT:
246             data.b[c] = op[0]->value.i[c] ? true : false;
247             break;
248          default:
249             unreachable("invalid type");
250          }
251       }
252       break;
253 
254    case ir_unop_b2i:
255       for (unsigned c = 0; c < op[0]->type->components(); c++) {
256          switch (op[0]->type->base_type) {
257          case GLSL_TYPE_BOOL:
258             data.i[c] = op[0]->value.b[c] ? 1 : 0;
259             break;
260          default:
261             unreachable("invalid type");
262          }
263       }
264       break;
265 
266    case ir_unop_u2f:
267       for (unsigned c = 0; c < op[0]->type->components(); c++) {
268          switch (op[0]->type->base_type) {
269          case GLSL_TYPE_UINT:
270             data.f[c] = (float) op[0]->value.u[c];
271             break;
272          default:
273             unreachable("invalid type");
274          }
275       }
276       break;
277 
278    case ir_unop_i2u:
279       for (unsigned c = 0; c < op[0]->type->components(); c++) {
280          switch (op[0]->type->base_type) {
281          case GLSL_TYPE_INT:
282             data.u[c] = op[0]->value.i[c];
283             break;
284          default:
285             unreachable("invalid type");
286          }
287       }
288       break;
289 
290    case ir_unop_u2i:
291       for (unsigned c = 0; c < op[0]->type->components(); c++) {
292          switch (op[0]->type->base_type) {
293          case GLSL_TYPE_UINT:
294             data.i[c] = op[0]->value.u[c];
295             break;
296          default:
297             unreachable("invalid type");
298          }
299       }
300       break;
301 
302    case ir_unop_d2f:
303       for (unsigned c = 0; c < op[0]->type->components(); c++) {
304          switch (op[0]->type->base_type) {
305          case GLSL_TYPE_DOUBLE:
306             data.f[c] = op[0]->value.d[c];
307             break;
308          default:
309             unreachable("invalid type");
310          }
311       }
312       break;
313 
314    case ir_unop_f2d:
315       for (unsigned c = 0; c < op[0]->type->components(); c++) {
316          switch (op[0]->type->base_type) {
317          case GLSL_TYPE_FLOAT:
318             data.d[c] = op[0]->value.f[c];
319             break;
320          default:
321             unreachable("invalid type");
322          }
323       }
324       break;
325 
326    case ir_unop_d2i:
327       for (unsigned c = 0; c < op[0]->type->components(); c++) {
328          switch (op[0]->type->base_type) {
329          case GLSL_TYPE_DOUBLE:
330             data.i[c] = op[0]->value.d[c];
331             break;
332          default:
333             unreachable("invalid type");
334          }
335       }
336       break;
337 
338    case ir_unop_i2d:
339       for (unsigned c = 0; c < op[0]->type->components(); c++) {
340          switch (op[0]->type->base_type) {
341          case GLSL_TYPE_INT:
342             data.d[c] = op[0]->value.i[c];
343             break;
344          default:
345             unreachable("invalid type");
346          }
347       }
348       break;
349 
350    case ir_unop_d2u:
351       for (unsigned c = 0; c < op[0]->type->components(); c++) {
352          switch (op[0]->type->base_type) {
353          case GLSL_TYPE_DOUBLE:
354             data.u[c] = op[0]->value.d[c];
355             break;
356          default:
357             unreachable("invalid type");
358          }
359       }
360       break;
361 
362    case ir_unop_u2d:
363       for (unsigned c = 0; c < op[0]->type->components(); c++) {
364          switch (op[0]->type->base_type) {
365          case GLSL_TYPE_UINT:
366             data.d[c] = op[0]->value.u[c];
367             break;
368          default:
369             unreachable("invalid type");
370          }
371       }
372       break;
373 
374    case ir_unop_d2b:
375       for (unsigned c = 0; c < op[0]->type->components(); c++) {
376          switch (op[0]->type->base_type) {
377          case GLSL_TYPE_DOUBLE:
378             data.b[c] = op[0]->value.d[c] != 0.0;
379             break;
380          default:
381             unreachable("invalid type");
382          }
383       }
384       break;
385 
386    case ir_unop_bitcast_i2f:
387       for (unsigned c = 0; c < op[0]->type->components(); c++) {
388          switch (op[0]->type->base_type) {
389          case GLSL_TYPE_INT:
390             data.f[c] = bitcast_u2f(op[0]->value.i[c]);
391             break;
392          default:
393             unreachable("invalid type");
394          }
395       }
396       break;
397 
398    case ir_unop_bitcast_f2i:
399       for (unsigned c = 0; c < op[0]->type->components(); c++) {
400          switch (op[0]->type->base_type) {
401          case GLSL_TYPE_FLOAT:
402             data.i[c] = bitcast_f2u(op[0]->value.f[c]);
403             break;
404          default:
405             unreachable("invalid type");
406          }
407       }
408       break;
409 
410    case ir_unop_bitcast_u2f:
411       for (unsigned c = 0; c < op[0]->type->components(); c++) {
412          switch (op[0]->type->base_type) {
413          case GLSL_TYPE_UINT:
414             data.f[c] = bitcast_u2f(op[0]->value.u[c]);
415             break;
416          default:
417             unreachable("invalid type");
418          }
419       }
420       break;
421 
422    case ir_unop_bitcast_f2u:
423       for (unsigned c = 0; c < op[0]->type->components(); c++) {
424          switch (op[0]->type->base_type) {
425          case GLSL_TYPE_FLOAT:
426             data.u[c] = bitcast_f2u(op[0]->value.f[c]);
427             break;
428          default:
429             unreachable("invalid type");
430          }
431       }
432       break;
433 
434    case ir_unop_trunc:
435       for (unsigned c = 0; c < op[0]->type->components(); c++) {
436          switch (op[0]->type->base_type) {
437          case GLSL_TYPE_FLOAT:
438             data.f[c] = truncf(op[0]->value.f[c]);
439             break;
440          case GLSL_TYPE_DOUBLE:
441             data.d[c] = trunc(op[0]->value.d[c]);
442             break;
443          default:
444             unreachable("invalid type");
445          }
446       }
447       break;
448 
449    case ir_unop_ceil:
450       for (unsigned c = 0; c < op[0]->type->components(); c++) {
451          switch (op[0]->type->base_type) {
452          case GLSL_TYPE_FLOAT:
453             data.f[c] = ceilf(op[0]->value.f[c]);
454             break;
455          case GLSL_TYPE_DOUBLE:
456             data.d[c] = ceil(op[0]->value.d[c]);
457             break;
458          default:
459             unreachable("invalid type");
460          }
461       }
462       break;
463 
464    case ir_unop_floor:
465       for (unsigned c = 0; c < op[0]->type->components(); c++) {
466          switch (op[0]->type->base_type) {
467          case GLSL_TYPE_FLOAT:
468             data.f[c] = floorf(op[0]->value.f[c]);
469             break;
470          case GLSL_TYPE_DOUBLE:
471             data.d[c] = floor(op[0]->value.d[c]);
472             break;
473          default:
474             unreachable("invalid type");
475          }
476       }
477       break;
478 
479    case ir_unop_fract:
480       for (unsigned c = 0; c < op[0]->type->components(); c++) {
481          switch (op[0]->type->base_type) {
482          case GLSL_TYPE_FLOAT:
483             data.f[c] = op[0]->value.f[c] - floorf(op[0]->value.f[c]);
484             break;
485          case GLSL_TYPE_DOUBLE:
486             data.d[c] = op[0]->value.d[c] - floor(op[0]->value.d[c]);
487             break;
488          default:
489             unreachable("invalid type");
490          }
491       }
492       break;
493 
494    case ir_unop_round_even:
495       for (unsigned c = 0; c < op[0]->type->components(); c++) {
496          switch (op[0]->type->base_type) {
497          case GLSL_TYPE_FLOAT:
498             data.f[c] = _mesa_roundevenf(op[0]->value.f[c]);
499             break;
500          case GLSL_TYPE_DOUBLE:
501             data.d[c] = _mesa_roundeven(op[0]->value.d[c]);
502             break;
503          default:
504             unreachable("invalid type");
505          }
506       }
507       break;
508 
509    case ir_unop_sin:
510       for (unsigned c = 0; c < op[0]->type->components(); c++) {
511          switch (op[0]->type->base_type) {
512          case GLSL_TYPE_FLOAT:
513             data.f[c] = sinf(op[0]->value.f[c]);
514             break;
515          default:
516             unreachable("invalid type");
517          }
518       }
519       break;
520 
521    case ir_unop_cos:
522       for (unsigned c = 0; c < op[0]->type->components(); c++) {
523          switch (op[0]->type->base_type) {
524          case GLSL_TYPE_FLOAT:
525             data.f[c] = cosf(op[0]->value.f[c]);
526             break;
527          default:
528             unreachable("invalid type");
529          }
530       }
531       break;
532 
533    case ir_unop_dFdx:
534       for (unsigned c = 0; c < op[0]->type->components(); c++) {
535          switch (op[0]->type->base_type) {
536          case GLSL_TYPE_FLOAT:
537             data.f[c] = 0.0f;
538             break;
539          default:
540             unreachable("invalid type");
541          }
542       }
543       break;
544 
545    case ir_unop_dFdx_coarse:
546       for (unsigned c = 0; c < op[0]->type->components(); c++) {
547          switch (op[0]->type->base_type) {
548          case GLSL_TYPE_FLOAT:
549             data.f[c] = 0.0f;
550             break;
551          default:
552             unreachable("invalid type");
553          }
554       }
555       break;
556 
557    case ir_unop_dFdx_fine:
558       for (unsigned c = 0; c < op[0]->type->components(); c++) {
559          switch (op[0]->type->base_type) {
560          case GLSL_TYPE_FLOAT:
561             data.f[c] = 0.0f;
562             break;
563          default:
564             unreachable("invalid type");
565          }
566       }
567       break;
568 
569    case ir_unop_dFdy:
570       for (unsigned c = 0; c < op[0]->type->components(); c++) {
571          switch (op[0]->type->base_type) {
572          case GLSL_TYPE_FLOAT:
573             data.f[c] = 0.0f;
574             break;
575          default:
576             unreachable("invalid type");
577          }
578       }
579       break;
580 
581    case ir_unop_dFdy_coarse:
582       for (unsigned c = 0; c < op[0]->type->components(); c++) {
583          switch (op[0]->type->base_type) {
584          case GLSL_TYPE_FLOAT:
585             data.f[c] = 0.0f;
586             break;
587          default:
588             unreachable("invalid type");
589          }
590       }
591       break;
592 
593    case ir_unop_dFdy_fine:
594       for (unsigned c = 0; c < op[0]->type->components(); c++) {
595          switch (op[0]->type->base_type) {
596          case GLSL_TYPE_FLOAT:
597             data.f[c] = 0.0f;
598             break;
599          default:
600             unreachable("invalid type");
601          }
602       }
603       break;
604 
605    case ir_unop_pack_snorm_2x16:
606       switch (op[0]->type->base_type) {
607       case GLSL_TYPE_FLOAT:
608          data.u[0] = pack_2x16(pack_snorm_1x16, op[0]->value.f[0], op[0]->value.f[1]);
609          break;
610       default:
611          unreachable("invalid type");
612       }
613       break;
614 
615    case ir_unop_pack_snorm_4x8:
616       switch (op[0]->type->base_type) {
617       case GLSL_TYPE_FLOAT:
618          data.u[0] = pack_4x8(pack_snorm_1x8, op[0]->value.f[0], op[0]->value.f[1], op[0]->value.f[2], op[0]->value.f[3]);
619          break;
620       default:
621          unreachable("invalid type");
622       }
623       break;
624 
625    case ir_unop_pack_unorm_2x16:
626       switch (op[0]->type->base_type) {
627       case GLSL_TYPE_FLOAT:
628          data.u[0] = pack_2x16(pack_unorm_1x16, op[0]->value.f[0], op[0]->value.f[1]);
629          break;
630       default:
631          unreachable("invalid type");
632       }
633       break;
634 
635    case ir_unop_pack_unorm_4x8:
636       switch (op[0]->type->base_type) {
637       case GLSL_TYPE_FLOAT:
638          data.u[0] = pack_4x8(pack_unorm_1x8, op[0]->value.f[0], op[0]->value.f[1], op[0]->value.f[2], op[0]->value.f[3]);
639          break;
640       default:
641          unreachable("invalid type");
642       }
643       break;
644 
645    case ir_unop_pack_half_2x16:
646       switch (op[0]->type->base_type) {
647       case GLSL_TYPE_FLOAT:
648          data.u[0] = pack_2x16(pack_half_1x16, op[0]->value.f[0], op[0]->value.f[1]);
649          break;
650       default:
651          unreachable("invalid type");
652       }
653       break;
654 
655    case ir_unop_unpack_snorm_2x16:
656       unpack_2x16(unpack_snorm_1x16, op[0]->value.u[0], &data.f[0], &data.f[1]);
657       break;
658 
659    case ir_unop_unpack_snorm_4x8:
660       unpack_4x8(unpack_snorm_1x8, op[0]->value.u[0], &data.f[0], &data.f[1], &data.f[2], &data.f[3]);
661       break;
662 
663    case ir_unop_unpack_unorm_2x16:
664       unpack_2x16(unpack_unorm_1x16, op[0]->value.u[0], &data.f[0], &data.f[1]);
665       break;
666 
667    case ir_unop_unpack_unorm_4x8:
668       unpack_4x8(unpack_unorm_1x8, op[0]->value.u[0], &data.f[0], &data.f[1], &data.f[2], &data.f[3]);
669       break;
670 
671    case ir_unop_unpack_half_2x16:
672       unpack_2x16(unpack_half_1x16, op[0]->value.u[0], &data.f[0], &data.f[1]);
673       break;
674 
675    case ir_unop_bitfield_reverse:
676       for (unsigned c = 0; c < op[0]->type->components(); c++) {
677          switch (op[0]->type->base_type) {
678          case GLSL_TYPE_UINT:
679             data.u[c] = bitfield_reverse(op[0]->value.u[c]);
680             break;
681          case GLSL_TYPE_INT:
682             data.i[c] = bitfield_reverse(op[0]->value.i[c]);
683             break;
684          default:
685             unreachable("invalid type");
686          }
687       }
688       break;
689 
690    case ir_unop_bit_count:
691       for (unsigned c = 0; c < op[0]->type->components(); c++) {
692          switch (op[0]->type->base_type) {
693          case GLSL_TYPE_UINT:
694             data.i[c] = _mesa_bitcount(op[0]->value.u[c]);
695             break;
696          case GLSL_TYPE_INT:
697             data.i[c] = _mesa_bitcount(op[0]->value.i[c]);
698             break;
699          default:
700             unreachable("invalid type");
701          }
702       }
703       break;
704 
705    case ir_unop_find_msb:
706       for (unsigned c = 0; c < op[0]->type->components(); c++) {
707          switch (op[0]->type->base_type) {
708          case GLSL_TYPE_UINT:
709             data.i[c] = find_msb_uint(op[0]->value.u[c]);
710             break;
711          case GLSL_TYPE_INT:
712             data.i[c] = find_msb_int(op[0]->value.i[c]);
713             break;
714          default:
715             unreachable("invalid type");
716          }
717       }
718       break;
719 
720    case ir_unop_find_lsb:
721       for (unsigned c = 0; c < op[0]->type->components(); c++) {
722          switch (op[0]->type->base_type) {
723          case GLSL_TYPE_UINT:
724             data.i[c] = find_msb_uint(op[0]->value.u[c] & -op[0]->value.u[c]);
725             break;
726          case GLSL_TYPE_INT:
727             data.i[c] = find_msb_uint(op[0]->value.i[c] & -op[0]->value.i[c]);
728             break;
729          default:
730             unreachable("invalid type");
731          }
732       }
733       break;
734 
735    case ir_unop_saturate:
736       for (unsigned c = 0; c < op[0]->type->components(); c++) {
737          switch (op[0]->type->base_type) {
738          case GLSL_TYPE_FLOAT:
739             data.f[c] = CLAMP(op[0]->value.f[c], 0.0f, 1.0f);
740             break;
741          default:
742             unreachable("invalid type");
743          }
744       }
745       break;
746 
747    case ir_unop_pack_double_2x32:
748       memcpy(&data.d[0], &op[0]->value.u[0], sizeof(double));
749       break;
750 
751    case ir_unop_unpack_double_2x32:
752       memcpy(&data.u[0], &op[0]->value.d[0], sizeof(double));
753       break;
754 
755    case ir_binop_add:
756       assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
757       for (unsigned c = 0, c0 = 0, c1 = 0;
758            c < components;
759            c0 += c0_inc, c1 += c1_inc, c++) {
760 
761          switch (op[0]->type->base_type) {
762          case GLSL_TYPE_UINT:
763             data.u[c] = op[0]->value.u[c0] + op[1]->value.u[c1];
764             break;
765          case GLSL_TYPE_INT:
766             data.i[c] = op[0]->value.i[c0] + op[1]->value.i[c1];
767             break;
768          case GLSL_TYPE_FLOAT:
769             data.f[c] = op[0]->value.f[c0] + op[1]->value.f[c1];
770             break;
771          case GLSL_TYPE_DOUBLE:
772             data.d[c] = op[0]->value.d[c0] + op[1]->value.d[c1];
773             break;
774          default:
775             unreachable("invalid type");
776          }
777       }
778       break;
779 
780    case ir_binop_sub:
781       assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
782       for (unsigned c = 0, c0 = 0, c1 = 0;
783            c < components;
784            c0 += c0_inc, c1 += c1_inc, c++) {
785 
786          switch (op[0]->type->base_type) {
787          case GLSL_TYPE_UINT:
788             data.u[c] = op[0]->value.u[c0] - op[1]->value.u[c1];
789             break;
790          case GLSL_TYPE_INT:
791             data.i[c] = op[0]->value.i[c0] - op[1]->value.i[c1];
792             break;
793          case GLSL_TYPE_FLOAT:
794             data.f[c] = op[0]->value.f[c0] - op[1]->value.f[c1];
795             break;
796          case GLSL_TYPE_DOUBLE:
797             data.d[c] = op[0]->value.d[c0] - op[1]->value.d[c1];
798             break;
799          default:
800             unreachable("invalid type");
801          }
802       }
803       break;
804 
805    case ir_binop_mul:
806       /* Check for equal types, or unequal types involving scalars */
807       if ((op[0]->type == op[1]->type && !op[0]->type->is_matrix())
808           || op0_scalar || op1_scalar) {
809          for (unsigned c = 0, c0 = 0, c1 = 0;
810               c < components;
811               c0 += c0_inc, c1 += c1_inc, c++) {
812 
813             switch (op[0]->type->base_type) {
814             case GLSL_TYPE_UINT:
815                data.u[c] = op[0]->value.u[c0] * op[1]->value.u[c1];
816                break;
817             case GLSL_TYPE_INT:
818                data.i[c] = op[0]->value.i[c0] * op[1]->value.i[c1];
819                break;
820             case GLSL_TYPE_FLOAT:
821                data.f[c] = op[0]->value.f[c0] * op[1]->value.f[c1];
822                break;
823             case GLSL_TYPE_DOUBLE:
824                data.d[c] = op[0]->value.d[c0] * op[1]->value.d[c1];
825                break;
826             default:
827                unreachable("invalid type");
828             }
829          }
830       } else {
831          assert(op[0]->type->is_matrix() || op[1]->type->is_matrix());
832 
833          /* Multiply an N-by-M matrix with an M-by-P matrix.  Since either
834           * matrix can be a GLSL vector, either N or P can be 1.
835           *
836           * For vec*mat, the vector is treated as a row vector.  This
837           * means the vector is a 1-row x M-column matrix.
838           *
839           * For mat*vec, the vector is treated as a column vector.  Since
840           * matrix_columns is 1 for vectors, this just works.
841           */
842          const unsigned n = op[0]->type->is_vector()
843             ? 1 : op[0]->type->vector_elements;
844          const unsigned m = op[1]->type->vector_elements;
845          const unsigned p = op[1]->type->matrix_columns;
846          for (unsigned j = 0; j < p; j++) {
847             for (unsigned i = 0; i < n; i++) {
848                for (unsigned k = 0; k < m; k++) {
849                   if (op[0]->type->base_type == GLSL_TYPE_DOUBLE)
850                      data.d[i+n*j] += op[0]->value.d[i+n*k]*op[1]->value.d[k+m*j];
851                   else
852                      data.f[i+n*j] += op[0]->value.f[i+n*k]*op[1]->value.f[k+m*j];
853                }
854             }
855          }
856       }
857       break;
858 
859    case ir_binop_div:
860       assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
861       for (unsigned c = 0, c0 = 0, c1 = 0;
862            c < components;
863            c0 += c0_inc, c1 += c1_inc, c++) {
864 
865          switch (op[0]->type->base_type) {
866          case GLSL_TYPE_UINT:
867             data.u[c] = op[1]->value.u[c1] == 0 ? 0 : op[0]->value.u[c0] / op[1]->value.u[c1];
868             break;
869          case GLSL_TYPE_INT:
870             data.i[c] = op[1]->value.i[c1] == 0 ? 0 : op[0]->value.i[c0] / op[1]->value.i[c1];
871             break;
872          case GLSL_TYPE_FLOAT:
873             data.f[c] = op[0]->value.f[c0] / op[1]->value.f[c1];
874             break;
875          case GLSL_TYPE_DOUBLE:
876             data.d[c] = op[0]->value.d[c0] / op[1]->value.d[c1];
877             break;
878          default:
879             unreachable("invalid type");
880          }
881       }
882       break;
883 
884    case ir_binop_mod:
885       assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
886       for (unsigned c = 0, c0 = 0, c1 = 0;
887            c < components;
888            c0 += c0_inc, c1 += c1_inc, c++) {
889 
890          switch (op[0]->type->base_type) {
891          case GLSL_TYPE_UINT:
892             data.u[c] = op[1]->value.u[c1] == 0 ? 0 : op[0]->value.u[c0] % op[1]->value.u[c1];
893             break;
894          case GLSL_TYPE_INT:
895             data.i[c] = op[1]->value.i[c1] == 0 ? 0 : op[0]->value.i[c0] % op[1]->value.i[c1];
896             break;
897          case GLSL_TYPE_FLOAT:
898             data.f[c] = op[0]->value.f[c0] - op[1]->value.f[c1] * floorf(op[0]->value.f[c0] / op[1]->value.f[c1]);
899             break;
900          case GLSL_TYPE_DOUBLE:
901             data.d[c] = op[0]->value.d[c0] - op[1]->value.d[c1] * floor(op[0]->value.d[c0] / op[1]->value.d[c1]);
902             break;
903          default:
904             unreachable("invalid type");
905          }
906       }
907       break;
908 
909    case ir_binop_less:
910       for (unsigned c = 0; c < op[0]->type->components(); c++) {
911          switch (op[0]->type->base_type) {
912          case GLSL_TYPE_UINT:
913             data.b[c] = op[0]->value.u[c] < op[1]->value.u[c];
914             break;
915          case GLSL_TYPE_INT:
916             data.b[c] = op[0]->value.i[c] < op[1]->value.i[c];
917             break;
918          case GLSL_TYPE_FLOAT:
919             data.b[c] = op[0]->value.f[c] < op[1]->value.f[c];
920             break;
921          case GLSL_TYPE_DOUBLE:
922             data.b[c] = op[0]->value.d[c] < op[1]->value.d[c];
923             break;
924          default:
925             unreachable("invalid type");
926          }
927       }
928       break;
929 
930    case ir_binop_greater:
931       for (unsigned c = 0; c < op[0]->type->components(); c++) {
932          switch (op[0]->type->base_type) {
933          case GLSL_TYPE_UINT:
934             data.b[c] = op[0]->value.u[c] > op[1]->value.u[c];
935             break;
936          case GLSL_TYPE_INT:
937             data.b[c] = op[0]->value.i[c] > op[1]->value.i[c];
938             break;
939          case GLSL_TYPE_FLOAT:
940             data.b[c] = op[0]->value.f[c] > op[1]->value.f[c];
941             break;
942          case GLSL_TYPE_DOUBLE:
943             data.b[c] = op[0]->value.d[c] > op[1]->value.d[c];
944             break;
945          default:
946             unreachable("invalid type");
947          }
948       }
949       break;
950 
951    case ir_binop_lequal:
952       for (unsigned c = 0; c < op[0]->type->components(); c++) {
953          switch (op[0]->type->base_type) {
954          case GLSL_TYPE_UINT:
955             data.b[c] = op[0]->value.u[c] <= op[1]->value.u[c];
956             break;
957          case GLSL_TYPE_INT:
958             data.b[c] = op[0]->value.i[c] <= op[1]->value.i[c];
959             break;
960          case GLSL_TYPE_FLOAT:
961             data.b[c] = op[0]->value.f[c] <= op[1]->value.f[c];
962             break;
963          case GLSL_TYPE_DOUBLE:
964             data.b[c] = op[0]->value.d[c] <= op[1]->value.d[c];
965             break;
966          default:
967             unreachable("invalid type");
968          }
969       }
970       break;
971 
972    case ir_binop_gequal:
973       for (unsigned c = 0; c < op[0]->type->components(); c++) {
974          switch (op[0]->type->base_type) {
975          case GLSL_TYPE_UINT:
976             data.b[c] = op[0]->value.u[c] >= op[1]->value.u[c];
977             break;
978          case GLSL_TYPE_INT:
979             data.b[c] = op[0]->value.i[c] >= op[1]->value.i[c];
980             break;
981          case GLSL_TYPE_FLOAT:
982             data.b[c] = op[0]->value.f[c] >= op[1]->value.f[c];
983             break;
984          case GLSL_TYPE_DOUBLE:
985             data.b[c] = op[0]->value.d[c] >= op[1]->value.d[c];
986             break;
987          default:
988             unreachable("invalid type");
989          }
990       }
991       break;
992 
993    case ir_binop_equal:
994       for (unsigned c = 0; c < op[0]->type->components(); c++) {
995          switch (op[0]->type->base_type) {
996          case GLSL_TYPE_UINT:
997             data.b[c] = op[0]->value.u[c] == op[1]->value.u[c];
998             break;
999          case GLSL_TYPE_INT:
1000             data.b[c] = op[0]->value.i[c] == op[1]->value.i[c];
1001             break;
1002          case GLSL_TYPE_FLOAT:
1003             data.b[c] = op[0]->value.f[c] == op[1]->value.f[c];
1004             break;
1005          case GLSL_TYPE_DOUBLE:
1006             data.b[c] = op[0]->value.d[c] == op[1]->value.d[c];
1007             break;
1008          case GLSL_TYPE_BOOL:
1009             data.b[c] = op[0]->value.b[c] == op[1]->value.b[c];
1010             break;
1011          default:
1012             unreachable("invalid type");
1013          }
1014       }
1015       break;
1016 
1017    case ir_binop_nequal:
1018       for (unsigned c = 0; c < op[0]->type->components(); c++) {
1019          switch (op[0]->type->base_type) {
1020          case GLSL_TYPE_UINT:
1021             data.b[c] = op[0]->value.u[c] != op[1]->value.u[c];
1022             break;
1023          case GLSL_TYPE_INT:
1024             data.b[c] = op[0]->value.i[c] != op[1]->value.i[c];
1025             break;
1026          case GLSL_TYPE_FLOAT:
1027             data.b[c] = op[0]->value.f[c] != op[1]->value.f[c];
1028             break;
1029          case GLSL_TYPE_DOUBLE:
1030             data.b[c] = op[0]->value.d[c] != op[1]->value.d[c];
1031             break;
1032          case GLSL_TYPE_BOOL:
1033             data.b[c] = op[0]->value.b[c] != op[1]->value.b[c];
1034             break;
1035          default:
1036             unreachable("invalid type");
1037          }
1038       }
1039       break;
1040 
1041    case ir_binop_all_equal:
1042       data.b[0] = op[0]->has_value(op[1]);
1043       break;
1044 
1045    case ir_binop_any_nequal:
1046       data.b[0] = !op[0]->has_value(op[1]);
1047       break;
1048 
1049    case ir_binop_lshift:
1050       assert(op[0]->type->base_type == GLSL_TYPE_UINT ||
1051              op[0]->type->base_type == GLSL_TYPE_INT);
1052       assert(op[1]->type->base_type == GLSL_TYPE_UINT ||
1053              op[1]->type->base_type == GLSL_TYPE_INT);
1054       for (unsigned c = 0, c0 = 0, c1 = 0;
1055            c < components;
1056            c0 += c0_inc, c1 += c1_inc, c++) {
1057 
1058          switch (op[0]->type->base_type) {
1059          case GLSL_TYPE_UINT:
1060             data.u[c] = op[0]->value.u[c0] << op[1]->value.u[c1];
1061             break;
1062          case GLSL_TYPE_INT:
1063             data.i[c] = op[0]->value.i[c0] << op[1]->value.i[c1];
1064             break;
1065          default:
1066             unreachable("invalid type");
1067          }
1068       }
1069       break;
1070 
1071    case ir_binop_rshift:
1072       assert(op[0]->type->base_type == GLSL_TYPE_UINT ||
1073              op[0]->type->base_type == GLSL_TYPE_INT);
1074       assert(op[1]->type->base_type == GLSL_TYPE_UINT ||
1075              op[1]->type->base_type == GLSL_TYPE_INT);
1076       for (unsigned c = 0, c0 = 0, c1 = 0;
1077            c < components;
1078            c0 += c0_inc, c1 += c1_inc, c++) {
1079 
1080          switch (op[0]->type->base_type) {
1081          case GLSL_TYPE_UINT:
1082             data.u[c] = op[0]->value.u[c0] >> op[1]->value.u[c1];
1083             break;
1084          case GLSL_TYPE_INT:
1085             data.i[c] = op[0]->value.i[c0] >> op[1]->value.i[c1];
1086             break;
1087          default:
1088             unreachable("invalid type");
1089          }
1090       }
1091       break;
1092 
1093    case ir_binop_bit_and:
1094       assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
1095       for (unsigned c = 0, c0 = 0, c1 = 0;
1096            c < components;
1097            c0 += c0_inc, c1 += c1_inc, c++) {
1098 
1099          switch (op[0]->type->base_type) {
1100          case GLSL_TYPE_UINT:
1101             data.u[c] = op[0]->value.u[c0] & op[1]->value.u[c1];
1102             break;
1103          case GLSL_TYPE_INT:
1104             data.i[c] = op[0]->value.i[c0] & op[1]->value.i[c1];
1105             break;
1106          default:
1107             unreachable("invalid type");
1108          }
1109       }
1110       break;
1111 
1112    case ir_binop_bit_xor:
1113       assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
1114       for (unsigned c = 0, c0 = 0, c1 = 0;
1115            c < components;
1116            c0 += c0_inc, c1 += c1_inc, c++) {
1117 
1118          switch (op[0]->type->base_type) {
1119          case GLSL_TYPE_UINT:
1120             data.u[c] = op[0]->value.u[c0] ^ op[1]->value.u[c1];
1121             break;
1122          case GLSL_TYPE_INT:
1123             data.i[c] = op[0]->value.i[c0] ^ op[1]->value.i[c1];
1124             break;
1125          default:
1126             unreachable("invalid type");
1127          }
1128       }
1129       break;
1130 
1131    case ir_binop_bit_or:
1132       assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
1133       for (unsigned c = 0, c0 = 0, c1 = 0;
1134            c < components;
1135            c0 += c0_inc, c1 += c1_inc, c++) {
1136 
1137          switch (op[0]->type->base_type) {
1138          case GLSL_TYPE_UINT:
1139             data.u[c] = op[0]->value.u[c0] | op[1]->value.u[c1];
1140             break;
1141          case GLSL_TYPE_INT:
1142             data.i[c] = op[0]->value.i[c0] | op[1]->value.i[c1];
1143             break;
1144          default:
1145             unreachable("invalid type");
1146          }
1147       }
1148       break;
1149 
1150    case ir_binop_logic_and:
1151       for (unsigned c = 0; c < op[0]->type->components(); c++) {
1152          switch (op[0]->type->base_type) {
1153          case GLSL_TYPE_BOOL:
1154             data.b[c] = op[0]->value.b[c] && op[1]->value.b[c];
1155             break;
1156          default:
1157             unreachable("invalid type");
1158          }
1159       }
1160       break;
1161 
1162    case ir_binop_logic_xor:
1163       for (unsigned c = 0; c < op[0]->type->components(); c++) {
1164          switch (op[0]->type->base_type) {
1165          case GLSL_TYPE_BOOL:
1166             data.b[c] = op[0]->value.b[c] != op[1]->value.b[c];
1167             break;
1168          default:
1169             unreachable("invalid type");
1170          }
1171       }
1172       break;
1173 
1174    case ir_binop_logic_or:
1175       for (unsigned c = 0; c < op[0]->type->components(); c++) {
1176          switch (op[0]->type->base_type) {
1177          case GLSL_TYPE_BOOL:
1178             data.b[c] = op[0]->value.b[c] || op[1]->value.b[c];
1179             break;
1180          default:
1181             unreachable("invalid type");
1182          }
1183       }
1184       break;
1185 
1186    case ir_binop_dot:
1187       switch (op[0]->type->base_type) {
1188       case GLSL_TYPE_FLOAT:
1189          data.f[0] = dot_f(op[0], op[1]);
1190          break;
1191       case GLSL_TYPE_DOUBLE:
1192          data.d[0] = dot_d(op[0], op[1]);
1193          break;
1194       default:
1195          unreachable("invalid type");
1196       }
1197       break;
1198 
1199    case ir_binop_min:
1200       assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
1201       for (unsigned c = 0, c0 = 0, c1 = 0;
1202            c < components;
1203            c0 += c0_inc, c1 += c1_inc, c++) {
1204 
1205          switch (op[0]->type->base_type) {
1206          case GLSL_TYPE_UINT:
1207             data.u[c] = MIN2(op[0]->value.u[c0], op[1]->value.u[c1]);
1208             break;
1209          case GLSL_TYPE_INT:
1210             data.i[c] = MIN2(op[0]->value.i[c0], op[1]->value.i[c1]);
1211             break;
1212          case GLSL_TYPE_FLOAT:
1213             data.f[c] = MIN2(op[0]->value.f[c0], op[1]->value.f[c1]);
1214             break;
1215          case GLSL_TYPE_DOUBLE:
1216             data.d[c] = MIN2(op[0]->value.d[c0], op[1]->value.d[c1]);
1217             break;
1218          default:
1219             unreachable("invalid type");
1220          }
1221       }
1222       break;
1223 
1224    case ir_binop_max:
1225       assert(op[0]->type == op[1]->type || op0_scalar || op1_scalar);
1226       for (unsigned c = 0, c0 = 0, c1 = 0;
1227            c < components;
1228            c0 += c0_inc, c1 += c1_inc, c++) {
1229 
1230          switch (op[0]->type->base_type) {
1231          case GLSL_TYPE_UINT:
1232             data.u[c] = MAX2(op[0]->value.u[c0], op[1]->value.u[c1]);
1233             break;
1234          case GLSL_TYPE_INT:
1235             data.i[c] = MAX2(op[0]->value.i[c0], op[1]->value.i[c1]);
1236             break;
1237          case GLSL_TYPE_FLOAT:
1238             data.f[c] = MAX2(op[0]->value.f[c0], op[1]->value.f[c1]);
1239             break;
1240          case GLSL_TYPE_DOUBLE:
1241             data.d[c] = MAX2(op[0]->value.d[c0], op[1]->value.d[c1]);
1242             break;
1243          default:
1244             unreachable("invalid type");
1245          }
1246       }
1247       break;
1248 
1249    case ir_binop_pow:
1250       for (unsigned c = 0; c < op[0]->type->components(); c++) {
1251          switch (op[0]->type->base_type) {
1252          case GLSL_TYPE_FLOAT:
1253             data.f[c] = powf(op[0]->value.f[c], op[1]->value.f[c]);
1254             break;
1255          default:
1256             unreachable("invalid type");
1257          }
1258       }
1259       break;
1260 
1261    case ir_binop_ldexp:
1262       for (unsigned c = 0; c < op[0]->type->components(); c++) {
1263          switch (op[0]->type->base_type) {
1264          case GLSL_TYPE_FLOAT:
1265             data.f[c] = ldexpf_flush_subnormal(op[0]->value.f[c], op[1]->value.i[c]);
1266             break;
1267          case GLSL_TYPE_DOUBLE:
1268             data.d[c] = ldexp_flush_subnormal(op[0]->value.d[c], op[1]->value.i[c]);
1269             break;
1270          default:
1271             unreachable("invalid type");
1272          }
1273       }
1274       break;
1275 
1276    case ir_binop_vector_extract: {
1277       const int c = CLAMP(op[1]->value.i[0], 0,
1278                           (int) op[0]->type->vector_elements - 1);
1279 
1280       switch (op[0]->type->base_type) {
1281       case GLSL_TYPE_UINT:
1282          data.u[0] = op[0]->value.u[c];
1283          break;
1284       case GLSL_TYPE_INT:
1285          data.i[0] = op[0]->value.i[c];
1286          break;
1287       case GLSL_TYPE_FLOAT:
1288          data.f[0] = op[0]->value.f[c];
1289          break;
1290       case GLSL_TYPE_DOUBLE:
1291          data.d[0] = op[0]->value.d[c];
1292          break;
1293       case GLSL_TYPE_BOOL:
1294          data.b[0] = op[0]->value.b[c];
1295          break;
1296       default:
1297          unreachable("invalid type");
1298       }
1299       break;
1300    }
1301 
1302    case ir_triop_fma:
1303       for (unsigned c = 0; c < op[0]->type->components(); c++) {
1304          switch (op[0]->type->base_type) {
1305          case GLSL_TYPE_FLOAT:
1306             data.f[c] = op[0]->value.f[c] * op[1]->value.f[c] + op[2]->value.f[c];
1307             break;
1308          case GLSL_TYPE_DOUBLE:
1309             data.d[c] = op[0]->value.d[c] * op[1]->value.d[c] + op[2]->value.d[c];
1310             break;
1311          default:
1312             unreachable("invalid type");
1313          }
1314       }
1315       break;
1316 
1317    case ir_triop_lrp: {
1318       assert(op[0]->type->base_type == GLSL_TYPE_FLOAT ||
1319              op[0]->type->base_type == GLSL_TYPE_DOUBLE);
1320       assert(op[1]->type->base_type == GLSL_TYPE_FLOAT ||
1321              op[1]->type->base_type == GLSL_TYPE_DOUBLE);
1322       assert(op[2]->type->base_type == GLSL_TYPE_FLOAT ||
1323              op[2]->type->base_type == GLSL_TYPE_DOUBLE);
1324 
1325       unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1;
1326       for (unsigned c = 0, c2 = 0; c < components; c2 += c2_inc, c++) {
1327          switch (this->type->base_type) {
1328          case GLSL_TYPE_FLOAT:
1329             data.f[c] = op[0]->value.f[c] * (1.0f - op[2]->value.f[c2]) + (op[1]->value.f[c] * op[2]->value.f[c2]);
1330             break;
1331          case GLSL_TYPE_DOUBLE:
1332             data.d[c] = op[0]->value.d[c] * (1.0 - op[2]->value.d[c2]) + (op[1]->value.d[c] * op[2]->value.d[c2]);
1333             break;
1334          default:
1335             unreachable("invalid type");
1336          }
1337       }
1338       break;
1339    }
1340 
1341    case ir_triop_csel:
1342       for (unsigned c = 0; c < components; c++) {
1343          switch (this->type->base_type) {
1344          case GLSL_TYPE_UINT:
1345             data.u[c] = op[0]->value.b[c] ? op[1]->value.u[c] : op[2]->value.u[c];
1346             break;
1347          case GLSL_TYPE_INT:
1348             data.i[c] = op[0]->value.b[c] ? op[1]->value.i[c] : op[2]->value.i[c];
1349             break;
1350          case GLSL_TYPE_FLOAT:
1351             data.f[c] = op[0]->value.b[c] ? op[1]->value.f[c] : op[2]->value.f[c];
1352             break;
1353          case GLSL_TYPE_DOUBLE:
1354             data.d[c] = op[0]->value.b[c] ? op[1]->value.d[c] : op[2]->value.d[c];
1355             break;
1356          case GLSL_TYPE_BOOL:
1357             data.b[c] = op[0]->value.b[c] ? op[1]->value.b[c] : op[2]->value.b[c];
1358             break;
1359          default:
1360             unreachable("invalid type");
1361          }
1362       }
1363       break;
1364 
1365    case ir_triop_bitfield_extract:
1366       for (unsigned c = 0; c < op[0]->type->components(); c++) {
1367          switch (op[0]->type->base_type) {
1368          case GLSL_TYPE_UINT:
1369             data.i[c] = bitfield_extract_uint(op[0]->value.u[c], op[1]->value.i[c], op[2]->value.i[c]);
1370             break;
1371          case GLSL_TYPE_INT:
1372             data.i[c] = bitfield_extract_int(op[0]->value.i[c], op[1]->value.i[c], op[2]->value.i[c]);
1373             break;
1374          default:
1375             unreachable("invalid type");
1376          }
1377       }
1378       break;
1379 
1380    case ir_triop_vector_insert: {
1381       const unsigned idx = op[2]->value.u[0];
1382 
1383       memcpy(&data, &op[0]->value, sizeof(data));
1384 
1385       switch (this->type->base_type) {
1386       case GLSL_TYPE_UINT:
1387          data.u[idx] = op[1]->value.u[0];
1388          break;
1389       case GLSL_TYPE_INT:
1390          data.i[idx] = op[1]->value.i[0];
1391          break;
1392       case GLSL_TYPE_FLOAT:
1393          data.f[idx] = op[1]->value.f[0];
1394          break;
1395       case GLSL_TYPE_DOUBLE:
1396          data.d[idx] = op[1]->value.d[0];
1397          break;
1398       case GLSL_TYPE_BOOL:
1399          data.b[idx] = op[1]->value.b[0];
1400          break;
1401       default:
1402          unreachable("invalid type");
1403       }
1404       break;
1405    }
1406 
1407    case ir_quadop_bitfield_insert:
1408       for (unsigned c = 0; c < op[0]->type->components(); c++) {
1409          switch (op[0]->type->base_type) {
1410          case GLSL_TYPE_UINT:
1411             data.u[c] = bitfield_insert(op[0]->value.u[c], op[1]->value.u[c], op[2]->value.i[c], op[3]->value.i[c]);
1412             break;
1413          case GLSL_TYPE_INT:
1414             data.i[c] = bitfield_insert(op[0]->value.i[c], op[1]->value.i[c], op[2]->value.i[c], op[3]->value.i[c]);
1415             break;
1416          default:
1417             unreachable("invalid type");
1418          }
1419       }
1420       break;
1421 
1422    case ir_quadop_vector:
1423       for (unsigned c = 0; c < this->type->vector_elements; c++) {
1424          switch (this->type->base_type) {
1425          case GLSL_TYPE_UINT:
1426             data.u[c] = op[c]->value.u[0];
1427             break;
1428          case GLSL_TYPE_INT:
1429             data.i[c] = op[c]->value.i[0];
1430             break;
1431          case GLSL_TYPE_FLOAT:
1432             data.f[c] = op[c]->value.f[0];
1433             break;
1434          case GLSL_TYPE_DOUBLE:
1435             data.d[c] = op[c]->value.d[0];
1436             break;
1437          case GLSL_TYPE_BOOL:
1438             data.b[c] = op[c]->value.b[0];
1439             break;
1440          default:
1441             unreachable("invalid type");
1442          }
1443       }
1444       break;
1445 
1446    default:
1447       /* FINISHME: Should handle all expression types. */
1448       return NULL;
1449    }
1450 
1451