pan/bi: Pack branch offset constants

This is not fully generic but for a single constant it will do.
Extensions left for future work.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5260>
This commit is contained in:
Alyssa Rosenzweig 2020-05-28 13:08:04 -04:00 committed by Marge Bot
parent 627872ef7f
commit b9967ab6da

View file

@ -1705,7 +1705,18 @@ bi_pack_bundle(bi_clause *clause, bi_bundle bundle, bi_bundle prev, bool first_b
}
/* Packs the next two constants as a dedicated constant quadword at the end of
* the clause, returning the number packed. */
* the clause, returning the number packed. There are two cases to consider:
*
* Case #1: Branching is not used. For a single constant copy the upper nibble
* over, easy.
*
* Case #2: Branching is used. For a single constant, it suffices to set the
* upper nibble to 4 and leave the latter constant 0, which matches what the
* blob does.
*
* Extending to multiple constants is considerably more tricky and left for
* future work.
*/
static unsigned
bi_pack_constants(bi_context *ctx, bi_clause *clause,
@ -1716,6 +1727,9 @@ bi_pack_constants(bi_context *ctx, bi_clause *clause,
bool done = clause->constant_count <= (index + 2);
bool only = clause->constant_count <= (index + 1);
/* Is the constant we're packing for a branch? */
bool branches = clause->branch_constant && done;
/* TODO: Pos */
assert(index == 0 && clause->bundle_count == 1);
assert(only);
@ -1729,6 +1743,13 @@ bi_pack_constants(bi_context *ctx, bi_clause *clause,
.imm_2 = ((hi < 8) ? (hi << 60ull) : 0) >> 4,
};
if (branches) {
/* Branch offsets are less than 60-bits so this should work at
* least for now */
quad.imm_1 |= (4ull << 60ull) >> 4;
assert (hi == 0);
}
/* XXX: On G71, Connor observed that the difference of the top 4 bits
* of the second constant with the first must be less than 8, otherwise
* we have to swap them. On G52, I'm able to reproduce a similar issue