[Mesa-dev] [PATCH 16/19] i965/fs: Combine fs_inst constructors using default parameters.
Matt Turner
mattst88 at gmail.com
Thu Feb 20 13:41:29 PST 2014
Wouldn't it be nice if case labels could be non-constant expressions.
---
src/mesa/drivers/dri/i965/brw_fs.cpp | 77 +++++++++++++-----------------------
src/mesa/drivers/dri/i965/brw_fs.h | 10 ++---
2 files changed, 31 insertions(+), 56 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 77b9f57..77cdfa2 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -66,69 +66,46 @@ fs_inst::fs_inst()
this->opcode = BRW_OPCODE_NOP;
}
-fs_inst::fs_inst(enum opcode opcode)
+fs_inst::fs_inst(enum opcode opcode, const fs_reg &dst,
+ const fs_reg &src0, const fs_reg &src1, const fs_reg &src2)
{
- init();
- this->opcode = opcode;
-}
+ if (&dst == ®_undef)
+ assert(&src0 == ®_undef);
+ if (&src0 == ®_undef)
+ assert(&src1 == ®_undef);
+ if (&src1 == ®_undef)
+ assert(&src2 == ®_undef);
-fs_inst::fs_inst(enum opcode opcode, fs_reg dst)
-{
init();
- this->opcode = opcode;
- this->dst = dst;
- if (dst.file == GRF)
- assert(dst.reg_offset >= 0);
-}
+ if (&src2 != ®_undef) {
+ goto src2;
+ } else if (&src1 != ®_undef) {
+ goto src1;
+ } else if (&src0 != ®_undef) {
+ goto src0;
+ } else if (&dst != ®_undef) {
+ goto dst;
+ }
-fs_inst::fs_inst(enum opcode opcode, fs_reg dst, fs_reg src0)
-{
- init();
- this->opcode = opcode;
- this->dst = dst;
+src2:
+ this->src[2] = src2;
+ if (src[2].file == GRF)
+ assert(src[2].reg_offset >= 0);
+src1:
+ this->src[1] = src1;
+ if (src[1].file == GRF)
+ assert(src[1].reg_offset >= 0);
+src0:
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();
- this->opcode = opcode;
+dst:
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();
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_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 77df64b..f73f835 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -176,12 +176,10 @@ public:
void init();
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);
+ fs_inst(enum opcode opcode, const fs_reg &dst = reg_undef,
+ const fs_reg &src0 = reg_undef,
+ const fs_reg &src1 = reg_undef,
+ const fs_reg &src2 = reg_undef);
fs_inst(const fs_inst &that);
bool equals(fs_inst *inst);
--
1.8.3.2
More information about the mesa-dev
mailing list