[Mesa-dev] [PATCH 01/14] i965: Split emitter out of backend_visitor
Topi Pohjolainen
topi.pohjolainen at intel.com
Wed May 28 05:35:57 PDT 2014
Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
src/mesa/drivers/dri/i965/brw_cfg.cpp | 8 ++++----
src/mesa/drivers/dri/i965/brw_cfg.h | 4 ++--
src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp | 6 +++---
src/mesa/drivers/dri/i965/brw_dead_control_flow.h | 2 +-
src/mesa/drivers/dri/i965/brw_fs.h | 2 +-
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 3 ++-
.../drivers/dri/i965/brw_schedule_instructions.cpp | 4 ++--
src/mesa/drivers/dri/i965/brw_shader.cpp | 15 +++++++++------
src/mesa/drivers/dri/i965/brw_shader.h | 20 ++++++++++++++------
src/mesa/drivers/dri/i965/brw_vec4.h | 2 +-
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 3 ++-
11 files changed, 41 insertions(+), 28 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_cfg.cpp b/src/mesa/drivers/dri/i965/brw_cfg.cpp
index 6bf99f1..0897c83 100644
--- a/src/mesa/drivers/dri/i965/brw_cfg.cpp
+++ b/src/mesa/drivers/dri/i965/brw_cfg.cpp
@@ -72,14 +72,14 @@ bblock_t::add_successor(void *mem_ctx, bblock_t *successor)
}
void
-bblock_t::dump(backend_visitor *v)
+bblock_t::dump(backend_emitter *e)
{
int ip = this->start_ip;
for (backend_instruction *inst = (backend_instruction *)this->start;
inst != this->end->next;
inst = (backend_instruction *) inst->next) {
fprintf(stderr, "%5d: ", ip);
- v->dump_instruction(inst);
+ e->dump_instruction(inst);
ip++;
}
}
@@ -302,7 +302,7 @@ cfg_t::make_block_array()
}
void
-cfg_t::dump(backend_visitor *v)
+cfg_t::dump(backend_emitter *e)
{
for (int b = 0; b < this->num_blocks; b++) {
bblock_t *block = this->blocks[b];
@@ -312,7 +312,7 @@ cfg_t::dump(backend_visitor *v)
link->block->block_num);
}
fprintf(stderr, "\n");
- block->dump(v);
+ block->dump(e);
fprintf(stderr, "END B%d", b);
foreach_list_typed(bblock_link, link, link, &block->children) {
fprintf(stderr, " ->B%d",
diff --git a/src/mesa/drivers/dri/i965/brw_cfg.h b/src/mesa/drivers/dri/i965/brw_cfg.h
index 9466bd2..50f9545 100644
--- a/src/mesa/drivers/dri/i965/brw_cfg.h
+++ b/src/mesa/drivers/dri/i965/brw_cfg.h
@@ -58,7 +58,7 @@ struct bblock_t {
bblock_t();
void add_successor(void *mem_ctx, bblock_t *successor);
- void dump(backend_visitor *v);
+ void dump(backend_emitter *e);
#endif
struct backend_instruction *start;
@@ -94,7 +94,7 @@ public:
void set_next_block(bblock_t **cur, bblock_t *block, int ip);
void make_block_array();
- void dump(backend_visitor *v);
+ void dump(backend_emitter *e);
void *mem_ctx;
diff --git a/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp b/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp
index 63a3e5b..35b0de0 100644
--- a/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp
+++ b/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp
@@ -35,11 +35,11 @@
* - if/else/endif
*/
bool
-dead_control_flow_eliminate(backend_visitor *v)
+dead_control_flow_eliminate(backend_emitter *e)
{
bool progress = false;
- cfg_t cfg(&v->instructions);
+ cfg_t cfg(&e->instructions);
for (int b = 0; b < cfg.num_blocks; b++) {
bblock_t *block = cfg.blocks[b];
@@ -77,7 +77,7 @@ dead_control_flow_eliminate(backend_visitor *v)
}
if (progress)
- v->invalidate_live_intervals();
+ e->invalidate_live_intervals();
return progress;
}
diff --git a/src/mesa/drivers/dri/i965/brw_dead_control_flow.h b/src/mesa/drivers/dri/i965/brw_dead_control_flow.h
index 57a4dab..58f8612 100644
--- a/src/mesa/drivers/dri/i965/brw_dead_control_flow.h
+++ b/src/mesa/drivers/dri/i965/brw_dead_control_flow.h
@@ -23,4 +23,4 @@
#include "brw_shader.h"
-bool dead_control_flow_eliminate(backend_visitor *v);
+bool dead_control_flow_eliminate(backend_emitter *e);
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 60a4906..29ca84c 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -239,7 +239,7 @@ public:
*
* Translates either GLSL IR or Mesa IR (for ARB_fragment_program) into FS IR.
*/
-class fs_visitor : public backend_visitor
+class fs_visitor : public backend_visitor, public backend_emitter
{
public:
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 171f063..b40a682 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2963,8 +2963,9 @@ fs_visitor::fs_visitor(struct brw_context *brw,
struct gl_shader_program *shader_prog,
struct gl_fragment_program *fp,
unsigned dispatch_width)
- : backend_visitor(brw, shader_prog, &fp->Base, &prog_data->base,
+ : backend_visitor(shader_prog, &fp->Base, &prog_data->base,
MESA_SHADER_FRAGMENT),
+ backend_emitter(brw),
key(key), prog_data(prog_data),
dispatch_width(dispatch_width)
{
diff --git a/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp b/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
index 42fc5e4..7046f8d 100644
--- a/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
+++ b/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
@@ -393,7 +393,7 @@ schedule_node::set_latency_gen7(bool is_haswell)
class instruction_scheduler {
public:
- instruction_scheduler(backend_visitor *v, int grf_count,
+ instruction_scheduler(backend_emitter *v, int grf_count,
instruction_scheduler_mode mode)
{
this->bv = v;
@@ -449,7 +449,7 @@ public:
int grf_count;
int time;
exec_list instructions;
- backend_visitor *bv;
+ backend_emitter *bv;
instruction_scheduler_mode mode;
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index f4f1334..aa7ea06 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -536,14 +536,11 @@ brw_instruction_name(enum opcode op)
}
}
-backend_visitor::backend_visitor(struct brw_context *brw,
- struct gl_shader_program *shader_prog,
+backend_visitor::backend_visitor(struct gl_shader_program *shader_prog,
struct gl_program *prog,
struct brw_stage_prog_data *stage_prog_data,
gl_shader_stage stage)
- : brw(brw),
- ctx(&brw->ctx),
- shader(shader_prog ?
+ : shader(shader_prog ?
(struct brw_shader *)shader_prog->_LinkedShaders[stage] : NULL),
shader_prog(shader_prog),
prog(prog),
@@ -551,6 +548,12 @@ backend_visitor::backend_visitor(struct brw_context *brw,
{
}
+backend_emitter::backend_emitter(struct brw_context *brw)
+ : brw(brw),
+ ctx(&brw->ctx)
+{
+}
+
bool
backend_instruction::is_tex() const
{
@@ -698,7 +701,7 @@ backend_instruction::has_side_effects() const
}
void
-backend_visitor::dump_instructions()
+backend_emitter::dump_instructions()
{
int ip = 0;
foreach_list(node, &this->instructions) {
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
index 5af6e08..980cd0a 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -84,20 +84,30 @@ enum instruction_scheduler_mode {
class backend_visitor : public ir_visitor {
protected:
- backend_visitor(struct brw_context *brw,
- struct gl_shader_program *shader_prog,
+ backend_visitor(struct gl_shader_program *shader_prog,
struct gl_program *prog,
struct brw_stage_prog_data *stage_prog_data,
gl_shader_stage stage);
public:
- struct brw_context * const brw;
- struct gl_context * const ctx;
+ void assign_common_binding_table_offsets(uint32_t next_binding_table_offset);
+
struct brw_shader * const shader;
struct gl_shader_program * const shader_prog;
struct gl_program * const prog;
struct brw_stage_prog_data * const stage_prog_data;
+};
+
+class backend_emitter {
+protected:
+
+ explicit backend_emitter(struct brw_context *brw);
+
+public:
+
+ struct brw_context * const brw;
+ struct gl_context * const ctx;
/** ralloc context for temporary data used during compile */
void *mem_ctx;
@@ -111,8 +121,6 @@ public:
virtual void dump_instruction(backend_instruction *inst) = 0;
virtual void dump_instructions();
- void assign_common_binding_table_offsets(uint32_t next_binding_table_offset);
-
virtual void invalidate_live_intervals() = 0;
};
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 4b2b019..2ec547c 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -283,7 +283,7 @@ public:
* Translates either GLSL IR or Mesa IR (for ARB_vertex_program and
* fixed-function) into VS IR.
*/
-class vec4_visitor : public backend_visitor
+class vec4_visitor : public backend_visitor, public backend_emitter
{
public:
vec4_visitor(struct brw_context *brw,
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 54a40dd..5e9d3d8 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -3363,7 +3363,8 @@ vec4_visitor::vec4_visitor(struct brw_context *brw,
shader_time_shader_type st_base,
shader_time_shader_type st_written,
shader_time_shader_type st_reset)
- : backend_visitor(brw, shader_prog, prog, &prog_data->base, stage),
+ : backend_visitor(shader_prog, prog, &prog_data->base, stage),
+ backend_emitter(brw),
c(c),
key(key),
prog_data(prog_data),
--
1.8.3.1
More information about the mesa-dev
mailing list