summaryrefslogtreecommitdiff
path: root/ir.h
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-05-19 11:37:35 +0200
committerIan Romanick <ian.d.romanick@intel.com>2010-05-26 15:23:19 -0700
commit70fe8b66632f4afd87ebb12a450b1e639428e88f (patch)
treea3eae48e0cf4b2ae22a61efd4e825961938137ba /ir.h
parent461c294ac57e387aa2355cfd2aa93cefaba03baa (diff)
Begin refactoring ir_dereference
Create separate subclasses of ir_dereference for variable, array, and record dereferences. As a side effect, array and record dereferences no longer point to ir_variable objects directly. Instead they each point to an ir_dereference_variable object. This is the first of several steps in the refactoring process. The intention is that ir_dereference will eventually become an abstract base class.
Diffstat (limited to 'ir.h')
-rw-r--r--ir.h67
1 files changed, 59 insertions, 8 deletions
diff --git a/ir.h b/ir.h
index 93b4c2b66a..70fe9f9db6 100644
--- a/ir.h
+++ b/ir.h
@@ -788,12 +788,6 @@ public:
class ir_dereference : public ir_rvalue {
public:
- ir_dereference(struct ir_instruction *);
-
- ir_dereference(ir_instruction *variable, ir_rvalue *array_index);
-
- ir_dereference(ir_instruction *variable, const char *field);
-
virtual ir_dereference *as_dereference()
{
return this;
@@ -811,9 +805,9 @@ public:
/**
* Get the variable that is ultimately referenced by an r-value
*/
- virtual ir_variable *variable_referenced();
+ virtual ir_variable *variable_referenced() = 0;
- enum {
+ enum ir_deref_mode {
ir_reference_variable,
ir_reference_array,
ir_reference_record
@@ -830,6 +824,63 @@ public:
ir_rvalue *array_index;
const char *field;
} selector;
+
+protected:
+ ir_dereference(ir_deref_mode mode)
+ : mode(mode)
+ {
+ /* empty */
+ }
+};
+
+
+class ir_dereference_variable : public ir_dereference {
+public:
+ ir_dereference_variable(ir_variable *var);
+
+ /**
+ * Get the variable that is ultimately referenced by an r-value
+ */
+ virtual ir_variable *variable_referenced()
+ {
+ return (ir_variable *) this->var;
+ }
+};
+
+
+class ir_dereference_array : public ir_dereference {
+public:
+ ir_dereference_array(ir_rvalue *value, ir_rvalue *array_index);
+
+ ir_dereference_array(ir_variable *var, ir_rvalue *array_index);
+
+ /**
+ * Get the variable that is ultimately referenced by an r-value
+ */
+ virtual ir_variable *variable_referenced()
+ {
+ return ((ir_rvalue *) this->var)->variable_referenced();
+ }
+
+
+private:
+ void set_array(ir_rvalue *value);
+};
+
+
+class ir_dereference_record : public ir_dereference {
+public:
+ ir_dereference_record(ir_rvalue *value, const char *field);
+
+ ir_dereference_record(ir_variable *var, const char *field);
+
+ /**
+ * Get the variable that is ultimately referenced by an r-value
+ */
+ virtual ir_variable *variable_referenced()
+ {
+ return ((ir_rvalue *) this->var)->variable_referenced();
+ }
};