summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConnor Abbott <cwabbott0@gmail.com>2021-06-18 13:40:56 +0200
committerMarge Bot <eric+marge@anholt.net>2021-06-23 17:20:29 +0000
commite93f15d4bc346dd56bdf93d81513768872d8d1fb (patch)
tree4ebf3f2e5daae512d1c9aaa3aacb6063d47f7bd1 /src
parent3071e2e93395efeba14204564eac56ce38adfa37 (diff)
ir3: Add separate src/dst count in ir3_instr
srcs and dsts will be in separate arrays, so we need everything creating it to give a separate source and dest max count. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11469>
Diffstat (limited to 'src')
-rw-r--r--src/freedreno/ir3/ir3.c27
-rw-r--r--src/freedreno/ir3/ir3.h34
-rw-r--r--src/freedreno/ir3/ir3_array_to_ssa.c2
-rw-r--r--src/freedreno/ir3/ir3_compiler_nir.c8
-rw-r--r--src/freedreno/ir3/ir3_context.c8
-rw-r--r--src/freedreno/ir3/ir3_legalize.c10
-rw-r--r--src/freedreno/ir3/ir3_lower_parallelcopy.c8
-rw-r--r--src/freedreno/ir3/ir3_merge_regs.c2
-rw-r--r--src/freedreno/ir3/ir3_parser.y2
-rw-r--r--src/freedreno/ir3/ir3_ra.c12
10 files changed, 64 insertions, 49 deletions
diff --git a/src/freedreno/ir3/ir3.c b/src/freedreno/ir3/ir3.c
index c42cbf65a5c..59e2777767f 100644
--- a/src/freedreno/ir3/ir3.c
+++ b/src/freedreno/ir3/ir3.c
@@ -388,13 +388,13 @@ unsigned ir3_block_get_pred_index(struct ir3_block *block, struct ir3_block *pre
}
static struct ir3_instruction *instr_create(struct ir3_block *block,
- opc_t opc, int nreg)
+ opc_t opc, int ndst, int nsrc)
{
/* Add extra sources for array destinations and the address reg */
if (1 <= opc_cat(opc))
- nreg += 2;
+ nsrc += 2;
struct ir3_instruction *instr;
- unsigned sz = sizeof(*instr) + (nreg * sizeof(instr->regs[0]));
+ unsigned sz = sizeof(*instr) + ((ndst + nsrc) * sizeof(instr->regs[0]));
char *ptr = ir3_alloc(block->shader, sz);
instr = (struct ir3_instruction *)ptr;
@@ -402,16 +402,18 @@ static struct ir3_instruction *instr_create(struct ir3_block *block,
instr->regs = (struct ir3_register **)ptr;
#ifdef DEBUG
- instr->regs_max = nreg;
+ instr->regs_max = ndst + nsrc;
+ instr->dsts_max = ndst;
+ instr->srcs_max = nsrc;
#endif
return instr;
}
struct ir3_instruction * ir3_instr_create(struct ir3_block *block,
- opc_t opc, int nreg)
+ opc_t opc, int ndst, int nsrc)
{
- struct ir3_instruction *instr = instr_create(block, opc, nreg);
+ struct ir3_instruction *instr = instr_create(block, opc, ndst, nsrc);
instr->block = block;
instr->opc = opc;
insert_instr(block, instr);
@@ -421,7 +423,7 @@ struct ir3_instruction * ir3_instr_create(struct ir3_block *block,
struct ir3_instruction * ir3_instr_clone(struct ir3_instruction *instr)
{
struct ir3_instruction *new_instr = instr_create(instr->block, instr->opc,
- instr->regs_count);
+ instr->dsts_count, instr->srcs_count);
struct ir3_register **regs;
unsigned i;
@@ -433,6 +435,8 @@ struct ir3_instruction * ir3_instr_clone(struct ir3_instruction *instr)
/* clone registers: */
new_instr->regs_count = 0;
+ new_instr->dsts_count = 0;
+ new_instr->srcs_count = 0;
for (i = 0; i < instr->regs_count; i++) {
struct ir3_register *reg = instr->regs[i];
struct ir3_register *new_reg;
@@ -475,12 +479,21 @@ struct ir3_register * ir3_src_create(struct ir3_instruction *instr,
int num, int flags)
{
assert(!(flags & IR3_REG_DEST));
+#ifdef DEBUG
+ debug_assert(instr->srcs_count < instr->srcs_max);
+#endif
+ instr->srcs_count++;
return ir3_reg_create(instr, num, flags);
}
struct ir3_register * ir3_dst_create(struct ir3_instruction *instr,
int num, int flags)
{
+ assert(instr->srcs_count == 0);
+#ifdef DEBUG
+ debug_assert(instr->dsts_count < instr->dsts_max);
+#endif
+ instr->dsts_count++;
return ir3_reg_create(instr, num, flags | IR3_REG_DEST);
}
diff --git a/src/freedreno/ir3/ir3.h b/src/freedreno/ir3/ir3.h
index 04956d597b5..141906d50d3 100644
--- a/src/freedreno/ir3/ir3.h
+++ b/src/freedreno/ir3/ir3.h
@@ -279,9 +279,9 @@ struct ir3_instruction {
uint8_t repeat;
uint8_t nop;
#ifdef DEBUG
- unsigned regs_max;
+ unsigned regs_max, srcs_max, dsts_max;
#endif
- unsigned regs_count;
+ unsigned regs_count, srcs_count, dsts_count;
struct ir3_register **regs;
union {
struct {
@@ -599,7 +599,7 @@ bool ir3_should_double_threadsize(struct ir3_shader_variant *v,
struct ir3_block * ir3_block_create(struct ir3 *shader);
struct ir3_instruction * ir3_instr_create(struct ir3_block *block,
- opc_t opc, int nreg);
+ opc_t opc, int ndst, int nsrc);
struct ir3_instruction * ir3_instr_clone(struct ir3_instruction *instr);
void ir3_instr_add_dep(struct ir3_instruction *instr, struct ir3_instruction *dep);
const char *ir3_instr_name(struct ir3_instruction *instr);
@@ -1538,7 +1538,7 @@ create_immed_typed(struct ir3_block *block, uint32_t val, type_t type)
struct ir3_instruction *mov;
unsigned flags = (type_size(type) < 32) ? IR3_REG_HALF : 0;
- mov = ir3_instr_create(block, OPC_MOV, 2);
+ mov = ir3_instr_create(block, OPC_MOV, 1, 1);
mov->cat1.src_type = type;
mov->cat1.dst_type = type;
__ssa_dst(mov)->flags |= flags;
@@ -1559,7 +1559,7 @@ create_uniform_typed(struct ir3_block *block, unsigned n, type_t type)
struct ir3_instruction *mov;
unsigned flags = (type_size(type) < 32) ? IR3_REG_HALF : 0;
- mov = ir3_instr_create(block, OPC_MOV, 2);
+ mov = ir3_instr_create(block, OPC_MOV, 1, 1);
mov->cat1.src_type = type;
mov->cat1.dst_type = type;
__ssa_dst(mov)->flags |= flags;
@@ -1580,7 +1580,7 @@ create_uniform_indirect(struct ir3_block *block, int n, type_t type,
{
struct ir3_instruction *mov;
- mov = ir3_instr_create(block, OPC_MOV, 2);
+ mov = ir3_instr_create(block, OPC_MOV, 1, 1);
mov->cat1.src_type = type;
mov->cat1.dst_type = type;
__ssa_dst(mov);
@@ -1594,7 +1594,7 @@ create_uniform_indirect(struct ir3_block *block, int n, type_t type,
static inline struct ir3_instruction *
ir3_MOV(struct ir3_block *block, struct ir3_instruction *src, type_t type)
{
- struct ir3_instruction *instr = ir3_instr_create(block, OPC_MOV, 2);
+ struct ir3_instruction *instr = ir3_instr_create(block, OPC_MOV, 1, 1);
unsigned flags = (type_size(type) < 32) ? IR3_REG_HALF : 0;
__ssa_dst(instr)->flags |= flags;
@@ -1614,7 +1614,7 @@ static inline struct ir3_instruction *
ir3_COV(struct ir3_block *block, struct ir3_instruction *src,
type_t src_type, type_t dst_type)
{
- struct ir3_instruction *instr = ir3_instr_create(block, OPC_MOV, 2);
+ struct ir3_instruction *instr = ir3_instr_create(block, OPC_MOV, 1, 1);
unsigned dst_flags = (type_size(dst_type) < 32) ? IR3_REG_HALF : 0;
unsigned src_flags = (type_size(src_type) < 32) ? IR3_REG_HALF : 0;
@@ -1631,7 +1631,7 @@ ir3_COV(struct ir3_block *block, struct ir3_instruction *src,
static inline struct ir3_instruction *
ir3_MOVMSK(struct ir3_block *block, unsigned components)
{
- struct ir3_instruction *instr = ir3_instr_create(block, OPC_MOVMSK, 1);
+ struct ir3_instruction *instr = ir3_instr_create(block, OPC_MOVMSK, 1, 0);
struct ir3_register *dst = __ssa_dst(instr);
dst->flags |= IR3_REG_SHARED;
@@ -1642,7 +1642,7 @@ ir3_MOVMSK(struct ir3_block *block, unsigned components)
static inline struct ir3_instruction *
ir3_NOP(struct ir3_block *block)
{
- return ir3_instr_create(block, OPC_NOP, 0);
+ return ir3_instr_create(block, OPC_NOP, 0, 0);
}
#define IR3_INSTR_0 0
@@ -1652,7 +1652,7 @@ static inline struct ir3_instruction * \
ir3_##name(struct ir3_block *block) \
{ \
struct ir3_instruction *instr = \
- ir3_instr_create(block, opc, 1); \
+ ir3_instr_create(block, opc, 1, 0); \
instr->flags |= flag; \
return instr; \
}
@@ -1665,7 +1665,7 @@ ir3_##name(struct ir3_block *block, \
struct ir3_instruction *a, unsigned aflags) \
{ \
struct ir3_instruction *instr = \
- ir3_instr_create(block, opc, 2); \
+ ir3_instr_create(block, opc, 1, 1); \
__ssa_dst(instr); \
__ssa_src(instr, a, aflags); \
instr->flags |= flag; \
@@ -1681,7 +1681,7 @@ ir3_##name(struct ir3_block *block, \
struct ir3_instruction *b, unsigned bflags) \
{ \
struct ir3_instruction *instr = \
- ir3_instr_create(block, opc, 3); \
+ ir3_instr_create(block, opc, 1, 2); \
__ssa_dst(instr); \
__ssa_src(instr, a, aflags); \
__ssa_src(instr, b, bflags); \
@@ -1699,7 +1699,7 @@ ir3_##name(struct ir3_block *block, \
struct ir3_instruction *c, unsigned cflags) \
{ \
struct ir3_instruction *instr = \
- ir3_instr_create(block, opc, 4); \
+ ir3_instr_create(block, opc, 1, 3); \
__ssa_dst(instr); \
__ssa_src(instr, a, aflags); \
__ssa_src(instr, b, bflags); \
@@ -1719,7 +1719,7 @@ ir3_##name(struct ir3_block *block, \
struct ir3_instruction *d, unsigned dflags) \
{ \
struct ir3_instruction *instr = \
- ir3_instr_create(block, opc, 5); \
+ ir3_instr_create(block, opc, 1, 4); \
__ssa_dst(instr); \
__ssa_src(instr, a, aflags); \
__ssa_src(instr, b, bflags); \
@@ -1837,7 +1837,7 @@ ir3_SAM(struct ir3_block *block, opc_t opc, type_t type,
struct ir3_instruction *src0, struct ir3_instruction *src1)
{
struct ir3_instruction *sam;
- unsigned nreg = 1; /* dst */
+ unsigned nreg = 0;
if (flags & IR3_INSTR_S2EN) {
nreg++;
@@ -1849,7 +1849,7 @@ ir3_SAM(struct ir3_block *block, opc_t opc, type_t type,
nreg++;
}
- sam = ir3_instr_create(block, opc, nreg);
+ sam = ir3_instr_create(block, opc, 1, nreg);
sam->flags |= flags;
__ssa_dst(sam)->wrmask = wrmask;
if (flags & IR3_INSTR_S2EN) {
diff --git a/src/freedreno/ir3/ir3_array_to_ssa.c b/src/freedreno/ir3/ir3_array_to_ssa.c
index d515f0a8cd5..da9024c6739 100644
--- a/src/freedreno/ir3/ir3_array_to_ssa.c
+++ b/src/freedreno/ir3/ir3_array_to_ssa.c
@@ -100,7 +100,7 @@ read_value_beginning(struct array_ctx *ctx, struct ir3_block *block, struct ir3_
unsigned flags = IR3_REG_ARRAY | (arr->half ? IR3_REG_HALF : 0);
struct ir3_instruction *phi =
- ir3_instr_create(block, OPC_META_PHI, block->predecessors_count + 1);
+ ir3_instr_create(block, OPC_META_PHI, 1, block->predecessors_count);
list_del(&phi->node);
list_add(&phi->node, &block->instr_list);
diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c
index 087f191044f..4078f891f79 100644
--- a/src/freedreno/ir3/ir3_compiler_nir.c
+++ b/src/freedreno/ir3/ir3_compiler_nir.c
@@ -64,7 +64,7 @@ create_input(struct ir3_context *ctx, unsigned compmask)
{
struct ir3_instruction *in;
- in = ir3_instr_create(ctx->in_block, OPC_META_INPUT, 1);
+ in = ir3_instr_create(ctx->in_block, OPC_META_INPUT, 1, 0);
in->input.sysval = ~0;
__ssa_dst(in)->wrmask = compmask;
@@ -2765,7 +2765,7 @@ emit_phi(struct ir3_context *ctx, nir_phi_instr *nphi)
dst = ir3_get_dst(ctx, &nphi->dest, 1);
phi = ir3_instr_create(ctx->block, OPC_META_PHI,
- 1 + exec_list_length(&nphi->srcs));
+ 1, exec_list_length(&nphi->srcs));
__ssa_dst(phi);
phi->phi.nphi = nphi;
@@ -3859,7 +3859,7 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler,
}
struct ir3_instruction *chmask =
- ir3_instr_create(ctx->block, OPC_CHMASK, outputs_count + 1);
+ ir3_instr_create(ctx->block, OPC_CHMASK, 1, outputs_count);
chmask->barrier_class = IR3_BARRIER_EVERYTHING;
chmask->barrier_conflict = IR3_BARRIER_EVERYTHING;
@@ -3955,7 +3955,7 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler,
ctx->block = old_block;
struct ir3_instruction *end = ir3_instr_create(ctx->block, OPC_END,
- outputs_count + 1);
+ 1, outputs_count);
__ssa_dst(end);
for (unsigned i = 0; i < outputs_count; i++) {
diff --git a/src/freedreno/ir3/ir3_context.c b/src/freedreno/ir3/ir3_context.c
index 954dd10979b..00ad005e5ba 100644
--- a/src/freedreno/ir3/ir3_context.c
+++ b/src/freedreno/ir3/ir3_context.c
@@ -308,7 +308,7 @@ ir3_create_collect(struct ir3_context *ctx, struct ir3_instruction *const *arr,
unsigned flags = dest_flags(arr[0]);
- collect = ir3_instr_create(block, OPC_META_COLLECT, 1 + arrsz);
+ collect = ir3_instr_create(block, OPC_META_COLLECT, 1, arrsz);
__ssa_dst(collect)->flags |= flags;
for (unsigned i = 0; i < arrsz; i++) {
struct ir3_instruction *elem = arr[i];
@@ -380,7 +380,7 @@ ir3_split_dest(struct ir3_block *block, struct ir3_instruction **dst,
for (int i = 0, j = 0; i < n; i++) {
struct ir3_instruction *split =
- ir3_instr_create(block, OPC_META_SPLIT, 2);
+ ir3_instr_create(block, OPC_META_SPLIT, 1, 1);
__ssa_dst(split)->flags |= flags;
__ssa_src(split, src, flags);
split->split.off = i + base;
@@ -571,7 +571,7 @@ ir3_create_array_load(struct ir3_context *ctx, struct ir3_array *arr, int n,
struct ir3_register *src;
unsigned flags = 0;
- mov = ir3_instr_create(block, OPC_MOV, 2);
+ mov = ir3_instr_create(block, OPC_MOV, 1, 1);
if (arr->half) {
mov->cat1.src_type = TYPE_U16;
mov->cat1.dst_type = TYPE_U16;
@@ -637,7 +637,7 @@ ir3_create_array_store(struct ir3_context *ctx, struct ir3_array *arr, int n,
return;
}
- mov = ir3_instr_create(block, OPC_MOV, 2);
+ mov = ir3_instr_create(block, OPC_MOV, 1, 1);
if (arr->half) {
mov->cat1.src_type = TYPE_U16;
mov->cat1.dst_type = TYPE_U16;
diff --git a/src/freedreno/ir3/ir3_legalize.c b/src/freedreno/ir3/ir3_legalize.c
index f1deae88b5a..4ffe8129c29 100644
--- a/src/freedreno/ir3/ir3_legalize.c
+++ b/src/freedreno/ir3/ir3_legalize.c
@@ -313,7 +313,7 @@ legalize_block(struct ir3_legalize_ctx *ctx, struct ir3_block *block)
struct ir3_instruction *baryf;
/* (ss)bary.f (ei)r63.x, 0, r0.x */
- baryf = ir3_instr_create(block, OPC_BARY_F, 3);
+ baryf = ir3_instr_create(block, OPC_BARY_F, 1, 2);
ir3_dst_create(baryf, regid(63, 0), 0);
ir3_src_create(baryf, 0, IR3_REG_IMMED)->iim_val = 0;
ir3_src_create(baryf, regid(0, 0), 0);
@@ -343,7 +343,7 @@ legalize_block(struct ir3_legalize_ctx *ctx, struct ir3_block *block)
struct ir3_instruction *baryf;
/* (ss)bary.f (ei)r63.x, 0, r0.x */
- baryf = ir3_instr_create(block, OPC_BARY_F, 3);
+ baryf = ir3_instr_create(block, OPC_BARY_F, 1, 2);
ir3_dst_create(baryf, regid(63, 0), 0)->flags |= IR3_REG_EI;
ir3_src_create(baryf, 0, IR3_REG_IMMED)->iim_val = 0;
ir3_src_create(baryf, regid(0, 0), 0);
@@ -627,14 +627,14 @@ block_sched(struct ir3 *ir)
/* create "else" branch first (since "then" block should
* frequently/always end up being a fall-thru):
*/
- br = ir3_instr_create(block, OPC_B, 2);
+ br = ir3_instr_create(block, OPC_B, 1, 1);
ir3_dst_create(br, INVALID_REG, 0);
ir3_src_create(br, regid(REG_P0, 0), 0)->def = block->condition->regs[0];
br->cat0.inv1 = true;
br->cat0.target = block->successors[1];
/* "then" branch: */
- br = ir3_instr_create(block, OPC_B, 2);
+ br = ir3_instr_create(block, OPC_B, 1, 1);
ir3_dst_create(br, INVALID_REG, 0);
ir3_src_create(br, regid(REG_P0, 0), 0)->def = block->condition->regs[0];
br->cat0.target = block->successors[0];
@@ -690,7 +690,7 @@ kill_sched(struct ir3 *ir, struct ir3_shader_variant *so)
if (instr->opc != OPC_KILL)
continue;
- struct ir3_instruction *br = ir3_instr_create(block, OPC_B, 2);
+ struct ir3_instruction *br = ir3_instr_create(block, OPC_B, 1, 1);
br->regs[1] = instr->regs[1];
br->cat0.target =
list_last_entry(&ir->block_list, struct ir3_block, node);
diff --git a/src/freedreno/ir3/ir3_lower_parallelcopy.c b/src/freedreno/ir3/ir3_lower_parallelcopy.c
index f0716e2daac..76109ccb382 100644
--- a/src/freedreno/ir3/ir3_lower_parallelcopy.c
+++ b/src/freedreno/ir3/ir3_lower_parallelcopy.c
@@ -71,7 +71,7 @@ get_copy_src(const struct ir3_register *reg, unsigned offset)
static void
do_xor(struct ir3_instruction *instr, unsigned dst_num, unsigned src1_num, unsigned src2_num, unsigned flags)
{
- struct ir3_instruction *xor = ir3_instr_create(instr->block, OPC_XOR_B, 3);
+ struct ir3_instruction *xor = ir3_instr_create(instr->block, OPC_XOR_B, 1, 2);
struct ir3_register *dst = ir3_dst_create(xor, dst_num, flags);
dst->wrmask = 1;
struct ir3_register *src1 = ir3_src_create(xor, src1_num, flags);
@@ -186,7 +186,7 @@ do_copy(struct ir3_instruction *instr, const struct copy_entry *entry)
if (entry->src.reg % 2 == 0) {
/* cov.u32u16 dst, src */
- struct ir3_instruction *cov = ir3_instr_create(instr->block, OPC_MOV, 2);
+ struct ir3_instruction *cov = ir3_instr_create(instr->block, OPC_MOV, 1, 1);
ir3_dst_create(cov, dst_num, entry->flags)->wrmask = 1;
ir3_src_create(cov, src_num, entry->flags & ~IR3_REG_HALF)->wrmask = 1;
cov->cat1.dst_type = TYPE_U16;
@@ -194,7 +194,7 @@ do_copy(struct ir3_instruction *instr, const struct copy_entry *entry)
ir3_instr_move_before(cov, instr);
} else {
/* shr.b dst, src, h(16) */
- struct ir3_instruction *shr = ir3_instr_create(instr->block, OPC_SHR_B, 3);
+ struct ir3_instruction *shr = ir3_instr_create(instr->block, OPC_SHR_B, 1, 2);
ir3_dst_create(shr, dst_num, entry->flags)->wrmask = 1;
ir3_src_create(shr, src_num, entry->flags & ~IR3_REG_HALF)->wrmask = 1;
ir3_src_create(shr, 0, entry->flags | IR3_REG_IMMED)->uim_val = 16;
@@ -207,7 +207,7 @@ do_copy(struct ir3_instruction *instr, const struct copy_entry *entry)
unsigned src_num = ra_physreg_to_num(entry->src.reg, entry->flags);
unsigned dst_num = ra_physreg_to_num(entry->dst, entry->flags);
- struct ir3_instruction *mov = ir3_instr_create(instr->block, OPC_MOV, 2);
+ struct ir3_instruction *mov = ir3_instr_create(instr->block, OPC_MOV, 1, 1);
ir3_dst_create(mov, dst_num, entry->flags)->wrmask = 1;
ir3_src_create(mov, src_num, entry->flags | entry->src.flags)->wrmask = 1;
mov->cat1.dst_type = (entry->flags & IR3_REG_HALF) ? TYPE_U16 : TYPE_U32;
diff --git a/src/freedreno/ir3/ir3_merge_regs.c b/src/freedreno/ir3/ir3_merge_regs.c
index abb8e86bc02..3da34bfca0d 100644
--- a/src/freedreno/ir3/ir3_merge_regs.c
+++ b/src/freedreno/ir3/ir3_merge_regs.c
@@ -430,7 +430,7 @@ create_parallel_copy(struct ir3_block *block)
assert(j == phi_count);
struct ir3_instruction *pcopy =
- ir3_instr_create(block, OPC_META_PARALLEL_COPY, 2 * phi_count);
+ ir3_instr_create(block, OPC_META_PARALLEL_COPY, phi_count, phi_count);
for (j = 0; j < phi_count; j++) {
struct ir3_register *reg = __ssa_dst(pcopy);
diff --git a/src/freedreno/ir3/ir3_parser.y b/src/freedreno/ir3/ir3_parser.y
index 931520adfe4..d9261f1b03d 100644
--- a/src/freedreno/ir3/ir3_parser.y
+++ b/src/freedreno/ir3/ir3_parser.y
@@ -92,7 +92,7 @@ static void new_label(const char *name)
static struct ir3_instruction * new_instr(opc_t opc)
{
- instr = ir3_instr_create(block, opc, 5);
+ instr = ir3_instr_create(block, opc, 4, 4);
instr->flags = iflags.flags;
instr->repeat = iflags.repeat;
instr->nop = iflags.nop;
diff --git a/src/freedreno/ir3/ir3_ra.c b/src/freedreno/ir3/ir3_ra.c
index 557d3cdf5ee..3ba2b0a43e1 100644
--- a/src/freedreno/ir3/ir3_ra.c
+++ b/src/freedreno/ir3/ir3_ra.c
@@ -1161,7 +1161,9 @@ insert_parallel_copy_instr(struct ra_ctx *ctx, struct ir3_instruction *instr)
return;
struct ir3_instruction *pcopy =
- ir3_instr_create(instr->block, OPC_META_PARALLEL_COPY, 2 * ctx->parallel_copies_count);
+ ir3_instr_create(instr->block, OPC_META_PARALLEL_COPY,
+ ctx->parallel_copies_count,
+ ctx->parallel_copies_count);
for (unsigned i = 0; i < ctx->parallel_copies_count; i++) {
struct ra_parallel_copy *entry = &ctx->parallel_copies[i];
@@ -1600,12 +1602,12 @@ insert_liveout_copy(struct ir3_block *block, physreg_t dst, physreg_t src,
old_pcopy = last;
}
- unsigned old_pcopy_regs = old_pcopy ? old_pcopy->regs_count : 0;
+ unsigned old_pcopy_srcs = old_pcopy ? old_pcopy->srcs_count : 0;
struct ir3_instruction *pcopy =
ir3_instr_create(block, OPC_META_PARALLEL_COPY,
- 2 + old_pcopy_regs);
+ old_pcopy_srcs + 1, old_pcopy_srcs + 1);
- for (unsigned i = 0; i < old_pcopy_regs / 2; i++) {
+ for (unsigned i = 0; i < old_pcopy_srcs; i++) {
old_pcopy->regs[i]->instr = pcopy;
pcopy->regs[pcopy->regs_count++] = old_pcopy->regs[i];
}
@@ -1617,7 +1619,7 @@ insert_liveout_copy(struct ir3_block *block, physreg_t dst, physreg_t src,
dst_reg->size = reg->size;
assign_reg(pcopy, dst_reg, ra_physreg_to_num(dst, reg->flags));
- for (unsigned i = old_pcopy_regs / 2; i < old_pcopy_regs; i++) {
+ for (unsigned i = old_pcopy_srcs; i < old_pcopy_srcs * 2; i++) {
pcopy->regs[pcopy->regs_count++] = old_pcopy->regs[i];
}