ir3: add helpers to handle 64b values

64b values occupy 2 registers but we receive them as a single component
value from NIR. Since there are many places that assume a 1:1
relationship between components and instructions, this can be error
prone as we have to remember to double the number of components whenever
a 64b value is involved.

This commit tries to improve on this situation by representing 64b
values as a collect of 2 registers, restoring the 1:1 mapping between
NIR components and ir3 instructions. This commit only adds some helpers
to create 64b values and access their individual components but doesn't
actually use them yet. This will happen in a follow-up commit.

Signed-off-by: Job Noorman <jnoorman@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33797>
This commit is contained in:
Job Noorman
2025-06-12 12:14:46 +02:00
committed by Marge Bot
parent 2f75e6cba9
commit 37f4786881
+30
View File
@@ -2698,6 +2698,36 @@ struct ir3_instruction *ir3_create_collect(struct ir3_builder *build,
void ir3_split_dest(struct ir3_builder *build, struct ir3_instruction **dst,
struct ir3_instruction *src, unsigned base, unsigned n);
static inline struct ir3_instruction *
ir3_64b(struct ir3_builder *build, struct ir3_instruction *lo,
struct ir3_instruction *hi)
{
assert((lo->dsts[0]->flags & IR3_REG_SHARED) ==
(hi->dsts[0]->flags & IR3_REG_SHARED));
return ir3_collect(build, lo, hi);
}
static inline struct ir3_instruction *
ir3_64b_immed(struct ir3_builder *build, uint64_t val)
{
return ir3_64b(build, create_immed(build, (uint32_t)val),
create_immed(build, val >> 32));
}
static inline struct ir3_instruction *
ir3_64b_get_lo(struct ir3_instruction *instr)
{
assert(instr->opc == OPC_META_COLLECT && instr->srcs_count == 2);
return instr->srcs[0]->def->instr;
}
static inline struct ir3_instruction *
ir3_64b_get_hi(struct ir3_instruction *instr)
{
assert(instr->opc == OPC_META_COLLECT && instr->srcs_count == 2);
return instr->srcs[1]->def->instr;
}
struct ir3_instruction *ir3_store_const(struct ir3_shader_variant *so,
struct ir3_builder *build,
struct ir3_instruction *src,