diff options
author | Eric Anholt <[email protected]> | 2011-08-26 16:37:37 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2011-08-30 12:09:40 -0700 |
commit | 88e08de8017b69591b37dafde9afd15f796fb404 (patch) | |
tree | 66a038544c69497ed2f31dc3301539e54445549d /src/mesa/drivers | |
parent | 8654931d117f178fa575d3fdc5bbff9f8bf9e816 (diff) |
i965/vs: Restructure emit() functions around a vec4_instruction constructor.
We sometimes want to put an instruction somewhere besides the end of
the instruction stream, and we also want per-opcode instruction
generation to enable compile-time checking of operands.
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4.h | 8 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 41 |
2 files changed, 33 insertions, 16 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h index c03d204f076..c6071544f61 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_vec4.h @@ -239,6 +239,12 @@ public: return node; } + vec4_instruction(vec4_visitor *v, enum opcode opcode, + dst_reg dst = dst_reg(), + src_reg src0 = src_reg(), + src_reg src1 = src_reg(), + src_reg src2 = src_reg()); + struct brw_reg get_dst(void); struct brw_reg get_src(int i); @@ -384,6 +390,8 @@ public: bool dead_code_eliminate(); bool virtual_grf_interferes(int a, int b); + vec4_instruction *emit(vec4_instruction *inst); + vec4_instruction *emit(enum opcode opcode); vec4_instruction *emit(enum opcode opcode, dst_reg dst, src_reg src0); diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp index 46f826cbfc1..912145538a6 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp @@ -72,43 +72,52 @@ dst_reg::dst_reg(src_reg reg) this->fixed_hw_reg = reg.fixed_hw_reg; } -vec4_instruction * -vec4_visitor::emit(enum opcode opcode, dst_reg dst, - src_reg src0, src_reg src1, src_reg src2) +vec4_instruction::vec4_instruction(vec4_visitor *v, + enum opcode opcode, dst_reg dst, + src_reg src0, src_reg src1, src_reg src2) { - vec4_instruction *inst = new(mem_ctx) vec4_instruction(); - - inst->opcode = opcode; - inst->dst = dst; - inst->src[0] = src0; - inst->src[1] = src1; - inst->src[2] = src2; - inst->ir = this->base_ir; - inst->annotation = this->current_annotation; + this->opcode = opcode; + this->dst = dst; + this->src[0] = src0; + this->src[1] = src1; + this->src[2] = src2; + this->ir = v->base_ir; + this->annotation = v->current_annotation; +} +vec4_instruction * +vec4_visitor::emit(vec4_instruction *inst) +{ this->instructions.push_tail(inst); return inst; } +vec4_instruction * +vec4_visitor::emit(enum opcode opcode, dst_reg dst, + src_reg src0, src_reg src1, src_reg src2) +{ + return emit(new(mem_ctx) vec4_instruction(this, opcode, dst, + src0, src1, src2)); +} + vec4_instruction * vec4_visitor::emit(enum opcode opcode, dst_reg dst, src_reg src0, src_reg src1) { - return emit(opcode, dst, src0, src1, src_reg()); + return emit(new(mem_ctx) vec4_instruction(this, opcode, dst, src0, src1)); } vec4_instruction * vec4_visitor::emit(enum opcode opcode, dst_reg dst, src_reg src0) { - assert(dst.writemask != 0); - return emit(opcode, dst, src0, src_reg(), src_reg()); + return emit(new(mem_ctx) vec4_instruction(this, opcode, dst, src0)); } vec4_instruction * vec4_visitor::emit(enum opcode opcode) { - return emit(opcode, dst_reg(), src_reg(), src_reg(), src_reg()); + return emit(new(mem_ctx) vec4_instruction(this, opcode, dst_reg())); } void |