Commit fbe504e2 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜 Committed by Marge Bot
Browse files

pan/bit: Handle read/write



We case the various sources and destinations to model register file
access and passthrough in particular.
Signed-off-by: Alyssa Rosenzweig's avatarAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <mesa/mesa!4458>
parent 7904a293
......@@ -39,26 +39,58 @@ typedef union {
/* Interprets a subset of Bifrost IR required for automated testing */
static uint64_t
bit_read(struct bit_state *s, bi_instruction *ins, unsigned index, nir_alu_type T)
bit_read(struct bit_state *s, bi_instruction *ins, unsigned index, nir_alu_type T, bool FMA)
{
/* STUB */
return 0;
if (index & BIR_INDEX_REGISTER) {
uint32_t reg = index & ~BIR_INDEX_REGISTER;
assert(reg < 64);
return s->r[reg];
} else if (index & BIR_INDEX_UNIFORM) {
unreachable("Uniform registers to be implemented");
} else if (index & BIR_INDEX_CONSTANT) {
return ins->constant.u64 >> (index & ~BIR_INDEX_CONSTANT);
} else if (index & BIR_INDEX_ZERO) {
return 0;
} else if (index & (BIR_INDEX_PASS | BIFROST_SRC_STAGE)) {
return FMA ? 0 : s->T;
} else if (index & (BIR_INDEX_PASS | BIFROST_SRC_PASS_FMA)) {
return s->T0;
} else if (index & (BIR_INDEX_PASS | BIFROST_SRC_PASS_ADD)) {
return s->T1;
} else if (!index) {
/* Placeholder */
return 0;
} else {
unreachable("Invalid source");
}
}
static void
bit_write(struct bit_state *s, unsigned index, nir_alu_type T, bit_t value)
bit_write(struct bit_state *s, unsigned index, nir_alu_type T, bit_t value, bool FMA)
{
/* STUB */
/* Always write stage passthrough */
if (FMA)
s->T = value.u32;
if (index & BIR_INDEX_REGISTER) {
uint32_t reg = index & ~BIR_INDEX_REGISTER;
assert(reg < 64);
s->r[reg] = value.u32;
} else if (!index) {
/* Nothing to do */
} else {
unreachable("Invalid destination");
}
}
void
bit_step(struct bit_state *s, bi_instruction *ins)
bit_step(struct bit_state *s, bi_instruction *ins, bool FMA)
{
/* First, load sources */
bit_t srcs[BIR_SRC_COUNT] = { 0 };
bi_foreach_src(ins, src)
srcs[src].u64 = bit_read(s, ins, ins->src[src], ins->src_types[src]);
srcs[src].u64 = bit_read(s, ins, ins->src[src], ins->src_types[src], FMA);
/* Next, do the action of the instruction */
bit_t dest = { 0 };
......@@ -96,5 +128,11 @@ bit_step(struct bit_state *s, bi_instruction *ins)
}
/* Finally, store the result */
bit_write(s, ins->dest, ins->dest_type, dest);
bit_write(s, ins->dest, ins->dest_type, dest, FMA);
/* For ADD - change out the passthrough */
if (!FMA) {
s->T0 = s->T;
s->T1 = dest.u32;
}
}
......@@ -53,11 +53,19 @@ bit_vertex(struct panfrost_device *dev, panfrost_program prog,
/* BIT interpreter */
struct bit_state {
/* Work registers */
uint32_t r[64];
/* Passthrough within the bundle */
uint32_t T;
/* Passthrough from last bundle */
uint32_t T0;
uint32_t T1;
};
void
bit_step(struct bit_state *s, bi_instruction *ins);
bit_step(struct bit_state *s, bi_instruction *ins, bool FMA);
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment