From 07af0abef024f8a17a00975265eff79aa069c9b5 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Tue, 27 May 2014 10:25:05 -0700 Subject: [PATCH] i965/fs: Clean up fs_inst constructors. In a fashion suggested by Ken. Reviewed-by: Chris Forbes Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_fs.cpp | 90 ++++++++-------------------- src/mesa/drivers/dri/i965/brw_fs.h | 17 +++--- 2 files changed, 32 insertions(+), 75 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index ba69107b100..9ebb86915c4 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -52,95 +52,53 @@ extern "C" { #include "glsl/glsl_types.h" void -fs_inst::init(int sources) +fs_inst::init(enum opcode opcode, const fs_reg &dst, fs_reg *src, int sources) { memset(this, 0, sizeof(*this)); + this->opcode = opcode; + this->dst = dst; + this->src = src; this->sources = sources; - this->src = ralloc_array(this, fs_reg, sources); this->conditional_mod = BRW_CONDITIONAL_NONE; - this->dst = reg_undef; - this->src[0] = reg_undef; - this->src[1] = reg_undef; - this->src[2] = reg_undef; - /* This will be the case for almost all instructions. */ this->regs_written = 1; this->writes_accumulator = false; } -fs_inst::fs_inst() +fs_inst::fs_inst(enum opcode opcode, const fs_reg &dst) { - init(3); - this->opcode = BRW_OPCODE_NOP; + fs_reg *src = ralloc_array(this, fs_reg, 3); + init(opcode, dst, src, 0); } -fs_inst::fs_inst(enum opcode opcode) +fs_inst::fs_inst(enum opcode opcode, const fs_reg &dst, const fs_reg &src0) { - init(3); - this->opcode = opcode; + fs_reg *src = ralloc_array(this, fs_reg, 3); + src[0] = src0; + init(opcode, dst, src, 1); } -fs_inst::fs_inst(enum opcode opcode, fs_reg dst) +fs_inst::fs_inst(enum opcode opcode, const fs_reg &dst, const fs_reg &src0, + const fs_reg &src1) { - init(3); - this->opcode = opcode; - this->dst = dst; - - if (dst.file == GRF) - assert(dst.reg_offset >= 0); + fs_reg *src = ralloc_array(this, fs_reg, 3); + src[0] = src0; + src[1] = src1; + init(opcode, dst, src, 2); } -fs_inst::fs_inst(enum opcode opcode, fs_reg dst, fs_reg src0) +fs_inst::fs_inst(enum opcode opcode, const fs_reg &dst, const fs_reg &src0, + const fs_reg &src1, const fs_reg &src2) { - init(3); - this->opcode = opcode; - this->dst = dst; - this->src[0] = src0; - - if (dst.file == GRF) - assert(dst.reg_offset >= 0); - if (src[0].file == GRF) - assert(src[0].reg_offset >= 0); -} - -fs_inst::fs_inst(enum opcode opcode, fs_reg dst, fs_reg src0, fs_reg src1) -{ - init(3); - this->opcode = opcode; - this->dst = dst; - this->src[0] = src0; - this->src[1] = src1; - - if (dst.file == GRF) - assert(dst.reg_offset >= 0); - if (src[0].file == GRF) - assert(src[0].reg_offset >= 0); - if (src[1].file == GRF) - assert(src[1].reg_offset >= 0); -} - -fs_inst::fs_inst(enum opcode opcode, fs_reg dst, - fs_reg src0, fs_reg src1, fs_reg src2) -{ - init(3); - this->opcode = opcode; - this->dst = dst; - this->src[0] = src0; - this->src[1] = src1; - this->src[2] = src2; - - if (dst.file == GRF) - assert(dst.reg_offset >= 0); - if (src[0].file == GRF) - assert(src[0].reg_offset >= 0); - if (src[1].file == GRF) - assert(src[1].reg_offset >= 0); - if (src[2].file == GRF) - assert(src[2].reg_offset >= 0); + fs_reg *src = ralloc_array(this, fs_reg, 3); + src[0] = src0; + src[1] = src1; + src[2] = src2; + init(opcode, dst, src, 3); } fs_inst::fs_inst(const fs_inst &that) diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 4f8a2b22ad8..fb68923009c 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -190,15 +190,14 @@ class fs_inst : public backend_instruction { public: DECLARE_RALLOC_CXX_OPERATORS(fs_inst) - void init(int sources); - - fs_inst(); - fs_inst(enum opcode opcode); - fs_inst(enum opcode opcode, fs_reg dst); - fs_inst(enum opcode opcode, fs_reg dst, fs_reg src0); - fs_inst(enum opcode opcode, fs_reg dst, fs_reg src0, fs_reg src1); - fs_inst(enum opcode opcode, fs_reg dst, - fs_reg src0, fs_reg src1,fs_reg src2); + void init(enum opcode opcode, const fs_reg &dst, fs_reg *src, int sources); + + fs_inst(enum opcode opcode = BRW_OPCODE_NOP, const fs_reg &dst = reg_undef); + fs_inst(enum opcode opcode, const fs_reg &dst, const fs_reg &src0); + fs_inst(enum opcode opcode, const fs_reg &dst, const fs_reg &src0, + const fs_reg &src1); + fs_inst(enum opcode opcode, const fs_reg &dst, const fs_reg &src0, + const fs_reg &src1, const fs_reg &src2); fs_inst(const fs_inst &that); bool equals(fs_inst *inst) const; -- 2.30.2