<div dir="ltr">1 and 4 are Reviewed-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 5, 2014 at 4:13 PM, Matt Turner <span dir="ltr"><<a href="mailto:mattst88@gmail.com" target="_blank">mattst88@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---<br>
 src/mesa/drivers/dri/i965/brw_cfg.h | 74 +++++++++++++++++++++++++++++++++++++<br>
 1 file changed, 74 insertions(+)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_cfg.h b/src/mesa/drivers/dri/i965/brw_cfg.h<br>
index e6403bd..c2029cc 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_cfg.h<br>
+++ b/src/mesa/drivers/dri/i965/brw_cfg.h<br>
@@ -71,6 +71,12 @@ struct bblock_t {<br>
    const bblock_t *next() const;<br>
    bblock_t *prev();<br>
    const bblock_t *prev() const;<br>
+<br>
+   bool starts_with_control_flow() const;<br>
+   bool ends_with_control_flow() const;<br>
+<br>
+   backend_instruction *first_non_control_flow_inst();<br>
+   backend_instruction *last_non_control_flow_inst();<br>
 #endif<br>
<br>
    struct exec_node link;<br>
@@ -142,6 +148,50 @@ bblock_prev_const(const struct bblock_t *block)<br>
    return (const struct bblock_t *)block->link.prev;<br>
 }<br>
<br>
+static inline bool<br>
+bblock_starts_with_control_flow(const struct bblock_t *block)<br>
+{<br>
+   enum opcode op = bblock_start_const(block)->opcode;<br>
+   return op == BRW_OPCODE_DO || op == BRW_OPCODE_ENDIF;<br>
+}<br>
+<br>
+static inline bool<br>
+bblock_ends_with_control_flow(const struct bblock_t *block)<br>
+{<br>
+   enum opcode op = bblock_end_const(block)->opcode;<br>
+   return op == BRW_OPCODE_IF ||<br>
+          op == BRW_OPCODE_ELSE ||<br>
+          op == BRW_OPCODE_WHILE ||<br>
+          op == BRW_OPCODE_BREAK ||<br>
+          op == BRW_OPCODE_CONTINUE;<br>
+}<br>
+<br>
+static inline struct backend_instruction *<br>
+bblock_first_non_control_flow_inst(struct bblock_t *block)<br>
+{<br>
+   struct backend_instruction *inst = bblock_start(block);<br>
+   if (bblock_starts_with_control_flow(block))<br>
+#ifdef __cplusplus<br>
+      inst = (struct backend_instruction *)inst->next;<br>
+#else<br>
+      inst = (struct backend_instruction *)inst->link.next;<br>
+#endif<br>
+   return inst;<br>
+}<br>
+<br>
+static inline struct backend_instruction *<br>
+bblock_last_non_control_flow_inst(struct bblock_t *block)<br>
+{<br>
+   struct backend_instruction *inst = bblock_end(block);<br>
+   if (bblock_ends_with_control_flow(block))<br>
+#ifdef __cplusplus<br>
+      inst = (struct backend_instruction *)inst->prev;<br>
+#else<br>
+      inst = (struct backend_instruction *)inst->link.prev;<br>
+#endif<br>
+   return inst;<br>
+}<br>
+<br>
 #ifdef __cplusplus<br>
 inline backend_instruction *<br>
 bblock_t::start()<br>
@@ -190,6 +240,30 @@ bblock_t::prev() const<br>
 {<br>
    return bblock_prev_const(this);<br>
 }<br>
+<br>
+inline bool<br>
+bblock_t::starts_with_control_flow() const<br>
+{<br>
+   return bblock_starts_with_control_flow(this);<br>
+}<br>
+<br>
+inline bool<br>
+bblock_t::ends_with_control_flow() const<br>
+{<br>
+   return bblock_ends_with_control_flow(this);<br>
+}<br>
+<br>
+inline backend_instruction *<br>
+bblock_t::first_non_control_flow_inst()<br>
+{<br>
+   return bblock_first_non_control_flow_inst(this);<br>
+}<br>
+<br>
+inline backend_instruction *<br>
+bblock_t::last_non_control_flow_inst()<br>
+{<br>
+   return bblock_last_non_control_flow_inst(this);<br>
+}<br>
 #endif<br>
<br>
 struct cfg_t {<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.0.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>