i965/cfg: Add functions to test if a block is a successor/predecessor.
authorMatt Turner <mattst88@gmail.com>
Wed, 16 Jul 2014 19:14:41 +0000 (12:14 -0700)
committerMatt Turner <mattst88@gmail.com>
Fri, 22 Aug 2014 17:23:33 +0000 (10:23 -0700)
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/brw_cfg.cpp
src/mesa/drivers/dri/i965/brw_cfg.h

index d806b83c0db3a9be200b558cb1ebc308a1bc711e..9cd8b9fcdf370171a3956cfa2103aac8ff75765d 100644 (file)
@@ -71,6 +71,30 @@ bblock_t::add_successor(void *mem_ctx, bblock_t *successor)
    children.push_tail(::link(mem_ctx, successor));
 }
 
+bool
+bblock_t::is_predecessor_of(const bblock_t *block) const
+{
+   foreach_list_typed_safe (bblock_link, parent, link, &block->parents) {
+      if (parent->block == this) {
+         return true;
+      }
+   }
+
+   return false;
+}
+
+bool
+bblock_t::is_successor_of(const bblock_t *block) const
+{
+   foreach_list_typed_safe (bblock_link, child, link, &block->children) {
+      if (child->block == this) {
+         return true;
+      }
+   }
+
+   return false;
+}
+
 void
 bblock_t::dump(backend_visitor *v)
 {
index 29e31e77efbd1c186bae63a6a9b4a78a9eed7460..a6888704e28b25dda8467d502983a53dca0b6220 100644 (file)
@@ -58,6 +58,8 @@ struct bblock_t {
    bblock_t();
 
    void add_successor(void *mem_ctx, bblock_t *successor);
+   bool is_predecessor_of(const bblock_t *block) const;
+   bool is_successor_of(const bblock_t *block) const;
    void dump(backend_visitor *v);
 #endif