i965: Add basic-block aware backend_instruction::insert_* methods.
authorMatt Turner <mattst88@gmail.com>
Sun, 13 Jul 2014 04:18:08 +0000 (21:18 -0700)
committerMatt Turner <mattst88@gmail.com>
Fri, 22 Aug 2014 17:23:34 +0000 (10:23 -0700)
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/brw_shader.cpp
src/mesa/drivers/dri/i965/brw_shader.h

index 464790af9dd2a780afe83274af03b935336371d2..1a1816908801241102421462053959c3dccb557d 100644 (file)
@@ -757,6 +757,53 @@ adjust_later_block_ips(bblock_t *start_block, int ip_adjustment)
    }
 }
 
+void
+backend_instruction::insert_after(bblock_t *block, backend_instruction *inst)
+{
+   assert(inst_is_in_block(block, this) || !"Instruction not in block");
+
+   block->end_ip++;
+
+   adjust_later_block_ips(block, 1);
+
+   if (block->end == this)
+      block->end = inst;
+
+   exec_node::insert_after(inst);
+}
+
+void
+backend_instruction::insert_before(bblock_t *block, backend_instruction *inst)
+{
+   assert(inst_is_in_block(block, this) || !"Instruction not in block");
+
+   block->end_ip++;
+
+   adjust_later_block_ips(block, 1);
+
+   if (block->start == this)
+      block->start = inst;
+
+   exec_node::insert_before(inst);
+}
+
+void
+backend_instruction::insert_before(bblock_t *block, exec_list *list)
+{
+   assert(inst_is_in_block(block, this) || !"Instruction not in block");
+
+   unsigned num_inst = list->length();
+
+   block->end_ip += num_inst;
+
+   adjust_later_block_ips(block, num_inst);
+
+   if (block->start == this)
+      block->start = (backend_instruction *)list->get_head();
+
+   exec_node::insert_before(list);
+}
+
 void
 backend_instruction::remove(bblock_t *block)
 {
index f5af4fd44e158cbaedb0815d40e7cbe5bbed3a9b..35a2b9635a3daf62b91e73d6a479e3d31eeb650a 100644 (file)
@@ -92,6 +92,11 @@ struct backend_instruction : public exec_node {
 
    using exec_node::remove;
    void remove(bblock_t *block);
+   using exec_node::insert_after;
+   void insert_after(bblock_t *block, backend_instruction *inst);
+   using exec_node::insert_before;
+   void insert_before(bblock_t *block, backend_instruction *inst);
+   void insert_before(bblock_t *block, exec_list *list);
 
    /**
     * True if the instruction has side effects other than writing to