r600/sb: replace memset by using member initialization/assignment

Closes #2860

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4939>
This commit is contained in:
Gert Wollny
2020-05-06 18:29:44 +02:00
parent ee3f4ab2f4
commit 79f20eb819
6 changed files with 45 additions and 10 deletions

View File

@@ -36,6 +36,7 @@ extern "C" {
/* ALU flags */
enum alu_op_flags
{
AF_NONE = 0,
AF_V = (1<<0), /* allowed in vector slots */
/* allowed in scalar(trans) slot (slots xyz on cayman, may be replicated

View File

@@ -495,6 +495,15 @@ struct bc_alu_src {
unsigned abs:1;
unsigned rel:1;
literal value;
void clear() {
sel = 0;
chan = 0;
neg = 0;
abs = 0;
rel = 0;
value = 0;
}
};
struct bc_alu {
@@ -529,6 +538,31 @@ struct bc_alu {
this->op = op;
op_ptr = r600_isa_alu(op);
}
void clear() {
op_ptr = nullptr;
op = 0;
for (int i = 0; i < 3; ++i)
src[i].clear();
dst_gpr = 0;
dst_chan = 0;
dst_rel = 0;
clamp = 0;
omod = 0;
bank_swizzle = 0;
index_mode = 0;
last = 0;
pred_sel = 0;
fog_merge = 0;
write_mask = 0;
update_exec_mask = 0;
update_pred = 0;
slot = 0;
lds_idx_offset = 0;
slot_flags = AF_NONE;
}
bc_alu() {
clear();
}
};
struct bc_fetch {

View File

@@ -719,7 +719,7 @@ bool expr_handler::fold_assoc(alu_node *n) {
n->src[0] = n->src[2];
n->bc.src[0] = n->bc.src[2];
n->src[1] = sh.get_const_value(cr);
memset(&n->bc.src[1], 0, sizeof(bc_alu_src));
n->bc.src[1].clear();
n->src.resize(2);
n->bc.set_op(ALU_OP2_ADD);
@@ -729,7 +729,7 @@ bool expr_handler::fold_assoc(alu_node *n) {
n->bc.src[0] = a->bc.src[last_arg];
n->bc.src[0].neg ^= cur_neg;
n->src[1] = sh.get_const_value(cr);
memset(&n->bc.src[1], 0, sizeof(bc_alu_src));
n->bc.src[1].clear();
}
return false;
@@ -770,7 +770,7 @@ bool expr_handler::fold_alu_op2(alu_node& n) {
case ALU_OP2_ADD: // (ADD x, x) => (MUL x, 2)
if (!sh.safe_math) {
n.src[1] = sh.get_const_value(2.0f);
memset(&n.bc.src[1], 0, sizeof(bc_alu_src));
n.bc.src[1].clear();
n.bc.set_op(ALU_OP2_MUL);
return fold_alu_op2(n);
}
@@ -1070,7 +1070,7 @@ bool expr_handler::fold_alu_op3(alu_node& n) {
}
n.src[1] = t;
memset(&n.bc.src[1], 0, sizeof(bc_alu_src));
n.bc.src[1].clear();
n.src.resize(2);
@@ -1101,7 +1101,7 @@ bool expr_handler::fold_alu_op3(alu_node& n) {
dv = cv0.f * cv1.f;
n.bc.set_op(ALU_OP2_ADD);
n.src[0] = sh.get_const_value(dv);
memset(&n.bc.src[0], 0, sizeof(bc_alu_src));
n.bc.src[0].clear();
n.src[1] = n.src[2];
n.bc.src[1] = n.bc.src[2];
n.src.resize(2);

View File

@@ -99,8 +99,8 @@ void if_conversion::convert_kill_instructions(region_node *r,
a->src[0] = cnd;
a->src[1] = sh.get_const_value(0);
// clear modifiers
memset(&a->bc.src[0], 0, sizeof(bc_alu_src));
memset(&a->bc.src[1], 0, sizeof(bc_alu_src));
a->bc.src[0].clear();
a->bc.src[1].clear();
} else {
// kill with constant 'false' condition, this shouldn't happen
// but remove it anyway

View File

@@ -1012,7 +1012,7 @@ public:
class alu_node : public node {
protected:
alu_node() : node(NT_OP, NST_ALU_INST) { memset(&bc, 0, sizeof(bc_alu)); }
alu_node() : node(NT_OP, NST_ALU_INST) { }
public:
bc_alu bc;

View File

@@ -131,8 +131,8 @@ void peephole::optimize_cc_op2(alu_node* a) {
std::swap(a->src[0],a->src[1]);
swapped = true;
// clear modifiers
memset(&a->bc.src[0], 0, sizeof(bc_alu_src));
memset(&a->bc.src[1], 0, sizeof(bc_alu_src));
a->bc.src[0].clear();
a->bc.src[1].clear();
}
if (swapped || (a->src[1]->is_const() &&