summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>2020-05-05 14:28:53 -0400
committerMarge Bot <eric+marge@anholt.net>2020-05-29 20:34:55 +0000
commitb042ddef325ee6f88ebfff76f84173825c40d33f (patch)
tree0c050da95e0aca406d248339f9b69edac5bcee13
parent79f30d8a86e9f9fe0f542c75f8ebf2e617f13135 (diff)
pan/bi: Move bi_registers to bi_bundle
Make it a part of the IR itself. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5260>
-rw-r--r--src/panfrost/bifrost/bi_pack.c66
-rw-r--r--src/panfrost/bifrost/compiler.h4
2 files changed, 35 insertions, 35 deletions
diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c
index 852dd07a136..deff7f55e0d 100644
--- a/src/panfrost/bifrost/bi_pack.c
+++ b/src/panfrost/bifrost/bi_pack.c
@@ -221,63 +221,61 @@ bi_assign_port_read(struct bi_registers *regs, unsigned src)
}
static struct bi_registers
-bi_assign_ports(bi_bundle now, bi_bundle prev)
+bi_assign_ports(bi_bundle *now, bi_bundle *prev)
{
- struct bi_registers regs = { 0 };
-
/* We assign ports for the main register mechanism. Special ops
* use the data registers, which has its own mechanism entirely
* and thus gets skipped over here. */
- unsigned read_dreg = now.add &&
- bi_class_props[now.add->type] & BI_DATA_REG_SRC;
+ unsigned read_dreg = now->add &&
+ bi_class_props[now->add->type] & BI_DATA_REG_SRC;
- unsigned write_dreg = prev.add &&
- bi_class_props[prev.add->type] & BI_DATA_REG_DEST;
+ unsigned write_dreg = prev->add &&
+ bi_class_props[prev->add->type] & BI_DATA_REG_DEST;
/* First, assign reads */
- if (now.fma)
- bi_foreach_src(now.fma, src)
- bi_assign_port_read(&regs, now.fma->src[src]);
+ if (now->fma)
+ bi_foreach_src(now->fma, src)
+ bi_assign_port_read(&now->regs, now->fma->src[src]);
- if (now.add) {
- bi_foreach_src(now.add, src) {
+ if (now->add) {
+ bi_foreach_src(now->add, src) {
if (!(src == 0 && read_dreg))
- bi_assign_port_read(&regs, now.add->src[src]);
+ bi_assign_port_read(&now->regs, now->add->src[src]);
}
}
/* Next, assign writes */
- if (prev.add && prev.add->dest & BIR_INDEX_REGISTER && !write_dreg) {
- regs.port[2] = prev.add->dest & ~BIR_INDEX_REGISTER;
- regs.write_add = true;
+ if (prev->add && prev->add->dest & BIR_INDEX_REGISTER && !write_dreg) {
+ now->regs.port[2] = prev->add->dest & ~BIR_INDEX_REGISTER;
+ now->regs.write_add = true;
}
- if (prev.fma && prev.fma->dest & BIR_INDEX_REGISTER) {
- unsigned r = prev.fma->dest & ~BIR_INDEX_REGISTER;
+ if (prev->fma && prev->fma->dest & BIR_INDEX_REGISTER) {
+ unsigned r = prev->fma->dest & ~BIR_INDEX_REGISTER;
- if (regs.write_add) {
+ if (now->regs.write_add) {
/* Scheduler constraint: cannot read 3 and write 2 */
- assert(!regs.read_port3);
- regs.port[3] = r;
+ assert(!now->regs.read_port3);
+ now->regs.port[3] = r;
} else {
- regs.port[2] = r;
+ now->regs.port[2] = r;
}
- regs.write_fma = true;
+ now->regs.write_fma = true;
}
/* Finally, ensure port 1 > port 0 for the 63-x trick to function */
- if (regs.enabled[0] && regs.enabled[1] && regs.port[1] < regs.port[0]) {
- unsigned temp = regs.port[0];
- regs.port[0] = regs.port[1];
- regs.port[1] = temp;
+ if (now->regs.enabled[0] && now->regs.enabled[1] && now->regs.port[1] < now->regs.port[0]) {
+ unsigned temp = now->regs.port[0];
+ now->regs.port[0] = now->regs.port[1];
+ now->regs.port[1] = temp;
}
- return regs;
+ return now->regs;
}
/* Determines the register control field, ignoring the first? flag */
@@ -1681,13 +1679,13 @@ struct bi_packed_bundle {
static struct bi_packed_bundle
bi_pack_bundle(bi_clause *clause, bi_bundle bundle, bi_bundle prev, bool first_bundle, gl_shader_stage stage)
{
- struct bi_registers regs = bi_assign_ports(bundle, prev);
- bi_assign_uniform_constant(clause, &regs, bundle);
- regs.first_instruction = first_bundle;
+ bi_assign_ports(&bundle, &prev);
+ bi_assign_uniform_constant(clause, &bundle.regs, bundle);
+ bundle.regs.first_instruction = first_bundle;
- uint64_t reg = bi_pack_registers(regs);
- uint64_t fma = bi_pack_fma(clause, bundle, &regs);
- uint64_t add = bi_pack_add(clause, bundle, &regs, stage);
+ uint64_t reg = bi_pack_registers(bundle.regs);
+ uint64_t fma = bi_pack_fma(clause, bundle, &bundle.regs);
+ uint64_t add = bi_pack_add(clause, bundle, &bundle.regs, stage);
struct bi_packed_bundle packed = {
.lo = reg | (fma << 35) | ((add & 0b111111) << 58),
diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h
index 349aff48cef..b167b8d4780 100644
--- a/src/panfrost/bifrost/compiler.h
+++ b/src/panfrost/bifrost/compiler.h
@@ -325,10 +325,12 @@ struct bi_registers {
};
/* A bi_bundle contains two paired instruction pointers. If a slot is unfilled,
- * leave it NULL; the emitter will fill in a nop.
+ * leave it NULL; the emitter will fill in a nop. Instructions reference
+ * registers via ports which are assigned per bundle.
*/
typedef struct {
+ struct bi_registers regs;
bi_instruction *fma;
bi_instruction *add;
} bi_bundle;