[Mesa-dev] [PATCH 01/10] glsl: Add ir_binop_carry and ir_binop_borrow.

Ian Romanick idr at freedesktop.org
Tue Sep 24 14:36:57 PDT 2013


Patches 1, 2, and 3 are

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

I'll skim the others, but I may not have anything to say about them...

On 09/23/2013 04:12 PM, Matt Turner wrote:
> Calculates the carry out of the addition of two values and the
> borrow from subtraction respectively. Will be used in uaddCarry() and
> usubBorrow() built-in implementations.
> ---
>  src/glsl/ir.cpp          |  4 ++++
>  src/glsl/ir.h            | 15 +++++++++++++++
>  src/glsl/ir_builder.cpp  | 10 ++++++++++
>  src/glsl/ir_builder.h    |  2 ++
>  src/glsl/ir_validate.cpp |  7 +++++++
>  5 files changed, 38 insertions(+)
> 
> diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
> index b0f92cb..4e88d69 100644
> --- a/src/glsl/ir.cpp
> +++ b/src/glsl/ir.cpp
> @@ -398,6 +398,8 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1)
>        this->type = glsl_type::uint_type;
>        break;
>  
> +   case ir_binop_carry:
> +   case ir_binop_borrow:
>     case ir_binop_lshift:
>     case ir_binop_rshift:
>     case ir_binop_bfm:
> @@ -528,6 +530,8 @@ static const char *const operator_strs[] = {
>     "-",
>     "*",
>     "/",
> +   "carry",
> +   "borrow",
>     "%",
>     "<",
>     ">",
> diff --git a/src/glsl/ir.h b/src/glsl/ir.h
> index 6c5630b..6ce60c2 100644
> --- a/src/glsl/ir.h
> +++ b/src/glsl/ir.h
> @@ -1095,6 +1095,21 @@ enum ir_expression_operation {
>     ir_binop_div,
>  
>     /**
> +    * Returns the carry resulting from the addition of the two arguments.
> +    */
> +   /*@{*/
> +   ir_binop_carry,
> +   /*@}*/
> +
> +   /**
> +    * Returns the borrow resulting from the subtraction of the second argument
> +    * from the first argument.
> +    */
> +   /*@{*/
> +   ir_binop_borrow,
> +   /*@}*/
> +
> +   /**
>      * Takes one of two combinations of arguments:
>      *
>      * - mod(vecN, vecN)
> diff --git a/src/glsl/ir_builder.cpp b/src/glsl/ir_builder.cpp
> index 98b4322..b6ce889 100644
> --- a/src/glsl/ir_builder.cpp
> +++ b/src/glsl/ir_builder.cpp
> @@ -221,6 +221,16 @@ ir_expression *div(operand a, operand b)
>     return expr(ir_binop_div, a, b);
>  }
>  
> +ir_expression *carry(operand a, operand b)
> +{
> +   return expr(ir_binop_carry, a, b);
> +}
> +
> +ir_expression *borrow(operand a, operand b)
> +{
> +   return expr(ir_binop_borrow, a, b);
> +}
> +
>  ir_expression *round_even(operand a)
>  {
>     return expr(ir_unop_round_even, a);
> diff --git a/src/glsl/ir_builder.h b/src/glsl/ir_builder.h
> index 6a5f771..1345788 100644
> --- a/src/glsl/ir_builder.h
> +++ b/src/glsl/ir_builder.h
> @@ -134,6 +134,8 @@ ir_expression *add(operand a, operand b);
>  ir_expression *sub(operand a, operand b);
>  ir_expression *mul(operand a, operand b);
>  ir_expression *div(operand a, operand b);
> +ir_expression *carry(operand a, operand b);
> +ir_expression *borrow(operand a, operand b);
>  ir_expression *round_even(operand a);
>  ir_expression *dot(operand a, operand b);
>  ir_expression *dotlike(operand a, operand b);
> diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
> index 2068de0..d26f3df 100644
> --- a/src/glsl/ir_validate.cpp
> +++ b/src/glsl/ir_validate.cpp
> @@ -426,6 +426,13 @@ ir_validate::visit_leave(ir_expression *ir)
>        }
>        break;
>  
> +   case ir_binop_carry:
> +   case ir_binop_borrow:
> +      assert(ir->type == ir->operands[0]->type);
> +      assert(ir->type == ir->operands[1]->type);
> +      assert(ir->type->base_type == GLSL_TYPE_UINT);
> +      break;
> +
>     case ir_binop_less:
>     case ir_binop_greater:
>     case ir_binop_lequal:
> 



More information about the mesa-dev mailing list