Add ir_rvalue::variable_referenced
diff --git a/ir.h b/ir.h
index df9a8c4..a533eee 100644
--- a/ir.h
+++ b/ir.h
@@ -85,6 +85,14 @@
       return false;
    }
 
+   /**
+    * Get the variable that is ultimately referenced by an r-value
+    */
+   virtual ir_variable *variable_referenced()
+   {
+      return NULL;
+   }
+
 protected:
    ir_rvalue()
    {
@@ -744,6 +752,11 @@
       return val->is_lvalue() && !mask.has_duplicates;
    }
 
+   /**
+    * Get the variable that is ultimately referenced by an r-value
+    */
+   virtual ir_variable *variable_referenced();
+
    ir_rvalue *val;
    ir_swizzle_mask mask;
 };
@@ -769,6 +782,11 @@
 
    bool is_lvalue();
 
+   /**
+    * Get the variable that is ultimately referenced by an r-value
+    */
+   virtual ir_variable *variable_referenced();
+
    enum {
       ir_reference_variable,
       ir_reference_array,