[Mesa-dev] [PATCH 3/5] glsl: Reorder ir_type_* enum for easier comparisons.

Ian Romanick idr at freedesktop.org
Mon Jun 2 14:52:04 PDT 2014


On 06/01/2014 12:58 PM, Matt Turner wrote:
> Makes checking whether an object is an ir_dereference, an ir_rvalue, or
> an ir_jump simpler. Since ir_dereference is a subclass or ir_rvalue,
> list its subtypes first so that they can both generate nice code.

This tickles a memory from back when we added the ir_type tag... it
could be useful to assign values in a different way.  Instead of just
assigning them in order, they could be created by combining a small bit
field and sequential values:

#define IR_TYPE_RVALUE_BASE  0x20
#define IR_TYPE_DEREF_BASE   (0x40 | IR_TYPE_RVALUE_BASE)
#define IR_TYPE_JUMP_BASE    0x80

enum ir_node_type {
   ir_type_unset,
   ir_type_variable,
   ir_type_assignment,
   ir_type_if,
   ir_type_call,
   ir_type_function,
   ir_type_function_signature,
   ir_type_emit_vertex,
   ir_type_end_primitive,

   ir_type_constant = IR_TYPE_RVALUE_BASE,
   ir_type_expression,
   ir_type_swizzle,
   ir_type_texture,

   ir_type_dereference_array = IR_TYPE_DEREF_BASE,
   ir_type_dereference_record,
   ir_type_dereference_variable,

   ir_type_discard = IR_TYPE_JUMP_BASE,
   ir_type_loop,
   ir_type_loop_jump,
   ir_type_return,
   ir_type_max /**< maximum ir_type enum number, for validation */
};

Then as_rvalue from patch 5 becomes:

   class ir_rvalue *as_rvalue()
   {
      return (ir_type & IR_TYPE_RVALUE_BASE != 0) ? this : NULL;
   }

This doesn't scale very well to many different intermediate classes in
the heirarchy.  Dunno.

> ---
>  src/glsl/ir.h | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/src/glsl/ir.h b/src/glsl/ir.h
> index 02784e1..57552e0 100644
> --- a/src/glsl/ir.h
> +++ b/src/glsl/ir.h
> @@ -64,23 +64,23 @@ enum ir_node_type {
>      * \c ir_instruction::ir_type has not been initialized.
>      */
>     ir_type_unset,
> -   ir_type_variable,
> -   ir_type_assignment,
> -   ir_type_call,
> -   ir_type_constant,
>     ir_type_dereference_array,
>     ir_type_dereference_record,
>     ir_type_dereference_variable,
> -   ir_type_discard,
> +   ir_type_constant,
>     ir_type_expression,
> +   ir_type_swizzle,
> +   ir_type_texture,
> +   ir_type_variable,
> +   ir_type_assignment,
> +   ir_type_call,
>     ir_type_function,
>     ir_type_function_signature,
>     ir_type_if,
>     ir_type_loop,
>     ir_type_loop_jump,
>     ir_type_return,
> -   ir_type_swizzle,
> -   ir_type_texture,
> +   ir_type_discard,
>     ir_type_emit_vertex,
>     ir_type_end_primitive,
>     ir_type_max /**< maximum ir_type enum number, for validation */



More information about the mesa-dev mailing list