glsl: Add is_rvalue, is_dereference, and is_jump methods
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 24 Mar 2015 15:55:15 +0000 (08:55 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 25 Mar 2015 17:34:59 +0000 (10:34 -0700)
These functions deteremine when an IR node is one of the non-leaf
classes.

v2: Adjust indentation to line up.  Suggested by Matt.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
src/glsl/ir.h

index fdc22edf133d7f585792f0ae7bc87c80d6c50e2b..b3a98b88a1e37c1dfbe451a02db33ec6b862c5f3 100644 (file)
@@ -109,6 +109,31 @@ public:
    virtual ir_instruction *clone(void *mem_ctx,
                                 struct hash_table *ht) const = 0;
 
+   bool is_rvalue() const
+   {
+      return ir_type == ir_type_dereference_array ||
+             ir_type == ir_type_dereference_record ||
+             ir_type == ir_type_dereference_variable ||
+             ir_type == ir_type_constant ||
+             ir_type == ir_type_expression ||
+             ir_type == ir_type_swizzle ||
+             ir_type == ir_type_texture;
+   }
+
+   bool is_dereference() const
+   {
+      return ir_type == ir_type_dereference_array ||
+             ir_type == ir_type_dereference_record ||
+             ir_type == ir_type_dereference_variable;
+   }
+
+   bool is_jump() const
+   {
+      return ir_type == ir_type_loop_jump ||
+             ir_type == ir_type_return ||
+             ir_type == ir_type_discard;
+   }
+
    /**
     * \name IR instruction downcast functions
     *