[Mesa-dev] [PATCH 04/20] i965: Split emitter out of backend_visitor
Topi Pohjolainen
topi.pohjolainen at intel.com
Fri Apr 11 00:28:44 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 53281c6..0852b94 100644
--- a/src/mesa/drivers/dri/i965/brw_cfg.cpp
+++ b/src/mesa/drivers/dri/i965/brw_cfg.cpp
@@ -65,14 +65,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++;
}
}
@@ -293,7 +293,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];
@@ -304,7 +304,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(node, &block->children) {
bblock_link *link = (bblock_link *)node;
diff --git a/src/mesa/drivers/dri/i965/brw_cfg.h b/src/mesa/drivers/dri/i965/brw_cfg.h
index 7bd3e24..1316518 100644
--- a/src/mesa/drivers/dri/i965/brw_cfg.h
+++ b/src/mesa/drivers/dri/i965/brw_cfg.h
@@ -46,7 +46,7 @@ public:
bblock_t();
void add_successor(void *mem_ctx, bblock_t *successor);
- void dump(backend_visitor *v);
+ void dump(backend_emitter *e);
backend_instruction *start;
backend_instruction *end;
@@ -80,7 +80,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 3d21ee5..95a7ff4 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -244,7 +244,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 63a0ae5..d9e1ba1 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2951,8 +2951,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, &c->prog_data.base,
+ : backend_visitor(shader_prog, &fp->Base, &c->prog_data.base,
MESA_SHADER_FRAGMENT),
+ backend_emitter(brw),
dispatch_width(dispatch_width)
{
this->c = c;
diff --git a/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp b/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
index a951459..e785071 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 f194437..496f540 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
{
@@ -675,7 +678,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 6bd7dc8..805d65c 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -71,20 +71,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;
@@ -98,8 +108,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 159a5bd..bb4bc15 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -286,7 +286,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 edace10..32b08c5 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -3352,7 +3352,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