Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  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 "nir_constant_expressions.h"
  31.  
  32. #if defined(_MSC_VER) && (_MSC_VER < 1800)
  33. static int isnormal(double x)
  34. {
  35.    return _fpclass(x) == _FPCLASS_NN || _fpclass(x) == _FPCLASS_PN;
  36. }
  37. #elif defined(__SUNPRO_CC)
  38. #include <ieeefp.h>
  39. static int isnormal(double x)
  40. {
  41.    return fpclass(x) == FP_NORMAL;
  42. }
  43. #endif
  44.  
  45. #if defined(_MSC_VER)
  46. static double copysign(double x, double y)
  47. {
  48.    return _copysign(x, y);
  49. }
  50. #endif
  51.  
  52. /**
  53.  * Evaluate one component of packSnorm4x8.
  54.  */
  55. static uint8_t
  56. pack_snorm_1x8(float x)
  57. {
  58.     /* From section 8.4 of the GLSL 4.30 spec:
  59.      *
  60.      *    packSnorm4x8
  61.      *    ------------
  62.      *    The conversion for component c of v to fixed point is done as
  63.      *    follows:
  64.      *
  65.      *      packSnorm4x8: round(clamp(c, -1, +1) * 127.0)
  66.      *
  67.      * We must first cast the float to an int, because casting a negative
  68.      * float to a uint is undefined.
  69.      */
  70.    return (uint8_t) (int)
  71.           _mesa_roundevenf(CLAMP(x, -1.0f, +1.0f) * 127.0f);
  72. }
  73.  
  74. /**
  75.  * Evaluate one component of packSnorm2x16.
  76.  */
  77. static uint16_t
  78. pack_snorm_1x16(float x)
  79. {
  80.     /* From section 8.4 of the GLSL ES 3.00 spec:
  81.      *
  82.      *    packSnorm2x16
  83.      *    -------------
  84.      *    The conversion for component c of v to fixed point is done as
  85.      *    follows:
  86.      *
  87.      *      packSnorm2x16: round(clamp(c, -1, +1) * 32767.0)
  88.      *
  89.      * We must first cast the float to an int, because casting a negative
  90.      * float to a uint is undefined.
  91.      */
  92.    return (uint16_t) (int)
  93.           _mesa_roundevenf(CLAMP(x, -1.0f, +1.0f) * 32767.0f);
  94. }
  95.  
  96. /**
  97.  * Evaluate one component of unpackSnorm4x8.
  98.  */
  99. static float
  100. unpack_snorm_1x8(uint8_t u)
  101. {
  102.     /* From section 8.4 of the GLSL 4.30 spec:
  103.      *
  104.      *    unpackSnorm4x8
  105.      *    --------------
  106.      *    The conversion for unpacked fixed-point value f to floating point is
  107.      *    done as follows:
  108.      *
  109.      *       unpackSnorm4x8: clamp(f / 127.0, -1, +1)
  110.      */
  111.    return CLAMP((int8_t) u / 127.0f, -1.0f, +1.0f);
  112. }
  113.  
  114. /**
  115.  * Evaluate one component of unpackSnorm2x16.
  116.  */
  117. static float
  118. unpack_snorm_1x16(uint16_t u)
  119. {
  120.     /* From section 8.4 of the GLSL ES 3.00 spec:
  121.      *
  122.      *    unpackSnorm2x16
  123.      *    ---------------
  124.      *    The conversion for unpacked fixed-point value f to floating point is
  125.      *    done as follows:
  126.      *
  127.      *       unpackSnorm2x16: clamp(f / 32767.0, -1, +1)
  128.      */
  129.    return CLAMP((int16_t) u / 32767.0f, -1.0f, +1.0f);
  130. }
  131.  
  132. /**
  133.  * Evaluate one component packUnorm4x8.
  134.  */
  135. static uint8_t
  136. pack_unorm_1x8(float x)
  137. {
  138.     /* From section 8.4 of the GLSL 4.30 spec:
  139.      *
  140.      *    packUnorm4x8
  141.      *    ------------
  142.      *    The conversion for component c of v to fixed point is done as
  143.      *    follows:
  144.      *
  145.      *       packUnorm4x8: round(clamp(c, 0, +1) * 255.0)
  146.      */
  147.    return (uint8_t) (int)
  148.           _mesa_roundevenf(CLAMP(x, 0.0f, 1.0f) * 255.0f);
  149. }
  150.  
  151. /**
  152.  * Evaluate one component packUnorm2x16.
  153.  */
  154. static uint16_t
  155. pack_unorm_1x16(float x)
  156. {
  157.     /* From section 8.4 of the GLSL ES 3.00 spec:
  158.      *
  159.      *    packUnorm2x16
  160.      *    -------------
  161.      *    The conversion for component c of v to fixed point is done as
  162.      *    follows:
  163.      *
  164.      *       packUnorm2x16: round(clamp(c, 0, +1) * 65535.0)
  165.      */
  166.    return (uint16_t) (int)
  167.           _mesa_roundevenf(CLAMP(x, 0.0f, 1.0f) * 65535.0f);
  168. }
  169.  
  170. /**
  171.  * Evaluate one component of unpackUnorm4x8.
  172.  */
  173. static float
  174. unpack_unorm_1x8(uint8_t u)
  175. {
  176.     /* From section 8.4 of the GLSL 4.30 spec:
  177.      *
  178.      *    unpackUnorm4x8
  179.      *    --------------
  180.      *    The conversion for unpacked fixed-point value f to floating point is
  181.      *    done as follows:
  182.      *
  183.      *       unpackUnorm4x8: f / 255.0
  184.      */
  185.    return (float) u / 255.0f;
  186. }
  187.  
  188. /**
  189.  * Evaluate one component of unpackUnorm2x16.
  190.  */
  191. static float
  192. unpack_unorm_1x16(uint16_t u)
  193. {
  194.     /* From section 8.4 of the GLSL ES 3.00 spec:
  195.      *
  196.      *    unpackUnorm2x16
  197.      *    ---------------
  198.      *    The conversion for unpacked fixed-point value f to floating point is
  199.      *    done as follows:
  200.      *
  201.      *       unpackUnorm2x16: f / 65535.0
  202.      */
  203.    return (float) u / 65535.0f;
  204. }
  205.  
  206. /**
  207.  * Evaluate one component of packHalf2x16.
  208.  */
  209. static uint16_t
  210. pack_half_1x16(float x)
  211. {
  212.    return _mesa_float_to_half(x);
  213. }
  214.  
  215. /**
  216.  * Evaluate one component of unpackHalf2x16.
  217.  */
  218. static float
  219. unpack_half_1x16(uint16_t u)
  220. {
  221.    return _mesa_half_to_float(u);
  222. }
  223.  
  224. /* Some typed vector structures to make things like src0.y work */
  225. struct float_vec {
  226.    float x;
  227.    float y;
  228.    float z;
  229.    float w;
  230. };
  231. struct int_vec {
  232.    int x;
  233.    int y;
  234.    int z;
  235.    int w;
  236. };
  237. struct unsigned_vec {
  238.    unsigned x;
  239.    unsigned y;
  240.    unsigned z;
  241.    unsigned w;
  242. };
  243. struct bool_vec {
  244.    bool x;
  245.    bool y;
  246.    bool z;
  247.    bool w;
  248. };
  249.  
  250. static nir_const_value
  251. evaluate_b2f(unsigned num_components, nir_const_value *_src)
  252. {
  253.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  254.  
  255.          
  256.       for (unsigned _i = 0; _i < num_components; _i++) {
  257.                bool src0 = _src[0].u[_i] != 0;
  258.  
  259.             float dst = src0 ? 1.0f : 0.0f;
  260.  
  261.             _dst_val.f[_i] = dst;
  262.       }
  263.  
  264.    return _dst_val;
  265. }
  266. static nir_const_value
  267. evaluate_b2i(unsigned num_components, nir_const_value *_src)
  268. {
  269.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  270.  
  271.          
  272.       for (unsigned _i = 0; _i < num_components; _i++) {
  273.                bool src0 = _src[0].u[_i] != 0;
  274.  
  275.             int dst = src0 ? 1 : 0;
  276.  
  277.             _dst_val.i[_i] = dst;
  278.       }
  279.  
  280.    return _dst_val;
  281. }
  282. static nir_const_value
  283. evaluate_ball2(unsigned num_components, nir_const_value *_src)
  284. {
  285.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  286.  
  287.  
  288.       struct bool_vec src0 = {
  289.             _src[0].u[0] != 0,
  290.             _src[0].u[1] != 0,
  291.       };
  292.  
  293.       struct bool_vec dst;
  294.  
  295.          dst.x = dst.y = dst.z = dst.w = ((src0.x) && (src0.y));
  296.  
  297.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  298.  
  299.    return _dst_val;
  300. }
  301. static nir_const_value
  302. evaluate_ball3(unsigned num_components, nir_const_value *_src)
  303. {
  304.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  305.  
  306.  
  307.       struct bool_vec src0 = {
  308.             _src[0].u[0] != 0,
  309.             _src[0].u[1] != 0,
  310.             _src[0].u[2] != 0,
  311.       };
  312.  
  313.       struct bool_vec dst;
  314.  
  315.          dst.x = dst.y = dst.z = dst.w = ((src0.x) && (src0.y) && (src0.z));
  316.  
  317.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  318.  
  319.    return _dst_val;
  320. }
  321. static nir_const_value
  322. evaluate_ball4(unsigned num_components, nir_const_value *_src)
  323. {
  324.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  325.  
  326.  
  327.       struct bool_vec src0 = {
  328.             _src[0].u[0] != 0,
  329.             _src[0].u[1] != 0,
  330.             _src[0].u[2] != 0,
  331.             _src[0].u[3] != 0,
  332.       };
  333.  
  334.       struct bool_vec dst;
  335.  
  336.          dst.x = dst.y = dst.z = dst.w = ((src0.x) && (src0.y) && (src0.z) && (src0.w));
  337.  
  338.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  339.  
  340.    return _dst_val;
  341. }
  342. static nir_const_value
  343. evaluate_ball_fequal2(unsigned num_components, nir_const_value *_src)
  344. {
  345.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  346.  
  347.  
  348.       struct float_vec src0 = {
  349.             _src[0].f[0],
  350.             _src[0].f[1],
  351.       };
  352.  
  353.       struct float_vec src1 = {
  354.             _src[1].f[0],
  355.             _src[1].f[1],
  356.       };
  357.  
  358.       struct bool_vec dst;
  359.  
  360.          dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y));
  361.  
  362.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  363.  
  364.    return _dst_val;
  365. }
  366. static nir_const_value
  367. evaluate_ball_fequal3(unsigned num_components, nir_const_value *_src)
  368. {
  369.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  370.  
  371.  
  372.       struct float_vec src0 = {
  373.             _src[0].f[0],
  374.             _src[0].f[1],
  375.             _src[0].f[2],
  376.       };
  377.  
  378.       struct float_vec src1 = {
  379.             _src[1].f[0],
  380.             _src[1].f[1],
  381.             _src[1].f[2],
  382.       };
  383.  
  384.       struct bool_vec dst;
  385.  
  386.          dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z));
  387.  
  388.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  389.  
  390.    return _dst_val;
  391. }
  392. static nir_const_value
  393. evaluate_ball_fequal4(unsigned num_components, nir_const_value *_src)
  394. {
  395.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  396.  
  397.  
  398.       struct float_vec src0 = {
  399.             _src[0].f[0],
  400.             _src[0].f[1],
  401.             _src[0].f[2],
  402.             _src[0].f[3],
  403.       };
  404.  
  405.       struct float_vec src1 = {
  406.             _src[1].f[0],
  407.             _src[1].f[1],
  408.             _src[1].f[2],
  409.             _src[1].f[3],
  410.       };
  411.  
  412.       struct bool_vec dst;
  413.  
  414.          dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z) && (src0.w == src1.w));
  415.  
  416.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  417.  
  418.    return _dst_val;
  419. }
  420. static nir_const_value
  421. evaluate_ball_iequal2(unsigned num_components, nir_const_value *_src)
  422. {
  423.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  424.  
  425.  
  426.       struct int_vec src0 = {
  427.             _src[0].i[0],
  428.             _src[0].i[1],
  429.       };
  430.  
  431.       struct int_vec src1 = {
  432.             _src[1].i[0],
  433.             _src[1].i[1],
  434.       };
  435.  
  436.       struct bool_vec dst;
  437.  
  438.          dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y));
  439.  
  440.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  441.  
  442.    return _dst_val;
  443. }
  444. static nir_const_value
  445. evaluate_ball_iequal3(unsigned num_components, nir_const_value *_src)
  446. {
  447.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  448.  
  449.  
  450.       struct int_vec src0 = {
  451.             _src[0].i[0],
  452.             _src[0].i[1],
  453.             _src[0].i[2],
  454.       };
  455.  
  456.       struct int_vec src1 = {
  457.             _src[1].i[0],
  458.             _src[1].i[1],
  459.             _src[1].i[2],
  460.       };
  461.  
  462.       struct bool_vec dst;
  463.  
  464.          dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z));
  465.  
  466.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  467.  
  468.    return _dst_val;
  469. }
  470. static nir_const_value
  471. evaluate_ball_iequal4(unsigned num_components, nir_const_value *_src)
  472. {
  473.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  474.  
  475.  
  476.       struct int_vec src0 = {
  477.             _src[0].i[0],
  478.             _src[0].i[1],
  479.             _src[0].i[2],
  480.             _src[0].i[3],
  481.       };
  482.  
  483.       struct int_vec src1 = {
  484.             _src[1].i[0],
  485.             _src[1].i[1],
  486.             _src[1].i[2],
  487.             _src[1].i[3],
  488.       };
  489.  
  490.       struct bool_vec dst;
  491.  
  492.          dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z) && (src0.w == src1.w));
  493.  
  494.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  495.  
  496.    return _dst_val;
  497. }
  498. static nir_const_value
  499. evaluate_bany2(unsigned num_components, nir_const_value *_src)
  500. {
  501.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  502.  
  503.  
  504.       struct bool_vec src0 = {
  505.             _src[0].u[0] != 0,
  506.             _src[0].u[1] != 0,
  507.       };
  508.  
  509.       struct bool_vec dst;
  510.  
  511.          dst.x = dst.y = dst.z = dst.w = ((src0.x) || (src0.y));
  512.  
  513.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  514.  
  515.    return _dst_val;
  516. }
  517. static nir_const_value
  518. evaluate_bany3(unsigned num_components, nir_const_value *_src)
  519. {
  520.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  521.  
  522.  
  523.       struct bool_vec src0 = {
  524.             _src[0].u[0] != 0,
  525.             _src[0].u[1] != 0,
  526.             _src[0].u[2] != 0,
  527.       };
  528.  
  529.       struct bool_vec dst;
  530.  
  531.          dst.x = dst.y = dst.z = dst.w = ((src0.x) || (src0.y) || (src0.z));
  532.  
  533.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  534.  
  535.    return _dst_val;
  536. }
  537. static nir_const_value
  538. evaluate_bany4(unsigned num_components, nir_const_value *_src)
  539. {
  540.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  541.  
  542.  
  543.       struct bool_vec src0 = {
  544.             _src[0].u[0] != 0,
  545.             _src[0].u[1] != 0,
  546.             _src[0].u[2] != 0,
  547.             _src[0].u[3] != 0,
  548.       };
  549.  
  550.       struct bool_vec dst;
  551.  
  552.          dst.x = dst.y = dst.z = dst.w = ((src0.x) || (src0.y) || (src0.z) || (src0.w));
  553.  
  554.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  555.  
  556.    return _dst_val;
  557. }
  558. static nir_const_value
  559. evaluate_bany_fnequal2(unsigned num_components, nir_const_value *_src)
  560. {
  561.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  562.  
  563.  
  564.       struct float_vec src0 = {
  565.             _src[0].f[0],
  566.             _src[0].f[1],
  567.       };
  568.  
  569.       struct float_vec src1 = {
  570.             _src[1].f[0],
  571.             _src[1].f[1],
  572.       };
  573.  
  574.       struct bool_vec dst;
  575.  
  576.          dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y));
  577.  
  578.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  579.  
  580.    return _dst_val;
  581. }
  582. static nir_const_value
  583. evaluate_bany_fnequal3(unsigned num_components, nir_const_value *_src)
  584. {
  585.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  586.  
  587.  
  588.       struct float_vec src0 = {
  589.             _src[0].f[0],
  590.             _src[0].f[1],
  591.             _src[0].f[2],
  592.       };
  593.  
  594.       struct float_vec src1 = {
  595.             _src[1].f[0],
  596.             _src[1].f[1],
  597.             _src[1].f[2],
  598.       };
  599.  
  600.       struct bool_vec dst;
  601.  
  602.          dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z));
  603.  
  604.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  605.  
  606.    return _dst_val;
  607. }
  608. static nir_const_value
  609. evaluate_bany_fnequal4(unsigned num_components, nir_const_value *_src)
  610. {
  611.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  612.  
  613.  
  614.       struct float_vec src0 = {
  615.             _src[0].f[0],
  616.             _src[0].f[1],
  617.             _src[0].f[2],
  618.             _src[0].f[3],
  619.       };
  620.  
  621.       struct float_vec src1 = {
  622.             _src[1].f[0],
  623.             _src[1].f[1],
  624.             _src[1].f[2],
  625.             _src[1].f[3],
  626.       };
  627.  
  628.       struct bool_vec dst;
  629.  
  630.          dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z) || (src0.w != src1.w));
  631.  
  632.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  633.  
  634.    return _dst_val;
  635. }
  636. static nir_const_value
  637. evaluate_bany_inequal2(unsigned num_components, nir_const_value *_src)
  638. {
  639.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  640.  
  641.  
  642.       struct int_vec src0 = {
  643.             _src[0].i[0],
  644.             _src[0].i[1],
  645.       };
  646.  
  647.       struct int_vec src1 = {
  648.             _src[1].i[0],
  649.             _src[1].i[1],
  650.       };
  651.  
  652.       struct bool_vec dst;
  653.  
  654.          dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y));
  655.  
  656.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  657.  
  658.    return _dst_val;
  659. }
  660. static nir_const_value
  661. evaluate_bany_inequal3(unsigned num_components, nir_const_value *_src)
  662. {
  663.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  664.  
  665.  
  666.       struct int_vec src0 = {
  667.             _src[0].i[0],
  668.             _src[0].i[1],
  669.             _src[0].i[2],
  670.       };
  671.  
  672.       struct int_vec src1 = {
  673.             _src[1].i[0],
  674.             _src[1].i[1],
  675.             _src[1].i[2],
  676.       };
  677.  
  678.       struct bool_vec dst;
  679.  
  680.          dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z));
  681.  
  682.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  683.  
  684.    return _dst_val;
  685. }
  686. static nir_const_value
  687. evaluate_bany_inequal4(unsigned num_components, nir_const_value *_src)
  688. {
  689.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  690.  
  691.  
  692.       struct int_vec src0 = {
  693.             _src[0].i[0],
  694.             _src[0].i[1],
  695.             _src[0].i[2],
  696.             _src[0].i[3],
  697.       };
  698.  
  699.       struct int_vec src1 = {
  700.             _src[1].i[0],
  701.             _src[1].i[1],
  702.             _src[1].i[2],
  703.             _src[1].i[3],
  704.       };
  705.  
  706.       struct bool_vec dst;
  707.  
  708.          dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z) || (src0.w != src1.w));
  709.  
  710.             _dst_val.u[0] = dst.x ? NIR_TRUE : NIR_FALSE;
  711.  
  712.    return _dst_val;
  713. }
  714. static nir_const_value
  715. evaluate_bcsel(unsigned num_components, nir_const_value *_src)
  716. {
  717.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  718.  
  719.                            
  720.       for (unsigned _i = 0; _i < num_components; _i++) {
  721.                bool src0 = _src[0].u[_i] != 0;
  722.                unsigned src1 = _src[1].u[_i];
  723.                unsigned src2 = _src[2].u[_i];
  724.  
  725.             unsigned dst = src0 ? src1 : src2;
  726.  
  727.             _dst_val.u[_i] = dst;
  728.       }
  729.  
  730.    return _dst_val;
  731. }
  732. static nir_const_value
  733. evaluate_bfi(unsigned num_components, nir_const_value *_src)
  734. {
  735.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  736.  
  737.                            
  738.       for (unsigned _i = 0; _i < num_components; _i++) {
  739.                unsigned src0 = _src[0].u[_i];
  740.                unsigned src1 = _src[1].u[_i];
  741.                unsigned src2 = _src[2].u[_i];
  742.  
  743.             unsigned dst;
  744.            
  745. unsigned mask = src0, insert = src1 & mask, base = src2;
  746. if (mask == 0) {
  747.    dst = base;
  748. } else {
  749.    unsigned tmp = mask;
  750.    while (!(tmp & 1)) {
  751.       tmp >>= 1;
  752.       insert <<= 1;
  753.    }
  754.    dst = (base & ~mask) | insert;
  755. }
  756.  
  757.  
  758.             _dst_val.u[_i] = dst;
  759.       }
  760.  
  761.    return _dst_val;
  762. }
  763. static nir_const_value
  764. evaluate_bfm(unsigned num_components, nir_const_value *_src)
  765. {
  766.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  767.  
  768.                  
  769.       for (unsigned _i = 0; _i < num_components; _i++) {
  770.                int src0 = _src[0].i[_i];
  771.                int src1 = _src[1].i[_i];
  772.  
  773.             unsigned dst;
  774.            
  775. int offset = src0, bits = src1;
  776. if (offset < 0 || bits < 0 || offset + bits > 32)
  777.    dst = 0; /* undefined per the spec */
  778. else
  779.    dst = ((1 << bits)- 1) << offset;
  780.  
  781.  
  782.             _dst_val.u[_i] = dst;
  783.       }
  784.  
  785.    return _dst_val;
  786. }
  787. static nir_const_value
  788. evaluate_bit_count(unsigned num_components, nir_const_value *_src)
  789. {
  790.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  791.  
  792.          
  793.       for (unsigned _i = 0; _i < num_components; _i++) {
  794.                unsigned src0 = _src[0].u[_i];
  795.  
  796.             unsigned dst;
  797.            
  798. dst = 0;
  799. for (unsigned bit = 0; bit < 32; bit++) {
  800.    if ((src0 >> bit) & 1)
  801.       dst++;
  802. }
  803.  
  804.  
  805.             _dst_val.u[_i] = dst;
  806.       }
  807.  
  808.    return _dst_val;
  809. }
  810. static nir_const_value
  811. evaluate_bitfield_insert(unsigned num_components, nir_const_value *_src)
  812. {
  813.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  814.  
  815.                  
  816.       struct int_vec src2 = {
  817.             _src[2].i[0],
  818.       };
  819.  
  820.       struct int_vec src3 = {
  821.             _src[3].i[0],
  822.       };
  823.  
  824.       for (unsigned _i = 0; _i < num_components; _i++) {
  825.                unsigned src0 = _src[0].u[_i];
  826.                unsigned src1 = _src[1].u[_i];
  827.                              
  828.             unsigned dst;
  829.            
  830. unsigned base = src0, insert = src1;
  831. int offset = src2.x, bits = src3.x;
  832. if (bits == 0) {
  833.    dst = 0;
  834. } else if (offset < 0 || bits < 0 || bits + offset > 32) {
  835.    dst = 0;
  836. } else {
  837.    unsigned mask = ((1 << bits) - 1) << offset;
  838.    dst = (base & ~mask) | ((insert << bits) & mask);
  839. }
  840.  
  841.  
  842.             _dst_val.u[_i] = dst;
  843.       }
  844.  
  845.    return _dst_val;
  846. }
  847. static nir_const_value
  848. evaluate_bitfield_reverse(unsigned num_components, nir_const_value *_src)
  849. {
  850.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  851.  
  852.          
  853.       for (unsigned _i = 0; _i < num_components; _i++) {
  854.                unsigned src0 = _src[0].u[_i];
  855.  
  856.             unsigned dst;
  857.            
  858. /* we're not winning any awards for speed here, but that's ok */
  859. dst = 0;
  860. for (unsigned bit = 0; bit < 32; bit++)
  861.    dst |= ((src0 >> bit) & 1) << (31 - bit);
  862.  
  863.  
  864.             _dst_val.u[_i] = dst;
  865.       }
  866.  
  867.    return _dst_val;
  868. }
  869. static nir_const_value
  870. evaluate_f2b(unsigned num_components, nir_const_value *_src)
  871. {
  872.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  873.  
  874.          
  875.       for (unsigned _i = 0; _i < num_components; _i++) {
  876.                float src0 = _src[0].f[_i];
  877.  
  878.             bool dst = src0 != 0.0f;
  879.  
  880.             _dst_val.u[_i] = dst ? NIR_TRUE : NIR_FALSE;
  881.       }
  882.  
  883.    return _dst_val;
  884. }
  885. static nir_const_value
  886. evaluate_f2i(unsigned num_components, nir_const_value *_src)
  887. {
  888.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  889.  
  890.          
  891.       for (unsigned _i = 0; _i < num_components; _i++) {
  892.                float src0 = _src[0].f[_i];
  893.  
  894.             int dst = src0;
  895.  
  896.             _dst_val.i[_i] = dst;
  897.       }
  898.  
  899.    return _dst_val;
  900. }
  901. static nir_const_value
  902. evaluate_f2u(unsigned num_components, nir_const_value *_src)
  903. {
  904.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  905.  
  906.          
  907.       for (unsigned _i = 0; _i < num_components; _i++) {
  908.                float src0 = _src[0].f[_i];
  909.  
  910.             unsigned dst = src0;
  911.  
  912.             _dst_val.u[_i] = dst;
  913.       }
  914.  
  915.    return _dst_val;
  916. }
  917. static nir_const_value
  918. evaluate_fabs(unsigned num_components, nir_const_value *_src)
  919. {
  920.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  921.  
  922.          
  923.       for (unsigned _i = 0; _i < num_components; _i++) {
  924.                float src0 = _src[0].f[_i];
  925.  
  926.             float dst = fabsf(src0);
  927.  
  928.             _dst_val.f[_i] = dst;
  929.       }
  930.  
  931.    return _dst_val;
  932. }
  933. static nir_const_value
  934. evaluate_fadd(unsigned num_components, nir_const_value *_src)
  935. {
  936.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  937.  
  938.                  
  939.       for (unsigned _i = 0; _i < num_components; _i++) {
  940.                float src0 = _src[0].f[_i];
  941.                float src1 = _src[1].f[_i];
  942.  
  943.             float dst = src0 + src1;
  944.  
  945.             _dst_val.f[_i] = dst;
  946.       }
  947.  
  948.    return _dst_val;
  949. }
  950. static nir_const_value
  951. evaluate_fall2(unsigned num_components, nir_const_value *_src)
  952. {
  953.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  954.  
  955.  
  956.       struct float_vec src0 = {
  957.             _src[0].f[0],
  958.             _src[0].f[1],
  959.       };
  960.  
  961.       struct float_vec dst;
  962.  
  963.          dst.x = dst.y = dst.z = dst.w = ((src0.x != 0.0f) && (src0.y != 0.0f)) ? 1.0f : 0.0f;
  964.  
  965.             _dst_val.f[0] = dst.x;
  966.  
  967.    return _dst_val;
  968. }
  969. static nir_const_value
  970. evaluate_fall3(unsigned num_components, nir_const_value *_src)
  971. {
  972.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  973.  
  974.  
  975.       struct float_vec src0 = {
  976.             _src[0].f[0],
  977.             _src[0].f[1],
  978.             _src[0].f[2],
  979.       };
  980.  
  981.       struct float_vec dst;
  982.  
  983.          dst.x = dst.y = dst.z = dst.w = ((src0.x != 0.0f) && (src0.y != 0.0f) && (src0.z != 0.0f)) ? 1.0f : 0.0f;
  984.  
  985.             _dst_val.f[0] = dst.x;
  986.  
  987.    return _dst_val;
  988. }
  989. static nir_const_value
  990. evaluate_fall4(unsigned num_components, nir_const_value *_src)
  991. {
  992.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  993.  
  994.  
  995.       struct float_vec src0 = {
  996.             _src[0].f[0],
  997.             _src[0].f[1],
  998.             _src[0].f[2],
  999.             _src[0].f[3],
  1000.       };
  1001.  
  1002.       struct float_vec dst;
  1003.  
  1004.          dst.x = dst.y = dst.z = dst.w = ((src0.x != 0.0f) && (src0.y != 0.0f) && (src0.z != 0.0f) && (src0.w != 0.0f)) ? 1.0f : 0.0f;
  1005.  
  1006.             _dst_val.f[0] = dst.x;
  1007.  
  1008.    return _dst_val;
  1009. }
  1010. static nir_const_value
  1011. evaluate_fall_equal2(unsigned num_components, nir_const_value *_src)
  1012. {
  1013.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1014.  
  1015.  
  1016.       struct float_vec src0 = {
  1017.             _src[0].f[0],
  1018.             _src[0].f[1],
  1019.       };
  1020.  
  1021.       struct float_vec src1 = {
  1022.             _src[1].f[0],
  1023.             _src[1].f[1],
  1024.       };
  1025.  
  1026.       struct float_vec dst;
  1027.  
  1028.          dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y)) ? 1.0f : 0.0f;
  1029.  
  1030.             _dst_val.f[0] = dst.x;
  1031.  
  1032.    return _dst_val;
  1033. }
  1034. static nir_const_value
  1035. evaluate_fall_equal3(unsigned num_components, nir_const_value *_src)
  1036. {
  1037.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1038.  
  1039.  
  1040.       struct float_vec src0 = {
  1041.             _src[0].f[0],
  1042.             _src[0].f[1],
  1043.             _src[0].f[2],
  1044.       };
  1045.  
  1046.       struct float_vec src1 = {
  1047.             _src[1].f[0],
  1048.             _src[1].f[1],
  1049.             _src[1].f[2],
  1050.       };
  1051.  
  1052.       struct float_vec dst;
  1053.  
  1054.          dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z)) ? 1.0f : 0.0f;
  1055.  
  1056.             _dst_val.f[0] = dst.x;
  1057.  
  1058.    return _dst_val;
  1059. }
  1060. static nir_const_value
  1061. evaluate_fall_equal4(unsigned num_components, nir_const_value *_src)
  1062. {
  1063.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1064.  
  1065.  
  1066.       struct float_vec src0 = {
  1067.             _src[0].f[0],
  1068.             _src[0].f[1],
  1069.             _src[0].f[2],
  1070.             _src[0].f[3],
  1071.       };
  1072.  
  1073.       struct float_vec src1 = {
  1074.             _src[1].f[0],
  1075.             _src[1].f[1],
  1076.             _src[1].f[2],
  1077.             _src[1].f[3],
  1078.       };
  1079.  
  1080.       struct float_vec dst;
  1081.  
  1082.          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;
  1083.  
  1084.             _dst_val.f[0] = dst.x;
  1085.  
  1086.    return _dst_val;
  1087. }
  1088. static nir_const_value
  1089. evaluate_fand(unsigned num_components, nir_const_value *_src)
  1090. {
  1091.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1092.  
  1093.                  
  1094.       for (unsigned _i = 0; _i < num_components; _i++) {
  1095.                float src0 = _src[0].f[_i];
  1096.                float src1 = _src[1].f[_i];
  1097.  
  1098.             float dst = ((src0 != 0.0f) && (src1 != 0.0f)) ? 1.0f : 0.0f;
  1099.  
  1100.             _dst_val.f[_i] = dst;
  1101.       }
  1102.  
  1103.    return _dst_val;
  1104. }
  1105. static nir_const_value
  1106. evaluate_fany2(unsigned num_components, nir_const_value *_src)
  1107. {
  1108.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1109.  
  1110.  
  1111.       struct float_vec src0 = {
  1112.             _src[0].f[0],
  1113.             _src[0].f[1],
  1114.       };
  1115.  
  1116.       struct float_vec dst;
  1117.  
  1118.          dst.x = dst.y = dst.z = dst.w = ((src0.x != 0.0f) || (src0.y != 0.0f)) ? 1.0f : 0.0f;
  1119.  
  1120.             _dst_val.f[0] = dst.x;
  1121.  
  1122.    return _dst_val;
  1123. }
  1124. static nir_const_value
  1125. evaluate_fany3(unsigned num_components, nir_const_value *_src)
  1126. {
  1127.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1128.  
  1129.  
  1130.       struct float_vec src0 = {
  1131.             _src[0].f[0],
  1132.             _src[0].f[1],
  1133.             _src[0].f[2],
  1134.       };
  1135.  
  1136.       struct float_vec dst;
  1137.  
  1138.          dst.x = dst.y = dst.z = dst.w = ((src0.x != 0.0f) || (src0.y != 0.0f) || (src0.z != 0.0f)) ? 1.0f : 0.0f;
  1139.  
  1140.             _dst_val.f[0] = dst.x;
  1141.  
  1142.    return _dst_val;
  1143. }
  1144. static nir_const_value
  1145. evaluate_fany4(unsigned num_components, nir_const_value *_src)
  1146. {
  1147.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1148.  
  1149.  
  1150.       struct float_vec src0 = {
  1151.             _src[0].f[0],
  1152.             _src[0].f[1],
  1153.             _src[0].f[2],
  1154.             _src[0].f[3],
  1155.       };
  1156.  
  1157.       struct float_vec dst;
  1158.  
  1159.          dst.x = dst.y = dst.z = dst.w = ((src0.x != 0.0f) || (src0.y != 0.0f) || (src0.z != 0.0f) || (src0.w != 0.0f)) ? 1.0f : 0.0f;
  1160.  
  1161.             _dst_val.f[0] = dst.x;
  1162.  
  1163.    return _dst_val;
  1164. }
  1165. static nir_const_value
  1166. evaluate_fany_nequal2(unsigned num_components, nir_const_value *_src)
  1167. {
  1168.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1169.  
  1170.  
  1171.       struct float_vec src0 = {
  1172.             _src[0].f[0],
  1173.             _src[0].f[1],
  1174.       };
  1175.  
  1176.       struct float_vec src1 = {
  1177.             _src[1].f[0],
  1178.             _src[1].f[1],
  1179.       };
  1180.  
  1181.       struct float_vec dst;
  1182.  
  1183.          dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y)) ? 1.0f : 0.0f;
  1184.  
  1185.             _dst_val.f[0] = dst.x;
  1186.  
  1187.    return _dst_val;
  1188. }
  1189. static nir_const_value
  1190. evaluate_fany_nequal3(unsigned num_components, nir_const_value *_src)
  1191. {
  1192.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1193.  
  1194.  
  1195.       struct float_vec src0 = {
  1196.             _src[0].f[0],
  1197.             _src[0].f[1],
  1198.             _src[0].f[2],
  1199.       };
  1200.  
  1201.       struct float_vec src1 = {
  1202.             _src[1].f[0],
  1203.             _src[1].f[1],
  1204.             _src[1].f[2],
  1205.       };
  1206.  
  1207.       struct float_vec dst;
  1208.  
  1209.          dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z)) ? 1.0f : 0.0f;
  1210.  
  1211.             _dst_val.f[0] = dst.x;
  1212.  
  1213.    return _dst_val;
  1214. }
  1215. static nir_const_value
  1216. evaluate_fany_nequal4(unsigned num_components, nir_const_value *_src)
  1217. {
  1218.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1219.  
  1220.  
  1221.       struct float_vec src0 = {
  1222.             _src[0].f[0],
  1223.             _src[0].f[1],
  1224.             _src[0].f[2],
  1225.             _src[0].f[3],
  1226.       };
  1227.  
  1228.       struct float_vec src1 = {
  1229.             _src[1].f[0],
  1230.             _src[1].f[1],
  1231.             _src[1].f[2],
  1232.             _src[1].f[3],
  1233.       };
  1234.  
  1235.       struct float_vec dst;
  1236.  
  1237.          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;
  1238.  
  1239.             _dst_val.f[0] = dst.x;
  1240.  
  1241.    return _dst_val;
  1242. }
  1243. static nir_const_value
  1244. evaluate_fceil(unsigned num_components, nir_const_value *_src)
  1245. {
  1246.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1247.  
  1248.          
  1249.       for (unsigned _i = 0; _i < num_components; _i++) {
  1250.                float src0 = _src[0].f[_i];
  1251.  
  1252.             float dst = ceilf(src0);
  1253.  
  1254.             _dst_val.f[_i] = dst;
  1255.       }
  1256.  
  1257.    return _dst_val;
  1258. }
  1259. static nir_const_value
  1260. evaluate_fcos(unsigned num_components, nir_const_value *_src)
  1261. {
  1262.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1263.  
  1264.          
  1265.       for (unsigned _i = 0; _i < num_components; _i++) {
  1266.                float src0 = _src[0].f[_i];
  1267.  
  1268.             float dst = cosf(src0);
  1269.  
  1270.             _dst_val.f[_i] = dst;
  1271.       }
  1272.  
  1273.    return _dst_val;
  1274. }
  1275. static nir_const_value
  1276. evaluate_fcsel(unsigned num_components, nir_const_value *_src)
  1277. {
  1278.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1279.  
  1280.                            
  1281.       for (unsigned _i = 0; _i < num_components; _i++) {
  1282.                float src0 = _src[0].f[_i];
  1283.                float src1 = _src[1].f[_i];
  1284.                float src2 = _src[2].f[_i];
  1285.  
  1286.             float dst = (src0 != 0.0f) ? src1 : src2;
  1287.  
  1288.             _dst_val.f[_i] = dst;
  1289.       }
  1290.  
  1291.    return _dst_val;
  1292. }
  1293. static nir_const_value
  1294. evaluate_fddx(unsigned num_components, nir_const_value *_src)
  1295. {
  1296.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1297.  
  1298.          
  1299.       for (unsigned _i = 0; _i < num_components; _i++) {
  1300.                
  1301.             float dst = 0.0f;
  1302.  
  1303.             _dst_val.f[_i] = dst;
  1304.       }
  1305.  
  1306.    return _dst_val;
  1307. }
  1308. static nir_const_value
  1309. evaluate_fddx_coarse(unsigned num_components, nir_const_value *_src)
  1310. {
  1311.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1312.  
  1313.          
  1314.       for (unsigned _i = 0; _i < num_components; _i++) {
  1315.                
  1316.             float dst = 0.0f;
  1317.  
  1318.             _dst_val.f[_i] = dst;
  1319.       }
  1320.  
  1321.    return _dst_val;
  1322. }
  1323. static nir_const_value
  1324. evaluate_fddx_fine(unsigned num_components, nir_const_value *_src)
  1325. {
  1326.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1327.  
  1328.          
  1329.       for (unsigned _i = 0; _i < num_components; _i++) {
  1330.                
  1331.             float dst = 0.0f;
  1332.  
  1333.             _dst_val.f[_i] = dst;
  1334.       }
  1335.  
  1336.    return _dst_val;
  1337. }
  1338. static nir_const_value
  1339. evaluate_fddy(unsigned num_components, nir_const_value *_src)
  1340. {
  1341.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1342.  
  1343.          
  1344.       for (unsigned _i = 0; _i < num_components; _i++) {
  1345.                
  1346.             float dst = 0.0f;
  1347.  
  1348.             _dst_val.f[_i] = dst;
  1349.       }
  1350.  
  1351.    return _dst_val;
  1352. }
  1353. static nir_const_value
  1354. evaluate_fddy_coarse(unsigned num_components, nir_const_value *_src)
  1355. {
  1356.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1357.  
  1358.          
  1359.       for (unsigned _i = 0; _i < num_components; _i++) {
  1360.                
  1361.             float dst = 0.0f;
  1362.  
  1363.             _dst_val.f[_i] = dst;
  1364.       }
  1365.  
  1366.    return _dst_val;
  1367. }
  1368. static nir_const_value
  1369. evaluate_fddy_fine(unsigned num_components, nir_const_value *_src)
  1370. {
  1371.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1372.  
  1373.          
  1374.       for (unsigned _i = 0; _i < num_components; _i++) {
  1375.                
  1376.             float dst = 0.0f;
  1377.  
  1378.             _dst_val.f[_i] = dst;
  1379.       }
  1380.  
  1381.    return _dst_val;
  1382. }
  1383. static nir_const_value
  1384. evaluate_fdiv(unsigned num_components, nir_const_value *_src)
  1385. {
  1386.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1387.  
  1388.                  
  1389.       for (unsigned _i = 0; _i < num_components; _i++) {
  1390.                float src0 = _src[0].f[_i];
  1391.                float src1 = _src[1].f[_i];
  1392.  
  1393.             float dst = src0 / src1;
  1394.  
  1395.             _dst_val.f[_i] = dst;
  1396.       }
  1397.  
  1398.    return _dst_val;
  1399. }
  1400. static nir_const_value
  1401. evaluate_fdot2(unsigned num_components, nir_const_value *_src)
  1402. {
  1403.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1404.  
  1405.  
  1406.       struct float_vec src0 = {
  1407.             _src[0].f[0],
  1408.             _src[0].f[1],
  1409.       };
  1410.  
  1411.       struct float_vec src1 = {
  1412.             _src[1].f[0],
  1413.             _src[1].f[1],
  1414.       };
  1415.  
  1416.       struct float_vec dst;
  1417.  
  1418.          dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y));
  1419.  
  1420.             _dst_val.f[0] = dst.x;
  1421.  
  1422.    return _dst_val;
  1423. }
  1424. static nir_const_value
  1425. evaluate_fdot3(unsigned num_components, nir_const_value *_src)
  1426. {
  1427.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1428.  
  1429.  
  1430.       struct float_vec src0 = {
  1431.             _src[0].f[0],
  1432.             _src[0].f[1],
  1433.             _src[0].f[2],
  1434.       };
  1435.  
  1436.       struct float_vec src1 = {
  1437.             _src[1].f[0],
  1438.             _src[1].f[1],
  1439.             _src[1].f[2],
  1440.       };
  1441.  
  1442.       struct float_vec dst;
  1443.  
  1444.          dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z));
  1445.  
  1446.             _dst_val.f[0] = dst.x;
  1447.  
  1448.    return _dst_val;
  1449. }
  1450. static nir_const_value
  1451. evaluate_fdot4(unsigned num_components, nir_const_value *_src)
  1452. {
  1453.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1454.  
  1455.  
  1456.       struct float_vec src0 = {
  1457.             _src[0].f[0],
  1458.             _src[0].f[1],
  1459.             _src[0].f[2],
  1460.             _src[0].f[3],
  1461.       };
  1462.  
  1463.       struct float_vec src1 = {
  1464.             _src[1].f[0],
  1465.             _src[1].f[1],
  1466.             _src[1].f[2],
  1467.             _src[1].f[3],
  1468.       };
  1469.  
  1470.       struct float_vec dst;
  1471.  
  1472.          dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z) + (src0.w * src1.w));
  1473.  
  1474.             _dst_val.f[0] = dst.x;
  1475.  
  1476.    return _dst_val;
  1477. }
  1478. static nir_const_value
  1479. evaluate_feq(unsigned num_components, nir_const_value *_src)
  1480. {
  1481.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1482.  
  1483.                  
  1484.       for (unsigned _i = 0; _i < num_components; _i++) {
  1485.                float src0 = _src[0].f[_i];
  1486.                float src1 = _src[1].f[_i];
  1487.  
  1488.             bool dst = src0 == src1;
  1489.  
  1490.             _dst_val.u[_i] = dst ? NIR_TRUE : NIR_FALSE;
  1491.       }
  1492.  
  1493.    return _dst_val;
  1494. }
  1495. static nir_const_value
  1496. evaluate_fexp2(unsigned num_components, nir_const_value *_src)
  1497. {
  1498.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1499.  
  1500.          
  1501.       for (unsigned _i = 0; _i < num_components; _i++) {
  1502.                float src0 = _src[0].f[_i];
  1503.  
  1504.             float dst = exp2f(src0);
  1505.  
  1506.             _dst_val.f[_i] = dst;
  1507.       }
  1508.  
  1509.    return _dst_val;
  1510. }
  1511. static nir_const_value
  1512. evaluate_ffloor(unsigned num_components, nir_const_value *_src)
  1513. {
  1514.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1515.  
  1516.          
  1517.       for (unsigned _i = 0; _i < num_components; _i++) {
  1518.                float src0 = _src[0].f[_i];
  1519.  
  1520.             float dst = floorf(src0);
  1521.  
  1522.             _dst_val.f[_i] = dst;
  1523.       }
  1524.  
  1525.    return _dst_val;
  1526. }
  1527. static nir_const_value
  1528. evaluate_ffma(unsigned num_components, nir_const_value *_src)
  1529. {
  1530.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1531.  
  1532.                            
  1533.       for (unsigned _i = 0; _i < num_components; _i++) {
  1534.                float src0 = _src[0].f[_i];
  1535.                float src1 = _src[1].f[_i];
  1536.                float src2 = _src[2].f[_i];
  1537.  
  1538.             float dst = src0 * src1 + src2;
  1539.  
  1540.             _dst_val.f[_i] = dst;
  1541.       }
  1542.  
  1543.    return _dst_val;
  1544. }
  1545. static nir_const_value
  1546. evaluate_ffract(unsigned num_components, nir_const_value *_src)
  1547. {
  1548.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1549.  
  1550.          
  1551.       for (unsigned _i = 0; _i < num_components; _i++) {
  1552.                float src0 = _src[0].f[_i];
  1553.  
  1554.             float dst = src0 - floorf(src0);
  1555.  
  1556.             _dst_val.f[_i] = dst;
  1557.       }
  1558.  
  1559.    return _dst_val;
  1560. }
  1561. static nir_const_value
  1562. evaluate_fge(unsigned num_components, nir_const_value *_src)
  1563. {
  1564.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1565.  
  1566.                  
  1567.       for (unsigned _i = 0; _i < num_components; _i++) {
  1568.                float src0 = _src[0].f[_i];
  1569.                float src1 = _src[1].f[_i];
  1570.  
  1571.             bool dst = src0 >= src1;
  1572.  
  1573.             _dst_val.u[_i] = dst ? NIR_TRUE : NIR_FALSE;
  1574.       }
  1575.  
  1576.    return _dst_val;
  1577. }
  1578. static nir_const_value
  1579. evaluate_find_lsb(unsigned num_components, nir_const_value *_src)
  1580. {
  1581.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1582.  
  1583.          
  1584.       for (unsigned _i = 0; _i < num_components; _i++) {
  1585.                int src0 = _src[0].i[_i];
  1586.  
  1587.             int dst;
  1588.            
  1589. dst = -1;
  1590. for (unsigned bit = 0; bit < 32; bit++) {
  1591.    if ((src0 >> bit) & 1) {
  1592.       dst = bit;
  1593.       break;
  1594.    }
  1595. }
  1596.  
  1597.  
  1598.             _dst_val.i[_i] = dst;
  1599.       }
  1600.  
  1601.    return _dst_val;
  1602. }
  1603. static nir_const_value
  1604. evaluate_flog2(unsigned num_components, nir_const_value *_src)
  1605. {
  1606.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1607.  
  1608.          
  1609.       for (unsigned _i = 0; _i < num_components; _i++) {
  1610.                float src0 = _src[0].f[_i];
  1611.  
  1612.             float dst = log2f(src0);
  1613.  
  1614.             _dst_val.f[_i] = dst;
  1615.       }
  1616.  
  1617.    return _dst_val;
  1618. }
  1619. static nir_const_value
  1620. evaluate_flrp(unsigned num_components, nir_const_value *_src)
  1621. {
  1622.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1623.  
  1624.                            
  1625.       for (unsigned _i = 0; _i < num_components; _i++) {
  1626.                float src0 = _src[0].f[_i];
  1627.                float src1 = _src[1].f[_i];
  1628.                float src2 = _src[2].f[_i];
  1629.  
  1630.             float dst = src0 * (1 - src2) + src1 * src2;
  1631.  
  1632.             _dst_val.f[_i] = dst;
  1633.       }
  1634.  
  1635.    return _dst_val;
  1636. }
  1637. static nir_const_value
  1638. evaluate_flt(unsigned num_components, nir_const_value *_src)
  1639. {
  1640.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1641.  
  1642.                  
  1643.       for (unsigned _i = 0; _i < num_components; _i++) {
  1644.                float src0 = _src[0].f[_i];
  1645.                float src1 = _src[1].f[_i];
  1646.  
  1647.             bool dst = src0 < src1;
  1648.  
  1649.             _dst_val.u[_i] = dst ? NIR_TRUE : NIR_FALSE;
  1650.       }
  1651.  
  1652.    return _dst_val;
  1653. }
  1654. static nir_const_value
  1655. evaluate_fmax(unsigned num_components, nir_const_value *_src)
  1656. {
  1657.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1658.  
  1659.                  
  1660.       for (unsigned _i = 0; _i < num_components; _i++) {
  1661.                float src0 = _src[0].f[_i];
  1662.                float src1 = _src[1].f[_i];
  1663.  
  1664.             float dst = fmaxf(src0, src1);
  1665.  
  1666.             _dst_val.f[_i] = dst;
  1667.       }
  1668.  
  1669.    return _dst_val;
  1670. }
  1671. static nir_const_value
  1672. evaluate_fmin(unsigned num_components, nir_const_value *_src)
  1673. {
  1674.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1675.  
  1676.                  
  1677.       for (unsigned _i = 0; _i < num_components; _i++) {
  1678.                float src0 = _src[0].f[_i];
  1679.                float src1 = _src[1].f[_i];
  1680.  
  1681.             float dst = fminf(src0, src1);
  1682.  
  1683.             _dst_val.f[_i] = dst;
  1684.       }
  1685.  
  1686.    return _dst_val;
  1687. }
  1688. static nir_const_value
  1689. evaluate_fmod(unsigned num_components, nir_const_value *_src)
  1690. {
  1691.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1692.  
  1693.                  
  1694.       for (unsigned _i = 0; _i < num_components; _i++) {
  1695.                float src0 = _src[0].f[_i];
  1696.                float src1 = _src[1].f[_i];
  1697.  
  1698.             float dst = src0 - src1 * floorf(src0 / src1);
  1699.  
  1700.             _dst_val.f[_i] = dst;
  1701.       }
  1702.  
  1703.    return _dst_val;
  1704. }
  1705. static nir_const_value
  1706. evaluate_fmov(unsigned num_components, nir_const_value *_src)
  1707. {
  1708.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1709.  
  1710.          
  1711.       for (unsigned _i = 0; _i < num_components; _i++) {
  1712.                float src0 = _src[0].f[_i];
  1713.  
  1714.             float dst = src0;
  1715.  
  1716.             _dst_val.f[_i] = dst;
  1717.       }
  1718.  
  1719.    return _dst_val;
  1720. }
  1721. static nir_const_value
  1722. evaluate_fmul(unsigned num_components, nir_const_value *_src)
  1723. {
  1724.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1725.  
  1726.                  
  1727.       for (unsigned _i = 0; _i < num_components; _i++) {
  1728.                float src0 = _src[0].f[_i];
  1729.                float src1 = _src[1].f[_i];
  1730.  
  1731.             float dst = src0 * src1;
  1732.  
  1733.             _dst_val.f[_i] = dst;
  1734.       }
  1735.  
  1736.    return _dst_val;
  1737. }
  1738. static nir_const_value
  1739. evaluate_fne(unsigned num_components, nir_const_value *_src)
  1740. {
  1741.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1742.  
  1743.                  
  1744.       for (unsigned _i = 0; _i < num_components; _i++) {
  1745.                float src0 = _src[0].f[_i];
  1746.                float src1 = _src[1].f[_i];
  1747.  
  1748.             bool dst = src0 != src1;
  1749.  
  1750.             _dst_val.u[_i] = dst ? NIR_TRUE : NIR_FALSE;
  1751.       }
  1752.  
  1753.    return _dst_val;
  1754. }
  1755. static nir_const_value
  1756. evaluate_fneg(unsigned num_components, nir_const_value *_src)
  1757. {
  1758.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1759.  
  1760.          
  1761.       for (unsigned _i = 0; _i < num_components; _i++) {
  1762.                float src0 = _src[0].f[_i];
  1763.  
  1764.             float dst = -src0;
  1765.  
  1766.             _dst_val.f[_i] = dst;
  1767.       }
  1768.  
  1769.    return _dst_val;
  1770. }
  1771. static nir_const_value
  1772. evaluate_fnoise1_1(unsigned num_components, nir_const_value *_src)
  1773. {
  1774.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1775.  
  1776.          
  1777.       struct float_vec dst;
  1778.  
  1779.          dst.x = dst.y = dst.z = dst.w = 0.0f;
  1780.  
  1781.             _dst_val.f[0] = dst.x;
  1782.  
  1783.    return _dst_val;
  1784. }
  1785. static nir_const_value
  1786. evaluate_fnoise1_2(unsigned num_components, nir_const_value *_src)
  1787. {
  1788.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1789.  
  1790.          
  1791.       struct float_vec dst;
  1792.  
  1793.          dst.x = dst.y = dst.z = dst.w = 0.0f;
  1794.  
  1795.             _dst_val.f[0] = dst.x;
  1796.  
  1797.    return _dst_val;
  1798. }
  1799. static nir_const_value
  1800. evaluate_fnoise1_3(unsigned num_components, nir_const_value *_src)
  1801. {
  1802.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1803.  
  1804.          
  1805.       struct float_vec dst;
  1806.  
  1807.          dst.x = dst.y = dst.z = dst.w = 0.0f;
  1808.  
  1809.             _dst_val.f[0] = dst.x;
  1810.  
  1811.    return _dst_val;
  1812. }
  1813. static nir_const_value
  1814. evaluate_fnoise1_4(unsigned num_components, nir_const_value *_src)
  1815. {
  1816.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1817.  
  1818.          
  1819.       struct float_vec dst;
  1820.  
  1821.          dst.x = dst.y = dst.z = dst.w = 0.0f;
  1822.  
  1823.             _dst_val.f[0] = dst.x;
  1824.  
  1825.    return _dst_val;
  1826. }
  1827. static nir_const_value
  1828. evaluate_fnoise2_1(unsigned num_components, nir_const_value *_src)
  1829. {
  1830.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1831.  
  1832.          
  1833.       struct float_vec dst;
  1834.  
  1835.          dst.x = dst.y = dst.z = dst.w = 0.0f;
  1836.  
  1837.             _dst_val.f[0] = dst.x;
  1838.             _dst_val.f[1] = dst.y;
  1839.  
  1840.    return _dst_val;
  1841. }
  1842. static nir_const_value
  1843. evaluate_fnoise2_2(unsigned num_components, nir_const_value *_src)
  1844. {
  1845.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1846.  
  1847.          
  1848.       struct float_vec dst;
  1849.  
  1850.          dst.x = dst.y = dst.z = dst.w = 0.0f;
  1851.  
  1852.             _dst_val.f[0] = dst.x;
  1853.             _dst_val.f[1] = dst.y;
  1854.  
  1855.    return _dst_val;
  1856. }
  1857. static nir_const_value
  1858. evaluate_fnoise2_3(unsigned num_components, nir_const_value *_src)
  1859. {
  1860.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1861.  
  1862.          
  1863.       struct float_vec dst;
  1864.  
  1865.          dst.x = dst.y = dst.z = dst.w = 0.0f;
  1866.  
  1867.             _dst_val.f[0] = dst.x;
  1868.             _dst_val.f[1] = dst.y;
  1869.  
  1870.    return _dst_val;
  1871. }
  1872. static nir_const_value
  1873. evaluate_fnoise2_4(unsigned num_components, nir_const_value *_src)
  1874. {
  1875.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1876.  
  1877.          
  1878.       struct float_vec dst;
  1879.  
  1880.          dst.x = dst.y = dst.z = dst.w = 0.0f;
  1881.  
  1882.             _dst_val.f[0] = dst.x;
  1883.             _dst_val.f[1] = dst.y;
  1884.  
  1885.    return _dst_val;
  1886. }
  1887. static nir_const_value
  1888. evaluate_fnoise3_1(unsigned num_components, nir_const_value *_src)
  1889. {
  1890.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1891.  
  1892.          
  1893.       struct float_vec dst;
  1894.  
  1895.          dst.x = dst.y = dst.z = dst.w = 0.0f;
  1896.  
  1897.             _dst_val.f[0] = dst.x;
  1898.             _dst_val.f[1] = dst.y;
  1899.             _dst_val.f[2] = dst.z;
  1900.  
  1901.    return _dst_val;
  1902. }
  1903. static nir_const_value
  1904. evaluate_fnoise3_2(unsigned num_components, nir_const_value *_src)
  1905. {
  1906.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1907.  
  1908.          
  1909.       struct float_vec dst;
  1910.  
  1911.          dst.x = dst.y = dst.z = dst.w = 0.0f;
  1912.  
  1913.             _dst_val.f[0] = dst.x;
  1914.             _dst_val.f[1] = dst.y;
  1915.             _dst_val.f[2] = dst.z;
  1916.  
  1917.    return _dst_val;
  1918. }
  1919. static nir_const_value
  1920. evaluate_fnoise3_3(unsigned num_components, nir_const_value *_src)
  1921. {
  1922.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1923.  
  1924.          
  1925.       struct float_vec dst;
  1926.  
  1927.          dst.x = dst.y = dst.z = dst.w = 0.0f;
  1928.  
  1929.             _dst_val.f[0] = dst.x;
  1930.             _dst_val.f[1] = dst.y;
  1931.             _dst_val.f[2] = dst.z;
  1932.  
  1933.    return _dst_val;
  1934. }
  1935. static nir_const_value
  1936. evaluate_fnoise3_4(unsigned num_components, nir_const_value *_src)
  1937. {
  1938.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1939.  
  1940.          
  1941.       struct float_vec dst;
  1942.  
  1943.          dst.x = dst.y = dst.z = dst.w = 0.0f;
  1944.  
  1945.             _dst_val.f[0] = dst.x;
  1946.             _dst_val.f[1] = dst.y;
  1947.             _dst_val.f[2] = dst.z;
  1948.  
  1949.    return _dst_val;
  1950. }
  1951. static nir_const_value
  1952. evaluate_fnoise4_1(unsigned num_components, nir_const_value *_src)
  1953. {
  1954.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1955.  
  1956.          
  1957.       struct float_vec dst;
  1958.  
  1959.          dst.x = dst.y = dst.z = dst.w = 0.0f;
  1960.  
  1961.             _dst_val.f[0] = dst.x;
  1962.             _dst_val.f[1] = dst.y;
  1963.             _dst_val.f[2] = dst.z;
  1964.             _dst_val.f[3] = dst.w;
  1965.  
  1966.    return _dst_val;
  1967. }
  1968. static nir_const_value
  1969. evaluate_fnoise4_2(unsigned num_components, nir_const_value *_src)
  1970. {
  1971.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1972.  
  1973.          
  1974.       struct float_vec dst;
  1975.  
  1976.          dst.x = dst.y = dst.z = dst.w = 0.0f;
  1977.  
  1978.             _dst_val.f[0] = dst.x;
  1979.             _dst_val.f[1] = dst.y;
  1980.             _dst_val.f[2] = dst.z;
  1981.             _dst_val.f[3] = dst.w;
  1982.  
  1983.    return _dst_val;
  1984. }
  1985. static nir_const_value
  1986. evaluate_fnoise4_3(unsigned num_components, nir_const_value *_src)
  1987. {
  1988.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  1989.  
  1990.          
  1991.       struct float_vec dst;
  1992.  
  1993.          dst.x = dst.y = dst.z = dst.w = 0.0f;
  1994.  
  1995.             _dst_val.f[0] = dst.x;
  1996.             _dst_val.f[1] = dst.y;
  1997.             _dst_val.f[2] = dst.z;
  1998.             _dst_val.f[3] = dst.w;
  1999.  
  2000.    return _dst_val;
  2001. }
  2002. static nir_const_value
  2003. evaluate_fnoise4_4(unsigned num_components, nir_const_value *_src)
  2004. {
  2005.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2006.  
  2007.          
  2008.       struct float_vec dst;
  2009.  
  2010.          dst.x = dst.y = dst.z = dst.w = 0.0f;
  2011.  
  2012.             _dst_val.f[0] = dst.x;
  2013.             _dst_val.f[1] = dst.y;
  2014.             _dst_val.f[2] = dst.z;
  2015.             _dst_val.f[3] = dst.w;
  2016.  
  2017.    return _dst_val;
  2018. }
  2019. static nir_const_value
  2020. evaluate_fnot(unsigned num_components, nir_const_value *_src)
  2021. {
  2022.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2023.  
  2024.          
  2025.       for (unsigned _i = 0; _i < num_components; _i++) {
  2026.                float src0 = _src[0].f[_i];
  2027.  
  2028.             float dst = (src0 == 0.0f) ? 1.0f : 0.0f;
  2029.  
  2030.             _dst_val.f[_i] = dst;
  2031.       }
  2032.  
  2033.    return _dst_val;
  2034. }
  2035. static nir_const_value
  2036. evaluate_for(unsigned num_components, nir_const_value *_src)
  2037. {
  2038.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2039.  
  2040.                  
  2041.       for (unsigned _i = 0; _i < num_components; _i++) {
  2042.                float src0 = _src[0].f[_i];
  2043.                float src1 = _src[1].f[_i];
  2044.  
  2045.             float dst = ((src0 != 0.0f) || (src1 != 0.0f)) ? 1.0f : 0.0f;
  2046.  
  2047.             _dst_val.f[_i] = dst;
  2048.       }
  2049.  
  2050.    return _dst_val;
  2051. }
  2052. static nir_const_value
  2053. evaluate_fpow(unsigned num_components, nir_const_value *_src)
  2054. {
  2055.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2056.  
  2057.                  
  2058.       for (unsigned _i = 0; _i < num_components; _i++) {
  2059.                float src0 = _src[0].f[_i];
  2060.                float src1 = _src[1].f[_i];
  2061.  
  2062.             float dst = powf(src0, src1);
  2063.  
  2064.             _dst_val.f[_i] = dst;
  2065.       }
  2066.  
  2067.    return _dst_val;
  2068. }
  2069. static nir_const_value
  2070. evaluate_frcp(unsigned num_components, nir_const_value *_src)
  2071. {
  2072.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2073.  
  2074.          
  2075.       for (unsigned _i = 0; _i < num_components; _i++) {
  2076.                float src0 = _src[0].f[_i];
  2077.  
  2078.             float dst = 1.0f / src0;
  2079.  
  2080.             _dst_val.f[_i] = dst;
  2081.       }
  2082.  
  2083.    return _dst_val;
  2084. }
  2085. static nir_const_value
  2086. evaluate_fround_even(unsigned num_components, nir_const_value *_src)
  2087. {
  2088.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2089.  
  2090.          
  2091.       for (unsigned _i = 0; _i < num_components; _i++) {
  2092.                float src0 = _src[0].f[_i];
  2093.  
  2094.             float dst = _mesa_roundevenf(src0);
  2095.  
  2096.             _dst_val.f[_i] = dst;
  2097.       }
  2098.  
  2099.    return _dst_val;
  2100. }
  2101. static nir_const_value
  2102. evaluate_frsq(unsigned num_components, nir_const_value *_src)
  2103. {
  2104.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2105.  
  2106.          
  2107.       for (unsigned _i = 0; _i < num_components; _i++) {
  2108.                float src0 = _src[0].f[_i];
  2109.  
  2110.             float dst = 1.0f / sqrtf(src0);
  2111.  
  2112.             _dst_val.f[_i] = dst;
  2113.       }
  2114.  
  2115.    return _dst_val;
  2116. }
  2117. static nir_const_value
  2118. evaluate_fsat(unsigned num_components, nir_const_value *_src)
  2119. {
  2120.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2121.  
  2122.          
  2123.       for (unsigned _i = 0; _i < num_components; _i++) {
  2124.                float src0 = _src[0].f[_i];
  2125.  
  2126.             float dst = (src0 > 1.0f) ? 1.0f : ((src0 <= 0.0f) ? 0.0f : src0);
  2127.  
  2128.             _dst_val.f[_i] = dst;
  2129.       }
  2130.  
  2131.    return _dst_val;
  2132. }
  2133. static nir_const_value
  2134. evaluate_fsign(unsigned num_components, nir_const_value *_src)
  2135. {
  2136.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2137.  
  2138.          
  2139.       for (unsigned _i = 0; _i < num_components; _i++) {
  2140.                float src0 = _src[0].f[_i];
  2141.  
  2142.             float dst = (src0 == 0.0f) ? 0.0f : ((src0 > 0.0f) ? 1.0f : -1.0f);
  2143.  
  2144.             _dst_val.f[_i] = dst;
  2145.       }
  2146.  
  2147.    return _dst_val;
  2148. }
  2149. static nir_const_value
  2150. evaluate_fsin(unsigned num_components, nir_const_value *_src)
  2151. {
  2152.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2153.  
  2154.          
  2155.       for (unsigned _i = 0; _i < num_components; _i++) {
  2156.                float src0 = _src[0].f[_i];
  2157.  
  2158.             float dst = sinf(src0);
  2159.  
  2160.             _dst_val.f[_i] = dst;
  2161.       }
  2162.  
  2163.    return _dst_val;
  2164. }
  2165. static nir_const_value
  2166. evaluate_fsqrt(unsigned num_components, nir_const_value *_src)
  2167. {
  2168.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2169.  
  2170.          
  2171.       for (unsigned _i = 0; _i < num_components; _i++) {
  2172.                float src0 = _src[0].f[_i];
  2173.  
  2174.             float dst = sqrtf(src0);
  2175.  
  2176.             _dst_val.f[_i] = dst;
  2177.       }
  2178.  
  2179.    return _dst_val;
  2180. }
  2181. static nir_const_value
  2182. evaluate_fsub(unsigned num_components, nir_const_value *_src)
  2183. {
  2184.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2185.  
  2186.                  
  2187.       for (unsigned _i = 0; _i < num_components; _i++) {
  2188.                float src0 = _src[0].f[_i];
  2189.                float src1 = _src[1].f[_i];
  2190.  
  2191.             float dst = src0 - src1;
  2192.  
  2193.             _dst_val.f[_i] = dst;
  2194.       }
  2195.  
  2196.    return _dst_val;
  2197. }
  2198. static nir_const_value
  2199. evaluate_ftrunc(unsigned num_components, nir_const_value *_src)
  2200. {
  2201.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2202.  
  2203.          
  2204.       for (unsigned _i = 0; _i < num_components; _i++) {
  2205.                float src0 = _src[0].f[_i];
  2206.  
  2207.             float dst = truncf(src0);
  2208.  
  2209.             _dst_val.f[_i] = dst;
  2210.       }
  2211.  
  2212.    return _dst_val;
  2213. }
  2214. static nir_const_value
  2215. evaluate_fxor(unsigned num_components, nir_const_value *_src)
  2216. {
  2217.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2218.  
  2219.                  
  2220.       for (unsigned _i = 0; _i < num_components; _i++) {
  2221.                float src0 = _src[0].f[_i];
  2222.                float src1 = _src[1].f[_i];
  2223.  
  2224.             float dst = (src0 != 0.0f && src1 == 0.0f) || (src0 == 0.0f && src1 != 0.0f) ? 1.0f : 0.0f;
  2225.  
  2226.             _dst_val.f[_i] = dst;
  2227.       }
  2228.  
  2229.    return _dst_val;
  2230. }
  2231. static nir_const_value
  2232. evaluate_i2b(unsigned num_components, nir_const_value *_src)
  2233. {
  2234.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2235.  
  2236.          
  2237.       for (unsigned _i = 0; _i < num_components; _i++) {
  2238.                int src0 = _src[0].i[_i];
  2239.  
  2240.             bool dst = src0 != 0;
  2241.  
  2242.             _dst_val.u[_i] = dst ? NIR_TRUE : NIR_FALSE;
  2243.       }
  2244.  
  2245.    return _dst_val;
  2246. }
  2247. static nir_const_value
  2248. evaluate_i2f(unsigned num_components, nir_const_value *_src)
  2249. {
  2250.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2251.  
  2252.          
  2253.       for (unsigned _i = 0; _i < num_components; _i++) {
  2254.                int src0 = _src[0].i[_i];
  2255.  
  2256.             float dst = src0;
  2257.  
  2258.             _dst_val.f[_i] = dst;
  2259.       }
  2260.  
  2261.    return _dst_val;
  2262. }
  2263. static nir_const_value
  2264. evaluate_iabs(unsigned num_components, nir_const_value *_src)
  2265. {
  2266.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2267.  
  2268.          
  2269.       for (unsigned _i = 0; _i < num_components; _i++) {
  2270.                int src0 = _src[0].i[_i];
  2271.  
  2272.             int dst = (src0 < 0) ? -src0 : src0;
  2273.  
  2274.             _dst_val.i[_i] = dst;
  2275.       }
  2276.  
  2277.    return _dst_val;
  2278. }
  2279. static nir_const_value
  2280. evaluate_iadd(unsigned num_components, nir_const_value *_src)
  2281. {
  2282.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2283.  
  2284.                  
  2285.       for (unsigned _i = 0; _i < num_components; _i++) {
  2286.                int src0 = _src[0].i[_i];
  2287.                int src1 = _src[1].i[_i];
  2288.  
  2289.             int dst = src0 + src1;
  2290.  
  2291.             _dst_val.i[_i] = dst;
  2292.       }
  2293.  
  2294.    return _dst_val;
  2295. }
  2296. static nir_const_value
  2297. evaluate_iand(unsigned num_components, nir_const_value *_src)
  2298. {
  2299.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2300.  
  2301.                  
  2302.       for (unsigned _i = 0; _i < num_components; _i++) {
  2303.                unsigned src0 = _src[0].u[_i];
  2304.                unsigned src1 = _src[1].u[_i];
  2305.  
  2306.             unsigned dst = src0 & src1;
  2307.  
  2308.             _dst_val.u[_i] = dst;
  2309.       }
  2310.  
  2311.    return _dst_val;
  2312. }
  2313. static nir_const_value
  2314. evaluate_ibitfield_extract(unsigned num_components, nir_const_value *_src)
  2315. {
  2316.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2317.  
  2318.          
  2319.       struct int_vec src1 = {
  2320.             _src[1].i[0],
  2321.       };
  2322.  
  2323.       struct int_vec src2 = {
  2324.             _src[2].i[0],
  2325.       };
  2326.  
  2327.       for (unsigned _i = 0; _i < num_components; _i++) {
  2328.                int src0 = _src[0].i[_i];
  2329.                              
  2330.             int dst;
  2331.            
  2332. int base = src0;
  2333. int offset = src1.x, bits = src2.x;
  2334. if (bits == 0) {
  2335.    dst = 0;
  2336. } else if (offset < 0 || bits < 0 || offset + bits > 32) {
  2337.    dst = 0;
  2338. } else {
  2339.    dst = (base << (32 - offset - bits)) >> offset; /* use sign-extending shift */
  2340. }
  2341.  
  2342.  
  2343.             _dst_val.i[_i] = dst;
  2344.       }
  2345.  
  2346.    return _dst_val;
  2347. }
  2348. static nir_const_value
  2349. evaluate_idiv(unsigned num_components, nir_const_value *_src)
  2350. {
  2351.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2352.  
  2353.                  
  2354.       for (unsigned _i = 0; _i < num_components; _i++) {
  2355.                int src0 = _src[0].i[_i];
  2356.                int src1 = _src[1].i[_i];
  2357.  
  2358.             int dst = src0 / src1;
  2359.  
  2360.             _dst_val.i[_i] = dst;
  2361.       }
  2362.  
  2363.    return _dst_val;
  2364. }
  2365. static nir_const_value
  2366. evaluate_ieq(unsigned num_components, nir_const_value *_src)
  2367. {
  2368.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2369.  
  2370.                  
  2371.       for (unsigned _i = 0; _i < num_components; _i++) {
  2372.                int src0 = _src[0].i[_i];
  2373.                int src1 = _src[1].i[_i];
  2374.  
  2375.             bool dst = src0 == src1;
  2376.  
  2377.             _dst_val.u[_i] = dst ? NIR_TRUE : NIR_FALSE;
  2378.       }
  2379.  
  2380.    return _dst_val;
  2381. }
  2382. static nir_const_value
  2383. evaluate_ifind_msb(unsigned num_components, nir_const_value *_src)
  2384. {
  2385.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2386.  
  2387.          
  2388.       for (unsigned _i = 0; _i < num_components; _i++) {
  2389.                int src0 = _src[0].i[_i];
  2390.  
  2391.             int dst;
  2392.            
  2393. dst = -1;
  2394. for (int bit = 31; bit >= 0; bit--) {
  2395.    /* If src0 < 0, we're looking for the first 0 bit.
  2396.     * if src0 >= 0, we're looking for the first 1 bit.
  2397.     */
  2398.    if ((((src0 >> bit) & 1) && (src0 >= 0)) ||
  2399.       (!((src0 >> bit) & 1) && (src0 < 0))) {
  2400.       dst = bit;
  2401.       break;
  2402.    }
  2403. }
  2404.  
  2405.  
  2406.             _dst_val.i[_i] = dst;
  2407.       }
  2408.  
  2409.    return _dst_val;
  2410. }
  2411. static nir_const_value
  2412. evaluate_ige(unsigned num_components, nir_const_value *_src)
  2413. {
  2414.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2415.  
  2416.                  
  2417.       for (unsigned _i = 0; _i < num_components; _i++) {
  2418.                int src0 = _src[0].i[_i];
  2419.                int src1 = _src[1].i[_i];
  2420.  
  2421.             bool dst = src0 >= src1;
  2422.  
  2423.             _dst_val.u[_i] = dst ? NIR_TRUE : NIR_FALSE;
  2424.       }
  2425.  
  2426.    return _dst_val;
  2427. }
  2428. static nir_const_value
  2429. evaluate_ilt(unsigned num_components, nir_const_value *_src)
  2430. {
  2431.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2432.  
  2433.                  
  2434.       for (unsigned _i = 0; _i < num_components; _i++) {
  2435.                int src0 = _src[0].i[_i];
  2436.                int src1 = _src[1].i[_i];
  2437.  
  2438.             bool dst = src0 < src1;
  2439.  
  2440.             _dst_val.u[_i] = dst ? NIR_TRUE : NIR_FALSE;
  2441.       }
  2442.  
  2443.    return _dst_val;
  2444. }
  2445. static nir_const_value
  2446. evaluate_imax(unsigned num_components, nir_const_value *_src)
  2447. {
  2448.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2449.  
  2450.                  
  2451.       for (unsigned _i = 0; _i < num_components; _i++) {
  2452.                int src0 = _src[0].i[_i];
  2453.                int src1 = _src[1].i[_i];
  2454.  
  2455.             int dst = src1 > src0 ? src1 : src0;
  2456.  
  2457.             _dst_val.i[_i] = dst;
  2458.       }
  2459.  
  2460.    return _dst_val;
  2461. }
  2462. static nir_const_value
  2463. evaluate_imin(unsigned num_components, nir_const_value *_src)
  2464. {
  2465.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2466.  
  2467.                  
  2468.       for (unsigned _i = 0; _i < num_components; _i++) {
  2469.                int src0 = _src[0].i[_i];
  2470.                int src1 = _src[1].i[_i];
  2471.  
  2472.             int dst = src1 > src0 ? src0 : src1;
  2473.  
  2474.             _dst_val.i[_i] = dst;
  2475.       }
  2476.  
  2477.    return _dst_val;
  2478. }
  2479. static nir_const_value
  2480. evaluate_imov(unsigned num_components, nir_const_value *_src)
  2481. {
  2482.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2483.  
  2484.          
  2485.       for (unsigned _i = 0; _i < num_components; _i++) {
  2486.                int src0 = _src[0].i[_i];
  2487.  
  2488.             int dst = src0;
  2489.  
  2490.             _dst_val.i[_i] = dst;
  2491.       }
  2492.  
  2493.    return _dst_val;
  2494. }
  2495. static nir_const_value
  2496. evaluate_imul(unsigned num_components, nir_const_value *_src)
  2497. {
  2498.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2499.  
  2500.                  
  2501.       for (unsigned _i = 0; _i < num_components; _i++) {
  2502.                int src0 = _src[0].i[_i];
  2503.                int src1 = _src[1].i[_i];
  2504.  
  2505.             int dst = src0 * src1;
  2506.  
  2507.             _dst_val.i[_i] = dst;
  2508.       }
  2509.  
  2510.    return _dst_val;
  2511. }
  2512. static nir_const_value
  2513. evaluate_imul_high(unsigned num_components, nir_const_value *_src)
  2514. {
  2515.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2516.  
  2517.                  
  2518.       for (unsigned _i = 0; _i < num_components; _i++) {
  2519.                int src0 = _src[0].i[_i];
  2520.                int src1 = _src[1].i[_i];
  2521.  
  2522.             int dst = (int32_t)(((int64_t) src0 * (int64_t) src1) >> 32);
  2523.  
  2524.             _dst_val.i[_i] = dst;
  2525.       }
  2526.  
  2527.    return _dst_val;
  2528. }
  2529. static nir_const_value
  2530. evaluate_ine(unsigned num_components, nir_const_value *_src)
  2531. {
  2532.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2533.  
  2534.                  
  2535.       for (unsigned _i = 0; _i < num_components; _i++) {
  2536.                int src0 = _src[0].i[_i];
  2537.                int src1 = _src[1].i[_i];
  2538.  
  2539.             bool dst = src0 != src1;
  2540.  
  2541.             _dst_val.u[_i] = dst ? NIR_TRUE : NIR_FALSE;
  2542.       }
  2543.  
  2544.    return _dst_val;
  2545. }
  2546. static nir_const_value
  2547. evaluate_ineg(unsigned num_components, nir_const_value *_src)
  2548. {
  2549.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2550.  
  2551.          
  2552.       for (unsigned _i = 0; _i < num_components; _i++) {
  2553.                int src0 = _src[0].i[_i];
  2554.  
  2555.             int dst = -src0;
  2556.  
  2557.             _dst_val.i[_i] = dst;
  2558.       }
  2559.  
  2560.    return _dst_val;
  2561. }
  2562. static nir_const_value
  2563. evaluate_inot(unsigned num_components, nir_const_value *_src)
  2564. {
  2565.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2566.  
  2567.          
  2568.       for (unsigned _i = 0; _i < num_components; _i++) {
  2569.                int src0 = _src[0].i[_i];
  2570.  
  2571.             int dst = ~src0;
  2572.  
  2573.             _dst_val.i[_i] = dst;
  2574.       }
  2575.  
  2576.    return _dst_val;
  2577. }
  2578. static nir_const_value
  2579. evaluate_ior(unsigned num_components, nir_const_value *_src)
  2580. {
  2581.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2582.  
  2583.                  
  2584.       for (unsigned _i = 0; _i < num_components; _i++) {
  2585.                unsigned src0 = _src[0].u[_i];
  2586.                unsigned src1 = _src[1].u[_i];
  2587.  
  2588.             unsigned dst = src0 | src1;
  2589.  
  2590.             _dst_val.u[_i] = dst;
  2591.       }
  2592.  
  2593.    return _dst_val;
  2594. }
  2595. static nir_const_value
  2596. evaluate_ishl(unsigned num_components, nir_const_value *_src)
  2597. {
  2598.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2599.  
  2600.                  
  2601.       for (unsigned _i = 0; _i < num_components; _i++) {
  2602.                int src0 = _src[0].i[_i];
  2603.                int src1 = _src[1].i[_i];
  2604.  
  2605.             int dst = src0 << src1;
  2606.  
  2607.             _dst_val.i[_i] = dst;
  2608.       }
  2609.  
  2610.    return _dst_val;
  2611. }
  2612. static nir_const_value
  2613. evaluate_ishr(unsigned num_components, nir_const_value *_src)
  2614. {
  2615.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2616.  
  2617.                  
  2618.       for (unsigned _i = 0; _i < num_components; _i++) {
  2619.                int src0 = _src[0].i[_i];
  2620.                int src1 = _src[1].i[_i];
  2621.  
  2622.             int dst = src0 >> src1;
  2623.  
  2624.             _dst_val.i[_i] = dst;
  2625.       }
  2626.  
  2627.    return _dst_val;
  2628. }
  2629. static nir_const_value
  2630. evaluate_isign(unsigned num_components, nir_const_value *_src)
  2631. {
  2632.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2633.  
  2634.          
  2635.       for (unsigned _i = 0; _i < num_components; _i++) {
  2636.                int src0 = _src[0].i[_i];
  2637.  
  2638.             int dst = (src0 == 0) ? 0 : ((src0 > 0) ? 1 : -1);
  2639.  
  2640.             _dst_val.i[_i] = dst;
  2641.       }
  2642.  
  2643.    return _dst_val;
  2644. }
  2645. static nir_const_value
  2646. evaluate_isub(unsigned num_components, nir_const_value *_src)
  2647. {
  2648.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2649.  
  2650.                  
  2651.       for (unsigned _i = 0; _i < num_components; _i++) {
  2652.                int src0 = _src[0].i[_i];
  2653.                int src1 = _src[1].i[_i];
  2654.  
  2655.             int dst = src0 - src1;
  2656.  
  2657.             _dst_val.i[_i] = dst;
  2658.       }
  2659.  
  2660.    return _dst_val;
  2661. }
  2662. static nir_const_value
  2663. evaluate_ixor(unsigned num_components, nir_const_value *_src)
  2664. {
  2665.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2666.  
  2667.                  
  2668.       for (unsigned _i = 0; _i < num_components; _i++) {
  2669.                unsigned src0 = _src[0].u[_i];
  2670.                unsigned src1 = _src[1].u[_i];
  2671.  
  2672.             unsigned dst = src0 ^ src1;
  2673.  
  2674.             _dst_val.u[_i] = dst;
  2675.       }
  2676.  
  2677.    return _dst_val;
  2678. }
  2679. static nir_const_value
  2680. evaluate_ldexp(unsigned num_components, nir_const_value *_src)
  2681. {
  2682.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2683.  
  2684.                  
  2685.       for (unsigned _i = 0; _i < num_components; _i++) {
  2686.                float src0 = _src[0].f[_i];
  2687.                int src1 = _src[1].i[_i];
  2688.  
  2689.             float dst;
  2690.            
  2691. dst = ldexp(src0, src1);
  2692. /* flush denormals to zero. */
  2693. if (!isnormal(dst))
  2694.    dst = copysign(0.0f, src0);
  2695.  
  2696.  
  2697.             _dst_val.f[_i] = dst;
  2698.       }
  2699.  
  2700.    return _dst_val;
  2701. }
  2702. static nir_const_value
  2703. evaluate_pack_half_2x16(unsigned num_components, nir_const_value *_src)
  2704. {
  2705.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2706.  
  2707.  
  2708.       struct float_vec src0 = {
  2709.             _src[0].f[0],
  2710.             _src[0].f[1],
  2711.       };
  2712.  
  2713.       struct unsigned_vec dst;
  2714.  
  2715.          
  2716. dst.x = (uint32_t) pack_half_1x16(src0.x);
  2717. dst.x |= ((uint32_t) pack_half_1x16(src0.y)) << 16;
  2718.  
  2719.  
  2720.             _dst_val.u[0] = dst.x;
  2721.  
  2722.    return _dst_val;
  2723. }
  2724. static nir_const_value
  2725. evaluate_pack_half_2x16_split(unsigned num_components, nir_const_value *_src)
  2726. {
  2727.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2728.  
  2729.  
  2730.       struct float_vec src0 = {
  2731.             _src[0].f[0],
  2732.       };
  2733.  
  2734.       struct float_vec src1 = {
  2735.             _src[1].f[0],
  2736.       };
  2737.  
  2738.       struct unsigned_vec dst;
  2739.  
  2740.          dst.x = dst.y = dst.z = dst.w = pack_half_1x16(src0.x) | (pack_half_1x16(src1.x) << 16);
  2741.  
  2742.             _dst_val.u[0] = dst.x;
  2743.  
  2744.    return _dst_val;
  2745. }
  2746. static nir_const_value
  2747. evaluate_pack_snorm_2x16(unsigned num_components, nir_const_value *_src)
  2748. {
  2749.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2750.  
  2751.  
  2752.       struct float_vec src0 = {
  2753.             _src[0].f[0],
  2754.             _src[0].f[1],
  2755.       };
  2756.  
  2757.       struct unsigned_vec dst;
  2758.  
  2759.          
  2760. dst.x = (uint32_t) pack_snorm_1x16(src0.x);
  2761. dst.x |= ((uint32_t) pack_snorm_1x16(src0.y)) << 16;
  2762.  
  2763.  
  2764.             _dst_val.u[0] = dst.x;
  2765.  
  2766.    return _dst_val;
  2767. }
  2768. static nir_const_value
  2769. evaluate_pack_snorm_4x8(unsigned num_components, nir_const_value *_src)
  2770. {
  2771.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2772.  
  2773.  
  2774.       struct float_vec src0 = {
  2775.             _src[0].f[0],
  2776.             _src[0].f[1],
  2777.             _src[0].f[2],
  2778.             _src[0].f[3],
  2779.       };
  2780.  
  2781.       struct unsigned_vec dst;
  2782.  
  2783.          
  2784. dst.x = (uint32_t) pack_snorm_1x8(src0.x);
  2785. dst.x |= ((uint32_t) pack_snorm_1x8(src0.y)) << 8;
  2786. dst.x |= ((uint32_t) pack_snorm_1x8(src0.z)) << 16;
  2787. dst.x |= ((uint32_t) pack_snorm_1x8(src0.w)) << 24;
  2788.  
  2789.  
  2790.             _dst_val.u[0] = dst.x;
  2791.  
  2792.    return _dst_val;
  2793. }
  2794. static nir_const_value
  2795. evaluate_pack_unorm_2x16(unsigned num_components, nir_const_value *_src)
  2796. {
  2797.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2798.  
  2799.  
  2800.       struct float_vec src0 = {
  2801.             _src[0].f[0],
  2802.             _src[0].f[1],
  2803.       };
  2804.  
  2805.       struct unsigned_vec dst;
  2806.  
  2807.          
  2808. dst.x = (uint32_t) pack_unorm_1x16(src0.x);
  2809. dst.x |= ((uint32_t) pack_unorm_1x16(src0.y)) << 16;
  2810.  
  2811.  
  2812.             _dst_val.u[0] = dst.x;
  2813.  
  2814.    return _dst_val;
  2815. }
  2816. static nir_const_value
  2817. evaluate_pack_unorm_4x8(unsigned num_components, nir_const_value *_src)
  2818. {
  2819.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2820.  
  2821.  
  2822.       struct float_vec src0 = {
  2823.             _src[0].f[0],
  2824.             _src[0].f[1],
  2825.             _src[0].f[2],
  2826.             _src[0].f[3],
  2827.       };
  2828.  
  2829.       struct unsigned_vec dst;
  2830.  
  2831.          
  2832. dst.x = (uint32_t) pack_unorm_1x8(src0.x);
  2833. dst.x |= ((uint32_t) pack_unorm_1x8(src0.y)) << 8;
  2834. dst.x |= ((uint32_t) pack_unorm_1x8(src0.z)) << 16;
  2835. dst.x |= ((uint32_t) pack_unorm_1x8(src0.w)) << 24;
  2836.  
  2837.  
  2838.             _dst_val.u[0] = dst.x;
  2839.  
  2840.    return _dst_val;
  2841. }
  2842. static nir_const_value
  2843. evaluate_seq(unsigned num_components, nir_const_value *_src)
  2844. {
  2845.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2846.  
  2847.                  
  2848.       for (unsigned _i = 0; _i < num_components; _i++) {
  2849.                float src0 = _src[0].f[_i];
  2850.                float src1 = _src[1].f[_i];
  2851.  
  2852.             float dst = (src0 == src1) ? 1.0f : 0.0f;
  2853.  
  2854.             _dst_val.f[_i] = dst;
  2855.       }
  2856.  
  2857.    return _dst_val;
  2858. }
  2859. static nir_const_value
  2860. evaluate_sge(unsigned num_components, nir_const_value *_src)
  2861. {
  2862.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2863.  
  2864.                  
  2865.       for (unsigned _i = 0; _i < num_components; _i++) {
  2866.                float src0 = _src[0].f[_i];
  2867.                float src1 = _src[1].f[_i];
  2868.  
  2869.             float dst = (src0 >= src1) ? 1.0f : 0.0f;
  2870.  
  2871.             _dst_val.f[_i] = dst;
  2872.       }
  2873.  
  2874.    return _dst_val;
  2875. }
  2876. static nir_const_value
  2877. evaluate_slt(unsigned num_components, nir_const_value *_src)
  2878. {
  2879.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2880.  
  2881.                  
  2882.       for (unsigned _i = 0; _i < num_components; _i++) {
  2883.                float src0 = _src[0].f[_i];
  2884.                float src1 = _src[1].f[_i];
  2885.  
  2886.             float dst = (src0 < src1) ? 1.0f : 0.0f;
  2887.  
  2888.             _dst_val.f[_i] = dst;
  2889.       }
  2890.  
  2891.    return _dst_val;
  2892. }
  2893. static nir_const_value
  2894. evaluate_sne(unsigned num_components, nir_const_value *_src)
  2895. {
  2896.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2897.  
  2898.                  
  2899.       for (unsigned _i = 0; _i < num_components; _i++) {
  2900.                float src0 = _src[0].f[_i];
  2901.                float src1 = _src[1].f[_i];
  2902.  
  2903.             float dst = (src0 != src1) ? 1.0f : 0.0f;
  2904.  
  2905.             _dst_val.f[_i] = dst;
  2906.       }
  2907.  
  2908.    return _dst_val;
  2909. }
  2910. static nir_const_value
  2911. evaluate_u2f(unsigned num_components, nir_const_value *_src)
  2912. {
  2913.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2914.  
  2915.          
  2916.       for (unsigned _i = 0; _i < num_components; _i++) {
  2917.                unsigned src0 = _src[0].u[_i];
  2918.  
  2919.             float dst = src0;
  2920.  
  2921.             _dst_val.f[_i] = dst;
  2922.       }
  2923.  
  2924.    return _dst_val;
  2925. }
  2926. static nir_const_value
  2927. evaluate_uadd_carry(unsigned num_components, nir_const_value *_src)
  2928. {
  2929.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2930.  
  2931.                  
  2932.       for (unsigned _i = 0; _i < num_components; _i++) {
  2933.                unsigned src0 = _src[0].u[_i];
  2934.                unsigned src1 = _src[1].u[_i];
  2935.  
  2936.             bool dst = src0 + src1 < src0;
  2937.  
  2938.             _dst_val.u[_i] = dst ? NIR_TRUE : NIR_FALSE;
  2939.       }
  2940.  
  2941.    return _dst_val;
  2942. }
  2943. static nir_const_value
  2944. evaluate_ubitfield_extract(unsigned num_components, nir_const_value *_src)
  2945. {
  2946.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2947.  
  2948.          
  2949.       struct int_vec src1 = {
  2950.             _src[1].i[0],
  2951.       };
  2952.  
  2953.       struct int_vec src2 = {
  2954.             _src[2].i[0],
  2955.       };
  2956.  
  2957.       for (unsigned _i = 0; _i < num_components; _i++) {
  2958.                unsigned src0 = _src[0].u[_i];
  2959.                              
  2960.             unsigned dst;
  2961.            
  2962. unsigned base = src0;
  2963. int offset = src1.x, bits = src2.x;
  2964. if (bits == 0) {
  2965.    dst = 0;
  2966. } else if (bits < 0 || offset < 0 || offset + bits > 32) {
  2967.    dst = 0; /* undefined per the spec */
  2968. } else {
  2969.    dst = (base >> offset) & ((1 << bits) - 1);
  2970. }
  2971.  
  2972.  
  2973.             _dst_val.u[_i] = dst;
  2974.       }
  2975.  
  2976.    return _dst_val;
  2977. }
  2978. static nir_const_value
  2979. evaluate_udiv(unsigned num_components, nir_const_value *_src)
  2980. {
  2981.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2982.  
  2983.                  
  2984.       for (unsigned _i = 0; _i < num_components; _i++) {
  2985.                unsigned src0 = _src[0].u[_i];
  2986.                unsigned src1 = _src[1].u[_i];
  2987.  
  2988.             unsigned dst = src0 / src1;
  2989.  
  2990.             _dst_val.u[_i] = dst;
  2991.       }
  2992.  
  2993.    return _dst_val;
  2994. }
  2995. static nir_const_value
  2996. evaluate_ufind_msb(unsigned num_components, nir_const_value *_src)
  2997. {
  2998.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  2999.  
  3000.          
  3001.       for (unsigned _i = 0; _i < num_components; _i++) {
  3002.                unsigned src0 = _src[0].u[_i];
  3003.  
  3004.             int dst;
  3005.            
  3006. dst = -1;
  3007. for (int bit = 31; bit > 0; bit--) {
  3008.    if ((src0 >> bit) & 1) {
  3009.       dst = bit;
  3010.       break;
  3011.    }
  3012. }
  3013.  
  3014.  
  3015.             _dst_val.i[_i] = dst;
  3016.       }
  3017.  
  3018.    return _dst_val;
  3019. }
  3020. static nir_const_value
  3021. evaluate_uge(unsigned num_components, nir_const_value *_src)
  3022. {
  3023.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3024.  
  3025.                  
  3026.       for (unsigned _i = 0; _i < num_components; _i++) {
  3027.                unsigned src0 = _src[0].u[_i];
  3028.                unsigned src1 = _src[1].u[_i];
  3029.  
  3030.             bool dst = src0 >= src1;
  3031.  
  3032.             _dst_val.u[_i] = dst ? NIR_TRUE : NIR_FALSE;
  3033.       }
  3034.  
  3035.    return _dst_val;
  3036. }
  3037. static nir_const_value
  3038. evaluate_ult(unsigned num_components, nir_const_value *_src)
  3039. {
  3040.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3041.  
  3042.                  
  3043.       for (unsigned _i = 0; _i < num_components; _i++) {
  3044.                unsigned src0 = _src[0].u[_i];
  3045.                unsigned src1 = _src[1].u[_i];
  3046.  
  3047.             bool dst = src0 < src1;
  3048.  
  3049.             _dst_val.u[_i] = dst ? NIR_TRUE : NIR_FALSE;
  3050.       }
  3051.  
  3052.    return _dst_val;
  3053. }
  3054. static nir_const_value
  3055. evaluate_umax(unsigned num_components, nir_const_value *_src)
  3056. {
  3057.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3058.  
  3059.                  
  3060.       for (unsigned _i = 0; _i < num_components; _i++) {
  3061.                unsigned src0 = _src[0].u[_i];
  3062.                unsigned src1 = _src[1].u[_i];
  3063.  
  3064.             unsigned dst = src1 > src0 ? src1 : src0;
  3065.  
  3066.             _dst_val.u[_i] = dst;
  3067.       }
  3068.  
  3069.    return _dst_val;
  3070. }
  3071. static nir_const_value
  3072. evaluate_umin(unsigned num_components, nir_const_value *_src)
  3073. {
  3074.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3075.  
  3076.                  
  3077.       for (unsigned _i = 0; _i < num_components; _i++) {
  3078.                unsigned src0 = _src[0].u[_i];
  3079.                unsigned src1 = _src[1].u[_i];
  3080.  
  3081.             unsigned dst = src1 > src0 ? src0 : src1;
  3082.  
  3083.             _dst_val.u[_i] = dst;
  3084.       }
  3085.  
  3086.    return _dst_val;
  3087. }
  3088. static nir_const_value
  3089. evaluate_umod(unsigned num_components, nir_const_value *_src)
  3090. {
  3091.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3092.  
  3093.                  
  3094.       for (unsigned _i = 0; _i < num_components; _i++) {
  3095.                unsigned src0 = _src[0].u[_i];
  3096.                unsigned src1 = _src[1].u[_i];
  3097.  
  3098.             unsigned dst = src1 == 0 ? 0 : src0 % src1;
  3099.  
  3100.             _dst_val.u[_i] = dst;
  3101.       }
  3102.  
  3103.    return _dst_val;
  3104. }
  3105. static nir_const_value
  3106. evaluate_umul_high(unsigned num_components, nir_const_value *_src)
  3107. {
  3108.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3109.  
  3110.                  
  3111.       for (unsigned _i = 0; _i < num_components; _i++) {
  3112.                unsigned src0 = _src[0].u[_i];
  3113.                unsigned src1 = _src[1].u[_i];
  3114.  
  3115.             unsigned dst = (uint32_t)(((uint64_t) src0 * (uint64_t) src1) >> 32);
  3116.  
  3117.             _dst_val.u[_i] = dst;
  3118.       }
  3119.  
  3120.    return _dst_val;
  3121. }
  3122. static nir_const_value
  3123. evaluate_unpack_half_2x16(unsigned num_components, nir_const_value *_src)
  3124. {
  3125.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3126.  
  3127.  
  3128.       struct unsigned_vec src0 = {
  3129.             _src[0].u[0],
  3130.       };
  3131.  
  3132.       struct float_vec dst;
  3133.  
  3134.          
  3135. dst.x = unpack_half_1x16((uint16_t)(src0.x & 0xffff));
  3136. dst.y = unpack_half_1x16((uint16_t)(src0.x << 16));
  3137.  
  3138.  
  3139.             _dst_val.f[0] = dst.x;
  3140.             _dst_val.f[1] = dst.y;
  3141.  
  3142.    return _dst_val;
  3143. }
  3144. static nir_const_value
  3145. evaluate_unpack_half_2x16_split_x(unsigned num_components, nir_const_value *_src)
  3146. {
  3147.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3148.  
  3149.  
  3150.       struct unsigned_vec src0 = {
  3151.             _src[0].u[0],
  3152.       };
  3153.  
  3154.       struct float_vec dst;
  3155.  
  3156.          dst.x = dst.y = dst.z = dst.w = unpack_half_1x16((uint16_t)(src0.x & 0xffff));
  3157.  
  3158.             _dst_val.f[0] = dst.x;
  3159.  
  3160.    return _dst_val;
  3161. }
  3162. static nir_const_value
  3163. evaluate_unpack_half_2x16_split_y(unsigned num_components, nir_const_value *_src)
  3164. {
  3165.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3166.  
  3167.  
  3168.       struct unsigned_vec src0 = {
  3169.             _src[0].u[0],
  3170.       };
  3171.  
  3172.       struct float_vec dst;
  3173.  
  3174.          dst.x = dst.y = dst.z = dst.w = unpack_half_1x16((uint16_t)(src0.x >> 16));
  3175.  
  3176.             _dst_val.f[0] = dst.x;
  3177.  
  3178.    return _dst_val;
  3179. }
  3180. static nir_const_value
  3181. evaluate_unpack_snorm_2x16(unsigned num_components, nir_const_value *_src)
  3182. {
  3183.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3184.  
  3185.  
  3186.       struct unsigned_vec src0 = {
  3187.             _src[0].u[0],
  3188.       };
  3189.  
  3190.       struct float_vec dst;
  3191.  
  3192.          
  3193. dst.x = unpack_snorm_1x16((uint16_t)(src0.x & 0xffff));
  3194. dst.y = unpack_snorm_1x16((uint16_t)(src0.x << 16));
  3195.  
  3196.  
  3197.             _dst_val.f[0] = dst.x;
  3198.             _dst_val.f[1] = dst.y;
  3199.  
  3200.    return _dst_val;
  3201. }
  3202. static nir_const_value
  3203. evaluate_unpack_snorm_4x8(unsigned num_components, nir_const_value *_src)
  3204. {
  3205.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3206.  
  3207.  
  3208.       struct unsigned_vec src0 = {
  3209.             _src[0].u[0],
  3210.       };
  3211.  
  3212.       struct float_vec dst;
  3213.  
  3214.          
  3215. dst.x = unpack_snorm_1x8((uint8_t)(src0.x & 0xff));
  3216. dst.y = unpack_snorm_1x8((uint8_t)((src0.x >> 8) & 0xff));
  3217. dst.z = unpack_snorm_1x8((uint8_t)((src0.x >> 16) & 0xff));
  3218. dst.w = unpack_snorm_1x8((uint8_t)(src0.x >> 24));
  3219.  
  3220.  
  3221.             _dst_val.f[0] = dst.x;
  3222.             _dst_val.f[1] = dst.y;
  3223.             _dst_val.f[2] = dst.z;
  3224.             _dst_val.f[3] = dst.w;
  3225.  
  3226.    return _dst_val;
  3227. }
  3228. static nir_const_value
  3229. evaluate_unpack_unorm_2x16(unsigned num_components, nir_const_value *_src)
  3230. {
  3231.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3232.  
  3233.  
  3234.       struct unsigned_vec src0 = {
  3235.             _src[0].u[0],
  3236.       };
  3237.  
  3238.       struct float_vec dst;
  3239.  
  3240.          
  3241. dst.x = unpack_unorm_1x16((uint16_t)(src0.x & 0xffff));
  3242. dst.y = unpack_unorm_1x16((uint16_t)(src0.x << 16));
  3243.  
  3244.  
  3245.             _dst_val.f[0] = dst.x;
  3246.             _dst_val.f[1] = dst.y;
  3247.  
  3248.    return _dst_val;
  3249. }
  3250. static nir_const_value
  3251. evaluate_unpack_unorm_4x8(unsigned num_components, nir_const_value *_src)
  3252. {
  3253.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3254.  
  3255.  
  3256.       struct unsigned_vec src0 = {
  3257.             _src[0].u[0],
  3258.       };
  3259.  
  3260.       struct float_vec dst;
  3261.  
  3262.          
  3263. dst.x = unpack_unorm_1x8((uint8_t)(src0.x & 0xff));
  3264. dst.y = unpack_unorm_1x8((uint8_t)((src0.x >> 8) & 0xff));
  3265. dst.z = unpack_unorm_1x8((uint8_t)((src0.x >> 16) & 0xff));
  3266. dst.w = unpack_unorm_1x8((uint8_t)(src0.x >> 24));
  3267.  
  3268.  
  3269.             _dst_val.f[0] = dst.x;
  3270.             _dst_val.f[1] = dst.y;
  3271.             _dst_val.f[2] = dst.z;
  3272.             _dst_val.f[3] = dst.w;
  3273.  
  3274.    return _dst_val;
  3275. }
  3276. static nir_const_value
  3277. evaluate_ushr(unsigned num_components, nir_const_value *_src)
  3278. {
  3279.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3280.  
  3281.                  
  3282.       for (unsigned _i = 0; _i < num_components; _i++) {
  3283.                unsigned src0 = _src[0].u[_i];
  3284.                unsigned src1 = _src[1].u[_i];
  3285.  
  3286.             unsigned dst = src0 >> src1;
  3287.  
  3288.             _dst_val.u[_i] = dst;
  3289.       }
  3290.  
  3291.    return _dst_val;
  3292. }
  3293. static nir_const_value
  3294. evaluate_usub_borrow(unsigned num_components, nir_const_value *_src)
  3295. {
  3296.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3297.  
  3298.                  
  3299.       for (unsigned _i = 0; _i < num_components; _i++) {
  3300.                unsigned src0 = _src[0].u[_i];
  3301.                unsigned src1 = _src[1].u[_i];
  3302.  
  3303.             bool dst = src1 < src0;
  3304.  
  3305.             _dst_val.u[_i] = dst ? NIR_TRUE : NIR_FALSE;
  3306.       }
  3307.  
  3308.    return _dst_val;
  3309. }
  3310. static nir_const_value
  3311. evaluate_vec2(unsigned num_components, nir_const_value *_src)
  3312. {
  3313.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3314.  
  3315.  
  3316.       struct unsigned_vec src0 = {
  3317.             _src[0].u[0],
  3318.       };
  3319.  
  3320.       struct unsigned_vec src1 = {
  3321.             _src[1].u[0],
  3322.       };
  3323.  
  3324.       struct unsigned_vec dst;
  3325.  
  3326.          
  3327. dst.x = src0.x;
  3328. dst.y = src1.x;
  3329.  
  3330.  
  3331.             _dst_val.u[0] = dst.x;
  3332.             _dst_val.u[1] = dst.y;
  3333.  
  3334.    return _dst_val;
  3335. }
  3336. static nir_const_value
  3337. evaluate_vec3(unsigned num_components, nir_const_value *_src)
  3338. {
  3339.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3340.  
  3341.  
  3342.       struct unsigned_vec src0 = {
  3343.             _src[0].u[0],
  3344.       };
  3345.  
  3346.       struct unsigned_vec src1 = {
  3347.             _src[1].u[0],
  3348.       };
  3349.  
  3350.       struct unsigned_vec src2 = {
  3351.             _src[2].u[0],
  3352.       };
  3353.  
  3354.       struct unsigned_vec dst;
  3355.  
  3356.          
  3357. dst.x = src0.x;
  3358. dst.y = src1.x;
  3359. dst.z = src2.x;
  3360.  
  3361.  
  3362.             _dst_val.u[0] = dst.x;
  3363.             _dst_val.u[1] = dst.y;
  3364.             _dst_val.u[2] = dst.z;
  3365.  
  3366.    return _dst_val;
  3367. }
  3368. static nir_const_value
  3369. evaluate_vec4(unsigned num_components, nir_const_value *_src)
  3370. {
  3371.    nir_const_value _dst_val = { { {0, 0, 0, 0} } };
  3372.  
  3373.  
  3374.       struct unsigned_vec src0 = {
  3375.             _src[0].u[0],
  3376.       };
  3377.  
  3378.       struct unsigned_vec src1 = {
  3379.             _src[1].u[0],
  3380.       };
  3381.  
  3382.       struct unsigned_vec src2 = {
  3383.             _src[2].u[0],
  3384.       };
  3385.  
  3386.       struct unsigned_vec src3 = {
  3387.             _src[3].u[0],
  3388.       };
  3389.  
  3390.       struct unsigned_vec dst;
  3391.  
  3392.          
  3393. dst.x = src0.x;
  3394. dst.y = src1.x;
  3395. dst.z = src2.x;
  3396. dst.w = src3.x;
  3397.  
  3398.  
  3399.             _dst_val.u[0] = dst.x;
  3400.             _dst_val.u[1] = dst.y;
  3401.             _dst_val.u[2] = dst.z;
  3402.             _dst_val.u[3] = dst.w;
  3403.  
  3404.    return _dst_val;
  3405. }
  3406.  
  3407. nir_const_value
  3408. nir_eval_const_opcode(nir_op op, unsigned num_components,
  3409.                       nir_const_value *src)
  3410. {
  3411.    switch (op) {
  3412.    case nir_op_b2f: {
  3413.       return evaluate_b2f(num_components, src);
  3414.       break;
  3415.    }
  3416.    case nir_op_b2i: {
  3417.       return evaluate_b2i(num_components, src);
  3418.       break;
  3419.    }
  3420.    case nir_op_ball2: {
  3421.       return evaluate_ball2(num_components, src);
  3422.       break;
  3423.    }
  3424.    case nir_op_ball3: {
  3425.       return evaluate_ball3(num_components, src);
  3426.       break;
  3427.    }
  3428.    case nir_op_ball4: {
  3429.       return evaluate_ball4(num_components, src);
  3430.       break;
  3431.    }
  3432.    case nir_op_ball_fequal2: {
  3433.       return evaluate_ball_fequal2(num_components, src);
  3434.       break;
  3435.    }
  3436.    case nir_op_ball_fequal3: {
  3437.       return evaluate_ball_fequal3(num_components, src);
  3438.       break;
  3439.    }
  3440.    case nir_op_ball_fequal4: {
  3441.       return evaluate_ball_fequal4(num_components, src);
  3442.       break;
  3443.    }
  3444.    case nir_op_ball_iequal2: {
  3445.       return evaluate_ball_iequal2(num_components, src);
  3446.       break;
  3447.    }
  3448.    case nir_op_ball_iequal3: {
  3449.       return evaluate_ball_iequal3(num_components, src);
  3450.       break;
  3451.    }
  3452.    case nir_op_ball_iequal4: {
  3453.       return evaluate_ball_iequal4(num_components, src);
  3454.       break;
  3455.    }
  3456.    case nir_op_bany2: {
  3457.       return evaluate_bany2(num_components, src);
  3458.       break;
  3459.    }
  3460.    case nir_op_bany3: {
  3461.       return evaluate_bany3(num_components, src);
  3462.       break;
  3463.    }
  3464.    case nir_op_bany4: {
  3465.       return evaluate_bany4(num_components, src);
  3466.       break;
  3467.    }
  3468.    case nir_op_bany_fnequal2: {
  3469.       return evaluate_bany_fnequal2(num_components, src);
  3470.       break;
  3471.    }
  3472.    case nir_op_bany_fnequal3: {
  3473.       return evaluate_bany_fnequal3(num_components, src);
  3474.       break;
  3475.    }
  3476.    case nir_op_bany_fnequal4: {
  3477.       return evaluate_bany_fnequal4(num_components, src);
  3478.       break;
  3479.    }
  3480.    case nir_op_bany_inequal2: {
  3481.       return evaluate_bany_inequal2(num_components, src);
  3482.       break;
  3483.    }
  3484.    case nir_op_bany_inequal3: {
  3485.       return evaluate_bany_inequal3(num_components, src);
  3486.       break;
  3487.    }
  3488.    case nir_op_bany_inequal4: {
  3489.       return evaluate_bany_inequal4(num_components, src);
  3490.       break;
  3491.    }
  3492.    case nir_op_bcsel: {
  3493.       return evaluate_bcsel(num_components, src);
  3494.       break;
  3495.    }
  3496.    case nir_op_bfi: {
  3497.       return evaluate_bfi(num_components, src);
  3498.       break;
  3499.    }
  3500.    case nir_op_bfm: {
  3501.       return evaluate_bfm(num_components, src);
  3502.       break;
  3503.    }
  3504.    case nir_op_bit_count: {
  3505.       return evaluate_bit_count(num_components, src);
  3506.       break;
  3507.    }
  3508.    case nir_op_bitfield_insert: {
  3509.       return evaluate_bitfield_insert(num_components, src);
  3510.       break;
  3511.    }
  3512.    case nir_op_bitfield_reverse: {
  3513.       return evaluate_bitfield_reverse(num_components, src);
  3514.       break;
  3515.    }
  3516.    case nir_op_f2b: {
  3517.       return evaluate_f2b(num_components, src);
  3518.       break;
  3519.    }
  3520.    case nir_op_f2i: {
  3521.       return evaluate_f2i(num_components, src);
  3522.       break;
  3523.    }
  3524.    case nir_op_f2u: {
  3525.       return evaluate_f2u(num_components, src);
  3526.       break;
  3527.    }
  3528.    case nir_op_fabs: {
  3529.       return evaluate_fabs(num_components, src);
  3530.       break;
  3531.    }
  3532.    case nir_op_fadd: {
  3533.       return evaluate_fadd(num_components, src);
  3534.       break;
  3535.    }
  3536.    case nir_op_fall2: {
  3537.       return evaluate_fall2(num_components, src);
  3538.       break;
  3539.    }
  3540.    case nir_op_fall3: {
  3541.       return evaluate_fall3(num_components, src);
  3542.       break;
  3543.    }
  3544.    case nir_op_fall4: {
  3545.       return evaluate_fall4(num_components, src);
  3546.       break;
  3547.    }
  3548.    case nir_op_fall_equal2: {
  3549.       return evaluate_fall_equal2(num_components, src);
  3550.       break;
  3551.    }
  3552.    case nir_op_fall_equal3: {
  3553.       return evaluate_fall_equal3(num_components, src);
  3554.       break;
  3555.    }
  3556.    case nir_op_fall_equal4: {
  3557.       return evaluate_fall_equal4(num_components, src);
  3558.       break;
  3559.    }
  3560.    case nir_op_fand: {
  3561.       return evaluate_fand(num_components, src);
  3562.       break;
  3563.    }
  3564.    case nir_op_fany2: {
  3565.       return evaluate_fany2(num_components, src);
  3566.       break;
  3567.    }
  3568.    case nir_op_fany3: {
  3569.       return evaluate_fany3(num_components, src);
  3570.       break;
  3571.    }
  3572.    case nir_op_fany4: {
  3573.       return evaluate_fany4(num_components, src);
  3574.       break;
  3575.    }
  3576.    case nir_op_fany_nequal2: {
  3577.       return evaluate_fany_nequal2(num_components, src);
  3578.       break;
  3579.    }
  3580.    case nir_op_fany_nequal3: {
  3581.       return evaluate_fany_nequal3(num_components, src);
  3582.       break;
  3583.    }
  3584.    case nir_op_fany_nequal4: {
  3585.       return evaluate_fany_nequal4(num_components, src);
  3586.       break;
  3587.    }
  3588.    case nir_op_fceil: {
  3589.       return evaluate_fceil(num_components, src);
  3590.       break;
  3591.    }
  3592.    case nir_op_fcos: {
  3593.       return evaluate_fcos(num_components, src);
  3594.       break;
  3595.    }
  3596.    case nir_op_fcsel: {
  3597.       return evaluate_fcsel(num_components, src);
  3598.       break;
  3599.    }
  3600.    case nir_op_fddx: {
  3601.       return evaluate_fddx(num_components, src);
  3602.       break;
  3603.    }
  3604.    case nir_op_fddx_coarse: {
  3605.       return evaluate_fddx_coarse(num_components, src);
  3606.       break;
  3607.    }
  3608.    case nir_op_fddx_fine: {
  3609.       return evaluate_fddx_fine(num_components, src);
  3610.       break;
  3611.    }
  3612.    case nir_op_fddy: {
  3613.       return evaluate_fddy(num_components, src);
  3614.       break;
  3615.    }
  3616.    case nir_op_fddy_coarse: {
  3617.       return evaluate_fddy_coarse(num_components, src);
  3618.       break;
  3619.    }
  3620.    case nir_op_fddy_fine: {
  3621.       return evaluate_fddy_fine(num_components, src);
  3622.       break;
  3623.    }
  3624.    case nir_op_fdiv: {
  3625.       return evaluate_fdiv(num_components, src);
  3626.       break;
  3627.    }
  3628.    case nir_op_fdot2: {
  3629.       return evaluate_fdot2(num_components, src);
  3630.       break;
  3631.    }
  3632.    case nir_op_fdot3: {
  3633.       return evaluate_fdot3(num_components, src);
  3634.       break;
  3635.    }
  3636.    case nir_op_fdot4: {
  3637.       return evaluate_fdot4(num_components, src);
  3638.       break;
  3639.    }
  3640.    case nir_op_feq: {
  3641.       return evaluate_feq(num_components, src);
  3642.       break;
  3643.    }
  3644.    case nir_op_fexp2: {
  3645.       return evaluate_fexp2(num_components, src);
  3646.       break;
  3647.    }
  3648.    case nir_op_ffloor: {
  3649.       return evaluate_ffloor(num_components, src);
  3650.       break;
  3651.    }
  3652.    case nir_op_ffma: {
  3653.       return evaluate_ffma(num_components, src);
  3654.       break;
  3655.    }
  3656.    case nir_op_ffract: {
  3657.       return evaluate_ffract(num_components, src);
  3658.       break;
  3659.    }
  3660.    case nir_op_fge: {
  3661.       return evaluate_fge(num_components, src);
  3662.       break;
  3663.    }
  3664.    case nir_op_find_lsb: {
  3665.       return evaluate_find_lsb(num_components, src);
  3666.       break;
  3667.    }
  3668.    case nir_op_flog2: {
  3669.       return evaluate_flog2(num_components, src);
  3670.       break;
  3671.    }
  3672.    case nir_op_flrp: {
  3673.       return evaluate_flrp(num_components, src);
  3674.       break;
  3675.    }
  3676.    case nir_op_flt: {
  3677.       return evaluate_flt(num_components, src);
  3678.       break;
  3679.    }
  3680.    case nir_op_fmax: {
  3681.       return evaluate_fmax(num_components, src);
  3682.       break;
  3683.    }
  3684.    case nir_op_fmin: {
  3685.       return evaluate_fmin(num_components, src);
  3686.       break;
  3687.    }
  3688.    case nir_op_fmod: {
  3689.       return evaluate_fmod(num_components, src);
  3690.       break;
  3691.    }
  3692.    case nir_op_fmov: {
  3693.       return evaluate_fmov(num_components, src);
  3694.       break;
  3695.    }
  3696.    case nir_op_fmul: {
  3697.       return evaluate_fmul(num_components, src);
  3698.       break;
  3699.    }
  3700.    case nir_op_fne: {
  3701.       return evaluate_fne(num_components, src);
  3702.       break;
  3703.    }
  3704.    case nir_op_fneg: {
  3705.       return evaluate_fneg(num_components, src);
  3706.       break;
  3707.    }
  3708.    case nir_op_fnoise1_1: {
  3709.       return evaluate_fnoise1_1(num_components, src);
  3710.       break;
  3711.    }
  3712.    case nir_op_fnoise1_2: {
  3713.       return evaluate_fnoise1_2(num_components, src);
  3714.       break;
  3715.    }
  3716.    case nir_op_fnoise1_3: {
  3717.       return evaluate_fnoise1_3(num_components, src);
  3718.       break;
  3719.    }
  3720.    case nir_op_fnoise1_4: {
  3721.       return evaluate_fnoise1_4(num_components, src);
  3722.       break;
  3723.    }
  3724.    case nir_op_fnoise2_1: {
  3725.       return evaluate_fnoise2_1(num_components, src);
  3726.       break;
  3727.    }
  3728.    case nir_op_fnoise2_2: {
  3729.       return evaluate_fnoise2_2(num_components, src);
  3730.       break;
  3731.    }
  3732.    case nir_op_fnoise2_3: {
  3733.       return evaluate_fnoise2_3(num_components, src);
  3734.       break;
  3735.    }
  3736.    case nir_op_fnoise2_4: {
  3737.       return evaluate_fnoise2_4(num_components, src);
  3738.       break;
  3739.    }
  3740.    case nir_op_fnoise3_1: {
  3741.       return evaluate_fnoise3_1(num_components, src);
  3742.       break;
  3743.    }
  3744.    case nir_op_fnoise3_2: {
  3745.       return evaluate_fnoise3_2(num_components, src);
  3746.       break;
  3747.    }
  3748.    case nir_op_fnoise3_3: {
  3749.       return evaluate_fnoise3_3(num_components, src);
  3750.       break;
  3751.    }
  3752.    case nir_op_fnoise3_4: {
  3753.       return evaluate_fnoise3_4(num_components, src);
  3754.       break;
  3755.    }
  3756.    case nir_op_fnoise4_1: {
  3757.       return evaluate_fnoise4_1(num_components, src);
  3758.       break;
  3759.    }
  3760.    case nir_op_fnoise4_2: {
  3761.       return evaluate_fnoise4_2(num_components, src);
  3762.       break;
  3763.    }
  3764.    case nir_op_fnoise4_3: {
  3765.       return evaluate_fnoise4_3(num_components, src);
  3766.       break;
  3767.    }
  3768.    case nir_op_fnoise4_4: {
  3769.       return evaluate_fnoise4_4(num_components, src);
  3770.       break;
  3771.    }
  3772.    case nir_op_fnot: {
  3773.       return evaluate_fnot(num_components, src);
  3774.       break;
  3775.    }
  3776.    case nir_op_for: {
  3777.       return evaluate_for(num_components, src);
  3778.       break;
  3779.    }
  3780.    case nir_op_fpow: {
  3781.       return evaluate_fpow(num_components, src);
  3782.       break;
  3783.    }
  3784.    case nir_op_frcp: {
  3785.       return evaluate_frcp(num_components, src);
  3786.       break;
  3787.    }
  3788.    case nir_op_fround_even: {
  3789.       return evaluate_fround_even(num_components, src);
  3790.       break;
  3791.    }
  3792.    case nir_op_frsq: {
  3793.       return evaluate_frsq(num_components, src);
  3794.       break;
  3795.    }
  3796.    case nir_op_fsat: {
  3797.       return evaluate_fsat(num_components, src);
  3798.       break;
  3799.    }
  3800.    case nir_op_fsign: {
  3801.       return evaluate_fsign(num_components, src);
  3802.       break;
  3803.    }
  3804.    case nir_op_fsin: {
  3805.       return evaluate_fsin(num_components, src);
  3806.       break;
  3807.    }
  3808.    case nir_op_fsqrt: {
  3809.       return evaluate_fsqrt(num_components, src);
  3810.       break;
  3811.    }
  3812.    case nir_op_fsub: {
  3813.       return evaluate_fsub(num_components, src);
  3814.       break;
  3815.    }
  3816.    case nir_op_ftrunc: {
  3817.       return evaluate_ftrunc(num_components, src);
  3818.       break;
  3819.    }
  3820.    case nir_op_fxor: {
  3821.       return evaluate_fxor(num_components, src);
  3822.       break;
  3823.    }
  3824.    case nir_op_i2b: {
  3825.       return evaluate_i2b(num_components, src);
  3826.       break;
  3827.    }
  3828.    case nir_op_i2f: {
  3829.       return evaluate_i2f(num_components, src);
  3830.       break;
  3831.    }
  3832.    case nir_op_iabs: {
  3833.       return evaluate_iabs(num_components, src);
  3834.       break;
  3835.    }
  3836.    case nir_op_iadd: {
  3837.       return evaluate_iadd(num_components, src);
  3838.       break;
  3839.    }
  3840.    case nir_op_iand: {
  3841.       return evaluate_iand(num_components, src);
  3842.       break;
  3843.    }
  3844.    case nir_op_ibitfield_extract: {
  3845.       return evaluate_ibitfield_extract(num_components, src);
  3846.       break;
  3847.    }
  3848.    case nir_op_idiv: {
  3849.       return evaluate_idiv(num_components, src);
  3850.       break;
  3851.    }
  3852.    case nir_op_ieq: {
  3853.       return evaluate_ieq(num_components, src);
  3854.       break;
  3855.    }
  3856.    case nir_op_ifind_msb: {
  3857.       return evaluate_ifind_msb(num_components, src);
  3858.       break;
  3859.    }
  3860.    case nir_op_ige: {
  3861.       return evaluate_ige(num_components, src);
  3862.       break;
  3863.    }
  3864.    case nir_op_ilt: {
  3865.       return evaluate_ilt(num_components, src);
  3866.       break;
  3867.    }
  3868.    case nir_op_imax: {
  3869.       return evaluate_imax(num_components, src);
  3870.       break;
  3871.    }
  3872.    case nir_op_imin: {
  3873.       return evaluate_imin(num_components, src);
  3874.       break;
  3875.    }
  3876.    case nir_op_imov: {
  3877.       return evaluate_imov(num_components, src);
  3878.       break;
  3879.    }
  3880.    case nir_op_imul: {
  3881.       return evaluate_imul(num_components, src);
  3882.       break;
  3883.    }
  3884.    case nir_op_imul_high: {
  3885.       return evaluate_imul_high(num_components, src);
  3886.       break;
  3887.    }
  3888.    case nir_op_ine: {
  3889.       return evaluate_ine(num_components, src);
  3890.       break;
  3891.    }
  3892.    case nir_op_ineg: {
  3893.       return evaluate_ineg(num_components, src);
  3894.       break;
  3895.    }
  3896.    case nir_op_inot: {
  3897.       return evaluate_inot(num_components, src);
  3898.       break;
  3899.    }
  3900.    case nir_op_ior: {
  3901.       return evaluate_ior(num_components, src);
  3902.       break;
  3903.    }
  3904.    case nir_op_ishl: {
  3905.       return evaluate_ishl(num_components, src);
  3906.       break;
  3907.    }
  3908.    case nir_op_ishr: {
  3909.       return evaluate_ishr(num_components, src);
  3910.       break;
  3911.    }
  3912.    case nir_op_isign: {
  3913.       return evaluate_isign(num_components, src);
  3914.       break;
  3915.    }
  3916.    case nir_op_isub: {
  3917.       return evaluate_isub(num_components, src);
  3918.       break;
  3919.    }
  3920.    case nir_op_ixor: {
  3921.       return evaluate_ixor(num_components, src);
  3922.       break;
  3923.    }
  3924.    case nir_op_ldexp: {
  3925.       return evaluate_ldexp(num_components, src);
  3926.       break;
  3927.    }
  3928.    case nir_op_pack_half_2x16: {
  3929.       return evaluate_pack_half_2x16(num_components, src);
  3930.       break;
  3931.    }
  3932.    case nir_op_pack_half_2x16_split: {
  3933.       return evaluate_pack_half_2x16_split(num_components, src);
  3934.       break;
  3935.    }
  3936.    case nir_op_pack_snorm_2x16: {
  3937.       return evaluate_pack_snorm_2x16(num_components, src);
  3938.       break;
  3939.    }
  3940.    case nir_op_pack_snorm_4x8: {
  3941.       return evaluate_pack_snorm_4x8(num_components, src);
  3942.       break;
  3943.    }
  3944.    case nir_op_pack_unorm_2x16: {
  3945.       return evaluate_pack_unorm_2x16(num_components, src);
  3946.       break;
  3947.    }
  3948.    case nir_op_pack_unorm_4x8: {
  3949.       return evaluate_pack_unorm_4x8(num_components, src);
  3950.       break;
  3951.    }
  3952.    case nir_op_seq: {
  3953.       return evaluate_seq(num_components, src);
  3954.       break;
  3955.    }
  3956.    case nir_op_sge: {
  3957.       return evaluate_sge(num_components, src);
  3958.       break;
  3959.    }
  3960.    case nir_op_slt: {
  3961.       return evaluate_slt(num_components, src);
  3962.       break;
  3963.    }
  3964.    case nir_op_sne: {
  3965.       return evaluate_sne(num_components, src);
  3966.       break;
  3967.    }
  3968.    case nir_op_u2f: {
  3969.       return evaluate_u2f(num_components, src);
  3970.       break;
  3971.    }
  3972.    case nir_op_uadd_carry: {
  3973.       return evaluate_uadd_carry(num_components, src);
  3974.       break;
  3975.    }
  3976.    case nir_op_ubitfield_extract: {
  3977.       return evaluate_ubitfield_extract(num_components, src);
  3978.       break;
  3979.    }
  3980.    case nir_op_udiv: {
  3981.       return evaluate_udiv(num_components, src);
  3982.       break;
  3983.    }
  3984.    case nir_op_ufind_msb: {
  3985.       return evaluate_ufind_msb(num_components, src);
  3986.       break;
  3987.    }
  3988.    case nir_op_uge: {
  3989.       return evaluate_uge(num_components, src);
  3990.       break;
  3991.    }
  3992.    case nir_op_ult: {
  3993.       return evaluate_ult(num_components, src);
  3994.       break;
  3995.    }
  3996.    case nir_op_umax: {
  3997.       return evaluate_umax(num_components, src);
  3998.       break;
  3999.    }
  4000.    case nir_op_umin: {
  4001.       return evaluate_umin(num_components, src);
  4002.       break;
  4003.    }
  4004.    case nir_op_umod: {
  4005.       return evaluate_umod(num_components, src);
  4006.       break;
  4007.    }
  4008.    case nir_op_umul_high: {
  4009.       return evaluate_umul_high(num_components, src);
  4010.       break;
  4011.    }
  4012.    case nir_op_unpack_half_2x16: {
  4013.       return evaluate_unpack_half_2x16(num_components, src);
  4014.       break;
  4015.    }
  4016.    case nir_op_unpack_half_2x16_split_x: {
  4017.       return evaluate_unpack_half_2x16_split_x(num_components, src);
  4018.       break;
  4019.    }
  4020.    case nir_op_unpack_half_2x16_split_y: {
  4021.       return evaluate_unpack_half_2x16_split_y(num_components, src);
  4022.       break;
  4023.    }
  4024.    case nir_op_unpack_snorm_2x16: {
  4025.       return evaluate_unpack_snorm_2x16(num_components, src);
  4026.       break;
  4027.    }
  4028.    case nir_op_unpack_snorm_4x8: {
  4029.       return evaluate_unpack_snorm_4x8(num_components, src);
  4030.       break;
  4031.    }
  4032.    case nir_op_unpack_unorm_2x16: {
  4033.       return evaluate_unpack_unorm_2x16(num_components, src);
  4034.       break;
  4035.    }
  4036.    case nir_op_unpack_unorm_4x8: {
  4037.       return evaluate_unpack_unorm_4x8(num_components, src);
  4038.       break;
  4039.    }
  4040.    case nir_op_ushr: {
  4041.       return evaluate_ushr(num_components, src);
  4042.       break;
  4043.    }
  4044.    case nir_op_usub_borrow: {
  4045.       return evaluate_usub_borrow(num_components, src);
  4046.       break;
  4047.    }
  4048.    case nir_op_vec2: {
  4049.       return evaluate_vec2(num_components, src);
  4050.       break;
  4051.    }
  4052.    case nir_op_vec3: {
  4053.       return evaluate_vec3(num_components, src);
  4054.       break;
  4055.    }
  4056.    case nir_op_vec4: {
  4057.       return evaluate_vec4(num_components, src);
  4058.       break;
  4059.    }
  4060.    default:
  4061.       unreachable("shouldn't get here");
  4062.    }
  4063. }
  4064.