summaryrefslogtreecommitdiff
path: root/ir.cpp
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-06-09 17:28:54 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-06-11 15:36:05 -0700
commitb94c29a47b5020e4d052679fc5d22c19533fd73b (patch)
tree04208980a049c211405b19fdbf90276a35a336e6 /ir.cpp
parenteeedd355cfc2f0c578282657bd4259440a88742c (diff)
ir_constant: Add get_record_field query
Diffstat (limited to 'ir.cpp')
-rw-r--r--ir.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/ir.cpp b/ir.cpp
index bb1c4589a5..38e2739449 100644
--- a/ir.cpp
+++ b/ir.cpp
@@ -406,6 +406,32 @@ ir_constant::get_uint_component(unsigned i) const
}
+ir_constant *
+ir_constant::get_record_field(const char *name)
+{
+ int idx = this->type->field_index(name);
+
+ if (idx < 0)
+ return NULL;
+
+ if (this->components.is_empty())
+ return NULL;
+
+ exec_node *node = this->components.head;
+ for (int i = 0; i < idx; i++) {
+ node = node->next;
+
+ /* If the end of the list is encountered before the element matching the
+ * requested field is found, return NULL.
+ */
+ if (node->is_tail_sentinal())
+ return NULL;
+ }
+
+ return (ir_constant *) node;
+}
+
+
ir_dereference_variable::ir_dereference_variable(ir_variable *var)
{
this->var = var;