Mesa (master): glsl2: Add cmp field to ir_loop

Ian Romanick idr at kemper.freedesktop.org
Fri Sep 3 19:01:03 UTC 2010


Module: Mesa
Branch: master
Commit: 3b85f1cc6cb12e9d4931e12cf29adde578f389fd
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=3b85f1cc6cb12e9d4931e12cf29adde578f389fd

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Thu Aug 26 15:11:26 2010 -0700

glsl2: Add cmp field to ir_loop

This reprents the type of comparison between the loop induction
variable and the loop termination value.

---

 src/glsl/ir.cpp       |   12 ++++++++++++
 src/glsl/ir.h         |   27 +++++++++++++++++++++------
 src/glsl/ir_clone.cpp |    1 +
 3 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index 68ad512..96b32a2 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -701,6 +701,18 @@ ir_constant::has_value(const ir_constant *c) const
    return true;
 }
 
+
+ir_loop::ir_loop()
+{
+   this->ir_type = ir_type_loop;
+   this->cmp = ir_unop_neg;
+   this->from = NULL;
+   this->to = NULL;
+   this->increment = NULL;
+   this->counter = NULL;
+}
+
+
 ir_dereference_variable::ir_dereference_variable(ir_variable *var)
 {
    this->ir_type = ir_type_dereference_variable;
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 0f887a9..cf3a882 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -461,10 +461,7 @@ public:
  */
 class ir_loop : public ir_instruction {
 public:
-   ir_loop() : from(NULL), to(NULL), increment(NULL), counter(NULL)
-   {
-      ir_type = ir_type_loop;
-   }
+   ir_loop();
 
    virtual ir_loop *clone(void *mem_ctx, struct hash_table *ht) const;
 
@@ -493,12 +490,30 @@ public:
 
    /**
     * \name Loop counter and controls
+    *
+    * Represents a loop like a FORTRAN \c do-loop.
+    *
+    * \note
+    * If \c from and \c to are the same value, the loop will execute once.
     */
    /*@{*/
-   ir_rvalue *from;
-   ir_rvalue *to;
+   ir_rvalue *from;             /** Value of the loop counter on the first
+				 * iteration of the loop.
+				 */
+   ir_rvalue *to;               /** Value of the loop counter on the last
+				 * iteration of the loop.
+				 */
    ir_rvalue *increment;
    ir_variable *counter;
+
+   /**
+    * Comparison operation in the loop terminator.
+    *
+    * If any of the loop control fields are non-\c NULL, this field must be
+    * one of \c ir_binop_less, \c ir_binop_greater, \c ir_binop_lequal,
+    * \c ir_binop_gequal, \c ir_binop_equal, or \c ir_binop_nequal.
+    */
+   int cmp;
    /*@}*/
 };
 
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
index 1d690a4..3b8beb5 100644
--- a/src/glsl/ir_clone.cpp
+++ b/src/glsl/ir_clone.cpp
@@ -134,6 +134,7 @@ ir_loop::clone(void *mem_ctx, struct hash_table *ht) const
       new_loop->body_instructions.push_tail(ir->clone(mem_ctx, ht));
    }
 
+   new_loop->cmp = this->cmp;
    return new_loop;
 }
 




More information about the mesa-commit mailing list