[Mesa-dev] [PATCH 38/56] glsl: Generate code for constant ir_binop_ldexp expressions

Dylan Baker dylan at pnwbakers.com
Fri Jul 22 22:24:31 UTC 2016


Quoting Ian Romanick (2016-07-19 12:24:57)
> From: Ian Romanick <ian.d.romanick at intel.com>
> 
> ldexp is weird because its two operands have different types.  Add
> support for directly specifying the exact signatures of all the possible
> variations of an operation.
> 
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
>  src/compiler/glsl/ir_expression_operation.py | 23 +++++++++++++++++++----
>  1 file changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/src/compiler/glsl/ir_expression_operation.py b/src/compiler/glsl/ir_expression_operation.py
> index 2351dcf..de9c7b7 100644
> --- a/src/compiler/glsl/ir_expression_operation.py
> +++ b/src/compiler/glsl/ir_expression_operation.py
> @@ -202,7 +202,7 @@ types_identical_operation = "identical"
>  non_assign_operation = "nonassign"
>  
>  class operation(object):
> -   def __init__(self, name, num_operands, printable_name = None, source_types = None, dest_type = None, c_expression = None, flags = None):
> +   def __init__(self, name, num_operands, printable_name = None, source_types = None, dest_type = None, c_expression = None, flags = None, all_signatures = None):
>        self.name = name
>        self.num_operands = num_operands
>  
> @@ -211,7 +211,13 @@ class operation(object):
>        else:
>           self.printable_name = printable_name
>  
> -      self.source_types = source_types
> +      self.all_signatures = all_signatures
> +
> +      if source_types is None:
> +         self.source_types = ()

Just for clarity could you make this "self.source_types = tuple()"?
Parens don't always mean tuple in python and I actually assumed that
would be None.

> +      else:
> +         self.source_types = source_types
> +
>        self.dest_type = dest_type
>  
>        if c_expression is None:
> @@ -261,6 +267,8 @@ class operation(object):
>              return constant_template0.render(op=self)
>           elif self.dest_type is not None:
>              return constant_template5.render(op=self)
> +         else:
> +            return constant_template3.render(op=self)
>  
>        return None
>  
> @@ -276,7 +284,10 @@ class operation(object):
>  
>  
>     def signatures(self):
> -      return type_signature_iter(self.dest_type, self.source_types, self.num_operands)
> +      if self.all_signatures is not None:
> +         return self.all_signatures
> +      else:
> +         return type_signature_iter(self.dest_type, self.source_types, self.num_operands)
>  
>  
>  ir_expression_operation = [
> @@ -469,7 +480,11 @@ ir_expression_operation = [
>     operation("ubo_load", 2),
>  
>     # Multiplies a number by two to a power, part of ARB_gpu_shader5.
> -   operation("ldexp", 2),
> +   operation("ldexp", 2,
> +             all_signatures=((float_type, (float_type, int_type)),
> +                             (double_type, (double_type, int_type))),
> +             c_expression={'f': "ldexpf_flush_subnormal({src0}, {src1})",
> +                           'd': "ldexp_flush_subnormal({src0}, {src1})"}),
>  
>     # Extract a scalar from a vector
>     #
> -- 
> 2.5.5
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160722/aaf84ef0/attachment.sig>


More information about the mesa-dev mailing list